Browse Source

df: include channel_id in openchannel2 hook

We already know what the channel id is, we should go ahead and pass it
on to any listening plugins -- this makes clean up easier/possible
if a open fails early on and we've got reserved utxos.
ppa
niftynei 4 years ago
committed by Christian Decker
parent
commit
d4ec052668
  1. 3
      lightningd/dual_open_control.c
  2. 12
      openingd/dualopend.c
  3. 1
      openingd/dualopend_wire.csv
  4. 8
      openingd/dualopend_wiregen.c
  5. 6
      openingd/dualopend_wiregen.h

3
lightningd/dual_open_control.c

@ -73,6 +73,7 @@ static void handle_signed_psbt(struct lightningd *ld,
struct openchannel2_payload { struct openchannel2_payload {
struct subd *dualopend; struct subd *dualopend;
struct node_id peer_id; struct node_id peer_id;
struct channel_id channel_id;
struct amount_sat their_funding; struct amount_sat their_funding;
struct amount_sat dust_limit_satoshis; struct amount_sat dust_limit_satoshis;
struct amount_msat max_htlc_value_in_flight_msat; 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_object_start(stream, "openchannel2");
json_add_node_id(stream, "id", &payload->peer_id); 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", json_add_amount_sat_only(stream, "their_funding",
payload->their_funding); payload->their_funding);
json_add_amount_sat_only(stream, "dust_limit_satoshis", 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; payload->err_msg = NULL;
if (!fromwire_dualopend_got_offer(payload, msg, if (!fromwire_dualopend_got_offer(payload, msg,
&payload->channel_id,
&payload->their_funding, &payload->their_funding,
&payload->dust_limit_satoshis, &payload->dust_limit_satoshis,
&payload->max_htlc_value_in_flight_msat, &payload->max_htlc_value_in_flight_msat,

12
openingd/dualopend.c

@ -1484,8 +1484,14 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
return; 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 */ /* FIXME: pass the podle back also */
msg = towire_dualopend_got_offer(NULL, msg = towire_dualopend_got_offer(NULL,
&cid,
state->opener_funding, state->opener_funding,
state->remoteconf.dust_limit, state->remoteconf.dust_limit,
state->remoteconf.max_htlc_value_in_flight, 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])) &state->upfront_shutdown_script[LOCAL]))
master_badmsg(WIRE_DUALOPEND_GOT_OFFER_REPLY, msg); master_badmsg(WIRE_DUALOPEND_GOT_OFFER_REPLY, msg);
/* We can figure out the channel id now */ /* Set the channel id now */
derive_channel_id_v2(&state->channel_id, state->channel_id = cid;
&state->our_points.revocation,
&state->their_points.revocation);
if (!state->psbt) if (!state->psbt)
state->psbt = create_psbt(state, 0, 0, state->tx_locktime); state->psbt = create_psbt(state, 0, 0, state->tx_locktime);

1
openingd/dualopend_wire.csv

@ -74,6 +74,7 @@ msgdata,dualopend_reinit,msg,u8,len
# dualopend->master: they offered channel, should we continue? # dualopend->master: they offered channel, should we continue?
msgtype,dualopend_got_offer,7005 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,opener_funding,amount_sat,
msgdata,dualopend_got_offer,dust_limit_satoshis,amount_sat, msgdata,dualopend_got_offer,dust_limit_satoshis,amount_sat,
msgdata,dualopend_got_offer,max_htlc_value_in_flight_msat,amount_msat, msgdata,dualopend_got_offer,max_htlc_value_in_flight_msat,amount_msat,

Can't render this file because it has a wrong number of fields in line 13.

8
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 */ /* WIRE: DUALOPEND_GOT_OFFER */
/* dualopend->master: they offered channel */ /* 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); u16 shutdown_len = tal_count(shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0); u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUALOPEND_GOT_OFFER); towire_u16(&p, WIRE_DUALOPEND_GOT_OFFER);
towire_channel_id(&p, channel_id);
towire_amount_sat(&p, opener_funding); towire_amount_sat(&p, opener_funding);
towire_amount_sat(&p, dust_limit_satoshis); towire_amount_sat(&p, dust_limit_satoshis);
towire_amount_msat(&p, max_htlc_value_in_flight_msat); 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)); 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; 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) if (fromwire_u16(&cursor, &plen) != WIRE_DUALOPEND_GOT_OFFER)
return false; return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*opener_funding = fromwire_amount_sat(&cursor, &plen); *opener_funding = fromwire_amount_sat(&cursor, &plen);
*dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen); *dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
*max_htlc_value_in_flight_msat = fromwire_amount_msat(&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); *leak = fromwire_bool(&cursor, &plen);
return cursor != NULL; return cursor != NULL;
} }
// SHA256STAMP:4410d5ca881f7d981e8eebf77c0acf69f5a5113eaec626251d51f21d8f16a649 // SHA256STAMP:a98345c38c5c28d10d403397332690a49b630fe6b214bcad10162010efa97a7c

6
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 */ /* WIRE: DUALOPEND_GOT_OFFER */
/* dualopend->master: they offered channel */ /* 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);
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);
/* WIRE: DUALOPEND_GOT_OFFER_REPLY */ /* WIRE: DUALOPEND_GOT_OFFER_REPLY */
/* master->dualopend: reply back with our first funding info/contribs */ /* 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 */ #endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
// SHA256STAMP:4410d5ca881f7d981e8eebf77c0acf69f5a5113eaec626251d51f21d8f16a649 // SHA256STAMP:a98345c38c5c28d10d403397332690a49b630fe6b214bcad10162010efa97a7c

Loading…
Cancel
Save