From be3641158a67cf41d711614f614b14eb96b85fac Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 13 Sep 2024 04:11:38 -0400 Subject: [PATCH] Only take cs_main lock in GetSaplingSpendDepth We do not seem to need this lock for the entire DecrementNoteWitnesses function, we need it only when calling GetSaplingSpendDepth. Also protects against the case in the future where some code without cs_main calls GetSaplingSpendDepth. --- src/wallet/wallet.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6d8c78979..26faed52a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -887,6 +887,8 @@ bool CWallet::IsSaplingSpent(const uint256& nullifier) const { } unsigned int CWallet::GetSaplingSpendDepth(const uint256& nullifier) const { + LOCK(cs_main); + pair range; range = mapTxSaplingNullifiers.equal_range(nullifier); @@ -977,10 +979,11 @@ void CWallet::ClearNoteWitnessCache() void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) { - LOCK2(cs_main, cs_wallet); extern int32_t HUSH_REWIND; + LOCK(cs_wallet); + for (std::pair& wtxItem : mapWallet) { //Sapling for (auto& item : wtxItem.second.mapSaplingNoteData) {