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) 2020-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 <primitives/transaction.h>6#include <test/fuzz/FuzzedDataProvider.h>7#include <test/fuzz/fuzz.h>8#include <test/fuzz/util.h>10#include <cstdint>11#include <optional>12#include <string>13#include <vector>15FUZZ_TARGET(primitives_transaction)16{17FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());18const CScript script = ConsumeScript(fuzzed_data_provider);19const std::optional<COutPoint> out_point = ConsumeDeserializable<COutPoint>(fuzzed_data_provider);20if (out_point) {21const CTxIn tx_in{*out_point, script, fuzzed_data_provider.ConsumeIntegral<uint32_t>()};22(void)tx_in;23}24const CTxOut tx_out_1{ConsumeMoney(fuzzed_data_provider), script};25const CTxOut tx_out_2{ConsumeMoney(fuzzed_data_provider), ConsumeScript(fuzzed_data_provider)};26assert((tx_out_1 == tx_out_2) != (tx_out_1 != tx_out_2));27const std::optional<CMutableTransaction> mutable_tx_1 = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);28const std::optional<CMutableTransaction> mutable_tx_2 = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider, TX_WITH_WITNESS);29if (mutable_tx_1 && mutable_tx_2) {30const CTransaction tx_1{*mutable_tx_1};31const CTransaction tx_2{*mutable_tx_2};32(void)tx_1.Equals(tx_2);33}34}
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.