Skip to content

Commit a60d9eb

Browse files
committed
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
1 parent 831675c commit a60d9eb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,7 @@ SigningResult CWallet::SignMessage(const std::string& message, const PKHash& pkh
25882588
CScript script_pub_key = GetScriptForDestination(pkhash);
25892589
for (const auto& spk_man_pair : m_spk_managers) {
25902590
if (spk_man_pair.second->CanProvide(script_pub_key, sigdata)) {
2591+
LOCK(cs_wallet); // DescriptorScriptPubKeyMan calls IsLocked which can lock cs_wallet in a deadlocking order
25912592
return spk_man_pair.second->SignMessage(message, pkhash, str_sig);
25922593
}
25932594
}

0 commit comments

Comments
 (0)