Inside Bitcoin
Opening the selected file…
Inside Bitcoin
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) 2023-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#ifndef BITCOIN_TEST_UTIL_COINS_H6#define BITCOIN_TEST_UTIL_COINS_H8#include <coins.h>9#include <crypto/hex_base.h>10#include <primitives/transaction.h>11#include <tinyformat.h>13#include <ostream>15class CCoinsViewCache;16class FastRandomContext;18/**19* Create a Coin with DynamicMemoryUsage of 80 bytes and add it to the given view.20* @param[in,out] coins_view The coins view cache to add the new coin to.21* @returns the COutPoint of the created coin.22*/23COutPoint AddTestCoin(FastRandomContext& rng, CCoinsViewCache& coins_view);25//! Strict equality, including fields of spent coins26inline bool operator==(const Coin& a, const Coin& b)27{28return a.fCoinBase == b.fCoinBase && a.nHeight == b.nHeight && a.out == b.out;29}31//! Printed when a coin comparison fails32inline std::ostream& operator<<(std::ostream& os, const Coin& coin)33{34return os << strprintf("Coin(spent=%d, coinbase=%d, height=%d, value=%d, scriptPubKey=%s)",35coin.IsSpent(), coin.fCoinBase, coin.nHeight, coin.out.nValue, HexStr(coin.out.scriptPubKey));36}38#endif // BITCOIN_TEST_UTIL_COINS_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.