Inside Bitcoin
Opening the selected file…
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-2010 Satoshi Nakamoto2// Copyright (c) 2009-present The Bitcoin Core developers3// Distributed under the MIT software license, see the accompanying4// file COPYING or http://www.opensource.org/licenses/mit-license.php.6// Compile-time verification of assumptions we make.8#ifndef BITCOIN_COMPAT_ASSUMPTIONS_H9#define BITCOIN_COMPAT_ASSUMPTIONS_H11#include <cstddef>12#include <limits>14// Assumption: We assume the floating-point types to fulfill the requirements of15// IEC 559 (IEEE 754) standard.16// Example(s): Floating-point division by zero in ConnectBlock, CreateTransaction17// and EstimateMedianVal.18static_assert(std::numeric_limits<float>::is_iec559, "IEEE 754 float assumed");19static_assert(std::numeric_limits<double>::is_iec559, "IEEE 754 double assumed");21// Assumption: We assume eight bits per byte (obviously, but remember: don't22// trust -- verify!).23// Example(s): Everywhere :-)24static_assert(std::numeric_limits<unsigned char>::digits == 8, "8-bit byte assumed");26// Assumption: We assume integer widths.27// Example(s): GetSizeOfCompactSize and WriteCompactSize in the serialization28// code.29static_assert(sizeof(short) == 2, "16-bit short assumed");30static_assert(sizeof(int) == 4, "32-bit int assumed");31static_assert(sizeof(unsigned) == 4, "32-bit unsigned assumed");33// Assumption: We assume size_t to be 32-bit or 64-bit.34// Example(s): size_t assumed to be at least 32-bit in ecdsa_signature_parse_der_lax(...).35// size_t assumed to be 32-bit or 64-bit in MallocUsage(...).36static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8, "size_t assumed to be 32-bit or 64-bit");37static_assert(sizeof(size_t) == sizeof(void*), "Sizes of size_t and void* assumed to be equal");39// Some important things we are NOT assuming (non-exhaustive list):40// * We are NOT assuming a specific value for std::endian::native.41// * We are NOT assuming a specific value for std::locale("").name().42// * We are NOT assuming a specific value for std::numeric_limits<char>::is_signed.44#endif // BITCOIN_COMPAT_ASSUMPTIONS_H
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.