(These obscure notes are for eventually cleaning up wallet confliction and are low priority)
In the block connection logic we call
0BOOST_FOREACH(const CTransaction &tx, txConflicted)
1 {
2 SyncWithWallets(tx, pindexNewTip);
3 }
txConflicted
is returned by mempool.removeForBlock
and can therefore contain transactions that should be marked conflicted that wouldn’t be caught by the wallets own dependency tracking code (chains of mempool txs not all of which are in the wallet).
However, calling SyncWithWallets
without setting a posInBlock
has virtually no effect other than marking the cached credit/debit values as dirty. Since #7105 however wallet txs, that aren’t explicitly marked conflicted via the wallets code, aren’t actually known to be conflicted and are treated as just unconfirmed. I think the result of this is this SyncWithWallets loop is of dubious value.
- All txs that are caught by the wallets conflict detection would already be marked dirty, and the new txs this loop catches, can’t correctly reflect the right balance state anyway.
- It actually serves a detrimental effect on the transactions that were marked as abandoned that will now erroneously have their abandoned state cleared and be treated as unconfirmed. Their true state of conflicted matches much more closely to abandoned. (This will be corrected in the immediately following loop for txs that the wallet code catches)
It may be possible to just correctly MarkConflicted all these transactions, and then I think the only issue will be the txs that are only conflicted because they are dependents won’t properly have their cached values dirtied if the conflict goes away. This issue already exists #7315.
See IRC discussion https://botbot.me/freenode/bitcoin-core-dev/2016-09-09/?msg=72745343&page=3