diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -92,10 +92,6 @@ //! Get chainparams. virtual const CChainParams &getChainParams() = 0; - //! Get set of addresses corresponding to a given label. - virtual std::set - getLabelAddresses(const std::string &label) = 0; - // Get a new address. virtual bool getNewDestination(const OutputType type, const std::string label, diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -135,10 +135,6 @@ return m_wallet->BackupWallet(filename); } std::string getWalletName() override { return m_wallet->GetName(); } - std::set - getLabelAddresses(const std::string &label) override { - return m_wallet->GetLabelAddresses(label); - }; bool getNewDestination(const OutputType type, const std::string label, CTxDestination &dest) override { LOCK(m_wallet->cs_wallet); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -754,7 +754,8 @@ 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 @@ -1082,7 +1083,8 @@ ScriptPubKeyMan * AddWalletDescriptor(WalletDescriptor &desc, const FlatSigningProvider &signing_provider, - const std::string &label, bool internal); + const std::string &label, bool internal) + EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); }; /** diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2395,7 +2395,7 @@ 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) { @@ -3451,13 +3451,14 @@ 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",