UI notifications and the -walletnotify process should be triggered for wallet transactions that are conflicted out of the mempool by a newly connected block.
Unfortunately, it has been broken by 7e89994 by removing the call to SyncTransaction()
for block-conflicted transactions in CWallet::BlockConnected
. This PR restores conflict tracking but instead relies on TransactionRemovedFromMempool
.
Doing so allows for wider conflict detection, i.e non-connected wallet transactions. Transaction A may not involves wallet but may be spent by a transaction B paying back to a wallet address. Double-spend of transaction A won’t trigger a conflict for transaction B as A isn’t tracked by wallet (mapTxSpends
).
This PR also extends conflicts detection to mempool replacement (MemPoolRemovalReason::REPLACED
), as for an end-user, consequences are likely to be interpreted the same, conflicted funds aren’t available. Distinction of reasons (block-connected or mempool-replacement) should stay clear for us.
Conflicts detection stays a best-effort, as a mempool replacement may happen while wallet is shutdown, and mempool isn’t replayed at wallet rescan, conflict can’t be see.
Fixes #18325