 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
73 assert(compressed_money_amount <= compressed_money_amount_max);
77 static const uint256 u256_min(
uint256S(
"0000000000000000000000000000000000000000000000000000000000000000"));
78 static const uint256 u256_max(
uint256S(
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
79 const std::vector<uint256> v256{u256, u256_min, u256_max};
85 assert(parsed.value() == i64);
111 const unsigned char uch =
static_cast<unsigned char>(
u8);
114 const std::set<int64_t> i64s{i64,
static_cast<int64_t
>(u64)};
117 assert(dynamic_usage == incremental_dynamic_usage * i64s.size());
127 assert(parsed.value() == i64);
130 if (i32 >= 0 && i32 <= 16) {
134 const std::chrono::seconds seconds{i64};
138 (void)script_num.
getint();
139 (void)script_num.getvch();
153 const CKeyID key_id{u160};
161 stream >> deserialized_u256;
162 assert(u256 == deserialized_u256 && stream.
empty());
166 stream >> deserialized_u160;
167 assert(u160 == deserialized_u160 && stream.
empty());
169 uint64_t deserialized_u64;
171 stream >> deserialized_u64;
174 int64_t deserialized_i64;
176 stream >> deserialized_i64;
179 uint32_t deserialized_u32;
181 stream >> deserialized_u32;
184 int32_t deserialized_i32;
186 stream >> deserialized_i32;
189 uint16_t deserialized_u16;
191 stream >> deserialized_u16;
194 int16_t deserialized_i16;
196 stream >> deserialized_i16;
199 uint8_t deserialized_u8;
201 stream >> deserialized_u8;
204 int8_t deserialized_i8;
206 stream >> deserialized_i8;
211 stream >> deserialized_b;
242 assert(u16 == deserialized_u16be && stream.
empty());
256 }
catch (
const std::ios_base::failure&) {
unsigned int GetSpecialScriptSize(unsigned int nSize)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
uint32_t ser_readdata32(Stream &s)
void ser_writedata16be(Stream &s, uint16_t obj)
uint256 ComputeMerkleRoot(std::vector< uint256 > hashes, bool *mutated)
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
std::string SighashToStr(unsigned char sighash_type)
std::string GetHex() const
unsigned int nBytesPerSigOp
void ser_writedata64(Stream &s, uint64_t obj)
256-bit unsigned big integer.
unsigned int size() const
unsigned int bits() const
Returns the position of the highest bit set plus one, or zero if the value is zero.
bool MoneyRange(const CAmount &nValue)
static opcodetype EncodeOP_N(int n)
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
const Consensus::Params & GetConsensus() const
ServiceFlags
nServices flags
A reference to a CKey: the Hash160 of its serialized public key.
static size_t DynamicUsage(const int8_t &v)
Dynamic memory usage for built-in types is zero.
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
static bool MayHaveUsefulAddressDB(ServiceFlags services)
Checks if a peer with the given service flags may be capable of having a robust address-storage DB.
static bool HasAllDesirableServiceFlags(ServiceFlags services)
A shortcut for (services & GetDesirableServiceFlags(services)) == GetDesirableServiceFlags(services),...
UniValue ValueFromAmount(const CAmount amount)
constexpr bool IsSpace(char c) noexcept
Tests if the given character is a whitespace character.
Parameters that influence chain consensus.
uint32_t ser_readdata32be(Stream &s)
bool MultiplicationOverflow(const T i, const T j) noexcept
signed char HexDigit(char c)
uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256 &val, uint32_t extra)
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val)
Optimized SipHash-2-4 implementation for uint256.
uint16_t ser_readdata16(Stream &s)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
uint16_t ser_readdata16be(Stream &s)
static const std::string REGTEST
uint64_t GetLow64() const
bool IsSwitchChar(char c)
uint8_t ser_readdata8(Stream &s)
uint32_t GetCompact(bool fNegative=false) const
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given chain name.
unsigned int GetSizeOfCompactSize(uint64_t nSize)
Compact Size size < 253 – 1 byte size <= USHRT_MAX – 3 bytes (253 + 2 bytes) size <= UINT_MAX – 5 byt...
std::string ToUpper(const std::string &str)
Returns the uppercase equivalent of the given string.
uint256 uint256S(const char *str)
void ser_writedata8(Stream &s, uint8_t obj)
void ser_writedata32(Stream &s, uint32_t obj)
void initialize_integer()
bool AdditionOverflow(const T i, const T j) noexcept
constexpr bool IsDigit(char c)
Tests if the given character is a decimal digit.
const std::string & getValStr() const
arith_uint256 UintToArith256(const uint256 &a)
uint64_t DecompressAmount(uint64_t x)
std::optional< CAmount > ParseMoney(const std::string &money_string)
Parse an amount denoted in full coins.
void ser_writedata32be(Stream &s, uint32_t obj)
void ser_writedata16(Stream &s, uint16_t obj)
static size_t IncrementalDynamicUsage(const std::set< X, Y > &s)
struct timeval MillisToTimeval(int64_t nTimeout)
Convert milliseconds to a struct timeval for e.g.
const CChainParams & Params()
Return the currently selected parameters.
constexpr int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
Double ended buffer combining vector and stream-like interfaces.
FUZZ_TARGET_INIT(integer, initialize_integer)
static constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
A reference to a CScript: the Hash160 of its serialization (see script.h)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
uint64_t CompressAmount(uint64_t n)
Compress amount.
uint64_t ser_readdata64(Stream &s)
uint256 ArithToUint256(const arith_uint256 &a)
std::vector< T > ConsumeBytes(size_t num_bytes)
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation
static uint64_t CountBits(uint64_t x)
Return the smallest number n such that (x >> n) == 0 (or 64 if the highest bit in x is set.
std::string ToLower(const std::string &str)
Returns the lowercase equivalent of the given string.
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
std::string ToString() const