Block header is a part of the block that contains date, merkle root of the block's transactions and additional data related to proof-of-work.
Returns a genesis block header for mainnet. See also BTC::Network#genesis_block_header.
Returns a genesis block header for testnet. See also BTC::Network#genesis_block_header.
Returns a new block header initialized with a binary string in wire format.
Raises ArgumentError
if block header is incomplete or incorrectly encoded.
Returns a new block header initialized with data in wire format read from a given stream.
Raises ArgumentError
if block header is incomplete or incorrectly encoded.
Returns a new block header with named attributes. All attributes are optional and have appropriate default values.
BlockHeader.new(
version: 2,
previous_block_id: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
merkle_root: "...",
timestamp: ...)
Block version (1 or 2).
Binary hash of the previous block.
Hex big-endian hash of the previous block. See Hash↔ID Conversion.
Binary root hash of the transactions’ merkle tree.
32-bit unsigned UNIX timestamp.
Time object derived from timestamp
Proof-of-work target in a compact form (uint32). See Proof-of-Work Conversion Routines.
Proof-of-work nonce (uint32 value iterated during mining).
Optional height in the block chain (genesis block has height 0). Not stored within block's binary representation. Third party APIs may set this value for user’s convenience.
Optional number of the confirmations for transactions in this block.
If this block is the latest one, confirmations
equals 1.
Not stored within block's binary representation.
Third party APIs may set this value for user’s convenience.
Binary hash of the block header. Equals SHA256(SHA256(header_data))
.
Hex big-endian hash of the block header. See Hash↔ID Conversion.
Returns block’s header data in wire format.
Returns header_data
.
Returns a copy of the block header.
Returns true
if binary representation of both block headers is equal (external attributes height
, confirmations
are ignored).