Skip to content

Commit

Permalink
fundchannel: only cap to 'max' if keyword 'all' passed in
Browse files Browse the repository at this point in the history
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
  • Loading branch information
niftynei authored and rustyrussell committed Sep 11, 2019
1 parent d9843c1 commit 7d06923
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/fundchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct funding_req {
const char *feerate_str;
const char *funding_str;
const char *utxo_str;
bool funding_all;

bool *announce_channel;
u32 *minconf;
Expand Down Expand Up @@ -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);

/* 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;

fr->funding_str = type_to_string(fr, struct amount_sat, &funding);
Expand All @@ -387,6 +388,8 @@ static struct command_result *json_fundchannel(struct command *cmd,
NULL))
return NULL;

fr->funding_all = streq(fr->funding_str, "all");

/* First we do a 'dry-run' of txprepare, so we can get
* an accurate idea of the funding amount */
ret = txprepare(cmd, fr, placeholder_funding_addr);
Expand Down

0 comments on commit 7d06923

Please sign in to comment.