diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2518,8 +2518,7 @@ "\"stuck\" or evicted transactions.\n" "It only works on transactions which are not included in a block " "and are not currently in the mempool.\n" - "It has no effect on transactions which are already conflicted or " - "abandoned.\n" + "It has no effect on transactions which are already abandoned.\n" "\nArguments:\n" "1. \"txid\" (string, required) The transaction id\n" "\nResult:\n" diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1117,7 +1117,7 @@ bool CWallet::TransactionCanBeAbandoned(const TxId &txid) const { LOCK2(cs_main, cs_wallet); const CWalletTx *wtx = GetWalletTx(txid); - return wtx && !wtx->isAbandoned() && wtx->GetDepthInMainChain() <= 0 && + return wtx && !wtx->isAbandoned() && wtx->GetDepthInMainChain() == 0 && !wtx->InMempool(); } @@ -1133,7 +1133,7 @@ auto it = mapWallet.find(txid); assert(it != mapWallet.end()); CWalletTx &origtx = it->second; - if (origtx.GetDepthInMainChain() > 0 || origtx.InMempool()) { + if (origtx.GetDepthInMainChain() != 0 || origtx.InMempool()) { return false; } diff --git a/test/functional/wallet_abandonconflict.py b/test/functional/wallet_abandonconflict.py --- a/test/functional/wallet_abandonconflict.py +++ b/test/functional/wallet_abandonconflict.py @@ -8,7 +8,7 @@ descendants as abandoned which allows their inputs to be respent. It can be used to replace "stuck" or evicted transactions. It only works on transactions which are not included in a block and are not currently in the mempool. It has - no effect on transactions which are already conflicted or abandoned. + no effect on transactions which are already abandoned. """ from decimal import Decimal @@ -16,6 +16,7 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, + assert_raises_rpc_error, connect_nodes, disconnect_nodes, satoshi_round, @@ -50,6 +51,14 @@ sync_mempools(self.nodes) self.nodes[1].generate(1) + + # Can not abandon non-wallet transaction + assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', + lambda: self.nodes[0].abandontransaction(txid='ff' * 32)) + # Can not abandon confirmed transaction + assert_raises_rpc_error(-5, 'Transaction not eligible for abandonment', + lambda: self.nodes[0].abandontransaction(txid=txA)) + sync_blocks(self.nodes) newbalance = self.nodes[0].getbalance()