regiusmark/script/
op.rs

1use crate::crypto::PublicKey;
2
3#[derive(PartialEq)]
4#[repr(u8)]
5pub enum Operand {
6    // Push value
7    PushFalse = 0x00,
8    PushTrue = 0x01,
9    PushPubKey = 0x02,
10
11    // Stack manipulation
12    OpNot = 0x10,
13
14    // Control
15    OpIf = 0x20,
16    OpElse = 0x21,
17    OpEndIf = 0x22,
18    OpReturn = 0x23,
19
20    // Crypto
21    OpCheckSig = 0x30,
22    OpCheckSigFastFail = 0x31,
23    OpCheckMultiSig = 0x32,
24    OpCheckMultiSigFastFail = 0x33,
25}
26
27impl From<Operand> for u8 {
28    fn from(op: Operand) -> u8 {
29        op as u8
30    }
31}
32
33#[derive(Debug, PartialEq)]
34pub enum OpFrame {
35    // Push value
36    False,
37    True,
38    PubKey(PublicKey),
39
40    // Stack manipulation
41    OpNot,
42
43    // Control
44    OpIf,
45    OpElse,
46    OpEndIf,
47    OpReturn,
48
49    // Crypto
50    OpCheckSig,
51    OpCheckSigFastFail,
52    OpCheckMultiSig(u8, u8), // M of N: minimum threshold to number of keys
53    OpCheckMultiSigFastFail(u8, u8),
54}
55
56impl From<bool> for OpFrame {
57    fn from(b: bool) -> OpFrame {
58        if b {
59            OpFrame::True
60        } else {
61            OpFrame::False
62        }
63    }
64}