Take a ProgramState
and return a new copy of that ProgramState
.
This method is used internally by stateEvaluate
, stateStep
, and
stateDebug
to prevent the AuthenticationVirtualMachine from
mutating an input when mutation is not desirable.
use structuredClone
instead
Test the ProgramState to determine if execution should continue.
This method is used internally by the
AuthenticationVirtualMachine's stateEvaluate
and stateDebug
methods after each operation, and should usually test for errors or program
completion. This method is exposed via the
AuthenticationVirtualMachine's stateContinue
method.
Test the ProgramState to determine if execution should continue.
This method is used internally by the
AuthenticationVirtualMachine's stateEvaluate
and stateDebug
methods after each operation, and should usually test for errors or program
completion. This method is exposed via the
AuthenticationVirtualMachine's stateContinue
method.
Evaluate a program to completion given the
AuthenticationVirtualMachine's stateEvaluate
method.
Each AuthenticationVirtualMachine can have precise operation
requirements modifying the ways in which AuthenticationProgram
s and
ProgramState
s are interpreted. (In the C++ implementations, these
requirements are encoded in VerifyScript
, and can significantly modify
the behavior of the basic EvalScript
system.) For example, the secondary
evaluation step required for P2SH can be performed in this method.
This method is used internally by the
AuthenticationVirtualMachine's evaluate
and debug
methods. It
should perform any necessary operations and validations before returning a
fully-evaluated ProgramState
.
Evaluate a program to completion given the
AuthenticationVirtualMachine's stateEvaluate
method.
Each AuthenticationVirtualMachine can have precise operation
requirements modifying the ways in which AuthenticationProgram
s and
ProgramState
s are interpreted. (In the C++ implementations, these
requirements are encoded in VerifyScript
, and can significantly modify
the behavior of the basic EvalScript
system.) For example, the secondary
evaluation step required for P2SH can be performed in this method.
This method is used internally by the
AuthenticationVirtualMachine's evaluate
and debug
methods. It
should perform any necessary operations and validations before returning a
fully-evaluated ProgramState
.
Optional
every?: Operation<ProgramState>An optional operation to be performed after every executed virtual machine operation. This is useful for implementing logic that is common to all operations, e.g. stack depth or memory usage, operation count, etc.
A mapping of opcode
numbers (between 0 and 255) to Operations
. When the
AuthenticationVirtualMachine encounters an instruction for the
specified opcode
, the program state will be passed to the
specified operation.
Verify that a program state has completed evaluation successfully.
This method should return true
if the evaluation was successful, or
an error message on failure.
Verify that a program state has completed evaluation successfully.
This method should return true
if the evaluation was successful, or
an error message on failure.
This operation is called when an undefined opcode is encountered.
This method should usually mark the ProgramState with an error.
Verify a transaction given the InstructionSet's evaluate
and
success
methods and a fully-resolved transaction (e.g. the decoded
transaction and an array of the outputs spent by its inputs).
This method should perform all possible stateless transaction validation but should not attempt to perform any kinds of network state-sensitive validation (ensuring source outputs remain unspent, validating claimed absolute or relative locktime values against current network conditions, etc.), as such results could not be safely cached.
This method should return true
if the transaction is valid, or an array
of error messages on failure.
Verify a transaction given the InstructionSet's evaluate
and
success
methods and a fully-resolved transaction (e.g. the decoded
transaction and an array of the outputs spent by its inputs).
This method should perform all possible stateless transaction validation but should not attempt to perform any kinds of network state-sensitive validation (ensuring source outputs remain unspent, validating claimed absolute or relative locktime values against current network conditions, etc.), as such results could not be safely cached.
This method should return true
if the transaction is valid, or an array
of error messages on failure.
Generated using TypeDoc
An InstructionSet is a mapping of methods that define the operation of an AuthenticationVirtualMachine.
An instruction set is composed of Operations that take a
ProgramState
and return aProgramState
, as well as several instruction set "lifecycle" methods.Each operation is assigned to its
opcode
number (between 0 and 255). When evaluating instructions, the virtual machine will select an Operation based on its opcode. Any opcodes that are unassigned by the instruction set will use theundefined
operation.