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

Function fundee_channel

openingd/openingd.c:856–1322  ·  view source on GitHub ↗

~ The peer sent us an `open_channel`, that means we're the fundee. */

Source from the content-addressed store, hash-verified

854
855/*~ The peer sent us an `open_channel`, that means we're the fundee. */
856static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
857{
858 struct channel_id id_in;
859 struct basepoints theirs;
860 struct pubkey their_funding_pubkey;
861 struct bitcoin_signature theirsig, sig;
862 struct bitcoin_tx *local_commit, *remote_commit;
863 struct bitcoin_blkid chain_hash;
864 u8 *msg;
865 const u8 *wscript;
866 u8 channel_flags;
867 u16 funding_txout;
868 char* err_reason;
869 struct wally_tx_output *direct_outputs[NUM_SIDES];
870 struct penalty_base *pbase;
871 struct tlv_accept_channel_tlvs *accept_tlvs;
872 struct tlv_open_channel_tlvs *open_tlvs;
873 struct amount_sat *reserve;
874
875 /* BOLT #2:
876 *
877 * The receiving node MUST fail the channel if:
878 *...
879 * - `funding_pubkey`, `revocation_basepoint`, `htlc_basepoint`,
880 * `payment_basepoint`, or `delayed_payment_basepoint` are not valid
881 * secp256k1 pubkeys in compressed format.
882 */
883 if (!fromwire_open_channel(tmpctx, open_channel_msg, &chain_hash,
884 &state->channel_id,
885 &state->funding_sats,
886 &state->push_msat,
887 &state->remoteconf.dust_limit,
888 &state->remoteconf.max_htlc_value_in_flight,
889 &state->remoteconf.channel_reserve,
890 &state->remoteconf.htlc_minimum,
891 &state->feerate_per_kw,
892 &state->remoteconf.to_self_delay,
893 &state->remoteconf.max_accepted_htlcs,
894 &their_funding_pubkey,
895 &theirs.revocation,
896 &theirs.payment,
897 &theirs.delayed_payment,
898 &theirs.htlc,
899 &state->first_per_commitment_point[REMOTE],
900 &channel_flags,
901 &open_tlvs))
902 peer_failed_err(state->pps,
903 &state->channel_id,
904 "Parsing open_channel %s", tal_hex(tmpctx, open_channel_msg));
905 set_remote_upfront_shutdown(state, open_tlvs->upfront_shutdown_script);
906
907 /* BOLT #2:
908 * The receiving node MUST fail the channel if:
909 *...
910 * - It supports `channel_type` and `channel_type` was set:
911 * - if `type` is not suitable.
912 * - if `type` includes `option_zeroconf` and it does not trust the sender to open an unconfirmed channel.
913 */

Callers 1

handle_peer_inFunction · 0.85

Calls 15

peer_failed_errFunction · 0.85
tal_hexFunction · 0.85
channel_type_acceptFunction · 0.85
fmt_featurebitsFunction · 0.85
default_channel_typeFunction · 0.85
amount_sat_greaterFunction · 0.85
amount_msat_greater_satFunction · 0.85
check_config_boundsFunction · 0.85
tal_freeFunction · 0.85
set_reserve_absoluteFunction · 0.85

Tested by

no test coverage detected