mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
openingd: Pass reserve down to openingd when funding
This commit is contained in:
@@ -1256,15 +1256,16 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||||||
} else
|
} else
|
||||||
upfront_shutdown_script_wallet_index = NULL;
|
upfront_shutdown_script_wallet_index = NULL;
|
||||||
|
|
||||||
fc->open_msg
|
fc->open_msg = towire_openingd_funder_start(
|
||||||
= towire_openingd_funder_start(fc,
|
fc,
|
||||||
*amount,
|
*amount,
|
||||||
fc->push,
|
fc->push,
|
||||||
fc->our_upfront_shutdown_script,
|
fc->our_upfront_shutdown_script,
|
||||||
upfront_shutdown_script_wallet_index,
|
upfront_shutdown_script_wallet_index,
|
||||||
*feerate_per_kw,
|
*feerate_per_kw,
|
||||||
&tmp_channel_id,
|
&tmp_channel_id,
|
||||||
fc->channel_flags);
|
fc->channel_flags,
|
||||||
|
fc->uc->reserve);
|
||||||
|
|
||||||
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
|
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
|
||||||
return command_fail(cmd, FUND_MAX_EXCEEDED,
|
return command_fail(cmd, FUND_MAX_EXCEEDED,
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ struct state {
|
|||||||
struct channel_type *channel_type;
|
struct channel_type *channel_type;
|
||||||
|
|
||||||
struct feature_set *our_features;
|
struct feature_set *our_features;
|
||||||
|
|
||||||
|
struct amount_sat *reserve;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*~ If we can't agree on parameters, we fail to open the channel.
|
/*~ 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)
|
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
|
#if DEVELOPER
|
||||||
/* --dev-force-tmp-channel-id specified */
|
/* --dev-force-tmp-channel-id specified */
|
||||||
if (dev_force_tmp_channel_id)
|
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))
|
if (!setup_channel_funder(state))
|
||||||
return NULL;
|
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])
|
if (!state->upfront_shutdown_script[LOCAL])
|
||||||
state->upfront_shutdown_script[LOCAL]
|
state->upfront_shutdown_script[LOCAL]
|
||||||
= no_upfront_shutdown_script(state,
|
= no_upfront_shutdown_script(state,
|
||||||
@@ -1352,7 +1359,8 @@ static u8 *handle_master_in(struct state *state)
|
|||||||
&state->local_upfront_shutdown_wallet_index,
|
&state->local_upfront_shutdown_wallet_index,
|
||||||
&state->feerate_per_kw,
|
&state->feerate_per_kw,
|
||||||
&state->channel_id,
|
&state->channel_id,
|
||||||
&channel_flags))
|
&channel_flags,
|
||||||
|
&state->reserve))
|
||||||
master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
|
master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
|
||||||
msg = funder_channel_start(state, channel_flags);
|
msg = funder_channel_start(state, channel_flags);
|
||||||
|
|
||||||
|
|||||||
@@ -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,feerate_per_kw,u32,
|
||||||
msgdata,openingd_funder_start,temporary_channel_id,channel_id,
|
msgdata,openingd_funder_start,temporary_channel_id,channel_id,
|
||||||
msgdata,openingd_funder_start,channel_flags,u8,
|
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
|
# openingd->master: send back output script for 2-of-2 funding output
|
||||||
msgtype,openingd_funder_start_reply,6102
|
msgtype,openingd_funder_start_reply,6102
|
||||||
|
|||||||
|
Reference in New Issue
Block a user