Script opcodes
Declared in <script/script.h>
enum opcodetype;
| Name | Description |
|---|---|
OP_0 | Pushes an empty byte array (numeric zero / false) onto the stack. |
OP_FALSE | Alias for OP_0. |
OP_PUSHDATA1 | Pushes the next byte's count of bytes onto the stack. |
OP_PUSHDATA2 | Pushes the next two bytes' count of bytes onto the stack. |
OP_PUSHDATA4 | Pushes the next four bytes' count of bytes onto the stack. |
OP_1NEGATE | Pushes the number -1 onto the stack. |
OP_RESERVED | Reserved opcode; makes the transaction invalid if executed. |
OP_1 | Pushes the number 1 onto the stack. |
OP_TRUE | Alias for OP_1. |
OP_2 | Pushes the number 2 onto the stack. |
OP_3 | Pushes the number 3 onto the stack. |
OP_4 | Pushes the number 4 onto the stack. |
OP_5 | Pushes the number 5 onto the stack. |
OP_6 | Pushes the number 6 onto the stack. |
OP_7 | Pushes the number 7 onto the stack. |
OP_8 | Pushes the number 8 onto the stack. |
OP_9 | Pushes the number 9 onto the stack. |
OP_10 | Pushes the number 10 onto the stack. |
OP_11 | Pushes the number 11 onto the stack. |
OP_12 | Pushes the number 12 onto the stack. |
OP_13 | Pushes the number 13 onto the stack. |
OP_14 | Pushes the number 14 onto the stack. |
OP_15 | Pushes the number 15 onto the stack. |
OP_16 | Pushes the number 16 onto the stack. |
OP_NOP | Does nothing. |
OP_VER | Reserved opcode; makes the transaction invalid if executed. |
OP_IF | Executes the following block if the top stack value is true. |
OP_NOTIF | Executes the following block if the top stack value is false. |
OP_VERIF | Reserved opcode; makes the transaction invalid even when unexecuted. |
OP_VERNOTIF | Reserved opcode; makes the transaction invalid even when unexecuted. |
OP_ELSE | Executes the following block if the preceding OP_IF/OP_NOTIF block was not. |
OP_ENDIF | Ends an OP_IF/OP_NOTIF/OP_ELSE block. |
OP_VERIFY | Marks the transaction invalid if the top stack value is not true. |
OP_RETURN | Marks the transaction invalid and the output provably unspendable. |
OP_TOALTSTACK | Moves the top item from the main stack to the alt stack. |
OP_FROMALTSTACK | Moves the top item from the alt stack to the main stack. |
OP_2DROP | Removes the top two stack items. |
OP_2DUP | Duplicates the top two stack items. |
OP_3DUP | Duplicates the top three stack items. |
OP_2OVER | Copies the pair of items two spaces back to the top. |
OP_2ROT | Moves the fifth and sixth items to the top of the stack. |
OP_2SWAP | Swaps the top two pairs of items. |
OP_IFDUP | Duplicates the top item if it is not zero. |
OP_DEPTH | Pushes the number of stack items onto the stack. |
OP_DROP | Removes the top stack item. |
OP_DUP | Duplicates the top stack item. |
OP_NIP | Removes the second-to-top stack item. |
OP_OVER | Copies the second-to-top item to the top of the stack. |
OP_PICK | Copies the item n back in the stack to the top. |
OP_ROLL | Moves the item n back in the stack to the top. |
OP_ROT | Rotates the top three items to the left. |
OP_SWAP | Swaps the top two stack items. |
OP_TUCK | Copies the top item and inserts it below the second item. |
OP_CAT | Disabled opcode; would concatenate two byte strings. |
OP_SUBSTR | Disabled opcode; would return a substring of a byte string. |
OP_LEFT | Disabled opcode; would return the left part of a byte string. |
OP_RIGHT | Disabled opcode; would return the right part of a byte string. |
OP_SIZE | Pushes the byte length of the top stack item. |
OP_INVERT | Disabled opcode; would flip all bits of the top item. |
OP_AND | Disabled opcode; would compute the bitwise AND of two items. |
OP_OR | Disabled opcode; would compute the bitwise OR of two items. |
OP_XOR | Disabled opcode; would compute the bitwise XOR of two items. |
OP_EQUAL | Pushes true if the top two items are equal, otherwise false. |
OP_EQUALVERIFY | Runs OP_EQUAL then OP_VERIFY. |
OP_RESERVED1 | Reserved opcode; makes the transaction invalid if executed. |
OP_RESERVED2 | Reserved opcode; makes the transaction invalid if executed. |
OP_1ADD | Adds 1 to the top item. |
OP_1SUB | Subtracts 1 from the top item. |
OP_2MUL | Disabled opcode; would multiply the top item by 2. |
OP_2DIV | Disabled opcode; would divide the top item by 2. |
OP_NEGATE | Negates the sign of the top item. |
OP_ABS | Replaces the top item with its absolute value. |
OP_NOT | Pushes 1 if the top item is 0, otherwise 0. |
OP_0NOTEQUAL | Pushes 0 if the top item is 0, otherwise 1. |
OP_ADD | Adds the top two items. |
OP_SUB | Subtracts the top item from the second item. |
OP_MUL | Disabled opcode; would multiply the top two items. |
OP_DIV | Disabled opcode; would divide the second item by the top item. |
OP_MOD | Disabled opcode; would compute the remainder of a division. |
OP_LSHIFT | Disabled opcode; would shift the second item left. |
OP_RSHIFT | Disabled opcode; would shift the second item right. |
OP_BOOLAND | Pushes true if both of the top two items are nonzero. |
OP_BOOLOR | Pushes true if either of the top two items is nonzero. |
OP_NUMEQUAL | Pushes true if the top two numbers are equal. |
OP_NUMEQUALVERIFY | Runs OP_NUMEQUAL then OP_VERIFY. |
OP_NUMNOTEQUAL | Pushes true if the top two numbers are not equal. |
OP_LESSTHAN | Pushes true if the second number is less than the top number. |
OP_GREATERTHAN | Pushes true if the second number is greater than the top number. |
OP_LESSTHANOREQUAL | Pushes true if the second number is less than or equal to the top. |
OP_GREATERTHANOREQUAL | Pushes true if the second number is greater than or equal to the top. |
OP_MIN | Pushes the smaller of the top two numbers. |
OP_MAX | Pushes the larger of the top two numbers. |
OP_WITHIN | Pushes true if the third number is within the range [second, top).] |
OP_RIPEMD160 | Hashes the top item with RIPEMD-160. |
OP_SHA1 | Hashes the top item with SHA-1. |
OP_SHA256 | Hashes the top item with SHA-256. |
OP_HASH160 | Hashes the top item with SHA-256 then RIPEMD-160. |
OP_HASH256 | Hashes the top item with SHA-256 twice. |
OP_CODESEPARATOR | Marks the point from which the script is signed. |
OP_CHECKSIG | Verifies a signature against a public key and pushes the result. |
OP_CHECKSIGVERIFY | Runs OP_CHECKSIG then OP_VERIFY. |
OP_CHECKMULTISIG | Verifies m signatures against n public keys. |
OP_CHECKMULTISIGVERIFY | Runs OP_CHECKMULTISIG then OP_VERIFY. |
OP_NOP1 | Reserved no-op opcode for future upgrades. |
OP_CHECKLOCKTIMEVERIFY | Marks the transaction invalid if the top item is greater than nLockTime (BIP 65). |
OP_NOP2 | Former no-op, now OP_CHECKLOCKTIMEVERIFY. |
OP_CHECKSEQUENCEVERIFY | Marks the transaction invalid if the top item is greater than the input sequence (BIP 112). |
OP_NOP3 | Former no-op, now OP_CHECKSEQUENCEVERIFY. |
OP_NOP4 | Reserved no-op opcode for future upgrades. |
OP_NOP5 | Reserved no-op opcode for future upgrades. |
OP_NOP6 | Reserved no-op opcode for future upgrades. |
OP_NOP7 | Reserved no-op opcode for future upgrades. |
OP_NOP8 | Reserved no-op opcode for future upgrades. |
OP_NOP9 | Reserved no-op opcode for future upgrades. |
OP_NOP10 | Reserved no-op opcode for future upgrades. |
OP_CHECKSIGADD | Adds a signature check result to an accumulator (Tapscript, BIP 342). |
OP_INVALIDOPCODE | Represents an invalid or unknown opcode. |
| Name | Description |
|---|---|
GetOpName | Returns the mnemonic name of an opcode. |
IsOpSuccess | Test for OP_SUCCESSx opcodes as defined by BIP342. |
IsPushdataOp | Test whether an opcode is a data-push operation. |