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

Function opener_start

openingd/dualopend.c:2661–2997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2659}
2660
2661static void opener_start(struct state *state, u8 *msg)
2662{
2663 struct tlv_opening_tlvs *open_tlv;
2664 struct tlv_accept_tlvs *a_tlv;
2665 struct channel_id cid;
2666 char *err_reason;
2667 struct amount_sat total, requested_sats;
2668 bool dry_run;
2669 struct lease_rates *expected_rates;
2670 struct tx_state *tx_state = state->tx_state;
2671
2672 if (!fromwire_dualopend_opener_init(state, msg,
2673 &tx_state->psbt,
2674 &tx_state->opener_funding,
2675 &state->upfront_shutdown_script[LOCAL],
2676 &state->local_upfront_shutdown_wallet_index,
2677 &state->feerate_per_kw_commitment,
2678 &tx_state->feerate_per_kw_funding,
2679 &state->channel_flags,
2680 &requested_sats,
2681 &tx_state->blockheight,
2682 &dry_run,
2683 &expected_rates))
2684 master_badmsg(WIRE_DUALOPEND_OPENER_INIT, msg);
2685
2686 state->our_role = TX_INITIATOR;
2687 tx_state->tx_locktime = tx_state->psbt->tx->locktime;
2688 open_tlv = tlv_opening_tlvs_new(tmpctx);
2689
2690 /* BOLT-* #2
2691 * If the peer's revocation basepoint is unknown (e.g.
2692 * `open_channel2`), a temporary `channel_id` should be found
2693 * by using a zeroed out basepoint for the unknown peer.
2694 */
2695 derive_tmp_channel_id(&state->channel_id,
2696 &state->our_points.revocation);
2697
2698 if (!state->upfront_shutdown_script[LOCAL])
2699 state->upfront_shutdown_script[LOCAL]
2700 = no_upfront_shutdown_script(state,
2701 state->our_features,
2702 state->their_features);
2703
2704 if (tal_bytelen(state->upfront_shutdown_script[LOCAL])) {
2705 open_tlv->option_upfront_shutdown_script =
2706 tal(open_tlv,
2707 struct tlv_opening_tlvs_option_upfront_shutdown_script);
2708 open_tlv->option_upfront_shutdown_script->shutdown_scriptpubkey =
2709 state->upfront_shutdown_script[LOCAL];
2710 }
2711
2712 if (!amount_sat_zero(requested_sats)) {
2713 open_tlv->request_funds =
2714 tal(open_tlv, struct tlv_opening_tlvs_request_funds);
2715 open_tlv->request_funds->requested_sats =
2716 requested_sats.satoshis; /* Raw: struct -> wire */
2717 open_tlv->request_funds->blockheight = tx_state->blockheight;
2718 }

Callers 1

handle_master_inFunction · 0.85

Calls 15

derive_tmp_channel_idFunction · 0.85
tal_bytelenFunction · 0.85
amount_sat_zeroFunction · 0.85
peer_writeFunction · 0.85
open_err_fatalFunction · 0.85
tal_hexFunction · 0.85
derive_channel_id_v2Function · 0.85
peer_failed_errFunction · 0.85
open_err_warnFunction · 0.85
amount_sat_lessFunction · 0.85
lease_rates_eqFunction · 0.85

Tested by

no test coverage detected