1#![allow(non_camel_case_types)]
10
11use core::fmt;
12
13use internals::debug_from_display;
14
15#[cfg(feature = "serde")]
16use crate::prelude::*;
17
18#[derive(Copy, Clone, PartialEq, Eq)]
32pub struct Opcode {
33 code: u8,
34}
35
36use self::all::*;
37
38macro_rules! all_opcodes {
39 ($($op:ident => $val:expr, $doc:expr);*) => {
40 pub mod all {
48 use super::Opcode;
49 $(
50 #[doc = $doc]
51 pub const $op: Opcode = Opcode { code: $val};
52 )*
53 }
54
55 pub static OP_0: Opcode = OP_PUSHBYTES_0;
57 pub static OP_FALSE: Opcode = OP_PUSHBYTES_0;
59 pub static OP_TRUE: Opcode = OP_PUSHNUM_1;
61 pub static OP_NOP2: Opcode = OP_CLTV;
63 pub static OP_NOP3: Opcode = OP_CSV;
65
66 impl fmt::Display for Opcode {
67 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
68 match *self {
69 $(
70 $op => core::fmt::Display::fmt(stringify!($op), f),
71 )+
72 }
73 }
74 }
75 }
76}
77
78all_opcodes! {
79 OP_PUSHBYTES_0 => 0x00, "Push an empty array onto the stack.";
80 OP_PUSHBYTES_1 => 0x01, "Push the next byte as an array onto the stack.";
81 OP_PUSHBYTES_2 => 0x02, "Push the next 2 bytes as an array onto the stack.";
82 OP_PUSHBYTES_3 => 0x03, "Push the next 3 bytes as an array onto the stack.";
83 OP_PUSHBYTES_4 => 0x04, "Push the next 4 bytes as an array onto the stack.";
84 OP_PUSHBYTES_5 => 0x05, "Push the next 5 bytes as an array onto the stack.";
85 OP_PUSHBYTES_6 => 0x06, "Push the next 6 bytes as an array onto the stack.";
86 OP_PUSHBYTES_7 => 0x07, "Push the next 7 bytes as an array onto the stack.";
87 OP_PUSHBYTES_8 => 0x08, "Push the next 8 bytes as an array onto the stack.";
88 OP_PUSHBYTES_9 => 0x09, "Push the next 9 bytes as an array onto the stack.";
89 OP_PUSHBYTES_10 => 0x0a, "Push the next 10 bytes as an array onto the stack.";
90 OP_PUSHBYTES_11 => 0x0b, "Push the next 11 bytes as an array onto the stack.";
91 OP_PUSHBYTES_12 => 0x0c, "Push the next 12 bytes as an array onto the stack.";
92 OP_PUSHBYTES_13 => 0x0d, "Push the next 13 bytes as an array onto the stack.";
93 OP_PUSHBYTES_14 => 0x0e, "Push the next 14 bytes as an array onto the stack.";
94 OP_PUSHBYTES_15 => 0x0f, "Push the next 15 bytes as an array onto the stack.";
95 OP_PUSHBYTES_16 => 0x10, "Push the next 16 bytes as an array onto the stack.";
96 OP_PUSHBYTES_17 => 0x11, "Push the next 17 bytes as an array onto the stack.";
97 OP_PUSHBYTES_18 => 0x12, "Push the next 18 bytes as an array onto the stack.";
98 OP_PUSHBYTES_19 => 0x13, "Push the next 19 bytes as an array onto the stack.";
99 OP_PUSHBYTES_20 => 0x14, "Push the next 20 bytes as an array onto the stack.";
100 OP_PUSHBYTES_21 => 0x15, "Push the next 21 bytes as an array onto the stack.";
101 OP_PUSHBYTES_22 => 0x16, "Push the next 22 bytes as an array onto the stack.";
102 OP_PUSHBYTES_23 => 0x17, "Push the next 23 bytes as an array onto the stack.";
103 OP_PUSHBYTES_24 => 0x18, "Push the next 24 bytes as an array onto the stack.";
104 OP_PUSHBYTES_25 => 0x19, "Push the next 25 bytes as an array onto the stack.";
105 OP_PUSHBYTES_26 => 0x1a, "Push the next 26 bytes as an array onto the stack.";
106 OP_PUSHBYTES_27 => 0x1b, "Push the next 27 bytes as an array onto the stack.";
107 OP_PUSHBYTES_28 => 0x1c, "Push the next 28 bytes as an array onto the stack.";
108 OP_PUSHBYTES_29 => 0x1d, "Push the next 29 bytes as an array onto the stack.";
109 OP_PUSHBYTES_30 => 0x1e, "Push the next 30 bytes as an array onto the stack.";
110 OP_PUSHBYTES_31 => 0x1f, "Push the next 31 bytes as an array onto the stack.";
111 OP_PUSHBYTES_32 => 0x20, "Push the next 32 bytes as an array onto the stack.";
112 OP_PUSHBYTES_33 => 0x21, "Push the next 33 bytes as an array onto the stack.";
113 OP_PUSHBYTES_34 => 0x22, "Push the next 34 bytes as an array onto the stack.";
114 OP_PUSHBYTES_35 => 0x23, "Push the next 35 bytes as an array onto the stack.";
115 OP_PUSHBYTES_36 => 0x24, "Push the next 36 bytes as an array onto the stack.";
116 OP_PUSHBYTES_37 => 0x25, "Push the next 37 bytes as an array onto the stack.";
117 OP_PUSHBYTES_38 => 0x26, "Push the next 38 bytes as an array onto the stack.";
118 OP_PUSHBYTES_39 => 0x27, "Push the next 39 bytes as an array onto the stack.";
119 OP_PUSHBYTES_40 => 0x28, "Push the next 40 bytes as an array onto the stack.";
120 OP_PUSHBYTES_41 => 0x29, "Push the next 41 bytes as an array onto the stack.";
121 OP_PUSHBYTES_42 => 0x2a, "Push the next 42 bytes as an array onto the stack.";
122 OP_PUSHBYTES_43 => 0x2b, "Push the next 43 bytes as an array onto the stack.";
123 OP_PUSHBYTES_44 => 0x2c, "Push the next 44 bytes as an array onto the stack.";
124 OP_PUSHBYTES_45 => 0x2d, "Push the next 45 bytes as an array onto the stack.";
125 OP_PUSHBYTES_46 => 0x2e, "Push the next 46 bytes as an array onto the stack.";
126 OP_PUSHBYTES_47 => 0x2f, "Push the next 47 bytes as an array onto the stack.";
127 OP_PUSHBYTES_48 => 0x30, "Push the next 48 bytes as an array onto the stack.";
128 OP_PUSHBYTES_49 => 0x31, "Push the next 49 bytes as an array onto the stack.";
129 OP_PUSHBYTES_50 => 0x32, "Push the next 50 bytes as an array onto the stack.";
130 OP_PUSHBYTES_51 => 0x33, "Push the next 51 bytes as an array onto the stack.";
131 OP_PUSHBYTES_52 => 0x34, "Push the next 52 bytes as an array onto the stack.";
132 OP_PUSHBYTES_53 => 0x35, "Push the next 53 bytes as an array onto the stack.";
133 OP_PUSHBYTES_54 => 0x36, "Push the next 54 bytes as an array onto the stack.";
134 OP_PUSHBYTES_55 => 0x37, "Push the next 55 bytes as an array onto the stack.";
135 OP_PUSHBYTES_56 => 0x38, "Push the next 56 bytes as an array onto the stack.";
136 OP_PUSHBYTES_57 => 0x39, "Push the next 57 bytes as an array onto the stack.";
137 OP_PUSHBYTES_58 => 0x3a, "Push the next 58 bytes as an array onto the stack.";
138 OP_PUSHBYTES_59 => 0x3b, "Push the next 59 bytes as an array onto the stack.";
139 OP_PUSHBYTES_60 => 0x3c, "Push the next 60 bytes as an array onto the stack.";
140 OP_PUSHBYTES_61 => 0x3d, "Push the next 61 bytes as an array onto the stack.";
141 OP_PUSHBYTES_62 => 0x3e, "Push the next 62 bytes as an array onto the stack.";
142 OP_PUSHBYTES_63 => 0x3f, "Push the next 63 bytes as an array onto the stack.";
143 OP_PUSHBYTES_64 => 0x40, "Push the next 64 bytes as an array onto the stack.";
144 OP_PUSHBYTES_65 => 0x41, "Push the next 65 bytes as an array onto the stack.";
145 OP_PUSHBYTES_66 => 0x42, "Push the next 66 bytes as an array onto the stack.";
146 OP_PUSHBYTES_67 => 0x43, "Push the next 67 bytes as an array onto the stack.";
147 OP_PUSHBYTES_68 => 0x44, "Push the next 68 bytes as an array onto the stack.";
148 OP_PUSHBYTES_69 => 0x45, "Push the next 69 bytes as an array onto the stack.";
149 OP_PUSHBYTES_70 => 0x46, "Push the next 70 bytes as an array onto the stack.";
150 OP_PUSHBYTES_71 => 0x47, "Push the next 71 bytes as an array onto the stack.";
151 OP_PUSHBYTES_72 => 0x48, "Push the next 72 bytes as an array onto the stack.";
152 OP_PUSHBYTES_73 => 0x49, "Push the next 73 bytes as an array onto the stack.";
153 OP_PUSHBYTES_74 => 0x4a, "Push the next 74 bytes as an array onto the stack.";
154 OP_PUSHBYTES_75 => 0x4b, "Push the next 75 bytes as an array onto the stack.";
155 OP_PUSHDATA1 => 0x4c, "Read the next byte as N; push the next N bytes as an array onto the stack.";
156 OP_PUSHDATA2 => 0x4d, "Read the next 2 bytes as N; push the next N bytes as an array onto the stack.";
157 OP_PUSHDATA4 => 0x4e, "Read the next 4 bytes as N; push the next N bytes as an array onto the stack.";
158 OP_PUSHNUM_NEG1 => 0x4f, "Push the array `0x81` onto the stack.";
159 OP_RESERVED => 0x50, "Synonym for OP_RETURN.";
160 OP_PUSHNUM_1 => 0x51, "Push the array `0x01` onto the stack.";
161 OP_PUSHNUM_2 => 0x52, "Push the array `0x02` onto the stack.";
162 OP_PUSHNUM_3 => 0x53, "Push the array `0x03` onto the stack.";
163 OP_PUSHNUM_4 => 0x54, "Push the array `0x04` onto the stack.";
164 OP_PUSHNUM_5 => 0x55, "Push the array `0x05` onto the stack.";
165 OP_PUSHNUM_6 => 0x56, "Push the array `0x06` onto the stack.";
166 OP_PUSHNUM_7 => 0x57, "Push the array `0x07` onto the stack.";
167 OP_PUSHNUM_8 => 0x58, "Push the array `0x08` onto the stack.";
168 OP_PUSHNUM_9 => 0x59, "Push the array `0x09` onto the stack.";
169 OP_PUSHNUM_10 => 0x5a, "Push the array `0x0a` onto the stack.";
170 OP_PUSHNUM_11 => 0x5b, "Push the array `0x0b` onto the stack.";
171 OP_PUSHNUM_12 => 0x5c, "Push the array `0x0c` onto the stack.";
172 OP_PUSHNUM_13 => 0x5d, "Push the array `0x0d` onto the stack.";
173 OP_PUSHNUM_14 => 0x5e, "Push the array `0x0e` onto the stack.";
174 OP_PUSHNUM_15 => 0x5f, "Push the array `0x0f` onto the stack.";
175 OP_PUSHNUM_16 => 0x60, "Push the array `0x10` onto the stack.";
176 OP_NOP => 0x61, "Does nothing.";
177 OP_VER => 0x62, "Synonym for OP_RETURN.";
178 OP_IF => 0x63, "Pop and execute the next statements if a nonzero element was popped.";
179 OP_NOTIF => 0x64, "Pop and execute the next statements if a zero element was popped.";
180 OP_VERIF => 0x65, "Fail the script unconditionally, does not even need to be executed.";
181 OP_VERNOTIF => 0x66, "Fail the script unconditionally, does not even need to be executed.";
182 OP_ELSE => 0x67, "Execute statements if those after the previous OP_IF were not, and vice-versa. \
183 If there is no previous OP_IF, this acts as a RETURN.";
184 OP_ENDIF => 0x68, "Pop and execute the next statements if a zero element was popped.";
185 OP_VERIFY => 0x69, "If the top value is zero or the stack is empty, fail; otherwise, pop the stack.";
186 OP_RETURN => 0x6a, "Fail the script immediately. (Must be executed.).";
187 OP_TOALTSTACK => 0x6b, "Pop one element from the main stack onto the alt stack.";
188 OP_FROMALTSTACK => 0x6c, "Pop one element from the alt stack onto the main stack.";
189 OP_2DROP => 0x6d, "Drops the top two stack items.";
190 OP_2DUP => 0x6e, "Duplicates the top two stack items as AB -> ABAB.";
191 OP_3DUP => 0x6f, "Duplicates the two three stack items as ABC -> ABCABC.";
192 OP_2OVER => 0x70, "Copies the two stack items of items two spaces back to the front, as xxAB -> ABxxAB.";
193 OP_2ROT => 0x71, "Moves the two stack items four spaces back to the front, as xxxxAB -> ABxxxx.";
194 OP_2SWAP => 0x72, "Swaps the top two pairs, as ABCD -> CDAB.";
195 OP_IFDUP => 0x73, "Duplicate the top stack element unless it is zero.";
196 OP_DEPTH => 0x74, "Push the current number of stack items onto the stack.";
197 OP_DROP => 0x75, "Drops the top stack item.";
198 OP_DUP => 0x76, "Duplicates the top stack item.";
199 OP_NIP => 0x77, "Drops the second-to-top stack item.";
200 OP_OVER => 0x78, "Copies the second-to-top stack item, as xA -> AxA.";
201 OP_PICK => 0x79, "Pop the top stack element as N. Copy the Nth stack element to the top.";
202 OP_ROLL => 0x7a, "Pop the top stack element as N. Move the Nth stack element to the top.";
203 OP_ROT => 0x7b, "Rotate the top three stack items, as [top next1 next2] -> [next2 top next1].";
204 OP_SWAP => 0x7c, "Swap the top two stack items.";
205 OP_TUCK => 0x7d, "Copy the top stack item to before the second item, as [top next] -> [top next top].";
206 OP_CAT => 0x7e, "Fail the script unconditionally, does not even need to be executed.";
207 OP_SUBSTR => 0x7f, "Fail the script unconditionally, does not even need to be executed.";
208 OP_LEFT => 0x80, "Fail the script unconditionally, does not even need to be executed.";
209 OP_RIGHT => 0x81, "Fail the script unconditionally, does not even need to be executed.";
210 OP_SIZE => 0x82, "Pushes the length of the top stack item onto the stack.";
211 OP_INVERT => 0x83, "Fail the script unconditionally, does not even need to be executed.";
212 OP_AND => 0x84, "Fail the script unconditionally, does not even need to be executed.";
213 OP_OR => 0x85, "Fail the script unconditionally, does not even need to be executed.";
214 OP_XOR => 0x86, "Fail the script unconditionally, does not even need to be executed.";
215 OP_EQUAL => 0x87, "Pushes 1 if the inputs are exactly equal, 0 otherwise.";
216 OP_EQUALVERIFY => 0x88, "Returns success if the inputs are exactly equal, failure otherwise.";
217 OP_RESERVED1 => 0x89, "Synonym for OP_RETURN.";
218 OP_RESERVED2 => 0x8a, "Synonym for OP_RETURN.";
219 OP_1ADD => 0x8b, "Increment the top stack element in place.";
220 OP_1SUB => 0x8c, "Decrement the top stack element in place.";
221 OP_2MUL => 0x8d, "Fail the script unconditionally, does not even need to be executed.";
222 OP_2DIV => 0x8e, "Fail the script unconditionally, does not even need to be executed.";
223 OP_NEGATE => 0x8f, "Multiply the top stack item by -1 in place.";
224 OP_ABS => 0x90, "Absolute value the top stack item in place.";
225 OP_NOT => 0x91, "Map 0 to 1 and everything else to 0, in place.";
226 OP_0NOTEQUAL => 0x92, "Map 0 to 0 and everything else to 1, in place.";
227 OP_ADD => 0x93, "Pop two stack items and push their sum.";
228 OP_SUB => 0x94, "Pop two stack items and push the second minus the top.";
229 OP_MUL => 0x95, "Fail the script unconditionally, does not even need to be executed.";
230 OP_DIV => 0x96, "Fail the script unconditionally, does not even need to be executed.";
231 OP_MOD => 0x97, "Fail the script unconditionally, does not even need to be executed.";
232 OP_LSHIFT => 0x98, "Fail the script unconditionally, does not even need to be executed.";
233 OP_RSHIFT => 0x99, "Fail the script unconditionally, does not even need to be executed.";
234 OP_BOOLAND => 0x9a, "Pop the top two stack items and push 1 if both are nonzero, else push 0.";
235 OP_BOOLOR => 0x9b, "Pop the top two stack items and push 1 if either is nonzero, else push 0.";
236 OP_NUMEQUAL => 0x9c, "Pop the top two stack items and push 1 if both are numerically equal, else push 0.";
237 OP_NUMEQUALVERIFY => 0x9d, "Pop the top two stack items and return success if both are numerically equal, else return failure.";
238 OP_NUMNOTEQUAL => 0x9e, "Pop the top two stack items and push 0 if both are numerically equal, else push 1.";
239 OP_LESSTHAN => 0x9f, "Pop the top two items; push 1 if the second is less than the top, 0 otherwise.";
240 OP_GREATERTHAN => 0xa0, "Pop the top two items; push 1 if the second is greater than the top, 0 otherwise.";
241 OP_LESSTHANOREQUAL => 0xa1, "Pop the top two items; push 1 if the second is <= the top, 0 otherwise.";
242 OP_GREATERTHANOREQUAL => 0xa2, "Pop the top two items; push 1 if the second is >= the top, 0 otherwise.";
243 OP_MIN => 0xa3, "Pop the top two items; push the smaller.";
244 OP_MAX => 0xa4, "Pop the top two items; push the larger.";
245 OP_WITHIN => 0xa5, "Pop the top three items; if the top is >= the second and < the third, push 1, otherwise push 0.";
246 OP_RIPEMD160 => 0xa6, "Pop the top stack item and push its RIPEMD160 hash.";
247 OP_SHA1 => 0xa7, "Pop the top stack item and push its SHA1 hash.";
248 OP_SHA256 => 0xa8, "Pop the top stack item and push its SHA256 hash.";
249 OP_HASH160 => 0xa9, "Pop the top stack item and push its RIPEMD(SHA256) hash.";
250 OP_HASH256 => 0xaa, "Pop the top stack item and push its SHA256(SHA256) hash.";
251 OP_CODESEPARATOR => 0xab, "Ignore this and everything preceding when deciding what to sign when signature-checking.";
252 OP_CHECKSIG => 0xac, "<https://en.bitcoin.it/wiki/OP_CHECKSIG> pushing 1/0 for success/failure.";
253 OP_CHECKSIGVERIFY => 0xad, "<https://en.bitcoin.it/wiki/OP_CHECKSIG> returning success/failure.";
254 OP_CHECKMULTISIG => 0xae, "Pop N, N pubkeys, M, M signatures, a dummy (due to bug in reference code), \
255 and verify that all M signatures are valid. Push 1 for 'all valid', 0 otherwise.";
256 OP_CHECKMULTISIGVERIFY => 0xaf, "Like the above but return success/failure.";
257 OP_NOP1 => 0xb0, "Does nothing.";
258 OP_CLTV => 0xb1, "<https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki>";
259 OP_CSV => 0xb2, "<https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki>";
260 OP_NOP4 => 0xb3, "Does nothing.";
261 OP_NOP5 => 0xb4, "Does nothing.";
262 OP_NOP6 => 0xb5, "Does nothing.";
263 OP_NOP7 => 0xb6, "Does nothing.";
264 OP_NOP8 => 0xb7, "Does nothing.";
265 OP_NOP9 => 0xb8, "Does nothing.";
266 OP_NOP10 => 0xb9, "Does nothing.";
267 OP_CHECKSIGADD => 0xba, "OP_CHECKSIGADD post tapscript.";
269 OP_RETURN_187 => 0xbb, "Synonym for OP_RETURN.";
270 OP_RETURN_188 => 0xbc, "Synonym for OP_RETURN.";
271 OP_RETURN_189 => 0xbd, "Synonym for OP_RETURN.";
272 OP_RETURN_190 => 0xbe, "Synonym for OP_RETURN.";
273 OP_RETURN_191 => 0xbf, "Synonym for OP_RETURN.";
274 OP_RETURN_192 => 0xc0, "Synonym for OP_RETURN.";
275 OP_RETURN_193 => 0xc1, "Synonym for OP_RETURN.";
276 OP_RETURN_194 => 0xc2, "Synonym for OP_RETURN.";
277 OP_RETURN_195 => 0xc3, "Synonym for OP_RETURN.";
278 OP_RETURN_196 => 0xc4, "Synonym for OP_RETURN.";
279 OP_RETURN_197 => 0xc5, "Synonym for OP_RETURN.";
280 OP_RETURN_198 => 0xc6, "Synonym for OP_RETURN.";
281 OP_RETURN_199 => 0xc7, "Synonym for OP_RETURN.";
282 OP_RETURN_200 => 0xc8, "Synonym for OP_RETURN.";
283 OP_RETURN_201 => 0xc9, "Synonym for OP_RETURN.";
284 OP_RETURN_202 => 0xca, "Synonym for OP_RETURN.";
285 OP_RETURN_203 => 0xcb, "Synonym for OP_RETURN.";
286 OP_RETURN_204 => 0xcc, "Synonym for OP_RETURN.";
287 OP_RETURN_205 => 0xcd, "Synonym for OP_RETURN.";
288 OP_RETURN_206 => 0xce, "Synonym for OP_RETURN.";
289 OP_RETURN_207 => 0xcf, "Synonym for OP_RETURN.";
290 OP_RETURN_208 => 0xd0, "Synonym for OP_RETURN.";
291 OP_RETURN_209 => 0xd1, "Synonym for OP_RETURN.";
292 OP_RETURN_210 => 0xd2, "Synonym for OP_RETURN.";
293 OP_RETURN_211 => 0xd3, "Synonym for OP_RETURN.";
294 OP_RETURN_212 => 0xd4, "Synonym for OP_RETURN.";
295 OP_RETURN_213 => 0xd5, "Synonym for OP_RETURN.";
296 OP_RETURN_214 => 0xd6, "Synonym for OP_RETURN.";
297 OP_RETURN_215 => 0xd7, "Synonym for OP_RETURN.";
298 OP_RETURN_216 => 0xd8, "Synonym for OP_RETURN.";
299 OP_RETURN_217 => 0xd9, "Synonym for OP_RETURN.";
300 OP_RETURN_218 => 0xda, "Synonym for OP_RETURN.";
301 OP_RETURN_219 => 0xdb, "Synonym for OP_RETURN.";
302 OP_RETURN_220 => 0xdc, "Synonym for OP_RETURN.";
303 OP_RETURN_221 => 0xdd, "Synonym for OP_RETURN.";
304 OP_RETURN_222 => 0xde, "Synonym for OP_RETURN.";
305 OP_RETURN_223 => 0xdf, "Synonym for OP_RETURN.";
306 OP_RETURN_224 => 0xe0, "Synonym for OP_RETURN.";
307 OP_RETURN_225 => 0xe1, "Synonym for OP_RETURN.";
308 OP_RETURN_226 => 0xe2, "Synonym for OP_RETURN.";
309 OP_RETURN_227 => 0xe3, "Synonym for OP_RETURN.";
310 OP_RETURN_228 => 0xe4, "Synonym for OP_RETURN.";
311 OP_RETURN_229 => 0xe5, "Synonym for OP_RETURN.";
312 OP_RETURN_230 => 0xe6, "Synonym for OP_RETURN.";
313 OP_RETURN_231 => 0xe7, "Synonym for OP_RETURN.";
314 OP_RETURN_232 => 0xe8, "Synonym for OP_RETURN.";
315 OP_RETURN_233 => 0xe9, "Synonym for OP_RETURN.";
316 OP_RETURN_234 => 0xea, "Synonym for OP_RETURN.";
317 OP_RETURN_235 => 0xeb, "Synonym for OP_RETURN.";
318 OP_RETURN_236 => 0xec, "Synonym for OP_RETURN.";
319 OP_RETURN_237 => 0xed, "Synonym for OP_RETURN.";
320 OP_RETURN_238 => 0xee, "Synonym for OP_RETURN.";
321 OP_RETURN_239 => 0xef, "Synonym for OP_RETURN.";
322 OP_RETURN_240 => 0xf0, "Synonym for OP_RETURN.";
323 OP_RETURN_241 => 0xf1, "Synonym for OP_RETURN.";
324 OP_RETURN_242 => 0xf2, "Synonym for OP_RETURN.";
325 OP_RETURN_243 => 0xf3, "Synonym for OP_RETURN.";
326 OP_RETURN_244 => 0xf4, "Synonym for OP_RETURN.";
327 OP_RETURN_245 => 0xf5, "Synonym for OP_RETURN.";
328 OP_RETURN_246 => 0xf6, "Synonym for OP_RETURN.";
329 OP_RETURN_247 => 0xf7, "Synonym for OP_RETURN.";
330 OP_RETURN_248 => 0xf8, "Synonym for OP_RETURN.";
331 OP_RETURN_249 => 0xf9, "Synonym for OP_RETURN.";
332 OP_RETURN_250 => 0xfa, "Synonym for OP_RETURN.";
333 OP_RETURN_251 => 0xfb, "Synonym for OP_RETURN.";
334 OP_RETURN_252 => 0xfc, "Synonym for OP_RETURN.";
335 OP_RETURN_253 => 0xfd, "Synonym for OP_RETURN.";
336 OP_RETURN_254 => 0xfe, "Synonym for OP_RETURN.";
337 OP_INVALIDOPCODE => 0xff, "Synonym for OP_RETURN."
338}
339
340#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
345pub enum ClassifyContext {
346 TapScript,
348 Legacy,
350}
351
352impl Opcode {
353 #[inline]
355 pub fn classify(self, ctx: ClassifyContext) -> Class {
356 match (self, ctx) {
357 (OP_VERIF, _) | (OP_VERNOTIF, _) | (OP_INVALIDOPCODE, _) => Class::IllegalOp,
359
360 #[rustfmt::skip]
362 (OP_CAT, ctx) | (OP_SUBSTR, ctx)
363 | (OP_LEFT, ctx) | (OP_RIGHT, ctx)
364 | (OP_INVERT, ctx)
365 | (OP_AND, ctx) | (OP_OR, ctx) | (OP_XOR, ctx)
366 | (OP_2MUL, ctx) | (OP_2DIV, ctx)
367 | (OP_MUL, ctx) | (OP_DIV, ctx) | (OP_MOD, ctx)
368 | (OP_LSHIFT, ctx) | (OP_RSHIFT, ctx) if ctx == ClassifyContext::Legacy => Class::IllegalOp,
369
370 (op, ClassifyContext::TapScript)
372 if op.code == 80
373 || op.code == 98
374 || (op.code >= 126 && op.code <= 129)
375 || (op.code >= 131 && op.code <= 134)
376 || (op.code >= 137 && op.code <= 138)
377 || (op.code >= 141 && op.code <= 142)
378 || (op.code >= 149 && op.code <= 153)
379 || (op.code >= 187 && op.code <= 254) =>
380 Class::SuccessOp,
381
382 (OP_NOP, _) => Class::NoOp,
384 (op, _) if op.code >= OP_NOP1.code && op.code <= OP_NOP10.code => Class::NoOp,
385
386 (OP_RETURN, _) => Class::ReturnOp,
388
389 (OP_RESERVED, ctx) | (OP_RESERVED1, ctx) | (OP_RESERVED2, ctx) | (OP_VER, ctx)
391 if ctx == ClassifyContext::Legacy =>
392 Class::ReturnOp,
393
394 (op, ClassifyContext::Legacy) if op.code >= OP_CHECKSIGADD.code => Class::ReturnOp,
396
397 (OP_CHECKMULTISIG, ClassifyContext::TapScript)
399 | (OP_CHECKMULTISIGVERIFY, ClassifyContext::TapScript) => Class::ReturnOp,
400
401 (OP_PUSHNUM_NEG1, _) => Class::PushNum(-1),
403
404 (op, _) if op.code >= OP_PUSHNUM_1.code && op.code <= OP_PUSHNUM_16.code =>
406 Class::PushNum(1 + self.code as i32 - OP_PUSHNUM_1.code as i32),
407
408 (op, _) if op.code <= OP_PUSHBYTES_75.code => Class::PushBytes(self.code as u32),
410
411 (_, _) => Class::Ordinary(Ordinary::with(self)),
413 }
414 }
415
416 #[inline]
418 pub const fn to_u8(self) -> u8 { self.code }
419
420 #[inline]
428 pub(crate) const fn decode_pushnum(self) -> Option<u8> {
429 const START: u8 = OP_PUSHNUM_1.code;
430 const END: u8 = OP_PUSHNUM_16.code;
431 match self.code {
432 START..=END => Some(self.code - START + 1),
433 _ => None,
434 }
435 }
436}
437
438impl From<u8> for Opcode {
439 #[inline]
440 fn from(b: u8) -> Opcode { Opcode { code: b } }
441}
442
443debug_from_display!(Opcode);
444
445#[cfg(feature = "serde")]
446impl serde::Serialize for Opcode {
447 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
448 where
449 S: serde::Serializer,
450 {
451 serializer.serialize_str(&self.to_string())
452 }
453}
454
455#[derive(Copy, Clone, PartialEq, Eq, Debug)]
457pub enum Class {
458 PushNum(i32),
460 PushBytes(u32),
462 ReturnOp,
464 SuccessOp,
466 IllegalOp,
468 NoOp,
470 Ordinary(Ordinary),
472}
473
474macro_rules! ordinary_opcode {
475 ($($op:ident),*) => (
476 #[repr(u8)]
477 #[doc(hidden)]
478 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
479 pub enum Ordinary {
480 $( $op = $op.code ),*
481 }
482
483 impl fmt::Display for Ordinary {
484 fn fmt(&self, f: &mut fmt::Formatter) -> core::fmt::Result {
485 match *self {
486 $(Ordinary::$op => { f.pad(stringify!($op)) }),*
487 }
488 }
489 }
490
491 impl Ordinary {
492 fn with(b: Opcode) -> Self {
493 match b {
494 $( $op => { Ordinary::$op } ),*
495 _ => unreachable!("construction of `Ordinary` type from non-ordinary opcode {}", b),
496 }
497 }
498
499 pub fn from_opcode(b: Opcode) -> Option<Self> {
501 match b {
502 $( $op => { Some(Ordinary::$op) } ),*
503 _ => None,
504 }
505 }
506 }
507 );
508}
509
510ordinary_opcode! {
512 OP_PUSHDATA1, OP_PUSHDATA2, OP_PUSHDATA4,
514 OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF, OP_VERIFY,
516 OP_TOALTSTACK, OP_FROMALTSTACK,
518 OP_2DROP, OP_2DUP, OP_3DUP, OP_2OVER, OP_2ROT, OP_2SWAP,
519 OP_DROP, OP_DUP, OP_NIP, OP_OVER, OP_PICK, OP_ROLL, OP_ROT, OP_SWAP, OP_TUCK,
520 OP_IFDUP, OP_DEPTH, OP_SIZE,
521 OP_EQUAL, OP_EQUALVERIFY,
523 OP_1ADD, OP_1SUB, OP_NEGATE, OP_ABS, OP_NOT, OP_0NOTEQUAL,
525 OP_ADD, OP_SUB, OP_BOOLAND, OP_BOOLOR,
526 OP_NUMEQUAL, OP_NUMEQUALVERIFY, OP_NUMNOTEQUAL, OP_LESSTHAN,
527 OP_GREATERTHAN, OP_LESSTHANOREQUAL, OP_GREATERTHANOREQUAL,
528 OP_MIN, OP_MAX, OP_WITHIN,
529 OP_RIPEMD160, OP_SHA1, OP_SHA256, OP_HASH160, OP_HASH256,
531 OP_CODESEPARATOR, OP_CHECKSIG, OP_CHECKSIGVERIFY,
532 OP_CHECKMULTISIG, OP_CHECKMULTISIGVERIFY,
533 OP_CHECKSIGADD
534}
535
536impl Ordinary {
537 #[inline]
539 pub fn to_u8(self) -> u8 { self as u8 }
540}
541
542#[cfg(test)]
543mod tests {
544 use std::collections::HashSet;
545
546 use super::*;
547
548 macro_rules! roundtrip {
549 ($unique:expr, $op:ident) => {
550 assert_eq!($op, Opcode::from($op.to_u8()));
551
552 let s1 = format!("{}", $op);
553 let s2 = format!("{:?}", $op);
554 assert_eq!(s1, s2);
555 assert_eq!(s1, stringify!($op));
556 assert!($unique.insert(s1));
557 };
558 }
559
560 #[test]
561 fn formatting_works() {
562 let op = all::OP_NOP;
563 let s = format!("{:>10}", op);
564 assert_eq!(s, " OP_NOP");
565 }
566
567 #[test]
568 fn decode_pushnum() {
569 assert_eq!(OP_PUSHNUM_1.code, 0x51_u8);
572 assert_eq!(OP_PUSHNUM_16.code, 0x60_u8);
573 for i in 0x00..=0xff_u8 {
574 let expected = match i {
575 0x51..=0x60 => Some(i - 0x50),
577 _ => None,
578 };
579 assert_eq!(Opcode::from(i).decode_pushnum(), expected);
580 }
581
582 assert!(OP_RESERVED.decode_pushnum().is_none());
585 assert_eq!(OP_PUSHNUM_1.decode_pushnum().expect("pushnum"), 1);
586 assert_eq!(OP_PUSHNUM_2.decode_pushnum().expect("pushnum"), 2);
587 assert_eq!(OP_PUSHNUM_3.decode_pushnum().expect("pushnum"), 3);
588 assert_eq!(OP_PUSHNUM_4.decode_pushnum().expect("pushnum"), 4);
589 assert_eq!(OP_PUSHNUM_5.decode_pushnum().expect("pushnum"), 5);
590 assert_eq!(OP_PUSHNUM_6.decode_pushnum().expect("pushnum"), 6);
591 assert_eq!(OP_PUSHNUM_7.decode_pushnum().expect("pushnum"), 7);
592 assert_eq!(OP_PUSHNUM_8.decode_pushnum().expect("pushnum"), 8);
593 assert_eq!(OP_PUSHNUM_9.decode_pushnum().expect("pushnum"), 9);
594 assert_eq!(OP_PUSHNUM_10.decode_pushnum().expect("pushnum"), 10);
595 assert_eq!(OP_PUSHNUM_11.decode_pushnum().expect("pushnum"), 11);
596 assert_eq!(OP_PUSHNUM_12.decode_pushnum().expect("pushnum"), 12);
597 assert_eq!(OP_PUSHNUM_13.decode_pushnum().expect("pushnum"), 13);
598 assert_eq!(OP_PUSHNUM_14.decode_pushnum().expect("pushnum"), 14);
599 assert_eq!(OP_PUSHNUM_15.decode_pushnum().expect("pushnum"), 15);
600 assert_eq!(OP_PUSHNUM_16.decode_pushnum().expect("pushnum"), 16);
601 assert!(OP_NOP.decode_pushnum().is_none());
603 }
604
605 #[test]
606 fn classify_test() {
607 let op174 = OP_CHECKMULTISIG;
608 assert_eq!(
609 op174.classify(ClassifyContext::Legacy),
610 Class::Ordinary(Ordinary::OP_CHECKMULTISIG)
611 );
612 assert_eq!(op174.classify(ClassifyContext::TapScript), Class::ReturnOp);
613
614 let op175 = OP_CHECKMULTISIGVERIFY;
615 assert_eq!(
616 op175.classify(ClassifyContext::Legacy),
617 Class::Ordinary(Ordinary::OP_CHECKMULTISIGVERIFY)
618 );
619 assert_eq!(op175.classify(ClassifyContext::TapScript), Class::ReturnOp);
620
621 let op186 = OP_CHECKSIGADD;
622 assert_eq!(op186.classify(ClassifyContext::Legacy), Class::ReturnOp);
623 assert_eq!(
624 op186.classify(ClassifyContext::TapScript),
625 Class::Ordinary(Ordinary::OP_CHECKSIGADD)
626 );
627
628 let op187 = OP_RETURN_187;
629 assert_eq!(op187.classify(ClassifyContext::Legacy), Class::ReturnOp);
630 assert_eq!(op187.classify(ClassifyContext::TapScript), Class::SuccessOp);
631 }
632
633 #[test]
634 fn str_roundtrip() {
635 let mut unique = HashSet::new();
636 roundtrip!(unique, OP_PUSHBYTES_0);
637 roundtrip!(unique, OP_PUSHBYTES_1);
638 roundtrip!(unique, OP_PUSHBYTES_2);
639 roundtrip!(unique, OP_PUSHBYTES_3);
640 roundtrip!(unique, OP_PUSHBYTES_4);
641 roundtrip!(unique, OP_PUSHBYTES_5);
642 roundtrip!(unique, OP_PUSHBYTES_6);
643 roundtrip!(unique, OP_PUSHBYTES_7);
644 roundtrip!(unique, OP_PUSHBYTES_8);
645 roundtrip!(unique, OP_PUSHBYTES_9);
646 roundtrip!(unique, OP_PUSHBYTES_10);
647 roundtrip!(unique, OP_PUSHBYTES_11);
648 roundtrip!(unique, OP_PUSHBYTES_12);
649 roundtrip!(unique, OP_PUSHBYTES_13);
650 roundtrip!(unique, OP_PUSHBYTES_14);
651 roundtrip!(unique, OP_PUSHBYTES_15);
652 roundtrip!(unique, OP_PUSHBYTES_16);
653 roundtrip!(unique, OP_PUSHBYTES_17);
654 roundtrip!(unique, OP_PUSHBYTES_18);
655 roundtrip!(unique, OP_PUSHBYTES_19);
656 roundtrip!(unique, OP_PUSHBYTES_20);
657 roundtrip!(unique, OP_PUSHBYTES_21);
658 roundtrip!(unique, OP_PUSHBYTES_22);
659 roundtrip!(unique, OP_PUSHBYTES_23);
660 roundtrip!(unique, OP_PUSHBYTES_24);
661 roundtrip!(unique, OP_PUSHBYTES_25);
662 roundtrip!(unique, OP_PUSHBYTES_26);
663 roundtrip!(unique, OP_PUSHBYTES_27);
664 roundtrip!(unique, OP_PUSHBYTES_28);
665 roundtrip!(unique, OP_PUSHBYTES_29);
666 roundtrip!(unique, OP_PUSHBYTES_30);
667 roundtrip!(unique, OP_PUSHBYTES_31);
668 roundtrip!(unique, OP_PUSHBYTES_32);
669 roundtrip!(unique, OP_PUSHBYTES_33);
670 roundtrip!(unique, OP_PUSHBYTES_34);
671 roundtrip!(unique, OP_PUSHBYTES_35);
672 roundtrip!(unique, OP_PUSHBYTES_36);
673 roundtrip!(unique, OP_PUSHBYTES_37);
674 roundtrip!(unique, OP_PUSHBYTES_38);
675 roundtrip!(unique, OP_PUSHBYTES_39);
676 roundtrip!(unique, OP_PUSHBYTES_40);
677 roundtrip!(unique, OP_PUSHBYTES_41);
678 roundtrip!(unique, OP_PUSHBYTES_42);
679 roundtrip!(unique, OP_PUSHBYTES_43);
680 roundtrip!(unique, OP_PUSHBYTES_44);
681 roundtrip!(unique, OP_PUSHBYTES_45);
682 roundtrip!(unique, OP_PUSHBYTES_46);
683 roundtrip!(unique, OP_PUSHBYTES_47);
684 roundtrip!(unique, OP_PUSHBYTES_48);
685 roundtrip!(unique, OP_PUSHBYTES_49);
686 roundtrip!(unique, OP_PUSHBYTES_50);
687 roundtrip!(unique, OP_PUSHBYTES_51);
688 roundtrip!(unique, OP_PUSHBYTES_52);
689 roundtrip!(unique, OP_PUSHBYTES_53);
690 roundtrip!(unique, OP_PUSHBYTES_54);
691 roundtrip!(unique, OP_PUSHBYTES_55);
692 roundtrip!(unique, OP_PUSHBYTES_56);
693 roundtrip!(unique, OP_PUSHBYTES_57);
694 roundtrip!(unique, OP_PUSHBYTES_58);
695 roundtrip!(unique, OP_PUSHBYTES_59);
696 roundtrip!(unique, OP_PUSHBYTES_60);
697 roundtrip!(unique, OP_PUSHBYTES_61);
698 roundtrip!(unique, OP_PUSHBYTES_62);
699 roundtrip!(unique, OP_PUSHBYTES_63);
700 roundtrip!(unique, OP_PUSHBYTES_64);
701 roundtrip!(unique, OP_PUSHBYTES_65);
702 roundtrip!(unique, OP_PUSHBYTES_66);
703 roundtrip!(unique, OP_PUSHBYTES_67);
704 roundtrip!(unique, OP_PUSHBYTES_68);
705 roundtrip!(unique, OP_PUSHBYTES_69);
706 roundtrip!(unique, OP_PUSHBYTES_70);
707 roundtrip!(unique, OP_PUSHBYTES_71);
708 roundtrip!(unique, OP_PUSHBYTES_72);
709 roundtrip!(unique, OP_PUSHBYTES_73);
710 roundtrip!(unique, OP_PUSHBYTES_74);
711 roundtrip!(unique, OP_PUSHBYTES_75);
712 roundtrip!(unique, OP_PUSHDATA1);
713 roundtrip!(unique, OP_PUSHDATA2);
714 roundtrip!(unique, OP_PUSHDATA4);
715 roundtrip!(unique, OP_PUSHNUM_NEG1);
716 roundtrip!(unique, OP_RESERVED);
717 roundtrip!(unique, OP_PUSHNUM_1);
718 roundtrip!(unique, OP_PUSHNUM_2);
719 roundtrip!(unique, OP_PUSHNUM_3);
720 roundtrip!(unique, OP_PUSHNUM_4);
721 roundtrip!(unique, OP_PUSHNUM_5);
722 roundtrip!(unique, OP_PUSHNUM_6);
723 roundtrip!(unique, OP_PUSHNUM_7);
724 roundtrip!(unique, OP_PUSHNUM_8);
725 roundtrip!(unique, OP_PUSHNUM_9);
726 roundtrip!(unique, OP_PUSHNUM_10);
727 roundtrip!(unique, OP_PUSHNUM_11);
728 roundtrip!(unique, OP_PUSHNUM_12);
729 roundtrip!(unique, OP_PUSHNUM_13);
730 roundtrip!(unique, OP_PUSHNUM_14);
731 roundtrip!(unique, OP_PUSHNUM_15);
732 roundtrip!(unique, OP_PUSHNUM_16);
733 roundtrip!(unique, OP_NOP);
734 roundtrip!(unique, OP_VER);
735 roundtrip!(unique, OP_IF);
736 roundtrip!(unique, OP_NOTIF);
737 roundtrip!(unique, OP_VERIF);
738 roundtrip!(unique, OP_VERNOTIF);
739 roundtrip!(unique, OP_ELSE);
740 roundtrip!(unique, OP_ENDIF);
741 roundtrip!(unique, OP_VERIFY);
742 roundtrip!(unique, OP_RETURN);
743 roundtrip!(unique, OP_TOALTSTACK);
744 roundtrip!(unique, OP_FROMALTSTACK);
745 roundtrip!(unique, OP_2DROP);
746 roundtrip!(unique, OP_2DUP);
747 roundtrip!(unique, OP_3DUP);
748 roundtrip!(unique, OP_2OVER);
749 roundtrip!(unique, OP_2ROT);
750 roundtrip!(unique, OP_2SWAP);
751 roundtrip!(unique, OP_IFDUP);
752 roundtrip!(unique, OP_DEPTH);
753 roundtrip!(unique, OP_DROP);
754 roundtrip!(unique, OP_DUP);
755 roundtrip!(unique, OP_NIP);
756 roundtrip!(unique, OP_OVER);
757 roundtrip!(unique, OP_PICK);
758 roundtrip!(unique, OP_ROLL);
759 roundtrip!(unique, OP_ROT);
760 roundtrip!(unique, OP_SWAP);
761 roundtrip!(unique, OP_TUCK);
762 roundtrip!(unique, OP_CAT);
763 roundtrip!(unique, OP_SUBSTR);
764 roundtrip!(unique, OP_LEFT);
765 roundtrip!(unique, OP_RIGHT);
766 roundtrip!(unique, OP_SIZE);
767 roundtrip!(unique, OP_INVERT);
768 roundtrip!(unique, OP_AND);
769 roundtrip!(unique, OP_OR);
770 roundtrip!(unique, OP_XOR);
771 roundtrip!(unique, OP_EQUAL);
772 roundtrip!(unique, OP_EQUALVERIFY);
773 roundtrip!(unique, OP_RESERVED1);
774 roundtrip!(unique, OP_RESERVED2);
775 roundtrip!(unique, OP_1ADD);
776 roundtrip!(unique, OP_1SUB);
777 roundtrip!(unique, OP_2MUL);
778 roundtrip!(unique, OP_2DIV);
779 roundtrip!(unique, OP_NEGATE);
780 roundtrip!(unique, OP_ABS);
781 roundtrip!(unique, OP_NOT);
782 roundtrip!(unique, OP_0NOTEQUAL);
783 roundtrip!(unique, OP_ADD);
784 roundtrip!(unique, OP_SUB);
785 roundtrip!(unique, OP_MUL);
786 roundtrip!(unique, OP_DIV);
787 roundtrip!(unique, OP_MOD);
788 roundtrip!(unique, OP_LSHIFT);
789 roundtrip!(unique, OP_RSHIFT);
790 roundtrip!(unique, OP_BOOLAND);
791 roundtrip!(unique, OP_BOOLOR);
792 roundtrip!(unique, OP_NUMEQUAL);
793 roundtrip!(unique, OP_NUMEQUALVERIFY);
794 roundtrip!(unique, OP_NUMNOTEQUAL);
795 roundtrip!(unique, OP_LESSTHAN);
796 roundtrip!(unique, OP_GREATERTHAN);
797 roundtrip!(unique, OP_LESSTHANOREQUAL);
798 roundtrip!(unique, OP_GREATERTHANOREQUAL);
799 roundtrip!(unique, OP_MIN);
800 roundtrip!(unique, OP_MAX);
801 roundtrip!(unique, OP_WITHIN);
802 roundtrip!(unique, OP_RIPEMD160);
803 roundtrip!(unique, OP_SHA1);
804 roundtrip!(unique, OP_SHA256);
805 roundtrip!(unique, OP_HASH160);
806 roundtrip!(unique, OP_HASH256);
807 roundtrip!(unique, OP_CODESEPARATOR);
808 roundtrip!(unique, OP_CHECKSIG);
809 roundtrip!(unique, OP_CHECKSIGVERIFY);
810 roundtrip!(unique, OP_CHECKMULTISIG);
811 roundtrip!(unique, OP_CHECKMULTISIGVERIFY);
812 roundtrip!(unique, OP_NOP1);
813 roundtrip!(unique, OP_CLTV);
814 roundtrip!(unique, OP_CSV);
815 roundtrip!(unique, OP_NOP4);
816 roundtrip!(unique, OP_NOP5);
817 roundtrip!(unique, OP_NOP6);
818 roundtrip!(unique, OP_NOP7);
819 roundtrip!(unique, OP_NOP8);
820 roundtrip!(unique, OP_NOP9);
821 roundtrip!(unique, OP_NOP10);
822 roundtrip!(unique, OP_CHECKSIGADD);
823 roundtrip!(unique, OP_RETURN_187);
824 roundtrip!(unique, OP_RETURN_188);
825 roundtrip!(unique, OP_RETURN_189);
826 roundtrip!(unique, OP_RETURN_190);
827 roundtrip!(unique, OP_RETURN_191);
828 roundtrip!(unique, OP_RETURN_192);
829 roundtrip!(unique, OP_RETURN_193);
830 roundtrip!(unique, OP_RETURN_194);
831 roundtrip!(unique, OP_RETURN_195);
832 roundtrip!(unique, OP_RETURN_196);
833 roundtrip!(unique, OP_RETURN_197);
834 roundtrip!(unique, OP_RETURN_198);
835 roundtrip!(unique, OP_RETURN_199);
836 roundtrip!(unique, OP_RETURN_200);
837 roundtrip!(unique, OP_RETURN_201);
838 roundtrip!(unique, OP_RETURN_202);
839 roundtrip!(unique, OP_RETURN_203);
840 roundtrip!(unique, OP_RETURN_204);
841 roundtrip!(unique, OP_RETURN_205);
842 roundtrip!(unique, OP_RETURN_206);
843 roundtrip!(unique, OP_RETURN_207);
844 roundtrip!(unique, OP_RETURN_208);
845 roundtrip!(unique, OP_RETURN_209);
846 roundtrip!(unique, OP_RETURN_210);
847 roundtrip!(unique, OP_RETURN_211);
848 roundtrip!(unique, OP_RETURN_212);
849 roundtrip!(unique, OP_RETURN_213);
850 roundtrip!(unique, OP_RETURN_214);
851 roundtrip!(unique, OP_RETURN_215);
852 roundtrip!(unique, OP_RETURN_216);
853 roundtrip!(unique, OP_RETURN_217);
854 roundtrip!(unique, OP_RETURN_218);
855 roundtrip!(unique, OP_RETURN_219);
856 roundtrip!(unique, OP_RETURN_220);
857 roundtrip!(unique, OP_RETURN_221);
858 roundtrip!(unique, OP_RETURN_222);
859 roundtrip!(unique, OP_RETURN_223);
860 roundtrip!(unique, OP_RETURN_224);
861 roundtrip!(unique, OP_RETURN_225);
862 roundtrip!(unique, OP_RETURN_226);
863 roundtrip!(unique, OP_RETURN_227);
864 roundtrip!(unique, OP_RETURN_228);
865 roundtrip!(unique, OP_RETURN_229);
866 roundtrip!(unique, OP_RETURN_230);
867 roundtrip!(unique, OP_RETURN_231);
868 roundtrip!(unique, OP_RETURN_232);
869 roundtrip!(unique, OP_RETURN_233);
870 roundtrip!(unique, OP_RETURN_234);
871 roundtrip!(unique, OP_RETURN_235);
872 roundtrip!(unique, OP_RETURN_236);
873 roundtrip!(unique, OP_RETURN_237);
874 roundtrip!(unique, OP_RETURN_238);
875 roundtrip!(unique, OP_RETURN_239);
876 roundtrip!(unique, OP_RETURN_240);
877 roundtrip!(unique, OP_RETURN_241);
878 roundtrip!(unique, OP_RETURN_242);
879 roundtrip!(unique, OP_RETURN_243);
880 roundtrip!(unique, OP_RETURN_244);
881 roundtrip!(unique, OP_RETURN_245);
882 roundtrip!(unique, OP_RETURN_246);
883 roundtrip!(unique, OP_RETURN_247);
884 roundtrip!(unique, OP_RETURN_248);
885 roundtrip!(unique, OP_RETURN_249);
886 roundtrip!(unique, OP_RETURN_250);
887 roundtrip!(unique, OP_RETURN_251);
888 roundtrip!(unique, OP_RETURN_252);
889 roundtrip!(unique, OP_RETURN_253);
890 roundtrip!(unique, OP_RETURN_254);
891 roundtrip!(unique, OP_INVALIDOPCODE);
892 assert_eq!(unique.len(), 256);
893 }
894}