Enum OpCode

Source
#[repr(u8)]
pub enum OpCode {
Show 117 variants OP_0 = 0, OP_PUSHDATA1 = 76, OP_PUSHDATA2 = 77, OP_PUSHDATA4 = 78, OP_1NEGATE = 79, OP_1 = 81, OP_2 = 82, OP_3 = 83, OP_4 = 84, OP_5 = 85, OP_6 = 86, OP_7 = 87, OP_8 = 88, OP_9 = 89, OP_10 = 90, OP_11 = 91, OP_12 = 92, OP_13 = 93, OP_14 = 94, OP_15 = 95, OP_16 = 96, OP_NOP = 97, OP_IF = 99, OP_NOTIF = 100, OP_ELSE = 103, OP_ENDIF = 104, OP_VERIFY = 105, OP_RETURN = 106, OP_TOALTSTACK = 107, OP_FROMALTSTACK = 108, OP_IFDUP = 115, OP_DEPTH = 116, OP_DROP = 117, OP_DUP = 118, OP_NIP = 119, OP_OVER = 120, OP_PICK = 121, OP_ROLL = 122, OP_ROT = 123, OP_SWAP = 124, OP_TUCK = 125, OP_2DROP = 109, OP_2DUP = 110, OP_3DUP = 111, OP_2OVER = 112, OP_2ROT = 113, OP_2SWAP = 114, OP_CAT = 126, OP_SPLIT = 127, OP_SIZE = 130, OP_INVERT = 131, OP_AND = 132, OP_OR = 133, OP_XOR = 134, OP_EQUAL = 135, OP_EQUALVERIFY = 136, OP_1ADD = 139, OP_1SUB = 140, OP_NEGATE = 143, OP_ABS = 144, OP_NOT = 145, OP_0NOTEQUAL = 146, OP_ADD = 147, OP_SUB = 148, OP_MUL = 149, OP_DIV = 150, OP_MOD = 151, OP_LSHIFT = 152, OP_RSHIFT = 153, OP_BOOLAND = 154, OP_BOOLOR = 155, OP_NUMEQUAL = 156, OP_NUMEQUALVERIFY = 157, OP_NUMNOTEQUAL = 158, OP_LESSTHAN = 159, OP_GREATERTHAN = 160, OP_LESSTHANOREQUAL = 161, OP_GREATERTHANOREQUAL = 162, OP_MIN = 163, OP_MAX = 164, OP_WITHIN = 165, OP_NUM2BIN = 128, OP_BIN2NUM = 129, OP_RIPEMD160 = 166, OP_SHA1 = 167, OP_SHA256 = 168, OP_HASH160 = 169, OP_HASH256 = 170, OP_CODESEPARATOR = 171, OP_CHECKSIG = 172, OP_CHECKSIGVERIFY = 173, OP_CHECKMULTISIG = 174, OP_CHECKMULTISIGVERIFY = 175, OP_CHECKLOCKTIMEVERIFY = 177, OP_CHECKSEQUENCEVERIFY = 178, OP_DATA = 251, OP_SIG = 252, OP_PUBKEYHASH = 253, OP_PUBKEY = 254, OP_INVALIDOPCODE = 255, OP_RESERVED = 80, OP_VER = 98, OP_VERIF = 101, OP_VERNOTIF = 102, OP_RESERVED1 = 137, OP_RESERVED2 = 138, OP_NOP1 = 176, OP_NOP4 = 179, OP_NOP5 = 180, OP_NOP6 = 181, OP_NOP7 = 182, OP_NOP8 = 183, OP_NOP9 = 184, OP_NOP10 = 185, OP_INVALID_ABOVE = 186, OP_2MUL = 141, OP_2DIV = 142,
}
Expand description

Majority of this page is borrowed from bsv-wasm (https://github.com/Firaenix/bsv-wasm/blob/master/src/script/op_codes.rs) & rust-sv (https://github.com/brentongunning/rust-sv/blob/master/src/script/op_codes.rs)

Variants§

§

OP_0 = 0

Pushes 0 onto the stack

§

OP_PUSHDATA1 = 76

The next byte sets the number of bytes to push onto the stack

§

OP_PUSHDATA2 = 77

The next two bytes sets the number of bytes to push onto the stack

§

OP_PUSHDATA4 = 78

The next four bytes sets the number of bytes to push onto the stack

§

OP_1NEGATE = 79

Pushes -1 onto the stack

§

OP_1 = 81

Pushes 1 onto the stack

§

OP_2 = 82

Pushes 2 onto the stack

§

OP_3 = 83

Pushes 3 onto the stack

§

OP_4 = 84

Pushes 4 onto the stack

§

OP_5 = 85

Pushes 5 onto the stack

§

OP_6 = 86

Pushes 6 onto the stack

§

OP_7 = 87

Pushes 7 onto the stack

§

OP_8 = 88

Pushes 8 onto the stack

§

OP_9 = 89

Pushes 9 onto the stack

§

OP_10 = 90

Pushes 10 onto the stack

§

OP_11 = 91

Pushes 11 onto the stack

§

OP_12 = 92

Pushes 12 onto the stack

§

OP_13 = 93

Pushes 13 onto the stack

§

OP_14 = 94

Pushes 14 onto the stack

§

OP_15 = 95

Pushes 15 onto the stack

§

OP_16 = 96

Pushes 16 onto the stack

§

OP_NOP = 97

Does nothing

§

OP_IF = 99

If the top stack is true, statements are executed. Top stack value is removed.

§

OP_NOTIF = 100

If the top stack is false, statements are executed. Top stack value is removed.

§

OP_ELSE = 103

If the preceding OP_IF or OP_NOTIF statemetns were not executed, then statements are executed.

§

OP_ENDIF = 104

Ends an if-else block

§

OP_VERIFY = 105

Marks a statement as invalid if the top stack value is false. Top stack value is removed.

§

OP_RETURN = 106

Marks a statements as invalid

§

OP_TOALTSTACK = 107

Moves the top item on the main stack to the alt stack

§

OP_FROMALTSTACK = 108

Moves the top item on the alt stack to the main stack

§

OP_IFDUP = 115

Duplicates the top stack value if it is not zero

§

OP_DEPTH = 116

Puts the number of stack items onto the stack

§

OP_DROP = 117

Drops the top stack value

§

OP_DUP = 118

Duplicates the top stack item

§

OP_NIP = 119

Removes the second-to-top stack item

§

OP_OVER = 120

Copies the second-to-top stack item to the top

§

OP_PICK = 121

The item n back in the stack is copied to the top

§

OP_ROLL = 122

The item n back in the stack is moved to the top

§

OP_ROT = 123

The top three items on the stack are rotated to the left

§

OP_SWAP = 124

The top two items on the stack are swapped

§

OP_TUCK = 125

The item at the top of the stack is copied and inserted before the second-to-top item

§

OP_2DROP = 109

Removes the top two items from the stack

§

OP_2DUP = 110

Duplicates the top two stack items

§

OP_3DUP = 111

Duplicates the top three stack items

§

OP_2OVER = 112

Copies the pair of items two spaces back to the front

§

OP_2ROT = 113

The fifth and sixth items back are moved to the top of the stack

§

OP_2SWAP = 114

Swaps the top two pairs of items

§

OP_CAT = 126

Concatenates two byte sequences

§

OP_SPLIT = 127

Splits the byte sequence at position n

§

OP_SIZE = 130

Pushes the byte sequence length of the top stack item without popping it

§

OP_INVERT = 131

Flips all of the bits in the input

§

OP_AND = 132

Boolean and between each bit in the inputs

§

OP_OR = 133

Boolean or between each bit in the inputs

§

OP_XOR = 134

Boolean exclusive or between each bit in the inputs

§

OP_EQUAL = 135

Returns 1 if the inputs are exactly equal, 0 otherwise

§

OP_EQUALVERIFY = 136

Same as OP_EQUAL, but runs OP_VERIFY afterward

§

OP_1ADD = 139

Adds 1 to the input

§

OP_1SUB = 140

Subtracts 1 from the input

§

OP_NEGATE = 143

The sign of the input is flipped

§

OP_ABS = 144

The input is made positive

§

OP_NOT = 145

If the input is 0 or 1, it is flipped. Otherwise, the output will be 0.

§

OP_0NOTEQUAL = 146

Returns 0 if the input is 0. 1 otherwise.

§

OP_ADD = 147

Adds a to b

§

OP_SUB = 148

Subtracts b from a

§

OP_MUL = 149

Multiplies a by b

§

OP_DIV = 150

Divides a by b

§

OP_MOD = 151

Returns the remainder after dividing a by b

§

OP_LSHIFT = 152

Shifts a left b bits, preserving sign

§

OP_RSHIFT = 153

Shifts a right b bits, preserving sign

§

OP_BOOLAND = 154

If both a and b are not empty, the output is 1. Otherwise, 0.

§

OP_BOOLOR = 155

If a or b is not empty, the output is 1. Otherwise, 0.

§

OP_NUMEQUAL = 156

Returns 1 if the numbers are equal. Otherwise, 0.

§

OP_NUMEQUALVERIFY = 157

Same as OP_NUMEQUAL, but runs OP_VERIFY afterward

§

OP_NUMNOTEQUAL = 158

Returns 1 if the numbers are not equal. Otherwise, 0.

§

OP_LESSTHAN = 159

Returns 1 if a is less than b. Otherwise, 0.

§

OP_GREATERTHAN = 160

Returns 1 if a is greater than b. Otherwise, 0.

§

OP_LESSTHANOREQUAL = 161

Returns 1 if a is less than or equal to b. Otherwise, 0.

§

OP_GREATERTHANOREQUAL = 162

Returns 1 if a is greater than or equal to b. Otherwise, 0.

§

OP_MIN = 163

Returns the smaller of a and b

§

OP_MAX = 164

Returns the larger of a and b

§

OP_WITHIN = 165

Returns 1 if x is within the specified range, left inclusive. Otherwise, 0.

§

OP_NUM2BIN = 128

Converts numeric value a into a byte sequence of length b

§

OP_BIN2NUM = 129

Converts byte sequence x into a numeric value

§

OP_RIPEMD160 = 166

The input is hashed using RIPEMD-160

§

OP_SHA1 = 167

The input is hashed using SHA-1

§

OP_SHA256 = 168

The input is hashed using SHA-256

§

OP_HASH160 = 169

The input is hashed twice: first with SHA-256 and then with RIPEMD-160

§

OP_HASH256 = 170

The input is hashed two times with SHA-256

§

OP_CODESEPARATOR = 171

Marks the part of the script after which the signature will begin matching

§

OP_CHECKSIG = 172

Puts 1 on the stack if the signature authorizes the public key and transaction hash. Otherwise 0.

§

OP_CHECKSIGVERIFY = 173

Same as OP_CHECKSIG, but OP_VERIFY is executed afterward

§

OP_CHECKMULTISIG = 174

Puts 1 on the stack if m of n signatures authorize the public key and transaction hash. Otherwise 0.

§

OP_CHECKMULTISIGVERIFY = 175

Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward

§

OP_CHECKLOCKTIMEVERIFY = 177

Marks transaction as invalid if the top stack item is greater than the transaction’s lock_time

§

OP_CHECKSEQUENCEVERIFY = 178

Marks transaction as invalid if the top stack item is less than the transaction’s sequence used for relative lock time

§

OP_DATA = 251

OP_DATA followed by a varint represents arbitrary data on chain. Used for matching Script Templates.

§

OP_SIG = 252

Represents a secp256k1 signature

§

OP_PUBKEYHASH = 253

Represents a public key hashed with OP_HASH160

§

OP_PUBKEY = 254

Represents a public key compatible with OP_CHECKSIG

§

OP_INVALIDOPCODE = 255

Matches any opcode that is not yet assigned

§

OP_RESERVED = 80

Transaction is invalid unless occuring in an unexecuted OP_IF branch

§

OP_VER = 98

Transaction is invalid unless occuring in an unexecuted OP_IF branch

§

OP_VERIF = 101

Transaction is invalid even when occuring in an unexecuted OP_IF branch

§

OP_VERNOTIF = 102

Transaction is invalid even when occuring in an unexecuted OP_IF branch

§

OP_RESERVED1 = 137

Transaction is invalid unless occuring in an unexecuted OP_IF branch

§

OP_RESERVED2 = 138

Transaction is invalid unless occuring in an unexecuted OP_IF branch

§

OP_NOP1 = 176

The word is ignored. Does not mark transaction as invalid.

§

OP_NOP4 = 179

The word is ignored. Does not mark transaction as invalid.

§

OP_NOP5 = 180

The word is ignored. Does not mark transaction as invalid.

§

OP_NOP6 = 181

The word is ignored. Does not mark transaction as invalid.

§

OP_NOP7 = 182

The word is ignored. Does not mark transaction as invalid.

§

OP_NOP8 = 183

The word is ignored. Does not mark transaction as invalid.

§

OP_NOP9 = 184

The word is ignored. Does not mark transaction as invalid.

§

OP_NOP10 = 185

The word is ignored. Does not mark transaction as invalid.

§

OP_INVALID_ABOVE = 186

Words at or above this number are invalid

§

OP_2MUL = 141

The input is multiplied by 2

§

OP_2DIV = 142

The input is divided by 2

Trait Implementations§

Source§

impl Clone for OpCode

Source§

fn clone(&self) -> OpCode

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OpCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for OpCode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for OpCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<OpCode> for u16

Source§

fn from(val: OpCode) -> Self

Converts to this type from the input type.
Source§

impl From<OpCode> for u32

Source§

fn from(val: OpCode) -> Self

Converts to this type from the input type.
Source§

impl From<OpCode> for u64

Source§

fn from(val: OpCode) -> Self

Converts to this type from the input type.
Source§

impl From<OpCode> for u8

Source§

fn from(val: OpCode) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for OpCode

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for OpCode

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for OpCode

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for OpCode

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl FromStr for OpCode

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<OpCode, <Self as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for OpCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq<u16> for OpCode

Source§

fn eq(&self, other: &u16) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u32> for OpCode

Source§

fn eq(&self, other: &u32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u64> for OpCode

Source§

fn eq(&self, other: &u64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u8> for OpCode

Source§

fn eq(&self, other: &u8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for OpCode

Source§

fn eq(&self, other: &OpCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for OpCode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&str> for OpCode

Source§

type Error = ParseError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &str) -> Result<OpCode, <Self as TryFrom<&str>>::Error>

Performs the conversion.
Source§

impl Copy for OpCode

Source§

impl Eq for OpCode

Source§

impl StructuralPartialEq for OpCode

Auto Trait Implementations§

§

impl Freeze for OpCode

§

impl RefUnwindSafe for OpCode

§

impl Send for OpCode

§

impl Sync for OpCode

§

impl Unpin for OpCode

§

impl UnwindSafe for OpCode

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,