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

Function fundee_channel

openingd/openingd.c:830–1306  ·  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

828
829/*~ The peer sent us an `open_channel`, that means we're the fundee. */
830static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
831{
832 struct channel_id id_in;
833 struct basepoints theirs;
834 struct pubkey their_funding_pubkey;
835 struct bitcoin_signature theirsig, sig;
836 struct bitcoin_tx *local_commit, *remote_commit;
837 struct bitcoin_blkid chain_hash;
838 u8 *msg;
839 const u8 *wscript;
840 u8 channel_flags;
841 u16 funding_txout;
842 char* err_reason;
843 struct wally_tx_output *direct_outputs[NUM_SIDES];
844 struct penalty_base *pbase;
845 struct tlv_accept_channel_tlvs *accept_tlvs;
846 struct tlv_open_channel_tlvs *open_tlvs;
847 struct amount_sat *reserve;
848
849 /* BOLT #2:
850 *
851 * The receiving node MUST fail the channel if:
852 *...
853 * - `funding_pubkey`, `revocation_basepoint`, `htlc_basepoint`,
854 * `payment_basepoint`, or `delayed_payment_basepoint` are not valid
855 * secp256k1 pubkeys in compressed format.
856 */
857 if (!fromwire_open_channel(tmpctx, open_channel_msg, &chain_hash,
858 &state->channel_id,
859 &state->funding_sats,
860 &state->push_msat,
861 &state->remoteconf.dust_limit,
862 &state->remoteconf.max_htlc_value_in_flight,
863 &state->remoteconf.channel_reserve,
864 &state->remoteconf.htlc_minimum,
865 &state->feerate_per_kw,
866 &state->remoteconf.to_self_delay,
867 &state->remoteconf.max_accepted_htlcs,
868 &their_funding_pubkey,
869 &theirs.revocation,
870 &theirs.payment,
871 &theirs.delayed_payment,
872 &theirs.htlc,
873 &state->first_per_commitment_point[REMOTE],
874 &channel_flags,
875 &open_tlvs))
876 peer_failed_err(state->pps,
877 &state->channel_id,
878 "Parsing open_channel %s", tal_hex(tmpctx, open_channel_msg));
879 set_remote_upfront_shutdown(state, open_tlvs->upfront_shutdown_script);
880
881 /* BOLT #2:
882 * - if the message doesn't include a `channel_type`:
883 * - fail the channel.
884 */
885 if (!open_tlvs->channel_type) {
886 negotiation_failed(state,
887 "Did not set channel_type in open_channel message");

Callers 2

runFunction · 0.85
handle_peer_inFunction · 0.85

Calls 15

tal_hexFunction · 0.85
channel_type_acceptFunction · 0.85
fmt_featurebitsFunction · 0.85
channel_type_fromFunction · 0.85
fmt_bitcoin_blkidFunction · 0.85
feature_negotiatedFunction · 0.85
amount_sat_greaterFunction · 0.85
amount_msat_greater_satFunction · 0.85
check_config_boundsFunction · 0.85
channel_type_hasFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected