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 <test/fuzz/fuzz.h>6#include <util/moneystr.h>7#include <util/strencodings.h>8#include <util/string.h>10#include <cassert>11#include <cstdint>12#include <optional>13#include <string>15FUZZ_TARGET(parse_numbers)16{17const std::string random_string(buffer.begin(), buffer.end());18{19const auto i8{ToIntegral<int8_t>(random_string)};20const auto u8{ToIntegral<uint8_t>(random_string)};21const auto i16{ToIntegral<int16_t>(random_string)};22const auto u16{ToIntegral<uint16_t>(random_string)};23const auto i32{ToIntegral<int32_t>(random_string)};24const auto u32{ToIntegral<uint32_t>(random_string)};25const auto i64{ToIntegral<int64_t>(random_string)};26const auto u64{ToIntegral<uint64_t>(random_string)};27// Dont check any values, just that each success result must fit into28// the one with the largest bit-width.29if (i8) {30assert(i8 == i64);31}32if (u8) {33assert(u8 == u64);34}35if (i16) {36assert(i16 == i64);37}38if (u16) {39assert(u16 == u64);40}41if (i32) {42assert(i32 == i64);43}44if (u32) {45assert(u32 == u64);46}47constexpr auto digits{"0123456789"};48if (i64) {49assert(util::RemovePrefixView(random_string, "-").find_first_not_of(digits) == std::string::npos);50}51if (u64) {52assert(random_string.find_first_not_of(digits) == std::string::npos);53}54}56(void)ParseMoney(random_string);58(void)LocaleIndependentAtoi<int>(random_string);60int64_t i64;61(void)LocaleIndependentAtoi<int64_t>(random_string);62(void)ParseFixedPoint(random_string, 3, &i64);63}
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.