mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 10:19:26 +02:00
Merge #20220: wallet, rpc: explicit fee rate follow-ups/fixes for 0.21
0be29000c0
rpc: update conf_target helps for correctness/consistency (Jon Atack)778b9be406
wallet, rpc: fix send subtract_fee_from_outputs help (Jon Atack)603c005083
wallet: add rpc send explicit fee rate coverage (Jon Atack)dd341e602d
wallet: add sendtoaddress/sendmany explicit fee rate coverage (Jon Atack)44e7bfa603
wallet: add walletcreatefundedpsbt explicit fee rate coverage (Jon Atack)6e1ea4273e
test: refactor for walletcreatefundedpsbt fee rate coverage (Jon Atack)3ac7b0c6f1
wallet: fundrawtx fee rate coverage, fixup ParseConfirmTarget() (Jon Atack)2d8eba8f84
wallet: combine redundant bumpfee invalid params and args tests (Jon Atack)1697a40b6f
wallet: improve bumpfee error/help, add explicit fee rate coverage (Jon Atack)fc5721723d
wallet: fix SetFeeEstimateMode() error message (Jon Atack)052427eef1
wallet, bugfix: fix bumpfee with explicit fee rate modes (Jon Atack) Pull request description: Follow-up to #11413 providing a base to build on for #19543: - bugfix for `bumpfee` raising a JSON error with explicit feerates, fixes issue #20219 - adds explicit feerate test coverage for `bumpfee`, `fundrawtransaction`, `walletcreatefundedpsbt`, `send`, `sendtoaddress`, and `sendmany` - improves a few related RPC error messages and `ParseConfirmTarget()` / error message - fixes/improves the explicit fee rate information in the 6 RPC helps, of which 2 were also missing `conf_target` sat/B units This provides a spec and regression coverage for the potential next step of a universal `sat/vB` feerate argument (see #19543), as well as immediate coverage and minimum fixes for 0.21. ACKs for top commit: kallewoof: Concept/Tested ACK0be29000c0
meshcollider: Code review + functional test run ACK0be29000c0
Tree-SHA512: efd965003e991cba51d4504e2940f06ab3d742e34022e96a673606b44fad85596aa03a8c1809f06df7ebcf21a38e18a891e54392fe3d6fb4d120bbe4ea0cf5e0
This commit is contained in:
@ -8,6 +8,7 @@ from decimal import Decimal
|
||||
from test_framework.descriptors import descsum_create
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_approx,
|
||||
assert_equal,
|
||||
assert_fee_amount,
|
||||
assert_greater_than,
|
||||
@ -89,6 +90,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
self.test_op_return()
|
||||
self.test_watchonly()
|
||||
self.test_all_watched_funds()
|
||||
self.test_feerate_with_conf_target_and_estimate_mode()
|
||||
self.test_option_feerate()
|
||||
self.test_address_reuse()
|
||||
self.test_option_subtract_fee_from_outputs()
|
||||
@ -722,6 +724,59 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
assert_fee_amount(result2['fee'], count_bytes(result2['hex']), 2 * result_fee_rate)
|
||||
assert_fee_amount(result3['fee'], count_bytes(result3['hex']), 10 * result_fee_rate)
|
||||
|
||||
def test_feerate_with_conf_target_and_estimate_mode(self):
|
||||
self.log.info("Test fundrawtxn passing an explicit fee rate using conf_target and estimate_mode")
|
||||
node = self.nodes[3]
|
||||
# Make sure there is exactly one input so coin selection can't skew the result.
|
||||
assert_equal(len(node.listunspent(1)), 1)
|
||||
inputs = []
|
||||
outputs = {node.getnewaddress() : 1}
|
||||
rawtx = node.createrawtransaction(inputs, outputs)
|
||||
|
||||
for unit, fee_rate in {"btc/kb": 0.1, "sat/b": 10000}.items():
|
||||
self.log.info("Test fundrawtxn with conf_target {} estimate_mode {} produces expected fee".format(fee_rate, unit))
|
||||
# With no arguments passed, expect fee of 141 sats/b.
|
||||
assert_approx(node.fundrawtransaction(rawtx)["fee"], vexp=0.00000141, vspan=0.00000001)
|
||||
# Expect fee to be 10,000x higher when explicit fee 10,000x greater is specified.
|
||||
result = node.fundrawtransaction(rawtx, {"conf_target": fee_rate, "estimate_mode": unit})
|
||||
assert_approx(result["fee"], vexp=0.0141, vspan=0.0001)
|
||||
|
||||
for field, fee_rate in {"conf_target": 0.1, "estimate_mode": "sat/b"}.items():
|
||||
self.log.info("Test fundrawtxn raises RPC error if both feeRate and {} are passed".format(field))
|
||||
assert_raises_rpc_error(
|
||||
-8, "Cannot specify both {} and feeRate".format(field),
|
||||
lambda: node.fundrawtransaction(rawtx, {"feeRate": 0.1, field: fee_rate}))
|
||||
|
||||
self.log.info("Test fundrawtxn with invalid estimate_mode settings")
|
||||
for k, v in {"number": 42, "object": {"foo": "bar"}}.items():
|
||||
assert_raises_rpc_error(-3, "Expected type string for estimate_mode, got {}".format(k),
|
||||
lambda: self.nodes[1].fundrawtransaction(rawtx, {"estimate_mode": v, "conf_target": 0.1}))
|
||||
for mode in ["foo", Decimal("3.141592")]:
|
||||
assert_raises_rpc_error(-8, "Invalid estimate_mode parameter",
|
||||
lambda: self.nodes[1].fundrawtransaction(rawtx, {"estimate_mode": mode, "conf_target": 0.1}))
|
||||
|
||||
self.log.info("Test fundrawtxn with invalid conf_target settings")
|
||||
for mode in ["unset", "economical", "conservative", "btc/kb", "sat/b"]:
|
||||
self.log.debug("{}".format(mode))
|
||||
for k, v in {"string": "", "object": {"foo": "bar"}}.items():
|
||||
assert_raises_rpc_error(-3, "Expected type number for conf_target, got {}".format(k),
|
||||
lambda: self.nodes[1].fundrawtransaction(rawtx, {"estimate_mode": mode, "conf_target": v}))
|
||||
if mode in ["btc/kb", "sat/b"]:
|
||||
assert_raises_rpc_error(-3, "Amount out of range",
|
||||
lambda: self.nodes[1].fundrawtransaction(rawtx, {"estimate_mode": mode, "conf_target": -1}))
|
||||
assert_raises_rpc_error(-4, "Fee rate (0.00000000 BTC/kB) is lower than the minimum fee rate setting (0.00001000 BTC/kB)",
|
||||
lambda: self.nodes[1].fundrawtransaction(rawtx, {"estimate_mode": mode, "conf_target": 0}))
|
||||
else:
|
||||
for n in [-1, 0, 1009]:
|
||||
assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008",
|
||||
lambda: self.nodes[1].fundrawtransaction(rawtx, {"estimate_mode": mode, "conf_target": n}))
|
||||
|
||||
for unit, fee_rate in {"sat/B": 0.99999999, "BTC/kB": 0.00000999}.items():
|
||||
self.log.info("- raises RPC error 'fee rate too low' if conf_target {} and estimate_mode {} are passed".format(fee_rate, unit))
|
||||
assert_raises_rpc_error(-4, "Fee rate (0.00000999 BTC/kB) is lower than the minimum fee rate setting (0.00001000 BTC/kB)",
|
||||
lambda: self.nodes[1].fundrawtransaction(rawtx, {"estimate_mode": unit, "conf_target": fee_rate, "add_inputs": True}))
|
||||
|
||||
|
||||
def test_address_reuse(self):
|
||||
"""Test no address reuse occurs."""
|
||||
self.log.info("Test fundrawtxn does not reuse addresses")
|
||||
|
Reference in New Issue
Block a user