Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2019-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <node/coin.h>7#include <node/context.h>8#include <txmempool.h>9#include <validation.h>11namespace node {12void FindCoins(const NodeContext& node, std::map<COutPoint, Coin>& coins)13{14assert(node.mempool);15assert(node.chainman);16LOCK2(cs_main, node.mempool->cs);17CCoinsViewCache& chain_view = node.chainman->ActiveChainstate().CoinsTip();18CCoinsViewMemPool mempool_view(&chain_view, *node.mempool);19for (auto& [outpoint, coin] : coins) {20if (auto c{mempool_view.GetCoin(outpoint)}) {21coin = std::move(*c);22} else {23coin.Clear(); // Either the coin is not in the CCoinsViewCache or is spent24}25}26}27} // namespace node