Skip to content

Commit 34cd496

Browse files
EmpactWarrows
authored andcommitted
Fix that CWallet::AbandonTransaction would only traverse one level
Prior to this change, it would mark only the first layer of child transactions abandoned, due to always following the input hashTx rather than the current now tx.
1 parent aba5b75 commit 34cd496

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
830830
wtx.WriteToDisk(&walletdb);
831831
NotifyTransactionChanged(this, wtx.GetHash(), CT_UPDATED);
832832
// Iterate over all its outputs, and mark transactions in the wallet that spend them abandoned too
833-
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(hashTx, 0));
833+
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0));
834834
while (iter != mapTxSpends.end() && iter->first.hash == now) {
835835
if (!done.count(iter->second)) {
836836
todo.insert(iter->second);

test/functional/wallet_abandonconflict.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,17 @@ def run_test(self):
6666
signed2 = self.nodes[0].signrawtransaction(self.nodes[0].createrawtransaction(inputs, outputs))
6767
txABC2 = self.nodes[0].sendrawtransaction(signed2["hex"])
6868

69+
# Create a child tx spending ABC2
70+
signed3_change = Decimal("24.999")
71+
inputs = [ {"txid":txABC2, "vout":0} ]
72+
outputs = { self.nodes[0].getnewaddress(): signed3_change }
73+
signed3 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs, outputs))
74+
# note tx is never directly referenced, only abandoned as a child of the above
75+
self.nodes[0].sendrawtransaction(signed3["hex"])
76+
6977
# In mempool txs from self should increase balance from change
7078
newbalance = self.nodes[0].getbalance()
71-
assert_equal(newbalance, balance - Decimal("30") + Decimal("24.9996"))
79+
assert_equal(newbalance, balance - Decimal("30") + signed3_change)
7280
balance = newbalance
7381

7482
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool
@@ -83,7 +91,7 @@ def run_test(self):
8391
# Not in mempool txs from self should only reduce balance
8492
# inputs are still spent, but change not received
8593
newbalance = self.nodes[0].getbalance()
86-
assert_equal(newbalance, balance - Decimal("24.9996"))
94+
assert_equal(newbalance, balance - signed3_change)
8795
# Unconfirmed received funds that are not in mempool, also shouldn't show
8896
# up in unconfirmed balance
8997
unconfbalance = self.nodes[0].getunconfirmedbalance() + self.nodes[0].getbalance()

0 commit comments

Comments
 (0)