NAME
Bitcoin::Crypto::Script::Opcode - Bitcoin Script opcode
SYNOPSIS
use Bitcoin::Crypto::Script::Opcode;
my $opcode1 = Bitcoin::Crypto::Script::Opcode->get_opcode_by_code(0x00);
my $opcode2 = Bitcoin::Crypto::Script::Opcode->get_opcode_by_name('OP_1');
print $opcode1->name; # 'OP_0'
print $opcode1->code; # 0
print 'implemented' if $opcode1->implemented;
DESCRIPTION
This is both a library of opcodes and a small struct-like class for opcodes.
INTERFACE
Class (static) methods
These methods are used to find an opcode.
get_opcode_by_name
my $object = Bitcoin::Crypto::Script::Opcode->get_opcode_by_name($name);
Finds an opcode by its name (OP_XXX) and returns an object instance.
If opcode was not found an exception is raised (Bitcoin::Crypto::Exception::ScriptOpcode).
get_opcode_by_code
my $object = Bitcoin::Crypto::Script::Opcode->get_opcode_by_code($int);
Finds an opcode by its code (integer in range 0-255) and returns an object instance.
If opcode was not found, an UNKNOWN opcode is returned which marks the script as invalid on execution.
Attributes
name
The name of the opcode (OP_XXX).
code
The code of the opcode - an 8-bit unsigned integer.
runner
A coderef which can be used to execute this opcode.
Methods
execute
Executes this opcode. Internal use only.