diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 4db2e5c29..b57d097a3 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -60,6 +60,10 @@ struct config { /* ipv6 bind disable */ bool no_ipv6_bind; + + /* Accept fee changes only if they are in the range our_fee - + * our_fee*multiplier */ + u32 max_fee_multiplier; }; struct lightningd { diff --git a/lightningd/options.c b/lightningd/options.c index 85a5561bd..8e0c332ba 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -462,6 +462,13 @@ static void dev_register_opts(struct lightningd *ld) opt_register_arg("--dev-bitcoind-poll", opt_set_u32, opt_show_u32, &ld->topology->poll_seconds, "Time between polling for new transactions"); + opt_register_arg("--dev-max-fee-multiplier", opt_set_u32, opt_show_u32, + &ld->config.max_fee_multiplier, + "Allow the fee proposed by the remote end to be up to " + "multiplier times higher than our own. Small values " + "will cause channels to be closed more often due to " + "fee fluctuations, large values may result in large " + "fees."); opt_register_arg("--dev-override-fee-rates", opt_set_fee_rates, NULL, ld->topology, "Force a specific rates (immediate/normal/slow) in satoshis per kw regardless of estimated fees"); @@ -515,6 +522,9 @@ static const struct config testnet_config = { /* Rescan 5 hours of blocks on testnet, it's reorg happy */ .rescan = 30, + + /* Fees may be in the range our_fee - 10*our_fee */ + .max_fee_multiplier = 5, }; /* aka. "Dude, where's my coins?" */ @@ -568,6 +578,9 @@ static const struct config mainnet_config = { /* Rescan 2.5 hours of blocks on startup, it's not so reorg happy */ .rescan = 15, + + /* Fees may be in the range our_fee - 10*our_fee */ + .max_fee_multiplier = 5, }; static void check_config(struct lightningd *ld) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index f2d51a439..56d2dc616 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -182,13 +182,14 @@ u32 feerate_min(struct lightningd *ld) * * Given the variance in fees, and the fact that the transaction may * be spent in the future, it's a good idea for the fee payer to keep - * a good margin, say 5x the expected fee requirement */ + * a good margin, say 10x the expected fee requirement */ u32 feerate_max(struct lightningd *ld) { if (ld->config.ignore_fee_limits) return UINT_MAX; - return get_feerate(ld->topology, FEERATE_IMMEDIATE) * 5; + return get_feerate(ld->topology, FEERATE_IMMEDIATE) * + ld->config.max_fee_multiplier; } static void sign_last_tx(struct channel *channel)