diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1110,8 +1110,7 @@ if (fMempool) { LOCK(mempool.cs); CCoinsViewMemPool view(pcoinsTip.get(), mempool); - if (!view.GetCoin(out, coin) || mempool.isSpent(out)) { - // TODO: this should be done by the CCoinsViewMemPool + if (!view.HasUnspentCoin(out, coin)) { return NullUniValue; } } else { diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -823,6 +823,7 @@ CCoinsViewMemPool(CCoinsView *baseIn, const CTxMemPool &mempoolIn); bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; bool HaveCoin(const COutPoint &outpoint) const override; + bool HasUnspentCoin(const COutPoint &outpoint, Coin &coin) const; }; // We want to sort transactions by coin age priority diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1099,6 +1099,10 @@ return mempool.exists(outpoint) || base->HaveCoin(outpoint); } +bool CCoinsViewMemPool::HasUnspentCoin(const COutPoint &outpoint, Coin &coin) const { + return GetCoin(outpoint, coin) && !mempool.isSpent(outpoint); +} + size_t CTxMemPool::DynamicMemoryUsage() const { LOCK(cs); // Estimate the overhead of mapTx to be 15 pointers + an allocation, as no