aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2022-09-20 00:36:47 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2022-09-20 00:46:27 +0000
commita60d9eb9e6b6a272a3fca8981d89a55955dced55 (patch)
tree5c0e37886ecb14790b940c077da6db144b901ee3 /src
parent831675c8dccfa6525ffe751da3cc60709c380953 (diff)
downloadbitcoin-a60d9eb9e6b6a272a3fca8981d89a55955dced55.tar.xz
Bugfix: Wallet: Lock cs_wallet for SignMessage
cs_desc_main is typically locked within scope of a cs_wallet lock, but: CWallet::IsLocked locks cs_wallet ...called from DescriptorScriptPubKeyMan::GetKeys ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index ff8bfff872..d517361e86 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2588,6 +2588,7 @@ SigningResult CWallet::SignMessage(const std::string& message, const PKHash& pkh
CScript script_pub_key = GetScriptForDestination(pkhash);
for (const auto& spk_man_pair : m_spk_managers) {
if (spk_man_pair.second->CanProvide(script_pub_key, sigdata)) {
+ LOCK(cs_wallet); // DescriptorScriptPubKeyMan calls IsLocked which can lock cs_wallet in a deadlocking order
return spk_man_pair.second->SignMessage(message, pkhash, str_sig);
}
}