Skip to content

Commit 89e70f9

Browse files
committed
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 dcb154e commit 89e70f9

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
@@ -1146,7 +1146,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
11461146
batch.WriteTx(wtx);
11471147
NotifyTransactionChanged(this, wtx.GetHash(), CT_UPDATED);
11481148
// Iterate over all its outputs, and mark transactions in the wallet that spend them abandoned too
1149-
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(hashTx, 0));
1149+
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0));
11501150
while (iter != mapTxSpends.end() && iter->first.hash == now) {
11511151
if (!done.count(iter->second)) {
11521152
todo.insert(iter->second);

test/functional/wallet_abandonconflict.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,17 @@ def run_test(self):
7070
signed2 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs, outputs))
7171
txABC2 = self.nodes[0].sendrawtransaction(signed2["hex"])
7272

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

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

0 commit comments

Comments
 (0)