Fixes #36363
test_maxfeerate configured -maxfeerate=0.00001009 and then created a
transaction requesting the exact same fee rate. This is fragile because the
wallet sizes the fee from the estimated (maximum) signed vsize, while the
-maxfeerate limit is checked against the actual signed vsize.
When the actual signature is smaller than the estimate, the actual vsize is smaller than estimated resulting in a higher feerate and the transaction is rejected, causing intermittent CI failures.
Request a fee rate slightly below -maxfeerate so the transaction is accepted
regardless of the signature size, while still exercising the limit.
Can be reproduced with
--- a/test/functional/wallet_send.py
+++ b/test/functional/wallet_send.py
@@ -221,8 +221,17 @@ class WalletSendTest(BitcoinTestFramework):
self.nodes[0].sendtoaddress, address=self.nodes[0].getnewaddress(), amount=1, fee_rate=11)
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), amount=1, fee_rate=9)
- self.restart_node(0, extra_args=['-maxfeerate=0.00001009'])
- self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), amount=1, fee_rate=Decimal("1.009"))
+ self.restart_node(0, extra_args=['-maxfeerate=0.00001009', '-changetype=bech32m'])
+ w = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
+ tr_addr = w.getnewaddress(address_type="bech32m")
+ funding_txid = w.sendtoaddress(tr_addr, 5)
+ self.generate(self.nodes[0], 1)
+ vout = next(o["n"] for o in w.gettransaction(funding_txid, verbose=True)["decoded"]["vout"]
+ if o["scriptPubKey"]["address"] == tr_addr)
+ # Spend the taproot input at exactly maxfeerate. The tr() descriptor
+ # estimates a 65-byte sig but the key-path spend is 64 bytes, so the
+ # estimated vsize always exceeds the actual deterministic rejection.
+ w.send(outputs={w.getnewaddress(): 1}, fee_rate=Decimal("1.009"),
+ options={"inputs": [{"txid": funding_txid, "vout": vout}], "add_inputs": False})
The actual failure in #36363 is intermittent because legacy output signatures only sometimes result in a tx size smaller than estimated. It can be reproduced in master by running the test on the file from 100 to 200 times.
And running it again at the same time with this PR does not fail.