From f598caa60d3c79408a62108d364ad34e2278501e Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Sun, 17 May 2020 16:53:37 +0200 Subject: [PATCH] config: don't ignore the --commit-fee option. We did not take the value of --commit-fee into account : this removes the unused option from lightningd and instead registers it in bcli, where we set the actual feerate of commitment transactions. This also corrects the documentation. Changelog-Fixed: config: we now take the --commit-fee parameter into account. Signed-off-by: Antoine Poinsot --- doc/lightningd-config.5 | 4 ++-- doc/lightningd-config.5.md | 4 ++-- lightningd/lightningd.h | 3 --- lightningd/options.c | 9 --------- plugins/bcli.c | 11 ++++++++++- wallet/test/test_utils.c | 1 - 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/doc/lightningd-config.5 b/doc/lightningd-config.5 index 5c7ec02e8..d78554b5d 100644 --- a/doc/lightningd-config.5 +++ b/doc/lightningd-config.5 @@ -332,8 +332,8 @@ opens a channel before the channel is usable\. \fBcommit-fee\fR=\fIPERCENT\fR -The percentage of \fIestimatesmartfee 2\fR to use for the bitcoin -transaction which funds a channel: can be greater than 100\. +The percentage of \fIestimatesmartfee 2/CONSERVATIVE\fR to use for the commitment +transactions: default is 100\. \fBcommit-fee-min\fR=\fIPERCENT\fR diff --git a/doc/lightningd-config.5.md b/doc/lightningd-config.5.md index e79df85a9..9f8585581 100644 --- a/doc/lightningd-config.5.md +++ b/doc/lightningd-config.5.md @@ -270,8 +270,8 @@ Confirmations required for the funding transaction when the other side opens a channel before the channel is usable. **commit-fee**=*PERCENT* -The percentage of *estimatesmartfee 2* to use for the bitcoin -transaction which funds a channel: can be greater than 100. +The percentage of *estimatesmartfee 2/CONSERVATIVE* to use for the commitment +transactions: default is 100. **commit-fee-min**=*PERCENT* **commit-fee-max**=*PERCENT* diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 96770ce91..76d50e78e 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -32,9 +32,6 @@ struct config { /* Minimum percent of fee rate we'll accept. */ u32 commitment_fee_min_percent; - /* Percent of fee rate we'll use. */ - u32 commitment_fee_percent; - /* Minimum CLTV to subtract from incoming HTLCs to outgoing */ u32 cltv_expiry_delta; diff --git a/lightningd/options.c b/lightningd/options.c index aeba673cc..c46f89ffd 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -571,9 +571,6 @@ static const struct config testnet_config = { .commitment_fee_min_percent = 0, .commitment_fee_max_percent = 0, - /* We offer to pay 5 times 2-block fee */ - .commitment_fee_percent = 500, - /* Testnet blockspace is free. */ .max_concurrent_htlcs = 483, @@ -619,9 +616,6 @@ static const struct config mainnet_config = { .commitment_fee_min_percent = 200, .commitment_fee_max_percent = 2000, - /* We offer to pay 5 times 2-block fee */ - .commitment_fee_percent = 500, - /* While up to 483 htlcs are possible we do 30 by default (as eclair does) to save blockspace */ .max_concurrent_htlcs = 30, @@ -820,9 +814,6 @@ static void register_opts(struct lightningd *ld) opt_register_arg("--commit-fee-max=", opt_set_u32, opt_show_u32, &ld->config.commitment_fee_max_percent, "Maximum percentage of fee to accept for commitment (0 for unlimited)"); - opt_register_arg("--commit-fee=", opt_set_u32, opt_show_u32, - &ld->config.commitment_fee_percent, - "Percentage of fee to request for their commitment"); opt_register_arg("--cltv-delta", opt_set_u32, opt_show_u32, &ld->config.cltv_expiry_delta, "Number of blocks for cltv_expiry_delta"); diff --git a/plugins/bcli.c b/plugins/bcli.c index 013c7cf54..7267616d0 100644 --- a/plugins/bcli.c +++ b/plugins/bcli.c @@ -63,6 +63,9 @@ struct bitcoind { /* The factor to time the urgent feerate by to get the maximum * acceptable feerate. */ u32 max_fee_multiplier; + + /* Percent of CONSERVATIVE/2 feerate we'll use for commitment txs. */ + u64 commit_fee_percent; }; static struct bitcoind *bitcoind; @@ -531,7 +534,8 @@ static struct command_result *estimatefees_final_step(struct bitcoin_cli *bcli) response = jsonrpc_stream_success(bcli->cmd); json_add_u64(response, "opening", stash->normal); json_add_u64(response, "mutual_close", stash->normal); - json_add_u64(response, "unilateral_close", stash->very_urgent); + json_add_u64(response, "unilateral_close", + stash->very_urgent * bitcoind->commit_fee_percent / 100); json_add_u64(response, "delayed_to_us", stash->normal); json_add_u64(response, "htlc_resolution", stash->urgent); json_add_u64(response, "penalty", stash->urgent); @@ -947,6 +951,7 @@ int main(int argc, char *argv[]) bitcoind->rpcconnect = NULL; bitcoind->rpcport = NULL; bitcoind->max_fee_multiplier = 10; + bitcoind->commit_fee_percent = 100; plugin_main(argv, init, PLUGIN_STATIC, NULL, commands, ARRAY_SIZE(commands), NULL, 0, NULL, 0, @@ -979,6 +984,10 @@ int main(int argc, char *argv[]) "how long to keep retrying to contact bitcoind" " before fatally exiting", u64_option, &bitcoind->retry_timeout), + plugin_option("commit-fee", + "string", + "Percentage of fee to request for their commitment", + u64_option, &bitcoind->commit_fee_percent), #if DEVELOPER plugin_option("dev-max-fee-multiplier", "string", diff --git a/wallet/test/test_utils.c b/wallet/test/test_utils.c index 4d49821b6..ef1fd8b0b 100644 --- a/wallet/test/test_utils.c +++ b/wallet/test/test_utils.c @@ -10,7 +10,6 @@ const struct config test_config = { .anchor_confirms = 1, .commitment_fee_min_percent = 0, .commitment_fee_max_percent = 0, - .commitment_fee_percent = 500, .cltv_expiry_delta = 6, .cltv_final = 10, .commit_time_ms = 10,