Skip to content

Commit 718304d

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#26084: sendall: check if the maxtxfee has been exceeded
6f8e381 sendall: check if the maxtxfee has been exceeded (ishaanam) Pull request description: Previously the `sendall` RPC didn't check whether the fees of the transaction it creates exceed the set `maxtxfee`. This PR adds this check to `sendall` and a test case for it. ACKs for top commit: achow101: ACK 6f8e381 Xekyo: ACK 6f8e381 glozow: Concept ACK 6f8e381. The high feerate is unlikely but sendall should respect the existing wallet options. Tree-SHA512: 6ef0961937091293d49be16f17e4451cff3159d901c0c7c6e508883999dfe0c20ed4d7126bf74bfea8150d4c1eef961a45f0c28ef64562e6cb817fede2319f1a
2 parents 2e3cd26 + 6f8e381 commit 718304d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/wallet/rpc/spend.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,10 @@ RPCHelpMan sendall()
14021402
const CAmount fee_from_size{fee_rate.GetFee(tx_size.vsize)};
14031403
const CAmount effective_value{total_input_value - fee_from_size};
14041404

1405+
if (fee_from_size > pwallet->m_default_max_tx_fee) {
1406+
throw JSONRPCError(RPC_WALLET_ERROR, TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED).original);
1407+
}
1408+
14051409
if (effective_value <= 0) {
14061410
if (send_max) {
14071411
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Total value of UTXO pool too low to pay for transaction, try using lower feerate.");

test/functional/wallet_sendall.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ def sendall_fails_on_specific_inputs_with_send_max(self):
264264
recipients=[self.remainder_target],
265265
options={"inputs": [utxo], "send_max": True})
266266

267+
@cleanup
268+
def sendall_fails_on_high_fee(self):
269+
self.log.info("Test sendall fails if the transaction fee exceeds the maxtxfee")
270+
self.add_utxos([21])
271+
272+
assert_raises_rpc_error(
273+
-4,
274+
"Fee exceeds maximum configured by user",
275+
self.wallet.sendall,
276+
recipients=[self.remainder_target],
277+
fee_rate=100000)
278+
267279
def run_test(self):
268280
self.nodes[0].createwallet("activewallet")
269281
self.wallet = self.nodes[0].get_wallet_rpc("activewallet")
@@ -312,5 +324,8 @@ def run_test(self):
312324
# Sendall fails when using send_max while specifying inputs
313325
self.sendall_fails_on_specific_inputs_with_send_max()
314326

327+
# Sendall fails when providing a fee that is too high
328+
self.sendall_fails_on_high_fee()
329+
315330
if __name__ == '__main__':
316331
SendallTest().main()

0 commit comments

Comments
 (0)