Skip to content

Commit 01f45dd

Browse files
committed
wallet: Avoid recursive lock in CWallet::SetUsedDestinationState
1 parent 463eab5 commit 01f45dd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,13 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
693693

694694
void CWallet::SetUsedDestinationState(const uint256& hash, unsigned int n, bool used)
695695
{
696+
AssertLockHeld(cs_wallet);
696697
const CWalletTx* srctx = GetWalletTx(hash);
697698
if (!srctx) return;
698699

699700
CTxDestination dst;
700701
if (ExtractDestination(srctx->tx->vout[n].scriptPubKey, dst)) {
701702
if (IsMine(dst)) {
702-
LOCK(cs_wallet);
703703
if (used && !GetDestData(dst, "used", nullptr)) {
704704
AddDestData(dst, "used", "p"); // p for "present", opposite of absent (null)
705705
} else if (!used && GetDestData(dst, "used", nullptr)) {

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ class CWallet final : public WalletStorage, private interfaces::Chain::Notificat
795795
// Whether this or any UTXO with the same CTxDestination has been spent.
796796
bool IsUsedDestination(const CTxDestination& dst) const;
797797
bool IsUsedDestination(const uint256& hash, unsigned int n) const;
798-
void SetUsedDestinationState(const uint256& hash, unsigned int n, bool used);
798+
void SetUsedDestinationState(const uint256& hash, unsigned int n, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
799799

800800
std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool single_coin) const;
801801

0 commit comments

Comments
 (0)