MCPcopy Create free account
hub / github.com/ElementsProject/lightning / do_quickclose

Function do_quickclose

closingd/closingd.c:682–832  ·  view source on GitHub ↗

We've received one offer; if we're opener, that means we've already sent one * too. */

Source from the content-addressed store, hash-verified

680/* We've received one offer; if we're opener, that means we've already sent one
681 * too. */
682static void do_quickclose(struct amount_sat offer[NUM_SIDES],
683 struct per_peer_state *pps,
684 const struct channel_id *channel_id,
685 const struct pubkey funding_pubkey[NUM_SIDES],
686 const u8 *funding_wscript,
687 u32 *local_wallet_index,
688 const struct ext_key *local_wallet_ext_key,
689 u8 *scriptpubkey[NUM_SIDES],
690 const struct bitcoin_outpoint *funding,
691 struct amount_sat funding_sats,
692 const struct amount_sat out[NUM_SIDES],
693 enum side opener,
694 struct amount_sat our_dust_limit,
695 const struct bitcoin_outpoint *wrong_funding,
696 struct bitcoin_txid *closing_txid,
697 const struct tlv_closing_signed_tlvs_fee_range *our_feerange,
698 const struct tlv_closing_signed_tlvs_fee_range *their_feerange)
699{
700 struct tlv_closing_signed_tlvs_fee_range overlap;
701
702
703 /* BOLT #2:
704 * - if the message contains a `fee_range`:
705 * - if there is no overlap between that and its own `fee_range`:
706 * - SHOULD send a warning
707 * - MUST fail the channel if it doesn't receive a satisfying `fee_range` after a reasonable amount of time
708 */
709 /* (Note we satisfy the "MUST fail" by our close command unilteraltimeout) */
710 if (!get_overlap(our_feerange, their_feerange, &overlap)) {
711 peer_failed_warn(pps, channel_id,
712 "Unable to agree on a feerate."
713 " Our range %s-%s, other range %s-%s",
714 fmt_amount_sat(tmpctx, our_feerange->min_fee_satoshis),
715 fmt_amount_sat(tmpctx, our_feerange->max_fee_satoshis),
716 fmt_amount_sat(tmpctx, their_feerange->min_fee_satoshis),
717 fmt_amount_sat(tmpctx, their_feerange->max_fee_satoshis));
718 return;
719 }
720
721 status_info("performing quickclose in range %s-%s",
722 fmt_amount_sat(tmpctx, overlap.min_fee_satoshis),
723 fmt_amount_sat(tmpctx, overlap.max_fee_satoshis));
724
725 /* BOLT #2:
726 * - otherwise:
727 * - if it is the funder:
728 * - if `fee_satoshis` is not in the overlap between the sent
729 * and received `fee_range`:
730 * - MUST fail the channel
731 * - otherwise:
732 * - MUST reply with the same `fee_satoshis`.
733 */
734 if (opener == LOCAL) {
735 if (!amount_in_range(offer[REMOTE], &overlap)) {
736 peer_failed_warn(pps, channel_id,
737 "Your fee %s was not in range:"
738 " Our range %s-%s, other range %s-%s",
739 fmt_amount_sat(tmpctx, offer[REMOTE]),

Callers 1

mainFunction · 0.85

Calls 11

get_overlapFunction · 0.85
peer_failed_warnFunction · 0.85
amount_in_rangeFunction · 0.85
send_offerFunction · 0.85
amount_sat_greaterFunction · 0.85
amount_sat_lessFunction · 0.85
receive_offerFunction · 0.85
fmt_bitcoin_txidFunction · 0.85
fmt_amount_satFunction · 0.50
amount_sat_eqFunction · 0.50
peer_billboardFunction · 0.50

Tested by

no test coverage detected