diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 51f8d3691..a94c9a1c8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1450,7 +1450,15 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO // surfaces exactly where it used to. std::vector rootNotes; for (const std::pair& wtxItem : mapWallet) { - if (wtxItem.second.mapSaplingNoteData.empty() || wtxItem.second.GetDepthInMainChain() <= 0) + // Once every note is validated (the steady state between restarts) nothing here selects one, so + // skip the depth lookup for such a tx. + bool fAnyUnvalidated = false; + for (const mapSaplingNoteData_t::value_type& item : wtxItem.second.mapSaplingNoteData) + if (!item.second.witnessRootValidated) { + fAnyUnvalidated = true; + break; + } + if (!fAnyUnvalidated || wtxItem.second.GetDepthInMainChain() <= 0) continue; for (const mapSaplingNoteData_t::value_type& item : wtxItem.second.mapSaplingNoteData) { const SaplingNoteData* nd = &(item.second);