diff options
author | João Barbosa <joao.paulo.barbosa@gmail.com> | 2020-08-21 00:28:10 +0100 |
---|---|---|
committer | João Barbosa <joao.paulo.barbosa@gmail.com> | 2020-08-21 00:28:10 +0100 |
commit | b8405b833ad28351c80fb10f6f896f974013fd9e (patch) | |
tree | 53334c952d8c22422f5b780009b92e5a9be83304 /src/wallet | |
parent | d8441f30ff57e4ae98cff6694c995eaffc19c51a (diff) |
wallet: IsChange requires cs_wallet lock
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 4 | ||||
-rw-r--r-- | src/wallet/wallet.h | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4e1d6b805b..f84f4fd718 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1283,7 +1283,7 @@ bool CWallet::IsChange(const CScript& script) const // a better way of identifying which 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; @@ -1298,6 +1298,7 @@ bool CWallet::IsChange(const CScript& script) const CAmount CWallet::GetChange(const CTxOut& txout) const { + AssertLockHeld(cs_wallet); if (!MoneyRange(txout.nValue)) throw std::runtime_error(std::string(__func__) + ": value out of range"); return (IsChange(txout) ? txout.nValue : 0); @@ -1364,6 +1365,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) c CAmount CWallet::GetChange(const CTransaction& tx) const { + LOCK(cs_wallet); CAmount nChange = 0; for (const CTxOut& txout : tx.vout) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 0bb7a6991d..e50d36da6f 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1048,9 +1048,9 @@ public: CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const; isminetype IsMine(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const; - bool IsChange(const CTxOut& txout) const; - bool IsChange(const CScript& script) const; - CAmount 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); + CAmount 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 */ bool IsFromMe(const CTransaction& tx) const; |