plugins/bcli: use getmempoolinfo to determine minimum possible fee.

Fixes: #4473
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: wallet: we no longer make txs below minrelaytxfee or mempoolminfee.
This commit is contained in:
Rusty Russell
2023-03-23 16:18:09 +10:30
parent 38bc04907b
commit e6db0eafc2
2 changed files with 162 additions and 14 deletions

View File

@@ -1883,8 +1883,10 @@ def test_bitcoind_fail_first(node_factory, bitcoind):
def mock_fail(*args):
raise ValueError()
# If any of these succeed, they reset fail timeout.
l1.daemon.rpcproxy.mock_rpc('getblockhash', mock_fail)
l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', mock_fail)
l1.daemon.rpcproxy.mock_rpc('getmempoolinfo', mock_fail)
l1.daemon.start(wait_for_initialized=False, stderr_redir=True)
l1.daemon.wait_for_logs([r'getblockhash [a-z0-9]* exited with status 1',
@@ -1898,6 +1900,94 @@ def test_bitcoind_fail_first(node_factory, bitcoind):
l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', None)
@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "Fees on elements are different")
def test_bitcoind_feerate_floor(node_factory, bitcoind):
"""Don't return a feerate less than minrelaytxfee/mempoolnifee."""
l1 = node_factory.get_node()
anchors = EXPERIMENTAL_FEATURES
assert l1.rpc.feerates('perkb') == {
"perkb": {
"opening": 30000,
"mutual_close": 15000,
"unilateral_close": 44000,
"delayed_to_us": 30000,
"htlc_resolution": 44000,
"penalty": 30000,
"min_acceptable": 7500,
"max_acceptable": 600000
},
"onchain_fee_estimates": {
"opening_channel_satoshis": 5265,
"mutual_close_satoshis": 2523,
"unilateral_close_satoshis": 6578,
"htlc_timeout_satoshis": 7326 if anchors else 7293,
"htlc_success_satoshis": 7766 if anchors else 7733,
}
}
l1.daemon.rpcproxy.mock_rpc('getmempoolinfo',
{
"mempoolminfee": 0.00010001,
"minrelaytxfee": 0.00020001
})
l1.restart()
assert l1.rpc.feerates('perkb') == {
"perkb": {
"opening": 30000,
# This has increased (rounded up)
"mutual_close": 20004,
"unilateral_close": 44000,
"delayed_to_us": 30000,
"htlc_resolution": 44000,
"penalty": 30000,
# This has increased (rounded up!)
"min_acceptable": 20004,
"max_acceptable": 600000
},
"onchain_fee_estimates": {
"opening_channel_satoshis": 5265,
# This increases too
"mutual_close_satoshis": 3365,
"unilateral_close_satoshis": 6578,
"htlc_timeout_satoshis": 7326 if anchors else 7293,
"htlc_success_satoshis": 7766 if anchors else 7733,
}
}
l1.daemon.rpcproxy.mock_rpc('getmempoolinfo',
{
"mempoolminfee": 0.00030001,
"minrelaytxfee": 0.00010001
})
l1.restart()
assert l1.rpc.feerates('perkb') == {
"perkb": {
# This has increased (rounded up!)
"opening": 30004,
# This has increased (rounded up!)
"mutual_close": 30004,
"unilateral_close": 44000,
# This has increased (rounded up!)
"delayed_to_us": 30004,
"htlc_resolution": 44000,
# This has increased (rounded up!)
"penalty": 30004,
# This has increased (rounded up!)
"min_acceptable": 30004,
"max_acceptable": 600000
},
"onchain_fee_estimates": {
"opening_channel_satoshis": 5265,
# This increases too
"mutual_close_satoshis": 5048,
"unilateral_close_satoshis": 6578,
"htlc_timeout_satoshis": 7326 if anchors else 7293,
"htlc_success_satoshis": 7766 if anchors else 7733,
}
}
@pytest.mark.developer("needs --dev-force-bip32-seed")
@unittest.skipIf(TEST_NETWORK != 'regtest', "Addresses are network specific")
def test_dev_force_bip32_seed(node_factory):