From 2b431b171b4f15df02e646a66468ff4ece6716eb Mon Sep 17 00:00:00 2001 From: Glenn Willen Date: Sat, 5 Nov 2016 23:46:58 -0700 Subject: [PATCH] config: Allow overriding the transaction fee rate --- daemon/chaintopology.c | 7 ++++++- daemon/lightningd.c | 9 +++++++++ daemon/lightningd.h | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/daemon/chaintopology.c b/daemon/chaintopology.c index 684d362de..880832994 100644 --- a/daemon/chaintopology.c +++ b/daemon/chaintopology.c @@ -485,7 +485,12 @@ u32 get_block_height(struct lightningd_state *dstate) u64 get_feerate(struct lightningd_state *dstate) { - if (dstate->topology->feerate == 0) { + if (dstate->config.override_fee_rate) { + log_debug(dstate->base_log, + "Forcing fee rate, ignoring estimate"); + return dstate->config.override_fee_rate; + } + else if (dstate->topology->feerate == 0) { log_info(dstate->base_log, "No fee estimate: using default fee rate"); return dstate->config.default_fee_rate; diff --git a/daemon/lightningd.c b/daemon/lightningd.c index 0993ca471..17390b9d6 100644 --- a/daemon/lightningd.c +++ b/daemon/lightningd.c @@ -127,6 +127,9 @@ static void config_register_opts(struct lightningd_state *dstate) opt_register_arg("--commit-fee=", opt_set_u32, opt_show_u32, &dstate->config.commitment_fee_percent, "Percentage of fee to request for their commitment"); + opt_register_arg("--override-fee-rate", opt_set_u64, opt_show_u64, + &dstate->config.override_fee_rate, + "Force a specific rate in satoshis per kb regardless of estimated fees"); opt_register_arg("--default-fee-rate", opt_set_u64, opt_show_u64, &dstate->config.default_fee_rate, "Satoshis per kb if can't estimate fees"); @@ -198,6 +201,9 @@ static const struct config testnet_config = { /* We offer to pay 5 times 2-block fee */ .commitment_fee_percent = 500, + /* Use this rate, if specified, regardless of what estimatefee says. */ + .override_fee_rate = 0, + /* Use this rate by default if estimatefee doesn't estimate. */ .default_fee_rate = 40000, @@ -256,6 +262,9 @@ static const struct config mainnet_config = { /* We offer to pay 5 times 2-block fee */ .commitment_fee_percent = 500, + /* Use this rate, if specified, regardless of what estimatefee says. */ + .override_fee_rate = 0, + /* Use this rate by default if estimatefee doesn't estimate. */ .default_fee_rate = 40000, diff --git a/daemon/lightningd.h b/daemon/lightningd.h index d5a5b8780..b81cfbd1f 100644 --- a/daemon/lightningd.h +++ b/daemon/lightningd.h @@ -37,7 +37,10 @@ struct config { /* Percent of fee rate we'll use. */ u32 commitment_fee_percent; - + + /* Force a partiular fee rate regardless of estimatefee (satoshis/kb) */ + u64 override_fee_rate; + /* What fee we use if estimatefee fails (satoshis/kb) */ u64 default_fee_rate;