@@ -1700,18 +1700,19 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
17001700 bool next_block;
17011701 uint256 next_block_hash;
17021702 bool reorg = false ;
1703+
1704+ next_block = chain ().findNextBlock (block_hash, block_height, FoundBlock ().hash (next_block_hash), &reorg);
1705+ if (reorg) {
1706+ // Abort scan if current block is no longer active, to prevent
1707+ // marking transactions as coming from the wrong block.
1708+ // TODO: This should return success instead of failure, see
1709+ // https://github.com/bitcoin/bitcoin/pull/14711#issuecomment-458342518
1710+ result.last_failed_block = block_hash;
1711+ result.status = ScanResult::FAILURE;
1712+ break ;
1713+ }
17031714 if (chain ().findBlock (block_hash, FoundBlock ().data (block)) && !block.IsNull ()) {
17041715 LOCK (cs_wallet);
1705- next_block = chain ().findNextBlock (block_hash, block_height, FoundBlock ().hash (next_block_hash), &reorg);
1706- if (reorg) {
1707- // Abort scan if current block is no longer active, to prevent
1708- // marking transactions as coming from the wrong block.
1709- // TODO: This should return success instead of failure, see
1710- // https://github.com/bitcoin/bitcoin/pull/14711#issuecomment-458342518
1711- result.last_failed_block = block_hash;
1712- result.status = ScanResult::FAILURE;
1713- break ;
1714- }
17151716 for (size_t posInBlock = 0 ; posInBlock < block.vtx .size (); ++posInBlock) {
17161717 SyncTransaction (block.vtx [posInBlock], {CWalletTx::Status::CONFIRMED, block_height, block_hash, (int )posInBlock}, fUpdate );
17171718 }
@@ -1722,7 +1723,6 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
17221723 // could not scan block, keep scanning but record this block as the most recent failure
17231724 result.last_failed_block = block_hash;
17241725 result.status = ScanResult::FAILURE;
1725- next_block = chain ().findNextBlock (block_hash, block_height, FoundBlock ().hash (next_block_hash), &reorg);
17261726 }
17271727 if (max_height && block_height >= *max_height) {
17281728 break ;
0 commit comments