Skip to content

Commit 17943f7

Browse files
committed
Merge #13652: rpc: Fix that CWallet::AbandonTransaction would leave the grandchildren, etc. active
89e70f9 Fix that CWallet::AbandonTransaction would only traverse one level (Ben Woosley) Pull request description: 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. Tree-SHA512: df068b49637d299ad73237c7244005fe5aa966d6beae57aff12e6948f173d9381e1b5d08533f7e3a1416991ed57f9f1f7b834057141d85c07dc60bb1f0872cea
2 parents 171b03d + 89e70f9 commit 17943f7

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