lightningd: don't use chainparams before param() call in json_fund_channel_start

With coming changes, this will segfault if we access it when param
code is trying to get usage from functions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-11-23 12:15:51 +10:30
parent 34c89cb226
commit 5673607ebc
1 changed files with 4 additions and 5 deletions

View File

@ -1105,9 +1105,8 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
u32 *feerate_per_kw;
u8 *msg = NULL;
struct amount_sat max_funding_satoshi, *amount;
struct amount_sat *amount;
max_funding_satoshi = chainparams->max_funding;
fc->cmd = cmd;
fc->cancels = tal_arr(fc, struct command *, 0);
fc->uc = NULL;
@ -1149,11 +1148,11 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
fc->our_upfront_shutdown_script = NULL;
}
if (amount_sat_greater(*amount, max_funding_satoshi))
if (amount_sat_greater(*amount, chainparams->max_funding))
return command_fail(cmd, FUND_MAX_EXCEEDED,
"Amount exceeded %s",
type_to_string(tmpctx, struct amount_sat,
&max_funding_satoshi));
&chainparams->max_funding));
fc->funding = *amount;
if (!feerate_per_kw) {
@ -1203,7 +1202,7 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
type_to_string(fc, struct node_id, id));
}
assert(!amount_sat_greater(*amount, max_funding_satoshi));
assert(!amount_sat_greater(*amount, chainparams->max_funding));
peer->uncommitted_channel->fc = tal_steal(peer->uncommitted_channel, fc);
fc->uc = peer->uncommitted_channel;