In commit "Replace Chain::checkFinal by CWallet::CheckFinalWalletTx" (1f479751b2eaf6f17ae76334b72ebc5fd76d8956)
I think it'd be safer to just add AssertLockHeld statements if the compiler can't determine that a particular lock is held, than to disable safety analysis altogether. On my system, the following changes seem to work:
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 9d291f0b585..c702f90681d 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1882,6 +1882,7 @@ bool CWalletTx::IsTrusted(interfaces::Chain::Lock& locked_chain) const
bool CWalletTx::IsTrusted(interfaces::Chain::Lock& locked_chain, std::set<uint256>& trusted_parents) const
{
// Quick answer in most cases
+ AssertLockHeld(pwallet->cs_wallet);
if (!pwallet->CheckFinalWalletTx(*tx)) return false;
int nDepth = GetDepthInMainChain();
if (nDepth >= 1) return true;
@@ -3967,6 +3968,7 @@ bool CWalletTx::IsImmatureCoinBase() const
bool CWalletTx::isFinal() const
{
+ AssertLockHeld(pwallet->cs_wallet);
return pwallet->CheckFinalWalletTx(*tx);
}
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index acf0de45f1c..4ae39ba328a 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -477,8 +477,8 @@ public:
bool IsEquivalentTo(const CWalletTx& tx) const;
bool InMempool() const;
- bool IsTrusted(interfaces::Chain::Lock& locked_chain) const NO_THREAD_SAFETY_ANALYSIS;
- bool IsTrusted(interfaces::Chain::Lock& locked_chain, std::set<uint256>& trusted_parents) const NO_THREAD_SAFETY_ANALYSIS;
+ bool IsTrusted(interfaces::Chain::Lock& locked_chain) const;
+ bool IsTrusted(interfaces::Chain::Lock& locked_chain, std::set<uint256>& trusted_parents) const;
int64_t GetTxTime() const;
@@ -531,7 +531,7 @@ public:
const uint256& GetHash() const { return tx->GetHash(); }
bool IsCoinBase() const { return tx->IsCoinBase(); }
bool IsImmatureCoinBase() const;
- bool isFinal() const NO_THREAD_SAFETY_ANALYSIS;
+ bool isFinal() const;
};
class COutput
6e10c40e9507c2ff45d47ca863778fff85584b36