pub enum ExprInner<T: ExtParam> {
Show 18 variants
Const(i64),
CurrInputIdx,
Input(IdxExpr),
Output(IdxExpr),
InputIssue(IdxExpr),
InputReIssue(IdxExpr),
Add(Box<Expr<T>>, Box<Expr<T>>),
Sub(Box<Expr<T>>, Box<Expr<T>>),
Mul(Box<Expr<T>>, Box<Expr<T>>),
Div(Box<Expr<T>>, Box<Expr<T>>),
Mod(Box<Expr<T>>, Box<Expr<T>>),
BitAnd(Box<Expr<T>>, Box<Expr<T>>),
BitOr(Box<Expr<T>>, Box<Expr<T>>),
Xor(Box<Expr<T>>, Box<Expr<T>>),
Invert(Box<Expr<T>>),
Negate(Box<Expr<T>>),
PriceOracle1(T, u64),
PriceOracle1W(T, u64),
}
Expand description
Enum representing arithmetic operations with transaction amounts. Every variant of this enum pushes a single singed 64 bit BE number on stack top. All of introspection opcodes explicitly assert the amount is explicit.
This will abort when - Any of operations are on confidential amounts. The Null case is automatically converted to explicit zero. - Supplied index is out of bounds. - Any of the operations overflow. Refer to tapscript opcodes spec for overflow specification - In extreme cases, when recursive operations exceed 400 depth
Variants§
Const(i64)
A constant i64 value
Minimal push of this <i64>
CurrInputIdx
Value under the current executing input
INSPECTCURRENTINPUTINDEX INPSECTINPUTVALUE <1> EQUALVERIFY
Input(IdxExpr)
Explicit amount at the given input index
i INPSECTINPUTVALUE <1> EQUALVERIFY
Output(IdxExpr)
Explicit amount at the given output index
i INPSECTOUTPUTVALUE <1> EQUALVERIFY
InputIssue(IdxExpr)
Explicit issuance amount at this input index
i OP_INSPECTINPUTISSUANCE DROP DROP <1> EQUALVERIFY NIP NIP
InputReIssue(IdxExpr)
Explicit re-issuance amount at this input index
i OP_INSPECTINPUTISSUANCE DROP DROP DROP DROP <1> EQUALVERIFY
Add(Box<Expr<T>>, Box<Expr<T>>)
Add two Arith expressions.
[X] [Y] ADD64 <1> EQUALVERIFY
Sub(Box<Expr<T>>, Box<Expr<T>>)
Subtract (X-Y)
[X] [Y] SUB64 <1> EQUALVERIFY
Mul(Box<Expr<T>>, Box<Expr<T>>)
Multiply two Expr expressions. (a*b)
[X] [Y] MUL64 <1> EQUALVERIFY
Div(Box<Expr<T>>, Box<Expr<T>>)
Divide two Expr expressions. (a//b)
The division operation pushes the quotient(a//b) such that the remainder a%b
(must be non-negative and less than |b|).
[X] [Y] DIV64 <1> EQUALVERIFY NIP
Mod(Box<Expr<T>>, Box<Expr<T>>)
Modulo operation (a % b)
The division operation the remainder a%b (must be non-negative and less than |b|).
[X] [Y] DIV64 <1> EQUALVERIFY DROP
BitAnd(Box<Expr<T>>, Box<Expr<T>>)
BitWise And (a & b)
[X] [Y] AND
(cannot fail)
BitOr(Box<Expr<T>>, Box<Expr<T>>)
BitWise or (a | b)
[X] [Y] OR
(cannot fail)
Xor(Box<Expr<T>>, Box<Expr<T>>)
BitWise or (a ^ b)
[X] [Y] XOR
(cannot fail)
Invert(Box<Expr<T>>)
BitWise invert (!a)
[X] INVERT
(cannot fail)
Negate(Box<Expr<T>>)
Negate -a
[X] NEG64 <1> EQUALVERIFY
PriceOracle1(T, u64)
Push the price as LE64 signed from oracle.
2DUP TOALTSTACK <T> OP_GREATERTHANEQ VERIFY CAT SHA256 <K> CHECKSIGFROMSTACKVERIFY OP_FROMATLSTACK
The fragment checks that the input timestamp is less than time at which the price was signed with
the given oracle key. The asset of which price is being checked is implicitly decided by the
public key
PriceOracle1W(T, u64)
Same as Self::PriceOracle1
but wrapped in an TOALTSTACK
and FROMALTSTACK
and SWAP
TOALTSTACK 2DUP TOALTSTACK <T> OP_GREATERTHANEQ VERIFY CAT SHA256 <K> CHECKSIGFROMSTACKVERIFY OP_FROMATLSTACK FROMALTSTACK SWAP
We need to swap at the end to make sure that the price pushed by this fragment is on top of the stack
In regular miniscript, all operations are commutative, but here some operations like sub and div are not and hence
we need to maintain the exact order of operations.