openingd: Pass reserve down to openingd when funding

This commit is contained in:
Christian Decker 2022-06-09 13:34:33 +02:00
parent 8d6423389a
commit 5a54f450bd
3 changed files with 24 additions and 14 deletions

View file

@ -1256,15 +1256,16 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
} else
upfront_shutdown_script_wallet_index = NULL;
fc->open_msg
= towire_openingd_funder_start(fc,
*amount,
fc->push,
fc->our_upfront_shutdown_script,
upfront_shutdown_script_wallet_index,
*feerate_per_kw,
&tmp_channel_id,
fc->channel_flags);
fc->open_msg = towire_openingd_funder_start(
fc,
*amount,
fc->push,
fc->our_upfront_shutdown_script,
upfront_shutdown_script_wallet_index,
*feerate_per_kw,
&tmp_channel_id,
fc->channel_flags,
fc->uc->reserve);
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
return command_fail(cmd, FUND_MAX_EXCEEDED,

View file

@ -99,6 +99,8 @@ struct state {
struct channel_type *channel_type;
struct feature_set *our_features;
struct amount_sat *reserve;
};
/*~ If we can't agree on parameters, we fail to open the channel.
@ -245,10 +247,6 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state,
static bool setup_channel_funder(struct state *state)
{
/*~ For symmetry, we calculate our own reserve even though lightningd
* could do it for the we-are-funding case. */
set_reserve(state, state->localconf.dust_limit);
#if DEVELOPER
/* --dev-force-tmp-channel-id specified */
if (dev_force_tmp_channel_id)
@ -329,6 +327,15 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
if (!setup_channel_funder(state))
return NULL;
/* If we have a reserve override we use that, otherwise we'll
* use our default of 1% of the funding value. */
if (state->reserve != NULL) {
set_reserve_absolute(state, state->localconf.dust_limit,
*state->reserve);
} else {
set_reserve(state, state->localconf.dust_limit);
}
if (!state->upfront_shutdown_script[LOCAL])
state->upfront_shutdown_script[LOCAL]
= no_upfront_shutdown_script(state,
@ -1352,7 +1359,8 @@ static u8 *handle_master_in(struct state *state)
&state->local_upfront_shutdown_wallet_index,
&state->feerate_per_kw,
&state->channel_id,
&channel_flags))
&channel_flags,
&state->reserve))
master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
msg = funder_channel_start(state, channel_flags);

View file

@ -80,6 +80,7 @@ msgdata,openingd_funder_start,upfront_shutdown_wallet_index,?u32,
msgdata,openingd_funder_start,feerate_per_kw,u32,
msgdata,openingd_funder_start,temporary_channel_id,channel_id,
msgdata,openingd_funder_start,channel_flags,u8,
msgdata,openingd_funder_start,reserve,?amount_sat,
# openingd->master: send back output script for 2-of-2 funding output
msgtype,openingd_funder_start_reply,6102

1 #include <bitcoin/chainparams.h>
80 msgdata,openingd_funder_start_reply,script_len,u8, msgtype,openingd_funder_start_reply,6102
81 msgdata,openingd_funder_start_reply,scriptpubkey,u8,script_len msgdata,openingd_funder_start_reply,script_len,u8,
82 msgdata,openingd_funder_start_reply,upfront_shutdown_negotiated,bool, msgdata,openingd_funder_start_reply,scriptpubkey,u8,script_len
83 msgdata,openingd_funder_start_reply,upfront_shutdown_negotiated,bool,
84 msgdata,openingd_funder_start_reply,channel_type,channel_type,
85 # master->openingd: complete channel establishment for a funding
86 # tx that will be paid for by an external wallet