Skip to content

Commit a06a8b4

Browse files
jonasschnellimorcos
authored andcommitted
add InMempool() function
1 parent 2a3161b commit a06a8b4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/wallet/wallet.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,15 @@ CAmount CWalletTx::GetChange() const
14421442
return nChangeCached;
14431443
}
14441444

1445+
bool CWalletTx::InMempool() const
1446+
{
1447+
LOCK(mempool.cs);
1448+
if (mempool.exists(GetHash())) {
1449+
return true;
1450+
}
1451+
return false;
1452+
}
1453+
14451454
bool CWalletTx::IsTrusted() const
14461455
{
14471456
// Quick answer in most cases
@@ -1456,12 +1465,8 @@ bool CWalletTx::IsTrusted() const
14561465
return false;
14571466

14581467
// Don't trust unconfirmed transactions from us unless they are in the mempool.
1459-
{
1460-
LOCK(mempool.cs);
1461-
if (!mempool.exists(GetHash())) {
1462-
return false;
1463-
}
1464-
}
1468+
if (!InMempool())
1469+
return false;
14651470

14661471
// Trusted if all inputs are from us and are in the mempool:
14671472
BOOST_FOREACH(const CTxIn& txin, vin)

src/wallet/wallet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ class CWalletTx : public CMerkleTx
393393
// True if only scriptSigs are different
394394
bool IsEquivalentTo(const CWalletTx& tx) const;
395395

396+
bool InMempool() const;
396397
bool IsTrusted() const;
397398

398399
bool WriteToDisk(CWalletDB *pwalletdb);

0 commit comments

Comments
 (0)