Companion
All of the Script Virtual Machine opcodes, and some helper functions to create opcodes, are defined in the companion object of this class.
Properties
Push the bytecode currently being evaluated, beginning after the last executed OP_CODESEPARATOR, to the stack1. For Pay-to-Script-Hash (P2SH) evaluations, this is the redeem bytecode of the Unspent Transaction Output (UTXO) being spent; for all other evaluations, this is the locking bytecode of the UTXO being spent. Input: nothing Output: number
Convert a byte string a to a big number, see detailed description (here)[https://spec.nexa.org/nexa/op_bin2bignum.md] Input: little-endian-sign-mag-byte-array Output: big number
Check if signature is valid for message and a public key. See checkdatasig Input: sig msg pubkey Output: true or false
Same as CHECKDATASIG, but runs VERIFY afterward. Input: sig msg pubkey Output: nothing or fail
Marks transaction as invalid if the top stack item is greater than the transaction’s nLockTime field, otherwise script evaluation continues as though an OP_NOP was executed. Transaction is also invalid if 1. the stack is empty; or 2. the top stack item is negative; or 3. the top stack item is greater than or equal to 500000000 while the transaction’s nLockTime field is less than 500000000, or vice versa; or 4. the input’s nSequence field is equal to 0xffffffff. The precise semantics are described in BIP65. Input: x Output: x or fail
Signatures are checked against public keys. Signatures must be placed in the unlocking script using the same order as their corresponding public keys were placed in the locking script or redeem script. If all signatures are valid, 1 is returned, 0 otherwise. All elements are removed from the stack. For more information on the execution of this opcode, see (Multisignature)https://spec.nexa.org/blockchain/cryptography/multisignature. Input: bitmap sig1 sig2 … #-of-sigs pub1 pub2 … #-of-pubkeys Output: true or false
Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward. Input: bitmap sig1 sig2 … #-of-sigs pub1 pub2 … #-of-pubkeys Output: nothing or fail
Marks transaction as invalid if the relative lock time of the input (enforced by BIP68 with nSequence) is not equal to or longer than the value of the top stack item. The precise semantics are described in BIP112. Input: x Output: x or fail
Sig is a Schnorr signature concatenated to a sighash type specifier. The sighash for this input is calculated based on the sighash type. The validity of the Schnorr signature for this hash and public key is checked. If it is valid, 1 is returned, if it is empty, 0 is returned, otherwise the operation fails. Input: sig pubkey Output: true or false
Makes OP_CHECK(MULTI)SIG(VERIFY) use the subset of the script of everything after the most recently-executed OP_CODESEPARATOR when computing the sighash. Input: nothing Output: nothing
Same as OP_EQUAL, but runs OP_VERIFY afterward. Input: x1 x2 Output: nothing or fail
Puts the input onto the top of the main stack. Removes it from the alt stack. Input: (alt) x1 Output: x1
Returns 1 if a is greater than b, 0 otherwise. Input: a b Output: true/false
Returns 1 if a is greater than or equal to b, 0 otherwise. Input: a b Output: true/false
Pop the top item from the stack as an input index (Script Number). Push the unlocking bytecode of the input at that index to the stack. Input: index Output: script
Push the index of the input being evaluated to the stack as a Script Number. Input: nothing Output: number
Pop the top item from the stack as an input index (Script Number). Push the sequence number of the input at that index to the stack as a Script Number. Input: index Output: number
Returns 1 if a is less than or equal to b, 0 otherwise. Input: a b Output: true/false
Same as OP_NUMEQUAL, but runs OP_VERIFY afterward. Input: a b Output: nothing or fail
Returns 1 if the numbers are not equal, 0 otherwise. Input: a b Output: true/false
Pop the top item from the stack as an input index (Script Number). From that input, push the outpoint transaction hash - the hash of the transaction which created the Unspent Transaction Output (UTXO) which is being spent - to the stack in OP_HASH256 byte order. Input: index Output: hash
Pop the top item from the stack as an output index (Script Number). Push the locking bytecode of the output at that index to the stack. Input: index Output: script
Pop the top item from the stack as an output index (Script Number). Push the value (in satoshis) of the output at that index to the stack as a Script Number. Input: index Output: number
Place information about the current transaction onto the stack, see detailed description (here)[https://spec.nexa.org/nexa/op_push_tx_state.md] Input: dataSpecifier Output: data
Puts the input onto the top of the alt stack. Removes it from the main stack. Input: x1 Output: (alt) x1
Push the count of inputs in the current transaction to the stack as a Script Number. Input: nothing Output: number
Push the locktime of the current transaction to the stack as a Script Number. Input: nothing Output: number
Push the count of outputs in the current transaction to the stack as a Script Number. Input: nothing Output: number
Pop the top item from the stack as an input index (Script Number). Push the full locking bytecode of the Unspent Transaction Output (UTXO) spent by that input to the stack. Input: index Output: script
Functions
If the opcode is a "direct numeric push" (opcodes OP1NEGATE -> OP16), return the value OP code represents as ByteArray. Otherwise, null.
Little endian serialization to 2, 4, or 8 bytes as defined in the Group Tokenization Consensus Specification
Return TRUE if the passed byte is a constant quantity pushdata opcode
Parse a byte array containing 1 instruction into an easy to use structure