uint256

256-bit opaque blob.

Synopsis

Declared in <uint256.h>

class uint256
    : public base_blob<256>

Description

NOTE

This type is called uint256 for historical reasons only. It is an opaque blob of 256 bits and has no integer operations. Use arith_uint256 if those are required.

Base Classes

NameDescription
base_blob<256>Template base class for fixed-sized opaque blobs.

Member Functions

NameDescription
uint256 [constructor]Constructors
GetHex The hex representation used by GetHex(), ToString(), and FromHex() is unusual, since it shows bytes of the base_blob in reverse order. For example, a 4-byte blob {0x12, 0x34, 0x56, 0x78} is represented as "78563412" instead of the more typical "12345678" representation that would be shown in a hex editor or used by typical byte-array / hex conversion functions like python's bytes.hex() and bytes.fromhex().
GetUint64 Reads a 64-bit little-endian word from the blob at a byte offset.
IsNull Returns true if every byte of the blob is zero.
Serialize Serializes the blob's raw bytes to a stream.
SetNull Sets every byte of the blob to zero.
ToString Returns the blob as a hex string in reverse byte order.
Unserialize Deserializes the blob's raw bytes from a stream.
begin Returns a pointer to the first byte of the blob.
data Returns a pointer to the blob's raw bytes.
end Returns a pointer just past the last byte of the blob.
operator== Compares two blobs for byte-wise equality.
operator<=> Lexicographic ordering

Static Member Functions

NameDescription
FromHex Parses a uint256 from a hex string.
FromUserHex Parses a uint256 from user-supplied hex, allowing a "0x" prefix and padding.
size Returns the size of the blob in bytes.

Static Data Members

NameDescription
ONE The uint256 value equal to one.
ZERO The all-zero uint256 value.

Protected Data Members

NameDescription
m_data Fixed-size byte storage holding the blob's raw bytes.

Non-Member Functions

NameDescription
ArithToUint256Converts an arithmetic 256-bit integer to a uint256 blob.
AsmapVersionCalculate the asmap version, a checksum identifying the asmap being used.
BlockMerkleRootCompute the Merkle root of the transactions in a block. *mutated is set to true if a duplicated subtree was found.
BlockWitnessMerkleRootCompute the Merkle root of the witness transactions in a block.
CheckProofOfWorkCheck whether a block hash satisfies the proof-of-work requirement specified by nBits
CheckProofOfWorkImplImplementation of CheckProofOfWork that verifies a hash against a compact target.
ComputeMerkleRootCompute a Merkle root from the provided leaf hashes. If non-null, *mutated is set to true if two identical hashes are paired at any tree level before the odd-count hash duplication step, and false otherwise.
ComputeTapbranchHashCompute the BIP341 tapbranch hash from two branches. Spans must be 32 bytes each.
ComputeTapleafHashCompute the BIP341 tapleaf hash from leaf version & script.
ComputeTaprootMerkleRootCompute the BIP341 taproot script tree Merkle root from control block and leaf hash. Requires control block to have valid length (33 + k*32, with k in {0,1,..,128}).
CreateMuSig2PartialSigProduce this participant's MuSig2 partial signature for the session.
DescriptorIDUnique identifier that may not change over time, unless explicitly marked as not backwards compatible. This is not part of BIP 380, not guaranteed to be interoperable and should not be exposed to the user.
GetPackageHashGet the hash of the concatenated wtxids of transactions, with wtxids treated as a little-endian numbers and sorted in ascending numeric order.
GetRandHashGenerate a random uint256.
GetTarget* Get the target for a given block index.
HashCompute the 256-bit hash of the concatenation of two objects.
HashCompute the 256-bit hash of an object.
IsBIP30UnspendableIdentifies blocks which coinbase output was subsequently overwritten in the UTXO set (see BIP30).
LocatorEntriesConstruct a list of hash entries to put in a locator.
MessageHashHashes a message for signing and verification in a manner that prevents inadvertently signing a transaction.
MuSig2SessionIDComputes an arbitrary unique session ID to identify ongoing signing sessions. It is the SHA256 of the signing (aggregate) pubkey, the participant pubkey, the sighash, and the pubnonce
ParseHashOParse a hex-encoded hash from a named field of an object.
ParseHashVParse a hex-encoded hash from a UniValue, throwing an RPC error if it is not valid hex.
SHA256Uint256Single-SHA256 a 32-byte input (represented as uint256).
SignatureHashCompute the signature hash for one input under the selected signature version.
SignatureHashSchnorrCompute the BIP341 Taproot signature hash for one input.
TransactionMerklePathCompute merkle path to the specified transaction
UintToArith256Converts a uint256 blob to an arithmetic 256-bit integer.
node::ReadSnapshotBaseBlockhashRead the blockhash of the snapshot base block that was used to construct the chainstate.