The following scenario will not notify the caller of the fact tx0
has been dropped:
- User 1 receives BTC in tx0 from utxo1 in block aa1.
- User 2 receives BTC in tx1 from utxo1 (same) in block bb1
- User 1 sees 2 confirmations at block aa3.
- Reorg into bb chain.
- User 1 asks
listsinceblock aa3
and does not see that tx0 is now invalidated.
See listsinceblock.py
commit for related test.
The proposed fix is to iterate from the given block down to the fork point, and to check each transaction in the blocks against the wallet, in addition to including all transactions from the fork point to the active chain tip (the current behavior). Any transactions that were present will now also be listed in the listsinceblock
output in a new replaced
array. This operation may be a bit heavy but the circumstances (and perceived frequency of occurrence) warrant it, I believe.
Example output:
0{
1 'transactions': [],
2 'replaced': [
3 {
4 'walletconflicts': [],
5 'vout': 1,
6 'account': '',
7 'timereceived': 1485234857,
8 'time': 1485234857,
9 'amount': '1.00000000',
10 'bip125-replaceable': 'unknown',
11 'trusted': False,
12 'category': 'receive',
13 'txid': 'ce673859a30dee1d2ebdb3c05f2eea7b1da54baf68f93bb8bfe37c5f09ed22ff',
14 'address': 'miqEt4kWp9zSizwGGuUWLAmxEcTW9bFUnQ',
15 'label': '',
16 'confirmations': -7
17 }
18 ],
19 'lastblock': '7a388f27d09e3699102a4ebf81597d974fc4c72093eeaa02adffbbf7527f6715'
20}
I believe this addresses the comment by @luke-jr in #9516 (comment) but I could be wrong..