mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-12 18:44:59 +01:00
wallet: Iterate block txs in reverse on blockDisconnected
When a block is disconnected, we need to process the transactions in reverse order so that the wallet's TXO set is updated in the correct order.
This commit is contained in:
parent
710a59dcc4
commit
f8a18da0fb
1 changed files with 4 additions and 1 deletions
|
@ -1558,7 +1558,10 @@ void CWallet::blockDisconnected(const interfaces::BlockInfo& block)
|
|||
|
||||
int disconnect_height = block.height;
|
||||
|
||||
for (const CTransactionRef& ptx : Assert(block.data)->vtx) {
|
||||
Assert(block.data);
|
||||
// Iterate the block backwards so that we can undo the UTXO changes in the correct order
|
||||
for (auto it = block.data->vtx.rbegin(); it != block.data->vtx.rend(); ++it) {
|
||||
const CTransactionRef& ptx = *it;
|
||||
SyncTransaction(ptx, TxStateInactive{});
|
||||
|
||||
for (const CTxIn& tx_in : ptx->vin) {
|
||||
|
|
Loading…
Add table
Reference in a new issue