Skip to content

Commit 5c824ac

Browse files
john-moffettfanquake
authored andcommitted
For feebump, ignore abandoned descendant spends
To be eligible for fee-bumping, a transaction must not have any of its outputs (eg - change) spent in other unconfirmed transactions in the wallet. However, this check should not apply to abandoned transactions. A new test case is added to cover this case. Github-Pull: #26675 Rebased-From: f9ce0ea
1 parent 428dcd5 commit 5c824ac

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ bool CWallet::HasWalletSpend(const CTransactionRef& tx) const
589589
AssertLockHeld(cs_wallet);
590590
const uint256& txid = tx->GetHash();
591591
for (unsigned int i = 0; i < tx->vout.size(); ++i) {
592-
auto iter = mapTxSpends.find(COutPoint(txid, i));
593-
if (iter != mapTxSpends.end()) {
592+
if (IsSpent(COutPoint(txid, i))) {
594593
return true;
595594
}
596595
}

test/functional/wallet_bumpfee.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def run_test(self):
8989
test_nonrbf_bumpfee_fails(self, peer_node, dest_address)
9090
test_notmine_bumpfee(self, rbf_node, peer_node, dest_address)
9191
test_bumpfee_with_descendant_fails(self, rbf_node, rbf_node_address, dest_address)
92+
test_bumpfee_with_abandoned_descendant_succeeds(self, rbf_node, rbf_node_address, dest_address)
9293
test_dust_to_fee(self, rbf_node, dest_address)
9394
test_watchonly_psbt(self, peer_node, rbf_node, dest_address)
9495
test_rebumping(self, rbf_node, dest_address)
@@ -294,6 +295,35 @@ def test_bumpfee_with_descendant_fails(self, rbf_node, rbf_node_address, dest_ad
294295
self.clear_mempool()
295296

296297

298+
def test_bumpfee_with_abandoned_descendant_succeeds(self, rbf_node, rbf_node_address, dest_address):
299+
self.log.info('Test that fee can be bumped when it has abandoned descendant')
300+
# parent is send-to-self, so we don't have to check which output is change when creating the child tx
301+
parent_id = spend_one_input(rbf_node, rbf_node_address)
302+
# Submit child transaction with low fee
303+
child_id = rbf_node.send(outputs={dest_address: 0.00020000},
304+
options={"inputs": [{"txid": parent_id, "vout": 0}], "fee_rate": 2})["txid"]
305+
assert child_id in rbf_node.getrawmempool()
306+
307+
# Restart the node with higher min relay fee so the descendant tx is no longer in mempool so that we can abandon it
308+
self.restart_node(1, ['-minrelaytxfee=0.00005'] + self.extra_args[1])
309+
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
310+
self.connect_nodes(1, 0)
311+
assert parent_id in rbf_node.getrawmempool()
312+
assert child_id not in rbf_node.getrawmempool()
313+
# Should still raise an error even if not in mempool
314+
assert_raises_rpc_error(-8, "Transaction has descendants in the wallet", rbf_node.bumpfee, parent_id)
315+
# Now abandon the child transaction and bump the original
316+
rbf_node.abandontransaction(child_id)
317+
bumped_result = rbf_node.bumpfee(parent_id, {"fee_rate": HIGH})
318+
assert bumped_result['txid'] in rbf_node.getrawmempool()
319+
assert parent_id not in rbf_node.getrawmempool()
320+
# Cleanup
321+
self.restart_node(1, self.extra_args[1])
322+
rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
323+
self.connect_nodes(1, 0)
324+
self.clear_mempool()
325+
326+
297327
def test_small_output_with_feerate_succeeds(self, rbf_node, dest_address):
298328
self.log.info('Testing small output with feerate bump succeeds')
299329

0 commit comments

Comments
 (0)