mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-12 22:52:47 +02:00
sendall: check if the maxtxfee has been exceeded
This commit is contained in:
@ -1402,6 +1402,10 @@ RPCHelpMan sendall()
|
|||||||
const CAmount fee_from_size{fee_rate.GetFee(tx_size.vsize)};
|
const CAmount fee_from_size{fee_rate.GetFee(tx_size.vsize)};
|
||||||
const CAmount effective_value{total_input_value - fee_from_size};
|
const CAmount effective_value{total_input_value - fee_from_size};
|
||||||
|
|
||||||
|
if (fee_from_size > pwallet->m_default_max_tx_fee) {
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED).original);
|
||||||
|
}
|
||||||
|
|
||||||
if (effective_value <= 0) {
|
if (effective_value <= 0) {
|
||||||
if (send_max) {
|
if (send_max) {
|
||||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Total value of UTXO pool too low to pay for transaction, try using lower feerate.");
|
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Total value of UTXO pool too low to pay for transaction, try using lower feerate.");
|
||||||
|
@ -264,6 +264,18 @@ class SendallTest(BitcoinTestFramework):
|
|||||||
recipients=[self.remainder_target],
|
recipients=[self.remainder_target],
|
||||||
options={"inputs": [utxo], "send_max": True})
|
options={"inputs": [utxo], "send_max": True})
|
||||||
|
|
||||||
|
@cleanup
|
||||||
|
def sendall_fails_on_high_fee(self):
|
||||||
|
self.log.info("Test sendall fails if the transaction fee exceeds the maxtxfee")
|
||||||
|
self.add_utxos([21])
|
||||||
|
|
||||||
|
assert_raises_rpc_error(
|
||||||
|
-4,
|
||||||
|
"Fee exceeds maximum configured by user",
|
||||||
|
self.wallet.sendall,
|
||||||
|
recipients=[self.remainder_target],
|
||||||
|
fee_rate=100000)
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.nodes[0].createwallet("activewallet")
|
self.nodes[0].createwallet("activewallet")
|
||||||
self.wallet = self.nodes[0].get_wallet_rpc("activewallet")
|
self.wallet = self.nodes[0].get_wallet_rpc("activewallet")
|
||||||
@ -312,5 +324,8 @@ class SendallTest(BitcoinTestFramework):
|
|||||||
# Sendall fails when using send_max while specifying inputs
|
# Sendall fails when using send_max while specifying inputs
|
||||||
self.sendall_fails_on_specific_inputs_with_send_max()
|
self.sendall_fails_on_specific_inputs_with_send_max()
|
||||||
|
|
||||||
|
# Sendall fails when providing a fee that is too high
|
||||||
|
self.sendall_fails_on_high_fee()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
SendallTest().main()
|
SendallTest().main()
|
||||||
|
Reference in New Issue
Block a user