NAME

Bitcoin::Crypto::Script::Opcode - Bitcoin Script opcode

SYNOPSIS

use Bitcoin::Crypto::Script::Opcode;

my $opcode1 = Bitcoin::Crypto::Script::Opcode->get_opcode_by_code("\x00");
my $opcode2 = Bitcoin::Crypto::Script::Opcode->get_opcode_by_name('OP_1');

print $opcode1->name; # 'OP_0'
print $opcode1->code; # "\x00"
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($bytestr);

Finds an opcode by its code (bytestring of length 1) and returns an object instance.

If opcode was not found an exception is raised (Bitcoin::Crypto::Exception::ScriptOpcode).

Attributes

name

The name of the opcode (OP_XXX).

code

The code of the opcode - a bytestring of length 1.

runner

A coderef which can be used to execute this opcode.

Methods

execute

Executes this opcode. Internal use only.

SEE ALSO

Bitcoin::Crypto::Script