diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8d12d903a..bda0140f0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1032,7 +1032,10 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO //Cycle through blocks and transactions building sapling tree until the commitment needed is reached const CBlock* pblock; CBlock block; - ReadBlockFromDisk(block, pblockindex, 1); + if (!ReadBlockFromDisk(block, pblockindex, 1)) { + throw std::runtime_error( + strprintf("Cannot read block height %d (%s) from disk", pindex->GetHeight(), pindex->GetBlockHash().GetHex())); + } pblock = █ for (const CTransaction& tx : block.vtx) { @@ -1102,7 +1105,10 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly) //Cycle through blocks and transactions building sapling tree until the commitment needed is reached CBlock block; - ReadBlockFromDisk(block, pblockindex, 1); + if (!ReadBlockFromDisk(block, pblockindex, 1)) { + throw std::runtime_error( + strprintf("Cannot read block height %d (%s) from disk", pindex->GetHeight(), pindex->GetBlockHash().GetHex())); + } for (std::pair& wtxItem : mapWallet) { @@ -2721,7 +2727,11 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) CBlock block; bool involvesMe = false; - ReadBlockFromDisk(block, pindex,1); + if (!ReadBlockFromDisk(block, pindex,1)) { + throw std::runtime_error( + strprintf("Cannot read block height %d (%s) from disk", pindex->GetHeight(), pindex->GetBlockHash().GetHex())); + } + BOOST_FOREACH(CTransaction& tx, block.vtx) { if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) {