From 8d6423389a4d58bafde6af417c7b52add0475d32 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 8 Jun 2022 13:55:47 +0200 Subject: [PATCH] openingd: Wire `reserve` value through to `openingd` --- lightningd/opening_control.c | 3 ++- openingd/openingd.c | 11 +++++++++-- openingd/openingd_wire.csv | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index bbdcf7745..6ba7c4097 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -711,7 +711,8 @@ openchannel_hook_final(struct openchannel_hook_payload *payload STEALS) subd_send_msg(openingd, take(towire_openingd_got_offer_reply(NULL, errmsg, our_upfront_shutdown_script, - upfront_shutdown_script_wallet_index))); + upfront_shutdown_script_wallet_index, + payload->uc->reserve))); } static bool diff --git a/openingd/openingd.c b/openingd/openingd.c index 90a439f15..d05152e4c 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -814,6 +814,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) struct penalty_base *pbase; struct tlv_accept_channel_tlvs *accept_tlvs; struct tlv_open_channel_tlvs *open_tlvs; + struct amount_sat *reserve; /* BOLT #2: * @@ -1013,8 +1014,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) /* We don't allocate off tmpctx, because that's freed inside * opening_negotiate_msg */ if (!fromwire_openingd_got_offer_reply(state, msg, &err_reason, - &state->upfront_shutdown_script[LOCAL], - &state->local_upfront_shutdown_wallet_index)) + &state->upfront_shutdown_script[LOCAL], + &state->local_upfront_shutdown_wallet_index, + &reserve)) master_badmsg(WIRE_OPENINGD_GOT_OFFER_REPLY, msg); /* If they give us a reason to reject, do so. */ @@ -1030,6 +1032,11 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) state->our_features, state->their_features); + if (reserve != NULL) { + set_reserve_absolute(state, state->remoteconf.dust_limit, + *reserve); + } + /* OK, we accept! */ accept_tlvs = tlv_accept_channel_tlvs_new(tmpctx); accept_tlvs->upfront_shutdown_script diff --git a/openingd/openingd_wire.csv b/openingd/openingd_wire.csv index a759e1a4f..d81dfff44 100644 --- a/openingd/openingd_wire.csv +++ b/openingd/openingd_wire.csv @@ -46,6 +46,7 @@ msgdata,openingd_got_offer_reply,rejection,?wirestring, msgdata,openingd_got_offer_reply,shutdown_len,u16, msgdata,openingd_got_offer_reply,our_shutdown_scriptpubkey,?u8,shutdown_len msgdata,openingd_got_offer_reply,our_shutdown_wallet_index,?u32, +msgdata,openingd_got_offer_reply,reserve,?amount_sat, #include # Openingd->master: we've successfully offered channel.