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

Name

Description

base_blob<256>

Template base class for fixed‐sized opaque blobs.

Member Functions

Name

Description

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

Name

Description

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

Name

Description

ONE

The uint256 value equal to one.

ZERO

The all‐zero uint256 value.

Protected Data Members

Name

Description

m_data

Fixed‐size byte storage holding the blob's raw bytes.

Non-Member Functions

Name

Description

ArithToUint256

Converts an arithmetic 256‐bit integer to a uint256 blob.

AsmapVersion

Calculate the asmap version, a checksum identifying the asmap being used.

BlockMerkleRoot

Compute the Merkle root of the transactions in a block. *mutated is set to true if a duplicated subtree was found.

BlockWitnessMerkleRoot

Compute the Merkle root of the witness transactions in a block.

CheckProofOfWork

Check whether a block hash satisfies the proof‐of‐work requirement specified by nBits

CheckProofOfWorkImpl

Implementation of CheckProofOfWork that verifies a hash against a compact target.

ComputeMerkleRoot

Compute 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.

ComputeTapbranchHash

Compute the BIP341 tapbranch hash from two branches. Spans must be 32 bytes each.

ComputeTapleafHash

Compute the BIP341 tapleaf hash from leaf version & script.

ComputeTaprootMerkleRoot

Compute 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}).

CreateMuSig2PartialSig

Produce this participant's MuSig2 partial signature for the session.

DescriptorID

Unique 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.

GetPackageHash

Get the hash of the concatenated wtxids of transactions, with wtxids treated as a little‐endian numbers and sorted in ascending numeric order.

GetRandHash

Generate a random uint256.

GetTarget

* Get the target for a given block index.

Hash

Compute the 256‐bit hash of the concatenation of two objects.

Hash

Compute the 256‐bit hash of an object.

IsBIP30Unspendable

Identifies blocks which coinbase output was subsequently overwritten in the UTXO set (see BIP30).

LocatorEntries

Construct a list of hash entries to put in a locator.

MessageHash

Hashes a message for signing and verification in a manner that prevents inadvertently signing a transaction.

MuSig2SessionID

Computes 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

ParseHashO

Parse a hex‐encoded hash from a named field of an object.

ParseHashV

Parse a hex‐encoded hash from a UniValue, throwing an RPC error if it is not valid hex.

SHA256Uint256

Single‐SHA256 a 32‐byte input (represented as uint256).

SignatureHash

Compute the signature hash for one input under the selected signature version.

SignatureHashSchnorr

Compute the BIP341 Taproot signature hash for one input.

TransactionMerklePath

Compute merkle path to the specified transaction

UintToArith256

Converts a uint256 blob to an arithmetic 256‐bit integer.

node::ReadSnapshotBaseBlockhash

Read the blockhash of the snapshot base block that was used to construct the chainstate.

Created with MrDocs