Module op_codes

Module op_codes 

Source
Expand description

Script commands

Constants§

OP_0
Pushes 0 onto the stack
OP_0NOTEQUAL
Returns 0 if the input is 0. 1 otherwise.
OP_1
Pushes 1 onto the stack
OP_2
Pushes 2 onto the stack
OP_3
Pushes 3 onto the stack
OP_4
Pushes 4 onto the stack
OP_5
Pushes 5 onto the stack
OP_6
Pushes 6 onto the stack
OP_7
Pushes 7 onto the stack
OP_8
Pushes 8 onto the stack
OP_9
Pushes 9 onto the stack
OP_1ADD
Adds 1 to the input
OP_1NEGATE
Pushes -1 onto the stack
OP_1SUB
Subtracts 1 from the input
OP_2DROP
Removes the top two items from the stack
OP_2DUP
Duplicates the top two stack items
OP_2OVER
Copies the pair of items two spaces back to the front
OP_2ROT
The fifth and sixth items back are moved to the top of the stack
OP_2SWAP
Swaps the top two pairs of items
OP_3DUP
Duplicates the top three stack items
OP_10
Pushes 10 onto the stack
OP_11
Pushes 11 onto the stack
OP_12
Pushes 12 onto the stack
OP_13
Pushes 13 onto the stack
OP_14
Pushes 14 onto the stack
OP_15
Pushes 15 onto the stack
OP_16
Pushes 16 onto the stack
OP_ABS
The input is made positive
OP_ADD
Adds a to b
OP_AND
Boolean and between each bit in the inputs
OP_BIN2NUM
Converts byte sequence x into a numeric value
OP_BOOLAND
If both a and b are not empty, the output is 1. Otherwise, 0.
OP_BOOLOR
If a or b is not empty, the output is 1. Otherwise, 0.
OP_CAT
Concatenates two byte sequences
OP_CHECKLOCKTIMEVERIFY
Marks transaction as invalid if the top stack item is greater than the transaction’s lock_time
OP_CHECKMULTISIG
Puts 1 on the stack if m of n signatures authorize the public key and transaction hash. Otherwise 0.
OP_CHECKMULTISIGVERIFY
Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward
OP_CHECKSEQUENCEVERIFY
Marks transaction as invalid if the top stack item is less than the transaction’s sequence used for relative lock time
OP_CHECKSIG
Puts 1 on the stack if the signature authorizes the public key and transaction hash. Otherwise 0.
OP_CHECKSIGVERIFY
Same as OP_CHECKSIG, but OP_VERIFY is executed afterward
OP_CODESEPARATOR
Marks the part of the script after which the signature will begin matching
OP_DEPTH
Puts the number of stack items onto the stack
OP_DIV
Divides a by b
OP_DROP
Drops the top stack value
OP_DUP
Duplicates the top stack item
OP_ELSE
If the preceding OP_IF or OP_NOTIF statemetns were not executed, then statements are executed.
OP_ENDIF
Ends an if-else block
OP_EQUAL
Returns 1 if the inputs are exactly equal, 0 otherwise
OP_EQUALVERIFY
Same as OP_EQUAL, but runs OP_VERIFY afterward
OP_FALSE
Pushes 0 onto the stack
OP_FROMALTSTACK
Moves the top item on the alt stack to the main stack
OP_GREATERTHAN
Returns 1 if a is greater than b. Otherwise, 0.
OP_GREATERTHANOREQUAL
Returns 1 if a is greater than or equal to b. Otherwise, 0.
OP_HASH160
The input is hashed twice: first with SHA-256 and then with RIPEMD-160
OP_HASH256
The input is hashed two times with SHA-256
OP_IF
If the top stack is true, statements are executed. Top stack value is removed.
OP_IFDUP
Duplicates the top stack value if it is not zero
OP_LESSTHAN
Returns 1 if a is less than b. Otherwise, 0.
OP_LESSTHANOREQUAL
Returns 1 if a is less than or equal to b. Otherwise, 0.
OP_MAX
Returns the larger of a and b
OP_MIN
Returns the smaller of a and b
OP_MOD
Returns the remainder after dividing a by b
OP_NEGATE
The sign of the input is flipped
OP_NIP
Removes the second-to-top stack item
OP_NOP
Does nothing
OP_NOT
If the input is 0 or 1, it is flipped. Otherwise, the output will be 0.
OP_NOTIF
If the top stack is false, statements are executed. Top stack value is removed.
OP_NUM2BIN
Converts numeric value a into a byte sequence of length b
OP_NUMEQUAL
Returns 1 if the numbers are equal. Otherwise, 0.
OP_NUMEQUALVERIFY
Same as OP_NUMEQUAL, but runs OP_VERIFY afterward
OP_NUMNOTEQUAL
Returns 1 if the numbers are not equal. Otherwise, 0.
OP_OR
Boolean or between each bit in the inputs
OP_OVER
Copies the second-to-top stack item to the top
OP_PICK
The item n back in the stack is copied to the top
OP_PUSH
Offset by n to push n bytes onto the stack, where n: [1-75]
OP_PUSHDATA1
The next byte sets the number of bytes to push onto the stack
OP_PUSHDATA2
The next two bytes sets the number of bytes to push onto the stack
OP_PUSHDATA4
The next four bytes sets the number of bytes to push onto the stack
OP_RETURN
Marks a statements as invalid
OP_RIPEMD160
The input is hashed using RIPEMD-160
OP_ROLL
The item n back in the stack is moved to the top
OP_ROT
The top three items on the stack are rotated to the left
OP_SHA1
The input is hashed using SHA-1
OP_SHA256
The input is hashed using SHA-256
OP_SIZE
Pushes the byte sequence length of the top stack item without popping it
OP_SPLIT
Splits the byte sequence at position n
OP_SUB
Subtracts b from a
OP_SWAP
The top two items on the stack are swapped
OP_TOALTSTACK
Moves the top item on the main stack to the alt stack
OP_TRUE
Pushes 1 onto the stack
OP_TUCK
The item at the top of the stack is copied and inserted before the second-to-top item
OP_VERIFY
Marks a statement as invalid if the top stack value is false. Top stack value is removed.
OP_WITHIN
Returns 1 if x is within the specified range, left inclusive. Otherwise, 0.
OP_XOR
Boolean exclusive or between each bit in the inputs