View Source BitcoinLib.Script (BitcoinLib v0.2.0-pre1)

Script manipulation module

Link to this section Summary

Functions

Transforms a list of opcodes into a compact integer reprensenting the size of the sript, and the script itself

Transforms a script in the bitstring form into a list of opcodes

Link to this section Functions

@spec encode(list()) :: {bitstring(), bitstring()}

Transforms a list of opcodes into a compact integer reprensenting the size of the sript, and the script itself

examples

Examples

iex> [ ...> %BitcoinLib.Script.Opcodes.Stack.Dup{}, ...> %BitcoinLib.Script.Opcodes.Crypto.Hash160{}, ...> %BitcoinLib.Script.Opcodes.Data{ ...> value: <<0xfde0a08625e327ba400644ad62d5c571d2eec3de::160>> ...> }, ...> %BitcoinLib.Script.Opcodes.BitwiseLogic.EqualVerify{}, ...> %BitcoinLib.Script.Opcodes.Crypto.CheckSig{} ...> ] |> BitcoinLib.Script.encode {<<0x19>>, <<0x76a914fde0a08625e327ba400644ad62d5c571d2eec3de88ac::200>>}

@spec execute(bitstring(), list()) :: {:ok, boolean()} | {:error, binary()}
@spec execute(list(), list()) :: {:ok, boolean()} | {:error, binary()}
@spec identify(bitstring() | list()) :: :unknown | :p2pk | :p2pkh | :p2sh
@spec parse(bitstring()) :: list()

Transforms a script in the bitstring form into a list of opcodes

examples

Examples

iex> <<0x76a914fde0a08625e327ba400644ad62d5c571d2eec3de88ac::200>> ...> |> BitcoinLib.Script.parse() [

%BitcoinLib.Script.Opcodes.Stack.Dup{},
%BitcoinLib.Script.Opcodes.Crypto.Hash160{},
%BitcoinLib.Script.Opcodes.Data{
  value: <<0xfde0a08625e327ba400644ad62d5c571d2eec3de::160>>
},
%BitcoinLib.Script.Opcodes.BitwiseLogic.EqualVerify{},
%BitcoinLib.Script.Opcodes.Crypto.CheckSig{
  script: <<0x76a914fde0a08625e327ba400644ad62d5c571d2eec3de88ac::200>>
}

]