chaintopology: new command 'parsefeerate'

Useful for parsing a passed in feerate before calling lightningd with
it, e.g. when you need to know what the feerate is for a fundpsbt before
calling fundpsbt

Changelog-Added: JSON-RPC: new command `parsefeerate` which takes a feerate string and returns the calculated perkw/perkb
This commit is contained in:
niftynei
2021-06-23 14:31:47 -05:00
committed by neil saitug
parent 2532aa003a
commit 43ae30df21
9 changed files with 148 additions and 10 deletions

View File

@@ -1462,6 +1462,11 @@ def test_feerates(node_factory):
types = ["opening", "mutual_close", "unilateral_close", "delayed_to_us",
"htlc_resolution", "penalty"]
# Try parsing the feerates, won't work because can't estimate
for t in types:
with pytest.raises(RpcError, match=r'Cannot estimate fees'):
feerate = l1.rpc.parsefeerate(t)
# Query feerates (shouldn't give any!)
wait_for(lambda: len(l1.rpc.feerates('perkw')['perkw']) == 2)
feerates = l1.rpc.feerates('perkw')
@@ -1539,6 +1544,13 @@ def test_feerates(node_factory):
htlc_feerate = feerates["perkw"]["htlc_resolution"]
htlc_timeout_cost = feerates["onchain_fee_estimates"]["htlc_timeout_satoshis"]
htlc_success_cost = feerates["onchain_fee_estimates"]["htlc_success_satoshis"]
# Try parsing the feerates, won't work because can't estimate
for t in types:
feerate = l1.rpc.parsefeerate(t)
assert feerate['perkw']
assert 'perkb' not in feerate
if EXPERIMENTAL_FEATURES:
# option_anchor_outputs
assert htlc_timeout_cost == htlc_feerate * 666 // 1000