BSV.ChainHash (bsv_sdk v1.1.0)

Copy Markdown View Source

A 32-byte hash used for block and transaction identifiers in Bitcoin. Hex display follows Bitcoin convention (byte-reversed).

Summary

Functions

Create a ChainHash from 32 raw bytes.

Create a ChainHash from a hex string (byte-reversed, Bitcoin convention).

Create a ChainHash from hex, raising on error.

Get raw 32 bytes.

Convert to hex string (byte-reversed).

Types

t()

@type t() :: %BSV.ChainHash{bytes: <<_::256>>}

Functions

from_bytes(arg)

@spec from_bytes(<<_::256>>) :: t()

Create a ChainHash from 32 raw bytes.

from_hex(hex)

@spec from_hex(String.t()) :: {:ok, t()} | {:error, String.t()}

Create a ChainHash from a hex string (byte-reversed, Bitcoin convention).

from_hex!(hex)

@spec from_hex!(String.t()) :: t()

Create a ChainHash from hex, raising on error.

to_bytes(chain_hash)

@spec to_bytes(t()) :: <<_::256>>

Get raw 32 bytes.

to_hex(chain_hash)

@spec to_hex(t()) :: String.t()

Convert to hex string (byte-reversed).