Enum OP

The supported opcodes for the script execution engine.

enum OP : ubyte { ... }

Opcodes named CHECK_* push their result to the stack, whereas VERIFY_* opcodes will cause the script execution to fail.

We can encode up to 255 opcodes (one of which is INVALID to halt execution).

Note that the range of values between PUSH_BYTES_1 and PUSH_BYTES_75 encodes a push to the stack between 1 .. 75 bytes. This range was chosen to allow pushing one of our largest types (Hash / Signature) in a single opcode as well as any associated metadata (e.g. Signature + SigHash).

For pushes of data longer than 75 bytes use one of the PUSH_DATA_* opcodes.

Enum members

NameDescription
CHECK_EQUAL Pops two items from the stack. Checks that the items are equal to each other, and pushes either TRUE or FALSE to the stack.
CHECK_MULTI_SIG Supports non-interactive threshold multi-signatures. A combination of N / M is supported where N <= M and where the number of keys and signatures does not exceed 5. Pops an item from the stack which is the count of public keys that should be read from the stack. It pops those public keys, and then pops another item which is the number of required signatures. Then it pops that many signatures from the stack. Then it walks through all the public keys and validates the signatures in sequence. If a key did not validate, it's removed from the internal list. If we've ran out of keys and the number of valid signatures is less than the required amount it means signature validation has failed. It pushes the result of validation to the tack. The keys and signatures must be placed in the same order on the stack. Supports up to 5 public keys total as the signature validation is not as efficient as alternative implementations such as MuSig.
CHECK_SEQ_SIG Expects a new sequence ID on the stack and an expected sequence ID on the stack. Verifies sequence_id >= expected_id, and adds sequence_id to the signature hash. The matching Input is blanked to implement floating transactions, as defined in Eltoo.
CHECK_SIG Pops two items from the stack. The two items must be a Point (Schnorr), and a Signature. If the items cannot be deserialized as a Point and Signature, the script validation fails. The signature is then validated using Schnorr, if the signature is valid then TRUE is pushed to the stack.
DUP Duplicate the item on the stack. Equivalent to value = pop() and push(value); push(value);
FALSE Pushes False onto the stack. Used by conditional opcodes.
HASH Pop the top item on the stack, hash it, and push the hash to the stack. Note that the item being hashed is a byte array.
HASH_SHA256 Same as HASH but uses SHA256
IF Conditionals
PUSH_BYTES_1 Used to encode a small data push to the stack (up to 75 bytes), may be used with case PUSH_BYTES_1: .. case PUSH_BYTES_64: syntax.
PUSH_BYTES_75 Used to encode a small data push to the stack (up to 75 bytes), may be used with case PUSH_BYTES_1: .. case PUSH_BYTES_64: syntax.
PUSH_DATA_1 The next 1 byte contains the number of bytes to push onto the stack. This opcode may not be used to encode data pushes of <= 75 bytes. PUSH_BYTES_* must be used for this purpose instead.
PUSH_DATA_2 The next 2 bytes (ushort in LE format) contains the number of bytes to push onto the stack. This opcode may not be used to encode data pushes of <= 255 bytes. PUSH_DATA_1 must be used for this purpose instead.
PUSH_NUM_1 This opcode may be reserved for a future PUSH_DATA_4.

Pushes 1 to 5 to the stack. To be used with counts for some opcodes such as CHECK_SEQ_SIG.

PUSH_NUM_2 This opcode may be reserved for a future PUSH_DATA_4.

Pushes 1 to 5 to the stack. To be used with counts for some opcodes such as CHECK_SEQ_SIG.

PUSH_NUM_3 This opcode may be reserved for a future PUSH_DATA_4.

Pushes 1 to 5 to the stack. To be used with counts for some opcodes such as CHECK_SEQ_SIG.

PUSH_NUM_4 This opcode may be reserved for a future PUSH_DATA_4.

Pushes 1 to 5 to the stack. To be used with counts for some opcodes such as CHECK_SEQ_SIG.

PUSH_NUM_5 This opcode may be reserved for a future PUSH_DATA_4.

Pushes 1 to 5 to the stack. To be used with counts for some opcodes such as CHECK_SEQ_SIG.

TRUE Pushes True onto the stack. Used by conditional opcodes. Additionally if after lock + unlock script execution the only value on the stack is TRUE, the script will be considered valid. Any other value (FALSE or otherwise) on the top of the stack after execution will cause the script to fail.
VERIFY_EQUAL Ditto, but instead of pushing to the stack it will cause the script execution to fail if the two items are not equal to each other.
VERIFY_LOCK_HEIGHT Verify the height lock of a spending Transaction. Expects an 8-byte unsigned integer as the height on the stack, and verifies that the Transaction's lock_height is greater than or equal to this value.
VERIFY_MULTI_SIG Ditto, but instead of pushing the result to the stack it will cause the script execution to fail if the signature is invalid
VERIFY_SEQ_SIG Expects a new sequence ID on the stack and an expected sequence ID on the stack. Verifies sequence_id >= expected_id, and adds sequence_id to the signature hash. The matching Input is blanked to implement floating transactions, as defined in Eltoo.
VERIFY_SIG Ditto, but instead of pushing the result to the stack it will cause the script execution to fail if the signature is invalid
VERIFY_UNLOCK_AGE Verify the time lock of the associated spending Input. Expects a 4-byte unsigned integer as the unlock age on the stack, and verifies that the Input's unlock_age is greater than or equal to this value.