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) 2009-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 <chainparams.h>6#include <rpc/util.h>7#include <script/signingprovider.h>8#include <test/fuzz/fuzz.h>9#include <univalue.h>10#include <util/chaintype.h>12#include <functional>13#include <limits>14#include <stdexcept>15#include <string>17void initialize_parse_univalue()18{19SelectParams(ChainType::REGTEST);20}22FUZZ_TARGET(parse_univalue, .init = initialize_parse_univalue)23{24const std::string random_string(buffer.begin(), buffer.end());25bool valid = true;26const UniValue univalue = [&] {27UniValue uv;28if (!uv.read(random_string)) valid = false;29return valid ? uv : UniValue{};30}();31if (!valid) {32return;33}34try {35(void)ParseHashO(univalue, "A");36} catch (const UniValue&) {37} catch (const std::runtime_error&) {38}39try {40(void)ParseHashO(univalue, random_string);41} catch (const UniValue&) {42} catch (const std::runtime_error&) {43}44try {45(void)ParseHashV(univalue, "A");46} catch (const UniValue&) {47} catch (const std::runtime_error&) {48}49try {50(void)ParseHashV(univalue, random_string);51} catch (const UniValue&) {52} catch (const std::runtime_error&) {53}54try {55(void)ParseHexO(univalue, "A");56} catch (const UniValue&) {57}58try {59(void)ParseHexO(univalue, random_string);60} catch (const UniValue&) {61}62try {63(void)ParseHexV(univalue, "A");64} catch (const UniValue&) {65} catch (const std::runtime_error&) {66}67try {68(void)ParseHexV(univalue, random_string);69} catch (const UniValue&) {70} catch (const std::runtime_error&) {71}72try {73if (univalue.isNull() || univalue.isStr()) (void)ParseSighashString(univalue);74} catch (const UniValue&) {75}76try {77(void)AmountFromValue(univalue);78} catch (const UniValue&) {79} catch (const std::runtime_error&) {80}81try {82FlatSigningProvider provider;83if (buffer.size() < 10'000) (void)EvalDescriptorStringOrObject(univalue, provider);84} catch (const UniValue&) {85} catch (const std::runtime_error&) {86}87try {88(void)ParseConfirmTarget(univalue, std::numeric_limits<unsigned int>::max());89} catch (const UniValue&) {90} catch (const std::runtime_error&) {91}92try {93(void)ParseDescriptorRange(univalue);94} catch (const UniValue&) {95} catch (const std::runtime_error&) {96}97}
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.