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 <common/messages.h>6#include <merkleblock.h>7#include <node/types.h>8#include <outputtype.h>9#include <policy/fees/block_policy_estimator.h>10#include <rpc/util.h>11#include <test/fuzz/FuzzedDataProvider.h>12#include <test/fuzz/fuzz.h>13#include <test/fuzz/util.h>14#include <util/check.h>15#include <util/translation.h>17#include <cstdint>18#include <optional>19#include <string>20#include <vector>22using common::TransactionErrorString;23using node::TransactionError;25namespace {26constexpr TransactionError ALL_TRANSACTION_ERROR[] = {27TransactionError::MISSING_INPUTS,28TransactionError::ALREADY_IN_UTXO_SET,29TransactionError::MEMPOOL_REJECTED,30TransactionError::MEMPOOL_ERROR,31TransactionError::MAX_FEE_EXCEEDED,32};33}; // namespace35// The fuzzing kitchen sink: Fuzzing harness for functions that need to be36// fuzzed but a.) don't belong in any existing fuzzing harness file, and37// b.) are not important enough to warrant their own fuzzing harness file.38FUZZ_TARGET(kitchen_sink)39{40FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());42const TransactionError transaction_error = fuzzed_data_provider.PickValueInArray(ALL_TRANSACTION_ERROR);43(void)JSONRPCTransactionError(transaction_error);44(void)RPCErrorFromTransactionError(transaction_error);45(void)TransactionErrorString(transaction_error);47(void)StringForFeeEstimateHorizon(fuzzed_data_provider.PickValueInArray(ALL_FEE_ESTIMATE_HORIZONS));49const OutputType output_type = fuzzed_data_provider.PickValueInArray(OUTPUT_TYPES);50const std::string& output_type_string = FormatOutputType(output_type);51const std::optional<OutputType> parsed = ParseOutputType(output_type_string);52assert(parsed);53assert(output_type == parsed.value());54(void)ParseOutputType(fuzzed_data_provider.ConsumeRandomLengthString(64));56const std::vector<uint8_t> bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider);57const std::vector<bool> bits = BytesToBits(bytes);58const std::vector<uint8_t> bytes_decoded = BitsToBytes(bits);59assert(bytes == bytes_decoded);60}
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.