mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
fundchannel: only cap to 'max' if keyword 'all' passed in
in order to preserve current behavior, we cap at max if specified 'all'; otherwise we fail since the amount requested is larger than the channel max capacity
This commit is contained in:
parent
d9843c1957
commit
7d069239aa
@ -20,6 +20,7 @@ struct funding_req {
|
|||||||
const char *feerate_str;
|
const char *feerate_str;
|
||||||
const char *funding_str;
|
const char *funding_str;
|
||||||
const char *utxo_str;
|
const char *utxo_str;
|
||||||
|
bool funding_all;
|
||||||
|
|
||||||
bool *announce_channel;
|
bool *announce_channel;
|
||||||
u32 *minconf;
|
u32 *minconf;
|
||||||
@ -363,7 +364,7 @@ static struct command_result *tx_prepare_dryrun(struct command *cmd,
|
|||||||
plugin_err("Error creating placebo funding tx, funding_out not found. %s", hex);
|
plugin_err("Error creating placebo funding tx, funding_out not found. %s", hex);
|
||||||
|
|
||||||
/* Update funding to actual amount */
|
/* Update funding to actual amount */
|
||||||
if (amount_sat_greater(funding, max_funding))
|
if (fr->funding_all && amount_sat_greater(funding, max_funding))
|
||||||
funding = max_funding;
|
funding = max_funding;
|
||||||
|
|
||||||
fr->funding_str = type_to_string(fr, struct amount_sat, &funding);
|
fr->funding_str = type_to_string(fr, struct amount_sat, &funding);
|
||||||
@ -387,6 +388,8 @@ static struct command_result *json_fundchannel(struct command *cmd,
|
|||||||
NULL))
|
NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
fr->funding_all = streq(fr->funding_str, "all");
|
||||||
|
|
||||||
/* First we do a 'dry-run' of txprepare, so we can get
|
/* First we do a 'dry-run' of txprepare, so we can get
|
||||||
* an accurate idea of the funding amount */
|
* an accurate idea of the funding amount */
|
||||||
ret = txprepare(cmd, fr, placeholder_funding_addr);
|
ret = txprepare(cmd, fr, placeholder_funding_addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user