diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 78f059f7e..1c37c4a34 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -73,6 +73,7 @@ static void handle_signed_psbt(struct lightningd *ld, struct openchannel2_payload { struct subd *dualopend; struct node_id peer_id; + struct channel_id channel_id; struct amount_sat their_funding; struct amount_sat dust_limit_satoshis; struct amount_msat max_htlc_value_in_flight_msat; @@ -103,6 +104,7 @@ openchannel2_hook_serialize(struct openchannel2_payload *payload, { json_object_start(stream, "openchannel2"); json_add_node_id(stream, "id", &payload->peer_id); + json_add_channel_id(stream, "channel_id", &payload->channel_id); json_add_amount_sat_only(stream, "their_funding", payload->their_funding); json_add_amount_sat_only(stream, "dust_limit_satoshis", @@ -1407,6 +1409,7 @@ static void accepter_got_offer(struct subd *dualopend, payload->err_msg = NULL; if (!fromwire_dualopend_got_offer(payload, msg, + &payload->channel_id, &payload->their_funding, &payload->dust_limit_satoshis, &payload->max_htlc_value_in_flight_msat, diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 39506d848..d721c6d6b 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -1484,8 +1484,14 @@ static void accepter_start(struct state *state, const u8 *oc2_msg) return; } + /* We can figure out the channel id now */ + derive_channel_id_v2(&cid, + &state->our_points.revocation, + &state->their_points.revocation); + /* FIXME: pass the podle back also */ msg = towire_dualopend_got_offer(NULL, + &cid, state->opener_funding, state->remoteconf.dust_limit, state->remoteconf.max_htlc_value_in_flight, @@ -1518,10 +1524,8 @@ static void accepter_start(struct state *state, const u8 *oc2_msg) &state->upfront_shutdown_script[LOCAL])) master_badmsg(WIRE_DUALOPEND_GOT_OFFER_REPLY, msg); - /* We can figure out the channel id now */ - derive_channel_id_v2(&state->channel_id, - &state->our_points.revocation, - &state->their_points.revocation); + /* Set the channel id now */ + state->channel_id = cid; if (!state->psbt) state->psbt = create_psbt(state, 0, 0, state->tx_locktime); diff --git a/openingd/dualopend_wire.csv b/openingd/dualopend_wire.csv index b5e282435..dc81bdfdc 100644 --- a/openingd/dualopend_wire.csv +++ b/openingd/dualopend_wire.csv @@ -74,6 +74,7 @@ msgdata,dualopend_reinit,msg,u8,len # dualopend->master: they offered channel, should we continue? msgtype,dualopend_got_offer,7005 +msgdata,dualopend_got_offer,channel_id,channel_id, msgdata,dualopend_got_offer,opener_funding,amount_sat, msgdata,dualopend_got_offer,dust_limit_satoshis,amount_sat, msgdata,dualopend_got_offer,max_htlc_value_in_flight_msat,amount_msat, diff --git a/openingd/dualopend_wiregen.c b/openingd/dualopend_wiregen.c index cfe9572a3..5ba1b9484 100644 --- a/openingd/dualopend_wiregen.c +++ b/openingd/dualopend_wiregen.c @@ -263,12 +263,13 @@ bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct cha /* WIRE: DUALOPEND_GOT_OFFER */ /* dualopend->master: they offered channel */ -u8 *towire_dualopend_got_offer(const tal_t *ctx, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey) +u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey) { u16 shutdown_len = tal_count(shutdown_scriptpubkey); u8 *p = tal_arr(ctx, u8, 0); towire_u16(&p, WIRE_DUALOPEND_GOT_OFFER); + towire_channel_id(&p, channel_id); towire_amount_sat(&p, opener_funding); towire_amount_sat(&p, dust_limit_satoshis); towire_amount_msat(&p, max_htlc_value_in_flight_msat); @@ -286,7 +287,7 @@ u8 *towire_dualopend_got_offer(const tal_t *ctx, struct amount_sat opener_fundin return memcheck(p, tal_count(p)); } -bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_funding_max, u32 *feerate_funding_min, u32 *feerate_funding_best, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey) +bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_funding_max, u32 *feerate_funding_min, u32 *feerate_funding_best, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey) { u16 shutdown_len; @@ -295,6 +296,7 @@ bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct amount if (fromwire_u16(&cursor, &plen) != WIRE_DUALOPEND_GOT_OFFER) return false; + fromwire_channel_id(&cursor, &plen, channel_id); *opener_funding = fromwire_amount_sat(&cursor, &plen); *dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen); *max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen); @@ -836,4 +838,4 @@ bool fromwire_dualopend_dev_memleak_reply(const void *p, bool *leak) *leak = fromwire_bool(&cursor, &plen); return cursor != NULL; } -// SHA256STAMP:4410d5ca881f7d981e8eebf77c0acf69f5a5113eaec626251d51f21d8f16a649 +// SHA256STAMP:a98345c38c5c28d10d403397332690a49b630fe6b214bcad10162010efa97a7c diff --git a/openingd/dualopend_wiregen.h b/openingd/dualopend_wiregen.h index 43b2fd72c..579e5a529 100644 --- a/openingd/dualopend_wiregen.h +++ b/openingd/dualopend_wiregen.h @@ -88,8 +88,8 @@ bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct cha /* WIRE: DUALOPEND_GOT_OFFER */ /* dualopend->master: they offered channel */ -u8 *towire_dualopend_got_offer(const tal_t *ctx, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey); -bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_funding_max, u32 *feerate_funding_min, u32 *feerate_funding_best, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey); +u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey); +bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_funding_max, u32 *feerate_funding_min, u32 *feerate_funding_best, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey); /* WIRE: DUALOPEND_GOT_OFFER_REPLY */ /* master->dualopend: reply back with our first funding info/contribs */ @@ -188,4 +188,4 @@ bool fromwire_dualopend_dev_memleak_reply(const void *p, bool *leak); #endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */ -// SHA256STAMP:4410d5ca881f7d981e8eebf77c0acf69f5a5113eaec626251d51f21d8f16a649 +// SHA256STAMP:a98345c38c5c28d10d403397332690a49b630fe6b214bcad10162010efa97a7c