ledger-core
operators.h
1 /*
2  *
3  * operators.h
4  * ledger-core
5  *
6  * Created by Pierre Pollastri on 03/04/2018.
7  *
8  * The MIT License (MIT)
9  *
10  * Copyright (c) 2017 Ledger
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy
13  * of this software and associated documentation files (the "Software"), to deal
14  * in the Software without restriction, including without limitation the rights
15  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16  * copies of the Software, and to permit persons to whom the Software is
17  * furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included in all
20  * copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  * SOFTWARE.
29  *
30  */
31 
32 #ifndef LEDGER_CORE_OPERATORS_H
33 #define LEDGER_CORE_OPERATORS_H
34 
35 #include <api/BitcoinLikeOperator.hpp>
36 
37 // Code from https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h
38 
39 namespace ledger {
40  namespace core {
41  namespace btccore {
43  enum opcodetype {
44  // push value
45  OP_0 = 0x00,
46  OP_FALSE = OP_0,
47  OP_PUSHDATA1 = 0x4c,
48  OP_PUSHDATA2 = 0x4d,
49  OP_PUSHDATA4 = 0x4e,
50  OP_1NEGATE = 0x4f,
51  OP_RESERVED = 0x50,
52  OP_1 = 0x51,
53  OP_TRUE = OP_1,
54  OP_2 = 0x52,
55  OP_3 = 0x53,
56  OP_4 = 0x54,
57  OP_5 = 0x55,
58  OP_6 = 0x56,
59  OP_7 = 0x57,
60  OP_8 = 0x58,
61  OP_9 = 0x59,
62  OP_10 = 0x5a,
63  OP_11 = 0x5b,
64  OP_12 = 0x5c,
65  OP_13 = 0x5d,
66  OP_14 = 0x5e,
67  OP_15 = 0x5f,
68  OP_16 = 0x60,
69 
70  // control
71  OP_NOP = 0x61,
72  OP_VER = 0x62,
73  OP_IF = 0x63,
74  OP_NOTIF = 0x64,
75  OP_VERIF = 0x65,
76  OP_VERNOTIF = 0x66,
77  OP_ELSE = 0x67,
78  OP_ENDIF = 0x68,
79  OP_VERIFY = 0x69,
80  OP_RETURN = 0x6a,
81 
82  // stack ops
83  OP_TOALTSTACK = 0x6b,
84  OP_FROMALTSTACK = 0x6c,
85  OP_2DROP = 0x6d,
86  OP_2DUP = 0x6e,
87  OP_3DUP = 0x6f,
88  OP_2OVER = 0x70,
89  OP_2ROT = 0x71,
90  OP_2SWAP = 0x72,
91  OP_IFDUP = 0x73,
92  OP_DEPTH = 0x74,
93  OP_DROP = 0x75,
94  OP_DUP = 0x76,
95  OP_NIP = 0x77,
96  OP_OVER = 0x78,
97  OP_PICK = 0x79,
98  OP_ROLL = 0x7a,
99  OP_ROT = 0x7b,
100  OP_SWAP = 0x7c,
101  OP_TUCK = 0x7d,
102 
103  // splice ops
104  OP_CAT = 0x7e,
105  OP_SUBSTR = 0x7f,
106  OP_LEFT = 0x80,
107  OP_RIGHT = 0x81,
108  OP_SIZE = 0x82,
109 
110  // bit logic
111  OP_INVERT = 0x83,
112  OP_AND = 0x84,
113  OP_OR = 0x85,
114  OP_XOR = 0x86,
115  OP_EQUAL = 0x87,
116  OP_EQUALVERIFY = 0x88,
117  OP_RESERVED1 = 0x89,
118  OP_RESERVED2 = 0x8a,
119 
120  // numeric
121  OP_1ADD = 0x8b,
122  OP_1SUB = 0x8c,
123  OP_2MUL = 0x8d,
124  OP_2DIV = 0x8e,
125  OP_NEGATE = 0x8f,
126  OP_ABS = 0x90,
127  OP_NOT = 0x91,
128  OP_0NOTEQUAL = 0x92,
129 
130  OP_ADD = 0x93,
131  OP_SUB = 0x94,
132  OP_MUL = 0x95,
133  OP_DIV = 0x96,
134  OP_MOD = 0x97,
135  OP_LSHIFT = 0x98,
136  OP_RSHIFT = 0x99,
137 
138  OP_BOOLAND = 0x9a,
139  OP_BOOLOR = 0x9b,
140  OP_NUMEQUAL = 0x9c,
141  OP_NUMEQUALVERIFY = 0x9d,
142  OP_NUMNOTEQUAL = 0x9e,
143  OP_LESSTHAN = 0x9f,
144  OP_GREATERTHAN = 0xa0,
145  OP_LESSTHANOREQUAL = 0xa1,
146  OP_GREATERTHANOREQUAL = 0xa2,
147  OP_MIN = 0xa3,
148  OP_MAX = 0xa4,
149 
150  OP_WITHIN = 0xa5,
151 
152  // crypto
153  OP_RIPEMD160 = 0xa6,
154  OP_SHA1 = 0xa7,
155  OP_SHA256 = 0xa8,
156  OP_HASH160 = 0xa9,
157  OP_HASH256 = 0xaa,
158  OP_CODESEPARATOR = 0xab,
159  OP_CHECKSIG = 0xac,
160  OP_CHECKSIGVERIFY = 0xad,
161  OP_CHECKMULTISIG = 0xae,
162  OP_CHECKMULTISIGVERIFY = 0xaf,
163 
164  // expansion
165  OP_NOP1 = 0xb0,
166  OP_CHECKLOCKTIMEVERIFY = 0xb1,
167  OP_NOP2 = OP_CHECKLOCKTIMEVERIFY,
168  OP_CHECKSEQUENCEVERIFY = 0xb2,
169  OP_NOP3 = OP_CHECKSEQUENCEVERIFY,
170  OP_NOP4 = 0xb3,
171  OP_CHECKBLOCKATHEIGHT = 0xb4,
172  OP_NOP6 = 0xb5,
173  OP_NOP7 = 0xb6,
174  OP_NOP8 = 0xb7,
175  OP_NOP9 = 0xb8,
176  OP_NOP10 = 0xb9,
177 
178 
179  // template matching params
180  OP_SMALLINTEGER = 0xfa,
181  OP_PUBKEYS = 0xfb,
182  OP_PUBKEYHASH = 0xfd,
183  OP_PUBKEY = 0xfe,
184 
185  OP_INVALIDOPCODE = 0xff,
186  };
187 
188  const char* GetOpName(opcodetype opcode);
189 
190  }
191  }
192 }
193 
194 #endif //LEDGER_CORE_OPERATORS_H
Definition: Account.cpp:8