From a06a8b488896dd83a320fff10d48300ca01e9ba4 Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Mon, 30 Nov 2015 16:15:15 +0100 Subject: add InMempool() function --- src/wallet/wallet.cpp | 17 +++++++++++------ src/wallet/wallet.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/wallet') 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); -- cgit v1.2.3