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 <blockfilter.h>6#include <clientversion.h>7#include <common/args.h>8#include <common/license_info.h>9#include <common/messages.h>10#include <common/settings.h>11#include <common/system.h>12#include <common/url.h>13#include <netbase.h>14#include <outputtype.h>15#include <rpc/client.h>16#include <rpc/request.h>17#include <rpc/server.h>18#include <rpc/util.h>19#include <script/descriptor.h>20#include <script/script.h>21#include <serialize.h>22#include <streams.h>23#include <test/fuzz/FuzzedDataProvider.h>24#include <test/fuzz/fuzz.h>25#include <test/fuzz/util.h>26#include <util/fees.h>27#include <util/strencodings.h>28#include <util/string.h>29#include <util/translation.h>31#include <cassert>32#include <cstdint>33#include <cstdlib>34#include <ios>35#include <stdexcept>36#include <string>37#include <vector>39using common::AmountErrMsg;40using common::AmountHighWarn;41using common::FeeModeFromString;42using common::ResolveErrMsg;43using util::ContainsNUL;44using util::Join;45using util::RemovePrefix;46using util::SplitString;47using util::TrimString;49FUZZ_TARGET(string)50{51FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());52const std::string random_string_1 = fuzzed_data_provider.ConsumeRandomLengthString(32);53const std::string random_string_2 = fuzzed_data_provider.ConsumeRandomLengthString(32);54const std::vector<std::string> random_string_vector = ConsumeRandomLengthStringVector(fuzzed_data_provider);56(void)AmountErrMsg(random_string_1, random_string_2);57(void)AmountHighWarn(random_string_1);58BlockFilterType block_filter_type;59(void)BlockFilterTypeByName(random_string_1, block_filter_type);60(void)Capitalize(random_string_1);61(void)CopyrightHolders(random_string_1);62FeeEstimateMode fee_estimate_mode;63(void)FeeModeFromString(random_string_1, fee_estimate_mode);64const auto width{fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 1000)};65(void)FormatParagraph(random_string_1, width, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, width));66(void)FormatSubVersion(random_string_1, fuzzed_data_provider.ConsumeIntegral<int>(), random_string_vector);67(void)HelpExampleCli(random_string_1, random_string_2);68(void)HelpExampleRpc(random_string_1, random_string_2);69(void)HelpMessageGroup(random_string_1);70(void)HelpMessageOpt(random_string_1, "", random_string_2);71(void)HelpMessageOpt(random_string_1, random_string_2, "");72(void)IsDeprecatedRPCEnabled(random_string_1);73(void)Join(random_string_vector, random_string_1);74(void)JSONRPCError(fuzzed_data_provider.ConsumeIntegral<int>(), random_string_1);75const common::Settings settings;76(void)OnlyHasDefaultSectionSetting(settings, random_string_1, random_string_2);77(void)ParseNetwork(random_string_1);78(void)ParseOutputType(random_string_1);79(void)RemovePrefix(random_string_1, random_string_2);80(void)ResolveErrMsg(random_string_1, random_string_2);81try {82(void)RPCConvertNamedValues(random_string_1, random_string_vector);83} catch (const std::runtime_error&) {84}85try {86(void)RPCConvertValues(random_string_1, random_string_vector);87} catch (const std::runtime_error&) {88}89(void)SanitizeString(random_string_1);90(void)SanitizeString(random_string_1, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 3));91#ifndef WIN3292(void)ShellEscape(random_string_1);93#endif // WIN3294uint16_t port_out;95std::string host_out;96SplitHostPort(random_string_1, port_out, host_out);97(void)TimingResistantEqual(random_string_1, random_string_2);98(void)ToLower(random_string_1);99(void)ToUpper(random_string_1);100(void)TrimString(random_string_1);101(void)TrimString(random_string_1, random_string_2);102(void)UrlDecode(random_string_1);103(void)ContainsNUL(random_string_1);104try {105throw scriptnum_error{random_string_1};106} catch (const std::runtime_error&) {107}109{110DataStream data_stream{};111std::string s;112auto limited_string = LIMITED_STRING(s, 10);113data_stream << random_string_1;114try {115data_stream >> limited_string;116assert(data_stream.empty());117assert(s.size() <= random_string_1.size());118assert(s.size() <= 10);119if (!random_string_1.empty()) {120assert(!s.empty());121}122} catch (const std::ios_base::failure&) {123}124}125{126DataStream data_stream{};127const auto limited_string = LIMITED_STRING(random_string_1, 10);128data_stream << limited_string;129std::string deserialized_string;130data_stream >> deserialized_string;131assert(data_stream.empty());132assert(deserialized_string == random_string_1);133}134{135int64_t amount_out;136(void)ParseFixedPoint(random_string_1, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 1024), &amount_out);137}138{139const auto single_split{SplitString(random_string_1, fuzzed_data_provider.ConsumeIntegral<char>())};140assert(single_split.size() >= 1);141const auto any_split{SplitString(random_string_1, random_string_2)};142assert(any_split.size() >= 1);143}144{145(void)Untranslated(random_string_1);146const bilingual_str bs1{random_string_1, random_string_2};147const bilingual_str bs2{random_string_2, random_string_1};148(void)(bs1 + bs2);149}150{151const ByteUnit all_units[] = {152ByteUnit::NOOP,153ByteUnit::k,154ByteUnit::K,155ByteUnit::m,156ByteUnit::M,157ByteUnit::g,158ByteUnit::G,159ByteUnit::t,160ByteUnit::T161};162ByteUnit default_multiplier = fuzzed_data_provider.PickValueInArray(all_units);163(void)ParseByteUnits(random_string_1, default_multiplier);164}165}
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.