aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2015-11-30 16:15:15 +0100
committerAlex Morcos <morcos@chaincode.com>2016-01-13 11:28:28 -0500
commita06a8b488896dd83a320fff10d48300ca01e9ba4 (patch)
tree70e3337f962474bf770e845366a20f9f62fe42e4
parent2a3161bf8bd458ef44a53af37899fad684b257d6 (diff)
add InMempool() function
-rw-r--r--src/wallet/wallet.cpp17
-rw-r--r--src/wallet/wallet.h1
2 files changed, 12 insertions, 6 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 2930131508..cbc71aa16b 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1442,6 +1442,15 @@ CAmount CWalletTx::GetChange() const
return nChangeCached;
}
+bool CWalletTx::InMempool() const
+{
+ LOCK(mempool.cs);
+ if (mempool.exists(GetHash())) {
+ return true;
+ }
+ return false;
+}
+
bool CWalletTx::IsTrusted() const
{
// Quick answer in most cases
@@ -1456,12 +1465,8 @@ bool CWalletTx::IsTrusted() const
return false;
// Don't trust unconfirmed transactions from us unless they are in the mempool.
- {
- LOCK(mempool.cs);
- if (!mempool.exists(GetHash())) {
- return false;
- }
- }
+ if (!InMempool())
+ return false;
// Trusted if all inputs are from us and are in the mempool:
BOOST_FOREACH(const CTxIn& txin, vin)
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index df417fef42..f7e57e2058 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -393,6 +393,7 @@ public:
// True if only scriptSigs are different
bool IsEquivalentTo(const CWalletTx& tx) const;
+ bool InMempool() const;
bool IsTrusted() const;
bool WriteToDisk(CWalletDB *pwalletdb);