Skip to content

Commit 5fabde6

Browse files
committed
wallet: AddWalletDescriptor requires cs_wallet lock
No change in behavior, the lock is already held at call sites.
1 parent 32d036e commit 5fabde6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3252,12 +3252,13 @@ DescriptorScriptPubKeyMan* CWallet::GetDescriptorScriptPubKeyMan(const WalletDes
32523252

32533253
ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal)
32543254
{
3255+
AssertLockHeld(cs_wallet);
3256+
32553257
if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
32563258
WalletLogPrintf("Cannot add WalletDescriptor to a non-descriptor wallet\n");
32573259
return nullptr;
32583260
}
32593261

3260-
LOCK(cs_wallet);
32613262
auto spk_man = GetDescriptorScriptPubKeyMan(desc);
32623263
if (spk_man) {
32633264
WalletLogPrintf("Update existing descriptor: %s\n", desc.descriptor->ToString());

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
876876
DescriptorScriptPubKeyMan* GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const;
877877

878878
//! Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type
879-
ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal);
879+
ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
880880
};
881881

882882
/**

0 commit comments

Comments
 (0)