From 32d036e8dab5f5b24096d9765236441e7b6a3b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Sat, 29 Aug 2020 15:26:39 +0100 Subject: [PATCH 1/2] wallet: GetLabelAddresses requires cs_wallet lock No change in behavior, the lock is already held at call sites. --- src/wallet/wallet.cpp | 2 +- src/wallet/wallet.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f3af9885a2e..1216bf5e081 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2191,7 +2191,7 @@ void CWallet::MarkDestinationsDirty(const std::set& destinations std::set CWallet::GetLabelAddresses(const std::string& label) const { - LOCK(cs_wallet); + AssertLockHeld(cs_wallet); std::set result; for (const std::pair& item : m_address_book) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index fbeec2aa30c..48efbbfde68 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -630,7 +630,7 @@ public: int64_t GetOldestKeyPoolTime() const; - std::set GetLabelAddresses(const std::string& label) const; + std::set GetLabelAddresses(const std::string& label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); /** * Marks all outputs in each one of the destinations dirty, so their cache is From 5fabde6fadd1b07e981c97f5087d67c4179340ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Sat, 29 Aug 2020 15:29:00 +0100 Subject: [PATCH 2/2] wallet: AddWalletDescriptor requires cs_wallet lock No change in behavior, the lock is already held at call sites. --- src/wallet/wallet.cpp | 3 ++- src/wallet/wallet.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1216bf5e081..70349b24558 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3252,12 +3252,13 @@ DescriptorScriptPubKeyMan* CWallet::GetDescriptorScriptPubKeyMan(const WalletDes ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) { + AssertLockHeld(cs_wallet); + if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { WalletLogPrintf("Cannot add WalletDescriptor to a non-descriptor wallet\n"); return nullptr; } - LOCK(cs_wallet); auto spk_man = GetDescriptorScriptPubKeyMan(desc); if (spk_man) { WalletLogPrintf("Update existing descriptor: %s\n", desc.descriptor->ToString()); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 48efbbfde68..2dc9eff7121 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -876,7 +876,7 @@ public: DescriptorScriptPubKeyMan* GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const; //! Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type - ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal); + ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); }; /**