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:
0diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
1index 9d291f0b585..c702f90681d 100644
2--- a/src/wallet/wallet.cpp
3+++ b/src/wallet/wallet.cpp
4@@ -1882,6 +1882,7 @@ bool CWalletTx::IsTrusted(interfaces::Chain::Lock& locked_chain) const
5 bool CWalletTx::IsTrusted(interfaces::Chain::Lock& locked_chain, std::set<uint256>& trusted_parents) const
6 {
7 // Quick answer in most cases
8+ AssertLockHeld(pwallet->cs_wallet);
9 if (!pwallet->CheckFinalWalletTx(*tx)) return false;
10 int nDepth = GetDepthInMainChain();
11 if (nDepth >= 1) return true;
12@@ -3967,6 +3968,7 @@ bool CWalletTx::IsImmatureCoinBase() const
13
14 bool CWalletTx::isFinal() const
15 {
16+ AssertLockHeld(pwallet->cs_wallet);
17 return pwallet->CheckFinalWalletTx(*tx);
18 }
19
20diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
21index acf0de45f1c..4ae39ba328a 100644
22--- a/src/wallet/wallet.h
23+++ b/src/wallet/wallet.h
24@@ -477,8 +477,8 @@ public:
25 bool IsEquivalentTo(const CWalletTx& tx) const;
26
27 bool InMempool() const;
28- bool IsTrusted(interfaces::Chain::Lock& locked_chain) const NO_THREAD_SAFETY_ANALYSIS;
29- bool IsTrusted(interfaces::Chain::Lock& locked_chain, std::set<uint256>& trusted_parents) const NO_THREAD_SAFETY_ANALYSIS;
30+ bool IsTrusted(interfaces::Chain::Lock& locked_chain) const;
31+ bool IsTrusted(interfaces::Chain::Lock& locked_chain, std::set<uint256>& trusted_parents) const;
32
33 int64_t GetTxTime() const;
34
35@@ -531,7 +531,7 @@ public:
36 const uint256& GetHash() const { return tx->GetHash(); }
37 bool IsCoinBase() const { return tx->IsCoinBase(); }
38 bool IsImmatureCoinBase() const;
39- bool isFinal() const NO_THREAD_SAFETY_ANALYSIS;
40+ bool isFinal() const;
41 };
42
43 class COutput
6e10c40e9507c2ff45d47ca863778fff85584b36