Bitcoin Script type — a sequence of opcodes and data pushes.
Scripts are used in transaction inputs (unlocking) and outputs (locking) to define spending conditions.
Summary
Functions
Parse a Bitcoin ASM string into a Script.
Parse a binary into a Script struct.
Parse a hex string into a Script.
Extract the public key hash from a P2PKH script.
Check if a script is OP_RETURN data.
Check if a script is P2PKH.
Check if a script is P2SH (OP_HASH160 <20 bytes> OP_EQUAL).
Create a new empty script.
Build an OP_RETURN data script (OP_FALSE OP_RETURN <data>...).
Build a P2PKH locking script from a 20-byte public key hash.
Build a P2PKH unlocking script from a signature and public key.
Convert a script to its ASM string representation.
Serialize a script to raw bytes.
Serialize a script to a hex string.
Types
Functions
Parse a Bitcoin ASM string into a Script.
Parse a binary into a Script struct.
Parse a hex string into a Script.
@spec get_pubkey_hash(t()) :: {:ok, <<_::160>>} | :error
Extract the public key hash from a P2PKH script.
Check if a script is OP_RETURN data.
Check if a script is P2PKH.
Check if a script is P2SH (OP_HASH160 <20 bytes> OP_EQUAL).
@spec new() :: t()
Create a new empty script.
Build an OP_RETURN data script (OP_FALSE OP_RETURN <data>...).
@spec p2pkh_lock(<<_::160>>) :: t()
Build a P2PKH locking script from a 20-byte public key hash.
Build a P2PKH unlocking script from a signature and public key.
Convert a script to its ASM string representation.
Serialize a script to raw bytes.
Serialize a script to a hex string.