Skip to content

Commit a13cafc

Browse files
committed
wallet: GetWalletTx requires cs_wallet lock
1 parent ffad348 commit a13cafc

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
@@ -276,7 +276,7 @@ std::string COutput::ToString() const
276276

277277
const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const
278278
{
279-
LOCK(cs_wallet);
279+
AssertLockHeld(cs_wallet);
280280
std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(hash);
281281
if (it == mapWallet.end())
282282
return nullptr;
@@ -1983,6 +1983,7 @@ bool CWalletTx::IsTrusted(std::set<uint256>& trusted_parents) const
19831983
if (!InMempool()) return false;
19841984

19851985
// Trusted if all inputs are from us and are in the mempool:
1986+
LOCK(pwallet->cs_wallet);
19861987
for (const CTxIn& txin : tx->vin)
19871988
{
19881989
// Transactions not sent by us: not trusted

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
793793
/** Interface for accessing chain state. */
794794
interfaces::Chain& chain() const { assert(m_chain); return *m_chain; }
795795

796-
const CWalletTx* GetWalletTx(const uint256& hash) const;
796+
const CWalletTx* GetWalletTx(const uint256& hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
797797

798798
//! check whether we are allowed to upgrade (or already support) to the named feature
799799
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }

0 commit comments

Comments
 (0)