lightningd: allow "NNblocks" and "minimum" as feerates.

And consolidate descriptions into lightning-feerates().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `close`, `fundchannel`, `fundpsbt`, `multifundchannel`, `multiwithdraw`, `txprepare`, `upgradewallet`, `withdraw` now allow "minimum" and NN"blocks" as `feerate` (`feerange` for `close`).
This commit is contained in:
Rusty Russell
2023-04-07 14:13:45 +09:30
parent 64b1ddd761
commit c46473e615
13 changed files with 69 additions and 81 deletions

View File

@@ -3282,10 +3282,25 @@ def test_feerate_arg(node_factory):
fees["penalty"] = by_blocks[12]
fees["unilateral_close"] = by_blocks[6]
fees["2blocks"] = by_blocks[2]
fees["6blocks"] = by_blocks[6]
fees["12blocks"] = by_blocks[12]
fees["100blocks"] = by_blocks[100]
# Simple interpolation
fees["9blocks"] = (by_blocks[6] + by_blocks[12]) // 2
for fee, expect in fees.items():
# Put arg in assertion, so it gets printed on failure!
assert (l1.rpc.parsefeerate(fee), fee) == ({'perkw': expect}, fee)
# More thorough interpolation
for block in range(12, 100):
# y = y1 + (x-x1)(y2-y1)/(x2-x1)
fee = by_blocks[12] + (block - 12) * (by_blocks[100] - by_blocks[12]) // (100 - 12)
# Rounding error is a thing!
assert abs(l1.rpc.parsefeerate(f"{block}blocks")['perkw'] - fee) <= 1
@pytest.mark.skip(reason="Fails by intention for creating test gossip stores")
def test_create_gossip_mesh(node_factory, bitcoind):