aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2020-08-21 00:28:10 +0100
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2020-08-21 00:28:10 +0100
commitb8405b833ad28351c80fb10f6f896f974013fd9e (patch)
tree53334c952d8c22422f5b780009b92e5a9be83304 /src/wallet/wallet.cpp
parentd8441f30ff57e4ae98cff6694c995eaffc19c51a (diff)
wallet: IsChange requires cs_wallet lock
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp4
1 files changed, 3 insertions, 1 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)
{