pub enum Opcode {
Show 36 variants
CheckHeightVerify(u64),
CheckHeight(u64),
CompareHeightVerify,
CompareHeight,
Nop,
PushZero,
PushOne,
PushHash(Box<HashValue>),
PushInt(i64),
PushPubKey(Box<CompressedKey<RistrettoPublicKey>>),
Drop,
Dup,
RevRot,
GeZero,
GtZero,
LeZero,
LtZero,
Add,
Sub,
Equal,
EqualVerify,
Or(u8),
OrVerify(u8),
HashBlake256,
HashSha256,
HashSha3,
CheckSig(Box<Message>),
CheckSigVerify(Box<Message>),
CheckMultiSig(u8, u8, Vec<CompressedKey<RistrettoPublicKey>>, Box<Message>),
CheckMultiSigVerify(u8, u8, Vec<CompressedKey<RistrettoPublicKey>>, Box<Message>),
CheckMultiSigVerifyAggregatePubKey(u8, u8, Vec<CompressedKey<RistrettoPublicKey>>, Box<Message>),
ToRistrettoPoint,
Return,
IfThen,
Else,
EndIf,
}Variants§
CheckHeightVerify(u64)
Compare the current block height to height. Fails with
IncompatibleTypes if u64 is not a valid 64-bit unsigned integer. Fails with VerifyFailed if the block
height < height.
CheckHeight(u64)
Pushes the value of (the current tip height - height) to the stack. In
other words, the top of the stack will hold the height difference between height and the current height.
If the chain has progressed beyond height, the value is positive; and negative if the chain has yet to
reach height. Fails with IncompatibleTypes if u64 is not a valid 64-bit unsigned integer. Fails with
StackOverflow if the stack would exceed the max stack height.
CompareHeightVerify
Pops the top of the stack as height and compares it to the current block height. Fails with InvalidInput
if there is not a valid integer value on top of the stack. Fails with StackUnderflow if the stack is empty.
Fails with VerifyFailed if the block height < height.
CompareHeight
Pops the top of the stack as height, then pushes the value of (the current height - height) to the stack.
In other words, this opcode replaces the top of the stack with the difference between height and the
current height. Fails with InvalidInput if there is not a valid integer value on top of the stack. Fails
with StackUnderflow if the stack is empty.
Nop
No op. Does nothing. Never fails.
PushZero
Pushes a zero onto the stack. This is a very common opcode and has the same effect as PushInt(0) but is more
compact. Fails with StackOverflow if the stack would exceed the max stack height.
PushOne
Pushes a one onto the stack. This is a very common opcode and has the same effect as PushInt(1) but is more
compact. Fails with StackOverflow if the stack would exceed the max stack height.
PushHash(Box<HashValue>)
Pushes the associated 32-byte value onto the stack. Fails with IncompatibleTypes if HashValue is not a valid
32 byte sequence. Fails with StackOverflow if the stack would exceed the max stack height.
PushInt(i64)
Pushes the associated 64-bit signed integer onto the stack Fails with IncompatibleTypes if i64 is not a valid
64-bit integer. Fails with StackOverflow if the stack would exceed the max stack height.
PushPubKey(Box<CompressedKey<RistrettoPublicKey>>)
Pushes the associated 32-byte value onto the stack. It will be interpreted as a public key or a commitment.
Fails with IncompatibleTypes if RistrettoPublicKey is not a valid 32 byte sequence. Fails with
StackOverflow if the stack would exceed the max stack height.
Drop
Drops the top stack item. Fails with StackUnderflow if the stack is empty.
Dup
Duplicates the top stack item. Fails with StackUnderflow if the stack is empty. Fails with StackOverflow if
the stack would exceed the max stack height.
RevRot
Reverse rotation. The top stack item moves into 3rd place, e.g. abc => bca. Fails with StackUnderflow if the
stack has fewer than three items.
GeZero
Pops the top stack element as val. If val is greater than or equal to zero, push a 1 to the stack,
otherwise push 0. Fails with StackUnderflow if the stack is empty. Fails with InvalidInput if val is
not an integer.
GtZero
Pops the top stack element as val. If val is strictly greater than zero, push a 1 to the stack, otherwise
push 0. Fails with StackUnderflow if the stack is empty. Fails with InvalidInput if the item is not an
integer.
LeZero
Pops the top stack element as val. If val is less than or equal to zero, push a 1 to the stack, otherwise
push 0. Fails with StackUnderflow if the stack is empty. Fails with InvalidInput if the item is not an
integer.
LtZero
Pops the top stack element as val. If val is strictly less than zero, push a 1 to the stack, otherwise push
0. Fails with StackUnderflow if the stack is empty. Fails with InvalidInput if the items is not an
integer.
Add
Pops two items from the stack and pushes their sum to the stack. Fails with StackUnderflow if the stack has
fewer than two items. Fails with InvalidInput if the items cannot be added to each other (e.g. an integer and
public key).
Sub
Pops two items from the stack and pushes the second minus the top to the stack. Fails with StackUnderflow if
the stack has fewer than two items. Fails with InvalidInput if the items cannot be subtracted from each other
(e.g. an integer and public key).
Equal
Pops the top two items from the stack, and pushes 1 to the stack if the inputs are exactly equal, 0 otherwise.
A 0 is also pushed if the values cannot be compared (e.g. integer and pubkey). Fails with StackUnderflow if
the stack has fewer than two items.
EqualVerify
Pops the top two items from the stack, and compares their values. Fails with StackUnderflow if the stack has
fewer than two items. Fails with VerifyFailed if the top two stack elements are not equal.
Or(u8)
Pops n + 1 items from the stack (with u8 as n). If the last item matches at least one of the first n
items, push 1 onto the stack, otherwise push 0 onto the stack. Fails with StackUnderflow if the stack has
fewer than n + 1 items. Fails with InvalidInput if u8 is not a valid 8-bit unsigned integer.
OrVerify(u8)
Pops n + 1 items from the stack (with u8 as n). If the last item matches at least one of the first n items,
continue. Fails with StackUnderflow if the stack has fewer than n + 1 items. Fails with VerifyFailed
the last item does not match at least one of the first n items. Fails with InvalidInput if u8 is not a
valid 8-bit unsigned integer.
HashBlake256
Pops the top element, hash it with the Blake2bStackUnderflow if the stack is empty. Fails with InvalidInput if the input is not a valid 32 byte hash
value.
HashSha256
Pops the top element, hash it with the SHA256 hash function and push the result to the stack. Fails with
StackUnderflow if the stack is empty. Fails with InvalidInput if the input is not a valid 32 byte hash
value.
HashSha3
Pops the top element, hash it with the SHA-3 hash function and push the result to the stack. Fails with
StackUnderflow if the stack is empty. Fails with InvalidInput if the input is not a valid 32 byte hash
value.
CheckSig(Box<Message>)
Pops the public key and then the signature from the stack. If signature validation using the 32-byte message
and public key succeeds , push 1 to the stack, otherwise push 0. Fails with IncompatibleTypes if Message
is not a valid 32-byte sequence. Fails with StackUnderflow if the stack has fewer than 2 items. Fails
with InvalidInput if the top stack element is not a PublicKey. Fails with InvalidInput if the second
stack element is not a Signature.
CheckSigVerify(Box<Message>)
Identical to CheckSig, except that nothing is pushed to the stack if the signature is valid, and the operation
fails with VerifyFailed if the signature is invalid.
CheckMultiSig(u8, u8, Vec<CompressedKey<RistrettoPublicKey>>, Box<Message>)
Pops exactly m signatures from the stack. The multiple signature validation will not succeed if the m
signatures are not unique or if VecIncompatibleTypes if either m (the 1st u8) or n (the 2nd u8) is not a valid 8-bit unsigned
integer, if VecValueExceedsBounds if m == 0 or if n == 0 or if m > n or if n > MAX_MULTISIG_LIMIT
(32) or if the number of public keys provided != n.
Fails with StackUnderflow if the stack has fewer than m items.
Fails with IncompatibleTypes if any of the m signatures from the stack is not a valid signature.
Fails with InvalidInput if each of the top m elements is not a Signature.
CheckMultiSigVerify(u8, u8, Vec<CompressedKey<RistrettoPublicKey>>, Box<Message>)
Identical to CheckMultiSig, except that nothing is pushed to the stack if the multiple signature validation is
either valid or invalid. Fails with VerifyFailed if any signature is invalid.
CheckMultiSigVerifyAggregatePubKey(u8, u8, Vec<CompressedKey<RistrettoPublicKey>>, Box<Message>)
Identical to CheckMultiSig, except that the aggregate of the public keys is pushed to the stack if multiple
signature validation succeeds. Fails with VerifyFailed if any signature is invalid.
ToRistrettoPoint
Pops the top element from the stack (either a scalar or a hash), parses it canonically as a Ristretto secret
key if possible, computes the corresponding Ristretto public key, and pushes this value to the stack.
Fails with StackUnderflow if the stack is empty.
Fails with IncompatibleTypes if the stack item is not either a scalar or a hash.
Fails with InvalidInput if the stack item cannot be canonically parsed as a Ristretto secret key.
Return
Always fails with Return.
IfThen
Pops the top element of the stack into pred. If pred is 1, the instructions between IfThen and Else are
executed. If pred is 0, instructions are popped until Else or EndIf is encountered. If Else is
encountered, instructions are executed until EndIf is reached. EndIf is a marker opcode and a no-op.
Fails with StackUnderflow if the stack is empty.
Fails with InvalidInput if pred is anything other than 0 or 1.
Fails with the corresponding failure code if any instruction during execution of the clause causes a failure.
Else
Marks the beginning of the Else branch.
EndIf
Marks the end of the IfThen statement.
Implementations§
Source§impl Opcode
impl Opcode
pub fn get_version(&self) -> OpcodeVersion
pub fn parse(bytes: &[u8]) -> Result<Vec<Opcode>, ScriptError>
Trait Implementations§
impl Eq for Opcode
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more