diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -895,7 +895,8 @@ return *m_chain; } - const CWalletTx *GetWalletTx(const TxId &txid) const; + const CWalletTx *GetWalletTx(const TxId &txid) const + EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! check whether we are allowed to upgrade (or already support) to the //! named feature diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -317,7 +317,7 @@ } const CWalletTx *CWallet::GetWalletTx(const TxId &txid) const { - LOCK(cs_wallet); + AssertLockHeld(cs_wallet); std::map::const_iterator it = mapWallet.find(txid); if (it == mapWallet.end()) { return nullptr; @@ -2201,6 +2201,7 @@ } // Trusted if all inputs are from us and are in the mempool: + LOCK(pwallet->cs_wallet); for (const CTxIn &txin : tx->vin) { // Transactions not sent by us: not trusted const CWalletTx *parent = pwallet->GetWalletTx(txin.prevout.GetTxId());