Browse Source

fundchannel: populate max_funding from chainparams

Since we pull the chainparams out to get the funding_addr placeholder,
we can also get the max_funding now!
travis-debug
lisa neigut 5 years ago
committed by Rusty Russell
parent
commit
548672ea0a
  1. 9
      plugins/fundchannel.c

9
plugins/fundchannel.c

@ -13,9 +13,7 @@
const char *placeholder_script = "0020b95810f824f843934fa042acd0becba52087813e260edaeebc42b5cb9abe1464"; const char *placeholder_script = "0020b95810f824f843934fa042acd0becba52087813e260edaeebc42b5cb9abe1464";
const char *placeholder_funding_addr; const char *placeholder_funding_addr;
const struct amount_sat *max_funding;
/* FIXME: dynamically query */
const struct amount_sat max_funding = AMOUNT_SAT_INIT((1 << 24) - 1);
struct funding_req { struct funding_req {
struct node_id *id; struct node_id *id;
@ -366,8 +364,8 @@ 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 (fr->funding_all && 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);
return fundchannel_start(cmd, fr); return fundchannel_start(cmd, fr);
@ -418,6 +416,7 @@ static void init(struct plugin_conn *rpc,
placeholder_funding_addr = encode_scriptpubkey_to_addr(NULL, placeholder_funding_addr = encode_scriptpubkey_to_addr(NULL,
chainparams->bip173_name, chainparams->bip173_name,
placeholder); placeholder);
max_funding = &chainparams->max_funding;
} }

Loading…
Cancel
Save