mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
rpc: for sat/vB fee rates, limit ParseFixedPoint decimals to 3
This commit is contained in:
parent
0742c7840f
commit
06a90fa038
5 changed files with 11 additions and 9 deletions
|
@ -216,7 +216,8 @@ static void SetFeeEstimateMode(const CWallet& wallet, CCoinControl& cc, const Un
|
|||
if (!estimate_mode.isNull() && estimate_mode.get_str() != "unset") {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify both estimate_mode and fee_rate");
|
||||
}
|
||||
cc.m_feerate = CFeeRate(AmountFromValue(fee_rate), COIN);
|
||||
// Fee rates in sat/vB cannot represent more than 3 significant digits.
|
||||
cc.m_feerate = CFeeRate{AmountFromValue(fee_rate, /* decimals */ 3)};
|
||||
if (override_min_fee) cc.fOverrideFeeRate = true;
|
||||
// Default RBF to true for explicit fee_rate, if unset.
|
||||
if (!cc.m_signal_bip125_rbf) cc.m_signal_bip125_rbf = true;
|
||||
|
|
|
@ -773,7 +773,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
assert_raises_rpc_error(-3, "Invalid amount", node.fundrawtransaction, rawtx, {param: invalid_value, "add_inputs": True})
|
||||
|
||||
self.log.info("Test min fee rate checks are bypassed with fundrawtxn, e.g. a fee_rate under 1 sat/vB is allowed")
|
||||
node.fundrawtransaction(rawtx, {"fee_rate": 0.99999999, "add_inputs": True})
|
||||
node.fundrawtransaction(rawtx, {"fee_rate": 0.999, "add_inputs": True})
|
||||
node.fundrawtransaction(rawtx, {"feeRate": 0.00000999, "add_inputs": True})
|
||||
|
||||
self.log.info("- raises RPC error if both feeRate and fee_rate are passed")
|
||||
|
|
|
@ -195,7 +195,7 @@ class PSBTTest(BitcoinTestFramework):
|
|||
assert_approx(res2["fee"], 0.055, 0.005)
|
||||
|
||||
self.log.info("Test min fee rate checks with walletcreatefundedpsbt are bypassed, e.g. a fee_rate under 1 sat/vB is allowed")
|
||||
res3 = self.nodes[1].walletcreatefundedpsbt(inputs, outputs, 0, {"fee_rate": "0.99999999", "add_inputs": True})
|
||||
res3 = self.nodes[1].walletcreatefundedpsbt(inputs, outputs, 0, {"fee_rate": "0.999", "add_inputs": True})
|
||||
assert_approx(res3["fee"], 0.00000381, 0.0000001)
|
||||
res4 = self.nodes[1].walletcreatefundedpsbt(inputs, outputs, 0, {"feeRate": 0.00000999, "add_inputs": True})
|
||||
assert_approx(res4["fee"], 0.00000381, 0.0000001)
|
||||
|
|
|
@ -265,7 +265,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
# Test setting explicit fee rate just below the minimum.
|
||||
self.log.info("Test sendmany raises 'fee rate too low' if fee_rate of 0.99999999 is passed")
|
||||
assert_raises_rpc_error(-6, "Fee rate (0.999 sat/vB) is lower than the minimum fee rate setting (1.000 sat/vB)",
|
||||
self.nodes[2].sendmany, amounts={address: 10}, fee_rate=0.99999999)
|
||||
self.nodes[2].sendmany, amounts={address: 10}, fee_rate=0.999)
|
||||
|
||||
self.log.info("Test sendmany raises if an invalid fee_rate is passed")
|
||||
# Test fee_rate with zero values.
|
||||
|
@ -458,7 +458,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
# Test setting explicit fee rate just below the minimum.
|
||||
self.log.info("Test sendtoaddress raises 'fee rate too low' if fee_rate of 0.99999999 is passed")
|
||||
assert_raises_rpc_error(-6, "Fee rate (0.999 sat/vB) is lower than the minimum fee rate setting (1.000 sat/vB)",
|
||||
self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=0.99999999)
|
||||
self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=0.999)
|
||||
|
||||
self.log.info("Test sendtoaddress raises if an invalid fee_rate is passed")
|
||||
# Test fee_rate with zero values.
|
||||
|
|
|
@ -350,10 +350,11 @@ class WalletSendTest(BitcoinTestFramework):
|
|||
|
||||
# Test setting explicit fee rate just below the minimum of 1 sat/vB.
|
||||
self.log.info("Explicit fee rate raises RPC error 'fee rate too low' if fee_rate of 0.99999999 is passed")
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=0.99999999,
|
||||
expect_error=(-4, "Fee rate (0.999 sat/vB) is lower than the minimum fee rate setting (1.000 sat/vB)"))
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=0.99999999,
|
||||
expect_error=(-4, "Fee rate (0.999 sat/vB) is lower than the minimum fee rate setting (1.000 sat/vB)"))
|
||||
msg = "Fee rate (0.999 sat/vB) is lower than the minimum fee rate setting (1.000 sat/vB)"
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=0.999, expect_error=(-4, msg))
|
||||
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=0.999, expect_error=(-4, msg))
|
||||
|
||||
self.log.info("Explicit fee rate raises if invalid fee_rate is passed")
|
||||
# Test fee_rate with zero values.
|
||||
msg = "Fee rate (0.000 sat/vB) is lower than the minimum fee rate setting (1.000 sat/vB)"
|
||||
for zero_value in [0, 0.000, 0.00000000, "0", "0.000", "0.00000000"]:
|
||||
|
|
Loading…
Add table
Reference in a new issue