lightningd: allow --commit-fee-max=0 for "no limit"

For testnet, fee estimates are not reliable at all.

Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-10-07 14:00:17 +10:30
parent 44282eed16
commit 1e6f7059d3
2 changed files with 6 additions and 4 deletions

View File

@ -117,7 +117,7 @@ static void config_register_opts(struct lightningd_state *dstate)
"Minimum percentage of fee to accept for commitment");
opt_register_arg("--commit-fee-max=<percent>", opt_set_u32, opt_show_u32,
&dstate->config.commitment_fee_max_percent,
"Maximum percentage of fee to accept for commitment");
"Maximum percentage of fee to accept for commitment (0 for unlimited)");
opt_register_arg("--commit-fee=<percent>", opt_set_u32, opt_show_u32,
&dstate->config.commitment_fee_percent,
"Percentage of fee to request for their commitment");
@ -226,7 +226,8 @@ static void default_config(struct config *config)
static void check_config(struct lightningd_state *dstate)
{
/* We do this by ensuring it's less than the minimum we would accept. */
if (dstate->config.commitment_fee_max_percent
if (dstate->config.commitment_fee_max_percent != 0
&& dstate->config.commitment_fee_max_percent
< dstate->config.commitment_fee_min_percent)
fatal("Commitment fee invalid min-max %u-%u",
dstate->config.commitment_fee_min_percent,

View File

@ -308,8 +308,9 @@ Pkt *accept_pkt_open(struct peer *peer, const Pkt *pkt,
return pkt_err(peer, "Commitment fee %u below %"PRIu64" x %u%%",
o->initial_fee_rate, feerate,
peer->dstate->config.commitment_fee_min_percent);
if (o->initial_fee_rate
> feerate * peer->dstate->config.commitment_fee_max_percent / 100)
if (peer->dstate->config.commitment_fee_max_percent != 0
&& (o->initial_fee_rate
> feerate * peer->dstate->config.commitment_fee_max_percent/100))
return pkt_err(peer, "Commitment fee %u above %"PRIu64" x %u%%",
o->initial_fee_rate, feerate,
peer->dstate->config.commitment_fee_max_percent);