diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1269,9 +1269,12 @@ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); ; Amount GetCredit(const CTxOut &txout, const isminefilter &filter) const; - bool IsChange(const CTxOut &txout) const; - bool IsChange(const CScript &script) const; - Amount GetChange(const CTxOut &txout) const; + bool IsChange(const CTxOut &txout) const + EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + bool IsChange(const CScript &script) const + EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + Amount GetChange(const CTxOut &txout) const + EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); bool IsMine(const CTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); /** should probably be renamed to IsRelevantToMe */ diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1390,7 +1390,7 @@ // outputs are 'the send' and which are 'the change' will need to be // implemented (maybe extend CWalletTx to remember which output, if any, was // change). - LOCK(cs_wallet); + AssertLockHeld(cs_wallet); if (IsMine(script)) { CTxDestination address; if (!ExtractDestination(script, address)) { @@ -1405,6 +1405,7 @@ } Amount CWallet::GetChange(const CTxOut &txout) const { + AssertLockHeld(cs_wallet); if (!MoneyRange(txout.nValue)) { throw std::runtime_error(std::string(__func__) + ": value out of range"); @@ -1483,6 +1484,7 @@ } Amount CWallet::GetChange(const CTransaction &tx) const { + LOCK(cs_wallet); Amount nChange = Amount::zero(); for (const CTxOut &txout : tx.vout) { nChange += GetChange(txout);