mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-21 06:12:30 +02:00
wallet: IsChange requires cs_wallet lock
This commit is contained in:
parent
d8441f30ff
commit
b8405b833a
@ -1283,7 +1283,7 @@ bool CWallet::IsChange(const CScript& script) const
|
|||||||
// a better way of identifying which outputs are 'the send' and which are
|
// 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
|
// 'the change' will need to be implemented (maybe extend CWalletTx to remember
|
||||||
// which output, if any, was change).
|
// which output, if any, was change).
|
||||||
LOCK(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
if (IsMine(script))
|
if (IsMine(script))
|
||||||
{
|
{
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
@ -1298,6 +1298,7 @@ bool CWallet::IsChange(const CScript& script) const
|
|||||||
|
|
||||||
CAmount CWallet::GetChange(const CTxOut& txout) const
|
CAmount CWallet::GetChange(const CTxOut& txout) const
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(cs_wallet);
|
||||||
if (!MoneyRange(txout.nValue))
|
if (!MoneyRange(txout.nValue))
|
||||||
throw std::runtime_error(std::string(__func__) + ": value out of range");
|
throw std::runtime_error(std::string(__func__) + ": value out of range");
|
||||||
return (IsChange(txout) ? txout.nValue : 0);
|
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
|
CAmount CWallet::GetChange(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
|
LOCK(cs_wallet);
|
||||||
CAmount nChange = 0;
|
CAmount nChange = 0;
|
||||||
for (const CTxOut& txout : tx.vout)
|
for (const CTxOut& txout : tx.vout)
|
||||||
{
|
{
|
||||||
|
@ -1048,9 +1048,9 @@ public:
|
|||||||
CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
|
CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
|
||||||
isminetype IsMine(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
isminetype IsMine(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const;
|
CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const;
|
||||||
bool IsChange(const CTxOut& txout) const;
|
bool IsChange(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
bool IsChange(const CScript& script) const;
|
bool IsChange(const CScript& script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
CAmount GetChange(const CTxOut& txout) const;
|
CAmount GetChange(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
/** should probably be renamed to IsRelevantToMe */
|
/** should probably be renamed to IsRelevantToMe */
|
||||||
bool IsFromMe(const CTransaction& tx) const;
|
bool IsFromMe(const CTransaction& tx) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user