@@ -799,10 +799,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
799
799
if (!maybe_chainman) return false ;
800
800
ChainstateManager& chainman = *maybe_chainman;
801
801
{
802
- auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool& mempool) {
802
+ auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool* mempool) {
803
803
for (const COutPoint& vOutPoint : vOutPoints) {
804
804
Coin coin;
805
- bool hit = !mempool. isSpent (vOutPoint) && view.GetCoin (vOutPoint, coin);
805
+ bool hit = ( !mempool || !mempool-> isSpent (vOutPoint) ) && view.GetCoin (vOutPoint, coin);
806
806
hits.push_back (hit);
807
807
if (hit) outs.emplace_back (std::move (coin));
808
808
}
@@ -815,10 +815,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
815
815
LOCK2 (cs_main, mempool->cs );
816
816
CCoinsViewCache& viewChain = chainman.ActiveChainstate ().CoinsTip ();
817
817
CCoinsViewMemPool viewMempool (&viewChain, *mempool);
818
- process_utxos (viewMempool, * mempool);
818
+ process_utxos (viewMempool, mempool);
819
819
} else {
820
- LOCK (cs_main); // no need to lock mempool!
821
- process_utxos (chainman.ActiveChainstate ().CoinsTip (), CTxMemPool () );
820
+ LOCK (cs_main);
821
+ process_utxos (chainman.ActiveChainstate ().CoinsTip (), nullptr );
822
822
}
823
823
824
824
for (size_t i = 0 ; i < hits.size (); ++i) {
0 commit comments