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) 2022-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 <consensus/amount.h>6#include <consensus/consensus.h>7#include <kernel/mempool_entry.h>8#include <primitives/transaction.h>9#include <test/fuzz/FuzzedDataProvider.h>10#include <test/fuzz/util.h>11#include <test/fuzz/util/mempool.h>13#include <cassert>14#include <cstdint>15#include <limits>17CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider& fuzzed_data_provider, const CTransaction& tx, uint32_t max_height) noexcept18{19// Avoid:20// policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'21//22// Reproduce using CFeeRate(348732081484775, 10).GetFeePerK()23const CAmount fee{ConsumeMoney(fuzzed_data_provider, /*max=*/std::numeric_limits<CAmount>::max() / CAmount{100'000})};24assert(MoneyRange(fee));25const int64_t time = fuzzed_data_provider.ConsumeIntegral<int64_t>();26const uint64_t entry_sequence{fuzzed_data_provider.ConsumeIntegral<uint64_t>()};27const auto entry_height{fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, max_height)};28const bool spends_coinbase = fuzzed_data_provider.ConsumeBool();29const unsigned int sig_op_cost = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, MAX_BLOCK_SIGOPS_COST);30return CTxMemPoolEntry{MakeTransactionRef(tx), fee, time, entry_height, entry_sequence, spends_coinbase, sig_op_cost, {}};31}
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.