bcli: register --dev-max-fee-multiplier on our side

That way we pass the real min_acceptable (SLOW/2) and max_acceptable
(URGENT * 10) feerates to lightningd.
This commit is contained in:
darosior 2020-03-11 13:37:24 +01:00 committed by Rusty Russell
parent 902edf56e6
commit 610aa0b8e3
5 changed files with 25 additions and 27 deletions

View File

@ -153,8 +153,7 @@ static void bitcoin_plugin_send(struct bitcoind *bitcoind,
* - `htlc_resolution` is used for resolving onchain HTLCs
* - `penalty` is used for resolving revoked transactions
* - `min` is the minimum acceptable feerate
* - `max` is the maximum acceptable feerate, note that it will be multiplied by the
* config's `max_fee_multiplier`.
* - `max` is the maximum acceptable feerate
*
* Plugin response:
* {

View File

@ -870,12 +870,6 @@ u32 feerate_min(struct lightningd *ld, bool *unknown)
return min;
}
/* BOLT #2:
*
* 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)
*/
u32 feerate_max(struct lightningd *ld, bool *unknown)
{
u32 feerate;
@ -900,7 +894,7 @@ u32 feerate_max(struct lightningd *ld, bool *unknown)
if (feehistory[i] > feerate)
feerate = feehistory[i];
}
return feerate * ld->config.max_fee_multiplier;
return feerate;
}
/* On shutdown, channels get deleted last. That frees from our list, so

View File

@ -61,10 +61,6 @@ 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;
/* Are we allowed to use DNS lookup for peers. */
bool use_dns;

View File

@ -518,13 +518,6 @@ 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_noarg("--dev-fast-gossip", opt_set_bool,
&ld->dev_fast_gossip,
@ -598,9 +591,6 @@ 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 = 10,
.use_dns = true,
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */
@ -659,9 +649,6 @@ 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 = 10,
.use_dns = true,
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */

View File

@ -59,6 +59,10 @@ struct bitcoind {
/* Passthrough parameters for bitcoin-cli */
char *rpcuser, *rpcpass, *rpcconnect, *rpcport;
/* The factor to time the urgent feerate by to get the maximum
* acceptable feerate. */
u32 max_fee_multiplier;
};
static struct bitcoind *bitcoind;
@ -535,7 +539,14 @@ static struct command_result *estimatefees_final_step(struct bitcoin_cli *bcli)
/* We divide the slow feerate for the minimum acceptable, lightningd
* will use floor if it's hit, though. */
json_add_u64(response, "min_acceptable", stash->slow / 2);
json_add_u64(response, "max_acceptable", stash->urgent);
/* BOLT #2:
*
* 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)
*/
json_add_u64(response, "max_acceptable",
stash->urgent * bitcoind->max_fee_multiplier);
return command_finished(bcli->cmd, response);
}
@ -910,6 +921,7 @@ int main(int argc, char *argv[])
bitcoind->rpcpass = NULL;
bitcoind->rpcconnect = NULL;
bitcoind->rpcport = NULL;
bitcoind->max_fee_multiplier = 10;
plugin_main(argv, init, PLUGIN_STATIC, commands, ARRAY_SIZE(commands),
NULL, 0, NULL, 0,
@ -942,5 +954,15 @@ int main(int argc, char *argv[])
"how long to keep retrying to contact bitcoind"
" before fatally exiting",
u64_option, &bitcoind->retry_timeout),
#if DEVELOPER
plugin_option("dev-max-fee-multiplier",
"string",
"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.",
u32_option, &bitcoind->max_fee_multiplier),
#endif /* DEVELOPER */
NULL);
}