diff --git a/CHANGELOG.md b/CHANGELOG.md index ac59b36e8..0be26d676 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,8 +20,7 @@ This release named by ZmnSCPxj. - JSON API: `listpeers` has new fields `global_features` and `local_features`. - JSON API: `listnodes` has new field `global_features`. - JSON API: `ping` command to send a ping to a connected peer. -- JSON API: `feerates` command to inject fee estimates manually, and retrieve - current estimates. +- JSON API: `feerates` command to retrieve current fee estimates. - JSON API: `withdraw` and `fundchannel` can be given manual feerate. - Config: `--conf` option to set config file. - Documentation: Added CHANGELOG.md @@ -48,7 +47,7 @@ This release named by ZmnSCPxj. the one given or the first one announced. - Crash logs are now placed one-per file like `crash.log.20180822233752` - We will no longer allow withdrawing funds or funding channels if we - do not have a fee estimate (eg. bitcoind not synced). + do not have a fee estimate (eg. bitcoind not synced); use new `feerate` arg. ### Deprecated @@ -63,7 +62,8 @@ changes. used to exist and set to `GOSSIPING` before we opened a channel). `connected` will indicate if we're connected, and the `channels` array indicates individual channel states (if any). -- Config: `default-fee-rate` is no longer available; use `feerates`. +- Config: `default-fee-rate` is no longer available; use explicit `feerate` + option if necessary. - Removed all Deprecated options from 0.6. ### Fixed diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index ce6d35f2f..de7112150 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -464,34 +464,15 @@ static void json_feerates(struct command *cmd, { struct chain_topology *topo = cmd->ld->topology; struct json_result *response; - u32 *urgent, *normal, *slow, feerates[NUM_FEERATES]; + u32 feerates[NUM_FEERATES]; bool missing; enum feerate_style *style; if (!param(cmd, buffer, params, p_req("style", json_tok_feerate_style, &style), - p_opt("urgent", json_tok_number, &urgent), - p_opt("normal", json_tok_number, &normal), - p_opt("slow", json_tok_number, &slow), NULL)) return; - /* update_feerates uses 0 as "don't know" */ - feerates[FEERATE_URGENT] = urgent ? *urgent : 0; - feerates[FEERATE_NORMAL] = normal ? *normal : 0; - feerates[FEERATE_SLOW] = slow ? *slow : 0; - - for (size_t i = 0; i < ARRAY_SIZE(feerates); i++) - feerates[i] = feerate_from_style(feerates[i], *style); - - log_info(topo->log, - "feerates: inserting feerates in sipa/kb %u/%u/%u", - feerates[FEERATE_URGENT], - feerates[FEERATE_NORMAL], - feerates[FEERATE_SLOW]); - - update_feerates(topo->bitcoind, feerates, topo); - missing = false; for (size_t i = 0; i < ARRAY_SIZE(feerates); i++) { feerates[i] = try_get_feerate(topo, i); @@ -539,7 +520,7 @@ static void json_feerates(struct command *cmd, static const struct json_command feerates_command = { "feerates", json_feerates, - "Add/query feerate estimates, either satoshi-per-kw ({style} sipa) or satoshi-per-kb ({style} bitcoind) for {urgent}, {normal} and {slow}." + "Return feerate estimates, either satoshi-per-kw ({style} perkw) or satoshi-per-kb ({style} perkb)." }; AUTODATA(json_command, &feerates_command); diff --git a/tests/test_misc.py b/tests/test_misc.py index a61ac864d..ed377055b 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -880,7 +880,8 @@ def test_feerates(node_factory): assert feerates['perkb']['min_acceptable'] == 253 * 4 # Now try setting them, one at a time. - feerates = l1.rpc.feerates('perkw', 15000) + l1.set_feerates((15000, 0, 0), True) + feerates = l1.rpc.feerates('perkw') assert len(feerates['perkw']) == 3 assert feerates['perkw']['urgent'] == 15000 assert feerates['warning'] == 'Some fee estimates unavailable: bitcoind startup?' @@ -888,7 +889,8 @@ def test_feerates(node_factory): assert feerates['perkw']['max_acceptable'] == 15000 * 10 assert feerates['perkw']['min_acceptable'] == 253 - feerates = l1.rpc.feerates('perkb', normal=25000) + l1.set_feerates((15000, 6250, 0), True) + feerates = l1.rpc.feerates('perkb') assert len(feerates['perkb']) == 4 assert feerates['perkb']['urgent'] == 15000 * 4 assert feerates['perkb']['normal'] == 25000 @@ -897,7 +899,8 @@ def test_feerates(node_factory): assert feerates['perkb']['max_acceptable'] == 15000 * 4 * 10 assert feerates['perkb']['min_acceptable'] == 253 * 4 - feerates = l1.rpc.feerates('perkw', None, None, 5000) + l1.set_feerates((15000, 6250, 5000), True) + feerates = l1.rpc.feerates('perkw') assert len(feerates['perkw']) == 5 assert feerates['perkw']['urgent'] == 15000 assert feerates['perkw']['normal'] == 25000 // 4 @@ -907,30 +910,6 @@ def test_feerates(node_factory): assert feerates['perkw']['max_acceptable'] == 15000 * 10 assert feerates['perkw']['min_acceptable'] == 5000 // 2 - # Now, outliers effect min and max, not so much the smoothed avg. - feerates = l1.rpc.feerates('perkw', 30000, None, 600) - assert len(feerates['perkw']) == 5 - assert feerates['perkw']['urgent'] > 15000 - assert feerates['perkw']['urgent'] < 30000 - assert feerates['perkw']['normal'] == 25000 // 4 - assert feerates['perkw']['slow'] < 5000 - assert feerates['perkw']['slow'] > 600 - assert 'warning' not in feerates - assert 'perkb' not in feerates - assert feerates['perkw']['max_acceptable'] == 30000 * 10 - assert feerates['perkw']['min_acceptable'] == 600 // 2 - - # Forgotten after 3 more values inserted. - feerates = l1.rpc.feerates('perkw', 15000, 25000 // 4, 5000) - assert feerates['perkw']['max_acceptable'] == 30000 * 10 - assert feerates['perkw']['min_acceptable'] == 600 // 2 - feerates = l1.rpc.feerates('perkw', 15000, 25000 // 4, 5000) - assert feerates['perkw']['max_acceptable'] == 30000 * 10 - assert feerates['perkw']['min_acceptable'] == 600 // 2 - feerates = l1.rpc.feerates('perkw', 15000, 25000 // 4, 5000) - assert feerates['perkw']['max_acceptable'] == 15000 * 10 - assert feerates['perkw']['min_acceptable'] == 5000 // 2 - assert len(feerates['onchain_fee_estimates']) == 3 assert feerates['onchain_fee_estimates']['opening_channel_satoshis'] == feerates['perkw']['normal'] * 702 // 1000 assert feerates['onchain_fee_estimates']['mutual_close_satoshis'] == feerates['perkw']['normal'] * 673 // 1000