BSV.OpCode (BSV v2.1.0) View Source
Module for accessing Bitcoin Script Op Codes.
Bitcoin Script provides a number of operations or commands, known as Op Codes. When the script is evaluated, the Op Codes manipulate the stack in some way.
Within a script, an Op Code is single byte integer. Op Codes can also be referenced by an atom representing the word or name of the Op Code.
Link to this section Summary
Functions
Returns a map of all Op Codes.
Returns an atom/0
Op Code from the given value. Returns nil if the value
is not a valid Op Code.
Returns an atom/0
Op Code from the given value.
Returns an integer/0
Op Code from the given value. Returns nil if the
value is not a valid Op Code.
Returns an integer/0
Op Code from the given value.
Link to this section Types
Specs
Op Code
Link to this section Functions
Specs
all() :: map()
Returns a map of all Op Codes.
Specs
Returns an atom/0
Op Code from the given value. Returns nil if the value
is not a valid Op Code.
Examples
iex> BSV.OpCode.to_atom :OP_RETURN
:OP_RETURN
iex> BSV.OpCode.to_atom "op_return"
:OP_RETURN
iex> BSV.OpCode.to_atom <<106>>
:OP_RETURN
iex> BSV.OpCode.to_atom 106
:OP_RETURN
iex> BSV.OpCode.to_atom :UNKNOWN_CODE
nil
Specs
Returns an atom/0
Op Code from the given value.
As to_atom/1
but raises an error if the value is not a valid Op Code.
Specs
Returns an integer/0
Op Code from the given value. Returns nil if the
value is not a valid Op Code.
Examples
iex> BSV.OpCode.to_integer :OP_RETURN
106
iex> BSV.OpCode.to_integer "op_return"
106
iex> BSV.OpCode.to_integer <<106>>
106
iex> BSV.OpCode.to_integer 106
106
iex> BSV.OpCode.to_integer :UNKNOWN_CODE
nil
Specs
Returns an integer/0
Op Code from the given value.
As to_integer/1
but raises an error if the value is not a valid Op Code.