Bitshala / BitcoinCore-PR-Review-Club

Bitcoin Core PR Review Organising repo
10 stars 2 forks source link

wallet: when a block is disconnected, update transactions that are no longer conflicted #27145 #25

Closed rajarshimaitra closed 1 year ago

rajarshimaitra commented 1 year ago

Session Details

Notes

A trasnaction is considered "conflicted" when one or more of its inputs are being spent by another transaction. A Conflicted transaction is marked with negative confirmation height in the gettransaction rpc call.

7315 described the situation when a conflicted transaction was previously in a block, which has later been reorged out. A reorg is a situation where a new longer chain has replaced a specific portion of the existing blockchain. So transactions in the reorged blocks are rejected.

When a conflict with an existing wallet transaction and a transaction in reorged block is identified, previously the conflicted transaction's state wasn't updated. This would cause irregular calculation in balance, as the inputs of the conflicting transaction, which were marked unspendable, becomes spendable again.

#27145 updates this behavior, and in case of block reorgs, the conflicted wallet transactions are marked as "inactive".

Questions?

Learning