bc/opcodes.rs
1// Bitcoin protocol consensus library.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Written in 2019-2024 by
6// Dr Maxim Orlovsky <orlovsky@lnp-bp.org>
7//
8// Copyright (C) 2019-2024 LNP/BP Standards Association. All rights reserved.
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21
22use crate::LIB_NAME_BITCOIN;
23
24/// Push an empty array onto the stack.
25pub const OP_PUSHBYTES_0: u8 = 0x00;
26/// Push the next byte as an array onto the stack.
27pub const OP_PUSHBYTES_1: u8 = 0x01;
28/// Push the next 2 bytes as an array onto the stack.
29pub const OP_PUSHBYTES_2: u8 = 0x02;
30/// Push the next 3 bytes as an array onto the stack.
31pub const OP_PUSHBYTES_3: u8 = 0x03;
32/// Push the next 4 bytes as an array onto the stack.
33pub const OP_PUSHBYTES_4: u8 = 0x04;
34/// Push the next 5 bytes as an array onto the stack.
35pub const OP_PUSHBYTES_5: u8 = 0x05;
36/// Push the next 6 bytes as an array onto the stack.
37pub const OP_PUSHBYTES_6: u8 = 0x06;
38/// Push the next 7 bytes as an array onto the stack.
39pub const OP_PUSHBYTES_7: u8 = 0x07;
40/// Push the next 8 bytes as an array onto the stack.
41pub const OP_PUSHBYTES_8: u8 = 0x08;
42/// Push the next 9 bytes as an array onto the stack.
43pub const OP_PUSHBYTES_9: u8 = 0x09;
44/// Push the next 10 bytes as an array onto the stack.
45pub const OP_PUSHBYTES_10: u8 = 0x0a;
46/// Push the next 11 bytes as an array onto the stack.
47pub const OP_PUSHBYTES_11: u8 = 0x0b;
48/// Push the next 12 bytes as an array onto the stack.
49pub const OP_PUSHBYTES_12: u8 = 0x0c;
50/// Push the next 13 bytes as an array onto the stack.
51pub const OP_PUSHBYTES_13: u8 = 0x0d;
52/// Push the next 14 bytes as an array onto the stack.
53pub const OP_PUSHBYTES_14: u8 = 0x0e;
54/// Push the next 15 bytes as an array onto the stack.
55pub const OP_PUSHBYTES_15: u8 = 0x0f;
56/// Push the next 16 bytes as an array onto the stack.
57pub const OP_PUSHBYTES_16: u8 = 0x10;
58/// Push the next 17 bytes as an array onto the stack.
59pub const OP_PUSHBYTES_17: u8 = 0x11;
60/// Push the next 18 bytes as an array onto the stack.
61pub const OP_PUSHBYTES_18: u8 = 0x12;
62/// Push the next 19 bytes as an array onto the stack.
63pub const OP_PUSHBYTES_19: u8 = 0x13;
64/// Push the next 20 bytes as an array onto the stack.
65pub const OP_PUSHBYTES_20: u8 = 0x14;
66/// Push the next 21 bytes as an array onto the stack.
67pub const OP_PUSHBYTES_21: u8 = 0x15;
68/// Push the next 22 bytes as an array onto the stack.
69pub const OP_PUSHBYTES_22: u8 = 0x16;
70/// Push the next 23 bytes as an array onto the stack.
71pub const OP_PUSHBYTES_23: u8 = 0x17;
72/// Push the next 24 bytes as an array onto the stack.
73pub const OP_PUSHBYTES_24: u8 = 0x18;
74/// Push the next 25 bytes as an array onto the stack.
75pub const OP_PUSHBYTES_25: u8 = 0x19;
76/// Push the next 26 bytes as an array onto the stack.
77pub const OP_PUSHBYTES_26: u8 = 0x1a;
78/// Push the next 27 bytes as an array onto the stack.
79pub const OP_PUSHBYTES_27: u8 = 0x1b;
80/// Push the next 28 bytes as an array onto the stack.
81pub const OP_PUSHBYTES_28: u8 = 0x1c;
82/// Push the next 29 bytes as an array onto the stack.
83pub const OP_PUSHBYTES_29: u8 = 0x1d;
84/// Push the next 30 bytes as an array onto the stack.
85pub const OP_PUSHBYTES_30: u8 = 0x1e;
86/// Push the next 31 bytes as an array onto the stack.
87pub const OP_PUSHBYTES_31: u8 = 0x1f;
88/// Push the next 32 bytes as an array onto the stack.
89pub const OP_PUSHBYTES_32: u8 = 0x20;
90/// Push the next 33 bytes as an array onto the stack.
91pub const OP_PUSHBYTES_33: u8 = 0x21;
92/// Push the next 34 bytes as an array onto the stack.
93pub const OP_PUSHBYTES_34: u8 = 0x22;
94/// Push the next 35 bytes as an array onto the stack.
95pub const OP_PUSHBYTES_35: u8 = 0x23;
96/// Push the next 36 bytes as an array onto the stack.
97pub const OP_PUSHBYTES_36: u8 = 0x24;
98/// Push the next 37 bytes as an array onto the stack.
99pub const OP_PUSHBYTES_37: u8 = 0x25;
100/// Push the next 38 bytes as an array onto the stack.
101pub const OP_PUSHBYTES_38: u8 = 0x26;
102/// Push the next 39 bytes as an array onto the stack.
103pub const OP_PUSHBYTES_39: u8 = 0x27;
104/// Push the next 40 bytes as an array onto the stack.
105pub const OP_PUSHBYTES_40: u8 = 0x28;
106/// Push the next 41 bytes as an array onto the stack.
107pub const OP_PUSHBYTES_41: u8 = 0x29;
108/// Push the next 42 bytes as an array onto the stack.
109pub const OP_PUSHBYTES_42: u8 = 0x2a;
110/// Push the next 43 bytes as an array onto the stack.
111pub const OP_PUSHBYTES_43: u8 = 0x2b;
112/// Push the next 44 bytes as an array onto the stack.
113pub const OP_PUSHBYTES_44: u8 = 0x2c;
114/// Push the next 45 bytes as an array onto the stack.
115pub const OP_PUSHBYTES_45: u8 = 0x2d;
116/// Push the next 46 bytes as an array onto the stack.
117pub const OP_PUSHBYTES_46: u8 = 0x2e;
118/// Push the next 47 bytes as an array onto the stack.
119pub const OP_PUSHBYTES_47: u8 = 0x2f;
120/// Push the next 48 bytes as an array onto the stack.
121pub const OP_PUSHBYTES_48: u8 = 0x30;
122/// Push the next 49 bytes as an array onto the stack.
123pub const OP_PUSHBYTES_49: u8 = 0x31;
124/// Push the next 50 bytes as an array onto the stack.
125pub const OP_PUSHBYTES_50: u8 = 0x32;
126/// Push the next 51 bytes as an array onto the stack.
127pub const OP_PUSHBYTES_51: u8 = 0x33;
128/// Push the next 52 bytes as an array onto the stack.
129pub const OP_PUSHBYTES_52: u8 = 0x34;
130/// Push the next 53 bytes as an array onto the stack.
131pub const OP_PUSHBYTES_53: u8 = 0x35;
132/// Push the next 54 bytes as an array onto the stack.
133pub const OP_PUSHBYTES_54: u8 = 0x36;
134/// Push the next 55 bytes as an array onto the stack.
135pub const OP_PUSHBYTES_55: u8 = 0x37;
136/// Push the next 56 bytes as an array onto the stack.
137pub const OP_PUSHBYTES_56: u8 = 0x38;
138/// Push the next 57 bytes as an array onto the stack.
139pub const OP_PUSHBYTES_57: u8 = 0x39;
140/// Push the next 58 bytes as an array onto the stack.
141pub const OP_PUSHBYTES_58: u8 = 0x3a;
142/// Push the next 59 bytes as an array onto the stack.
143pub const OP_PUSHBYTES_59: u8 = 0x3b;
144/// Push the next 60 bytes as an array onto the stack.
145pub const OP_PUSHBYTES_60: u8 = 0x3c;
146/// Push the next 61 bytes as an array onto the stack.
147pub const OP_PUSHBYTES_61: u8 = 0x3d;
148/// Push the next 62 bytes as an array onto the stack.
149pub const OP_PUSHBYTES_62: u8 = 0x3e;
150/// Push the next 63 bytes as an array onto the stack.
151pub const OP_PUSHBYTES_63: u8 = 0x3f;
152/// Push the next 64 bytes as an array onto the stack.
153pub const OP_PUSHBYTES_64: u8 = 0x40;
154/// Push the next 65 bytes as an array onto the stack.
155pub const OP_PUSHBYTES_65: u8 = 0x41;
156/// Push the next 66 bytes as an array onto the stack.
157pub const OP_PUSHBYTES_66: u8 = 0x42;
158/// Push the next 67 bytes as an array onto the stack.
159pub const OP_PUSHBYTES_67: u8 = 0x43;
160/// Push the next 68 bytes as an array onto the stack.
161pub const OP_PUSHBYTES_68: u8 = 0x44;
162/// Push the next 69 bytes as an array onto the stack.
163pub const OP_PUSHBYTES_69: u8 = 0x45;
164/// Push the next 70 bytes as an array onto the stack.
165pub const OP_PUSHBYTES_70: u8 = 0x46;
166/// Push the next 71 bytes as an array onto the stack.
167pub const OP_PUSHBYTES_71: u8 = 0x47;
168/// Push the next 72 bytes as an array onto the stack.
169pub const OP_PUSHBYTES_72: u8 = 0x48;
170/// Push the next 73 bytes as an array onto the stack.
171pub const OP_PUSHBYTES_73: u8 = 0x49;
172/// Push the next 74 bytes as an array onto the stack.
173pub const OP_PUSHBYTES_74: u8 = 0x4a;
174/// Push the next 75 bytes as an array onto the stack.
175pub const OP_PUSHBYTES_75: u8 = 0x4b;
176/// Read the next byte as N; push the next N bytes as an array onto the stack.
177pub const OP_PUSHDATA1: u8 = 0x4c;
178/// Read the next 2 bytes as N; push the next N bytes as an array onto the
179/// stack.
180pub const OP_PUSHDATA2: u8 = 0x4d;
181/// Read the next 4 bytes as N; push the next N bytes as an array onto the
182/// stack.
183pub const OP_PUSHDATA4: u8 = 0x4e;
184/// Push the array `0x81` onto the stack.
185pub const OP_PUSHNUM_NEG1: u8 = 0x4f;
186/// Synonym for OP_RETURN.
187pub const OP_RESERVED: u8 = 0x50;
188/// Push the array `0x01` onto the stack.
189pub const OP_PUSHNUM_1: u8 = 0x51;
190/// the array `0x02` onto the stack.
191pub const OP_PUSHNUM_2: u8 = 0x52;
192/// Push the array `0x03` onto the stack.
193pub const OP_PUSHNUM_3: u8 = 0x53;
194/// Push the array `0x04` onto the stack.
195pub const OP_PUSHNUM_4: u8 = 0x54;
196/// Push the array `0x05` onto the stack.
197pub const OP_PUSHNUM_5: u8 = 0x55;
198/// Push the array `0x06` onto the stack.
199pub const OP_PUSHNUM_6: u8 = 0x56;
200/// Push the array `0x07` onto the stack.
201pub const OP_PUSHNUM_7: u8 = 0x57;
202/// Push the array `0x08` onto the stack.
203pub const OP_PUSHNUM_8: u8 = 0x58;
204/// Push the array `0x09` onto the stack.
205pub const OP_PUSHNUM_9: u8 = 0x59;
206/// Push the array `0x0a` onto the stack.
207pub const OP_PUSHNUM_10: u8 = 0x5a;
208/// Push the array `0x0b` onto the stack.
209pub const OP_PUSHNUM_11: u8 = 0x5b;
210/// Push the array `0x0c` onto the stack.
211pub const OP_PUSHNUM_12: u8 = 0x5c;
212/// Push the array `0x0d` onto the stack.
213pub const OP_PUSHNUM_13: u8 = 0x5d;
214/// Push the array `0x0e` onto the stack.
215pub const OP_PUSHNUM_14: u8 = 0x5e;
216/// Push the array `0x0f` onto the stack.
217pub const OP_PUSHNUM_15: u8 = 0x5f;
218/// Push the array `0x10` onto the stack.
219pub const OP_PUSHNUM_16: u8 = 0x60;
220/// Does nothing.
221pub const OP_NOP: u8 = 0x61;
222/// Synonym for OP_RETURN.
223pub const OP_VER: u8 = 0x62;
224/// Pop and execute the next statements if a nonzero element was popped.
225pub const OP_IF: u8 = 0x63;
226/// Pop and execute the next statements if a zero element was popped.
227pub const OP_NOTIF: u8 = 0x64;
228/// Fail the script unconditionally, does not even need to be executed.
229pub const OP_VERIF: u8 = 0x65;
230/// Fail the script unconditionally, does not even need to be executed.
231pub const OP_VERNOTIF: u8 = 0x66;
232/// Execute statements if those after the previous OP_IF were not, and
233/// vice-versa. If there is no previous OP_IF, this acts as an OP_RETURN.
234pub const OP_ELSE: u8 = 0x67;
235/// Pop and execute the next statements if a zero element was popped.
236pub const OP_ENDIF: u8 = 0x68;
237/// If the top value is zero or the stack is empty, fail; otherwise, pop the
238/// stack.
239pub const OP_VERIFY: u8 = 0x69;
240/// Fail the script immediately. (Must be executed.).
241pub const OP_RETURN: u8 = 0x6a;
242/// Pop one element from the main stack onto the alt stack.
243pub const OP_TOALTSTACK: u8 = 0x6b;
244/// Pop one element from the alt stack onto the main stack.
245pub const OP_FROMALTSTACK: u8 = 0x6c;
246/// Drops the top two stack items.
247pub const OP_2DROP: u8 = 0x6d;
248/// Duplicates the top two stack items as AB -> ABAB.
249pub const OP_2DUP: u8 = 0x6e;
250/// Duplicates the two three stack items as ABC -> ABCABC.
251pub const OP_3DUP: u8 = 0x6f;
252/// Copies the two stack items of items two spaces back to the front, as xxAB ->
253/// ABxxAB.
254pub const OP_2OVER: u8 = 0x70;
255/// Moves the two stack items four spaces back to the front, as xxxxAB ->
256/// ABxxxx.
257pub const OP_2ROT: u8 = 0x71;
258/// Swaps the top two pairs, as ABCD -> CDAB.
259pub const OP_2SWAP: u8 = 0x72;
260/// Duplicate the top stack element unless it is zero.
261pub const OP_IFDUP: u8 = 0x73;
262/// Push the current number of stack items onto the stack.
263pub const OP_DEPTH: u8 = 0x74;
264/// Drops the top stack item.
265pub const OP_DROP: u8 = 0x75;
266/// Duplicates the top stack item.
267pub const OP_DUP: u8 = 0x76;
268/// Drops the second-to-top stack item.
269pub const OP_NIP: u8 = 0x77;
270/// Copies the second-to-top stack item, as xA -> AxA.
271pub const OP_OVER: u8 = 0x78;
272/// Pop the top stack element as N. Copy the Nth stack element to the top.
273pub const OP_PICK: u8 = 0x79;
274/// Pop the top stack element as N. Move the Nth stack element to the top.
275pub const OP_ROLL: u8 = 0x7a;
276/// Rotate the top three stack items, as [top next1 next2] -> [next2 top next1].
277pub const OP_ROT: u8 = 0x7b;
278/// Swap the top two stack items.
279pub const OP_SWAP: u8 = 0x7c;
280/// Copy the top stack item to before the second item, as [top next] -> [top
281/// next top].
282pub const OP_TUCK: u8 = 0x7d;
283/// Fail the script unconditionally, does not even need to be executed.
284pub const OP_CAT: u8 = 0x7e;
285/// Fail the script unconditionally, does not even need to be executed.
286pub const OP_SUBSTR: u8 = 0x7f;
287/// Fail the script unconditionally, does not even need to be executed.
288pub const OP_LEFT: u8 = 0x80;
289/// Fail the script unconditionally, does not even need to be executed.
290pub const OP_RIGHT: u8 = 0x81;
291/// Pushes the length of the top stack item onto the stack.
292pub const OP_SIZE: u8 = 0x82;
293/// Fail the script unconditionally, does not even need to be executed.
294pub const OP_INVERT: u8 = 0x83;
295/// Fail the script unconditionally, does not even need to be executed.
296pub const OP_AND: u8 = 0x84;
297/// Fail the script unconditionally, does not even need to be executed.
298pub const OP_OR: u8 = 0x85;
299/// Fail the script unconditionally, does not even need to be executed.
300pub const OP_XOR: u8 = 0x86;
301/// Pushes 1 if the inputs are exactly equal, 0 otherwise.
302pub const OP_EQUAL: u8 = 0x87;
303/// Returns success if the inputs are exactly equal, failure otherwise.
304pub const OP_EQUALVERIFY: u8 = 0x88;
305/// Synonym for OP_RETURN.
306pub const OP_RESERVED1: u8 = 0x89;
307/// Synonym for OP_RETURN.
308pub const OP_RESERVED2: u8 = 0x8a;
309/// Increment the top stack element in place.
310pub const OP_1ADD: u8 = 0x8b;
311/// Decrement the top stack element in place.
312pub const OP_1SUB: u8 = 0x8c;
313/// Fail the script unconditionally, does not even need to be executed.
314pub const OP_2MUL: u8 = 0x8d;
315/// Fail the script unconditionally, does not even need to be executed.
316pub const OP_2DIV: u8 = 0x8e;
317/// Multiply the top stack item by -1 in place.
318pub const OP_NEGATE: u8 = 0x8f;
319/// Absolute value the top stack item in place.
320pub const OP_ABS: u8 = 0x90;
321/// Map 0 to 1 and everything else to 0, in place.
322pub const OP_NOT: u8 = 0x91;
323/// Map 0 to 0 and everything else to 1, in place.
324pub const OP_0NOTEQUAL: u8 = 0x92;
325/// Pop two stack items and push their sum.
326pub const OP_ADD: u8 = 0x93;
327/// Pop two stack items and push the second minus the top.
328pub const OP_SUB: u8 = 0x94;
329/// Fail the script unconditionally, does not even need to be executed.
330pub const OP_MUL: u8 = 0x95;
331/// Fail the script unconditionally, does not even need to be executed.
332pub const OP_DIV: u8 = 0x96;
333/// Fail the script unconditionally, does not even need to be executed.
334pub const OP_MOD: u8 = 0x97;
335/// Fail the script unconditionally, does not even need to be executed.
336pub const OP_LSHIFT: u8 = 0x98;
337/// Fail the script unconditionally, does not even need to be executed.
338pub const OP_RSHIFT: u8 = 0x99;
339/// Pop the top two stack items and push 1 if both are nonzero, else push 0.
340pub const OP_BOOLAND: u8 = 0x9a;
341/// Pop the top two stack items and push 1 if either is nonzero, else push 0.
342pub const OP_BOOLOR: u8 = 0x9b;
343/// Pop the top two stack items and push 1 if both are numerically equal, else
344/// push 0.
345pub const OP_NUMEQUAL: u8 = 0x9c;
346/// Pop the top two stack items and return success if both are numerically
347/// equal, else return failure.
348pub const OP_NUMEQUALVERIFY: u8 = 0x9d;
349/// Pop the top two stack items and push 0 if both are numerically equal, else
350/// push 1.
351pub const OP_NUMNOTEQUAL: u8 = 0x9e;
352/// Pop the top two items; push 1 if the second is less than the top, 0
353/// otherwise.
354pub const OP_LESSTHAN: u8 = 0x9f;
355/// Pop the top two items; push 1 if the second is greater than the top, 0
356/// otherwise.
357pub const OP_GREATERTHAN: u8 = 0xa0;
358/// Pop the top two items; push 1 if the second is <= the top, 0 otherwise.
359pub const OP_LESSTHANOREQUAL: u8 = 0xa1;
360/// Pop the top two items; push 1 if the second is >= the top, 0 otherwise.
361pub const OP_GREATERTHANOREQUAL: u8 = 0xa2;
362/// Pop the top two items; push the smaller.
363pub const OP_MIN: u8 = 0xa3;
364/// Pop the top two items; push the larger.
365pub const OP_MAX: u8 = 0xa4;
366/// Pop the top three items; if the top is >= the second and < the third, push
367/// 1, otherwise push 0.
368pub const OP_WITHIN: u8 = 0xa5;
369/// Pop the top stack item and push its RIPEMD160 hash.
370pub const OP_RIPEMD160: u8 = 0xa6;
371/// Pop the top stack item and push its SHA1 hash.
372pub const OP_SHA1: u8 = 0xa7;
373/// Pop the top stack item and push its SHA256 hash.
374pub const OP_SHA256: u8 = 0xa8;
375/// Pop the top stack item and push its RIPEMD(SHA256) hash.
376pub const OP_HASH160: u8 = 0xa9;
377/// Pop the top stack item and push its SHA256(SHA256) hash.
378pub const OP_HASH256: u8 = 0xaa;
379/// Ignore this and everything preceding when deciding what to sign when
380/// signature-checking.
381pub const OP_CODESEPARATOR: u8 = 0xab;
382/// <https://en.bitcoin.it/wiki/OP_CHECKSIG> pushing 1/0 for success/failure.
383pub const OP_CHECKSIG: u8 = 0xac;
384/// <https://en.bitcoin.it/wiki/OP_CHECKSIG> returning success/failure.
385pub const OP_CHECKSIGVERIFY: u8 = 0xad;
386/// Pop N, N pubkeys, M, M signatures, a dummy (due to bug in reference code),
387/// and verify that all M signatures are valid. Push 1 for 'all valid', 0
388/// otherwise.
389pub const OP_CHECKMULTISIG: u8 = 0xae;
390/// Like the above but return success/failure.
391pub const OP_CHECKMULTISIGVERIFY: u8 = 0xaf;
392/// Does nothing.
393pub const OP_NOP1: u8 = 0xb0;
394/// <https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki>
395pub const OP_CLTV: u8 = 0xb1;
396/// <https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki>
397pub const OP_CSV: u8 = 0xb2;
398/// Does nothing.
399pub const OP_NOP4: u8 = 0xb3;
400/// Does nothing.
401pub const OP_NOP5: u8 = 0xb4;
402/// Does nothing.
403pub const OP_NOP6: u8 = 0xb5;
404/// Does nothing.
405pub const OP_NOP7: u8 = 0xb6;
406/// Does nothing.
407pub const OP_NOP8: u8 = 0xb7;
408/// Does nothing.
409pub const OP_NOP9: u8 = 0xb8;
410/// Does nothing.
411pub const OP_NOP10: u8 = 0xb9;
412// Every other opcode acts as OP_RETURN
413/// OP_CHECKSIGADD post tapscript.
414pub const OP_CHECKSIGADD: u8 = 0xba;
415/// Synonym for OP_RETURN.
416pub const OP_RETURN_187: u8 = 0xbb;
417/// Synonym for OP_RETURN.
418pub const OP_RETURN_188: u8 = 0xbc;
419/// Synonym for OP_RETURN.
420pub const OP_RETURN_189: u8 = 0xbd;
421/// Synonym for OP_RETURN.
422pub const OP_RETURN_190: u8 = 0xbe;
423/// Synonym for OP_RETURN.
424pub const OP_RETURN_191: u8 = 0xbf;
425/// Synonym for OP_RETURN.
426pub const OP_RETURN_192: u8 = 0xc0;
427/// Synonym for OP_RETURN.
428pub const OP_RETURN_193: u8 = 0xc1;
429/// Synonym for OP_RETURN.
430pub const OP_RETURN_194: u8 = 0xc2;
431/// Synonym for OP_RETURN.
432pub const OP_RETURN_195: u8 = 0xc3;
433/// Synonym for OP_RETURN.
434pub const OP_RETURN_196: u8 = 0xc4;
435/// Synonym for OP_RETURN.
436pub const OP_RETURN_197: u8 = 0xc5;
437/// Synonym for OP_RETURN.
438pub const OP_RETURN_198: u8 = 0xc6;
439/// Synonym for OP_RETURN.
440pub const OP_RETURN_199: u8 = 0xc7;
441/// Synonym for OP_RETURN.
442pub const OP_RETURN_200: u8 = 0xc8;
443/// Synonym for OP_RETURN.
444pub const OP_RETURN_201: u8 = 0xc9;
445/// Synonym for OP_RETURN.
446pub const OP_RETURN_202: u8 = 0xca;
447/// Synonym for OP_RETURN.
448pub const OP_RETURN_203: u8 = 0xcb;
449/// Synonym for OP_RETURN.
450pub const OP_RETURN_204: u8 = 0xcc;
451/// Synonym for OP_RETURN.
452pub const OP_RETURN_205: u8 = 0xcd;
453/// Synonym for OP_RETURN.
454pub const OP_RETURN_206: u8 = 0xce;
455/// Synonym for OP_RETURN.
456pub const OP_RETURN_207: u8 = 0xcf;
457/// Synonym for OP_RETURN.
458pub const OP_RETURN_208: u8 = 0xd0;
459/// Synonym for OP_RETURN.
460pub const OP_RETURN_209: u8 = 0xd1;
461/// Synonym for OP_RETURN.
462pub const OP_RETURN_210: u8 = 0xd2;
463/// Synonym for OP_RETURN.
464pub const OP_RETURN_211: u8 = 0xd3;
465/// Synonym for OP_RETURN.
466pub const OP_RETURN_212: u8 = 0xd4;
467/// Synonym for OP_RETURN.
468pub const OP_RETURN_213: u8 = 0xd5;
469/// Synonym for OP_RETURN.
470pub const OP_RETURN_214: u8 = 0xd6;
471/// Synonym for OP_RETURN.
472pub const OP_RETURN_215: u8 = 0xd7;
473/// Synonym for OP_RETURN.
474pub const OP_RETURN_216: u8 = 0xd8;
475/// Synonym for OP_RETURN.
476pub const OP_RETURN_217: u8 = 0xd9;
477/// Synonym for OP_RETURN.
478pub const OP_RETURN_218: u8 = 0xda;
479/// Synonym for OP_RETURN.
480pub const OP_RETURN_219: u8 = 0xdb;
481/// Synonym for OP_RETURN.
482pub const OP_RETURN_220: u8 = 0xdc;
483/// Synonym for OP_RETURN.
484pub const OP_RETURN_221: u8 = 0xdd;
485/// Synonym for OP_RETURN.
486pub const OP_RETURN_222: u8 = 0xde;
487/// Synonym for OP_RETURN.
488pub const OP_RETURN_223: u8 = 0xdf;
489/// Synonym for OP_RETURN.
490pub const OP_RETURN_224: u8 = 0xe0;
491/// Synonym for OP_RETURN.
492pub const OP_RETURN_225: u8 = 0xe1;
493/// Synonym for OP_RETURN.
494pub const OP_RETURN_226: u8 = 0xe2;
495/// Synonym for OP_RETURN.
496pub const OP_RETURN_227: u8 = 0xe3;
497/// Synonym for OP_RETURN.
498pub const OP_RETURN_228: u8 = 0xe4;
499/// Synonym for OP_RETURN.
500pub const OP_RETURN_229: u8 = 0xe5;
501/// Synonym for OP_RETURN.
502pub const OP_RETURN_230: u8 = 0xe6;
503/// Synonym for OP_RETURN.
504pub const OP_RETURN_231: u8 = 0xe7;
505/// Synonym for OP_RETURN.
506pub const OP_RETURN_232: u8 = 0xe8;
507/// Synonym for OP_RETURN.
508pub const OP_RETURN_233: u8 = 0xe9;
509/// Synonym for OP_RETURN.
510pub const OP_RETURN_234: u8 = 0xea;
511/// Synonym for OP_RETURN.
512pub const OP_RETURN_235: u8 = 0xeb;
513/// Synonym for OP_RETURN.
514pub const OP_RETURN_236: u8 = 0xec;
515/// Synonym for OP_RETURN.
516pub const OP_RETURN_237: u8 = 0xed;
517/// Synonym for OP_RETURN.
518pub const OP_RETURN_238: u8 = 0xee;
519/// Synonym for OP_RETURN.
520pub const OP_RETURN_239: u8 = 0xef;
521/// Synonym for OP_RETURN.
522pub const OP_RETURN_240: u8 = 0xf0;
523/// Synonym for OP_RETURN.
524pub const OP_RETURN_241: u8 = 0xf1;
525/// Synonym for OP_RETURN.
526pub const OP_RETURN_242: u8 = 0xf2;
527/// Synonym for OP_RETURN.
528pub const OP_RETURN_243: u8 = 0xf3;
529/// Synonym for OP_RETURN.
530pub const OP_RETURN_244: u8 = 0xf4;
531/// Synonym for OP_RETURN.
532pub const OP_RETURN_245: u8 = 0xf5;
533/// Synonym for OP_RETURN.
534pub const OP_RETURN_246: u8 = 0xf6;
535/// Synonym for OP_RETURN.
536pub const OP_RETURN_247: u8 = 0xf7;
537/// Synonym for OP_RETURN.
538pub const OP_RETURN_248: u8 = 0xf8;
539/// Synonym for OP_RETURN.
540pub const OP_RETURN_249: u8 = 0xf9;
541/// Synonym for OP_RETURN.
542pub const OP_RETURN_250: u8 = 0xfa;
543/// Synonym for OP_RETURN.
544pub const OP_RETURN_251: u8 = 0xfb;
545/// Synonym for OP_RETURN.
546pub const OP_RETURN_252: u8 = 0xfc;
547/// Synonym for OP_RETURN.
548pub const OP_RETURN_253: u8 = 0xfd;
549/// Synonym for OP_RETURN.
550pub const OP_RETURN_254: u8 = 0xfe;
551/// Synonym for OP_RETURN.
552pub const OP_INVALIDOPCODE: u8 = 0xff;
553
554#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, Display)]
555#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
556#[strict_type(lib = LIB_NAME_BITCOIN, tags = repr, into_u8, try_from_u8)]
557#[non_exhaustive]
558#[repr(u8)]
559pub enum OpCode {
560 /// Push an empty array onto the stack.
561 #[display("OP_PUSH_BYTES0")]
562 PushBytes0 = OP_PUSHBYTES_0,
563
564 /// Push the next byte as an array onto the stack.
565 #[display("OP_PUSH_BYTES1")]
566 PushBytes1 = OP_PUSHBYTES_1,
567
568 /// Push the next 2 bytes as an array onto the stack.
569 #[display("OP_PUSH_BYTES2")]
570 PushBytes2 = OP_PUSHBYTES_2,
571
572 /// Push the next 3 bytes as an array onto the stack.
573 #[display("OP_PUSH_BYTES3")]
574 PushBytes3 = OP_PUSHBYTES_3,
575
576 /// Push the next 4 bytes as an array onto the stack.
577 #[display("OP_PUSH_BYTES4")]
578 PushBytes4 = OP_PUSHBYTES_4,
579
580 /// Push the next 5 bytes as an array onto the stack.
581 #[display("OP_PUSH_BYTES5")]
582 PushBytes5 = OP_PUSHBYTES_5,
583
584 /// Push the next 6 bytes as an array onto the stack.
585 #[display("OP_PUSH_BYTES6")]
586 PushBytes6 = OP_PUSHBYTES_6,
587
588 /// Push the next 7 bytes as an array onto the stack.
589 #[display("OP_PUSH_BYTES7")]
590 PushBytes7 = OP_PUSHBYTES_7,
591
592 /// Push the next 8 bytes as an array onto the stack.
593 #[display("OP_PUSH_BYTES8")]
594 PushBytes8 = OP_PUSHBYTES_8,
595
596 /// Push the next 9 bytes as an array onto the stack.
597 #[display("OP_PUSH_BYTES9")]
598 PushBytes9 = OP_PUSHBYTES_9,
599
600 /// Push the next 10 bytes as an array onto the stack.
601 #[display("OP_PUSH_BYTES10")]
602 PushBytes10 = OP_PUSHBYTES_10,
603
604 /// Push the next 11 bytes as an array onto the stack.
605 #[display("OP_PUSH_BYTES11")]
606 PushBytes11 = OP_PUSHBYTES_11,
607
608 /// Push the next 12 bytes as an array onto the stack.
609 #[display("OP_PUSH_BYTES12")]
610 PushBytes12 = OP_PUSHBYTES_12,
611
612 /// Push the next 13 bytes as an array onto the stack.
613 #[display("OP_PUSH_BYTES13")]
614 PushBytes13 = OP_PUSHBYTES_13,
615
616 /// Push the next 14 bytes as an array onto the stack.
617 #[display("OP_PUSH_BYTES14")]
618 PushBytes14 = OP_PUSHBYTES_14,
619
620 /// Push the next 15 bytes as an array onto the stack.
621 #[display("OP_PUSH_BYTES15")]
622 PushBytes15 = OP_PUSHBYTES_15,
623
624 /// Push the next 16 bytes as an array onto the stack.
625 #[display("OP_PUSH_BYTES16")]
626 PushBytes16 = OP_PUSHBYTES_16,
627
628 /// Push the next 17 bytes as an array onto the stack.
629 #[display("OP_PUSH_BYTES17")]
630 PushBytes17 = OP_PUSHBYTES_17,
631
632 /// Push the next 18 bytes as an array onto the stack.
633 #[display("OP_PUSH_BYTES18")]
634 PushBytes18 = OP_PUSHBYTES_18,
635
636 /// Push the next 19 bytes as an array onto the stack.
637 #[display("OP_PUSH_BYTES19")]
638 PushBytes19 = OP_PUSHBYTES_19,
639
640 /// Push the next 20 bytes as an array onto the stack.
641 #[display("OP_PUSH_BYTES20")]
642 PushBytes20 = OP_PUSHBYTES_20,
643
644 /// Push the next 21 bytes as an array onto the stack.
645 #[display("OP_PUSH_BYTES21")]
646 PushBytes21 = OP_PUSHBYTES_21,
647
648 /// Push the next 22 bytes as an array onto the stack.
649 #[display("OP_PUSH_BYTES22")]
650 PushBytes22 = OP_PUSHBYTES_22,
651
652 /// Push the next 23 bytes as an array onto the stack.
653 #[display("OP_PUSH_BYTES23")]
654 PushBytes23 = OP_PUSHBYTES_23,
655
656 /// Push the next 24 bytes as an array onto the stack.
657 #[display("OP_PUSH_BYTES24")]
658 PushBytes24 = OP_PUSHBYTES_24,
659
660 /// Push the next 25 bytes as an array onto the stack.
661 #[display("OP_PUSH_BYTES25")]
662 PushBytes25 = OP_PUSHBYTES_25,
663
664 /// Push the next 26 bytes as an array onto the stack.
665 #[display("OP_PUSH_BYTES26")]
666 PushBytes26 = OP_PUSHBYTES_26,
667
668 /// Push the next 27 bytes as an array onto the stack.
669 #[display("OP_PUSH_BYTES27")]
670 PushBytes27 = OP_PUSHBYTES_27,
671
672 /// Push the next 28 bytes as an array onto the stack.
673 #[display("OP_PUSH_BYTES28")]
674 PushBytes28 = OP_PUSHBYTES_28,
675
676 /// Push the next 29 bytes as an array onto the stack.
677 #[display("OP_PUSH_BYTES29")]
678 PushBytes29 = OP_PUSHBYTES_29,
679
680 /// Push the next 30 bytes as an array onto the stack.
681 #[display("OP_PUSH_BYTES30")]
682 PushBytes30 = OP_PUSHBYTES_30,
683
684 /// Push the next 30 bytes as an array onto the stack.
685 #[display("OP_PUSH_BYTES31")]
686 PushBytes31 = OP_PUSHBYTES_31,
687
688 /// Push the next 32 bytes as an array onto the stack.
689 #[display("OP_PUSH_BYTES32")]
690 PushBytes32 = OP_PUSHBYTES_32,
691
692 /// Read the next byte as N; push the next N bytes as an array onto the
693 /// stack.
694 #[display("OP_PUSH_DATA1")]
695 PushData1 = OP_PUSHDATA1,
696 /// Read the next 2 bytes as N; push the next N bytes as an array onto the
697 /// stack.
698 #[display("OP_PUSH_DATA2")]
699 PushData2 = OP_PUSHDATA2,
700 /// Read the next 4 bytes as N; push the next N bytes as an array onto the
701 /// stack.
702 #[display("OP_PUSH_DATA3")]
703 PushData4 = OP_PUSHDATA4,
704
705 /// Push the array `0x01` onto the stack.
706 #[display("OP_PUSHNUM_1")]
707 PushNum1 = OP_PUSHNUM_1,
708
709 /// Synonym for OP_RETURN.
710 Reserved = OP_RESERVED,
711
712 /// Fail the script immediately.
713 #[display("OP_RETURN")]
714 #[strict_type(dumb)]
715 Return = OP_RETURN,
716
717 /// Duplicates the top stack item.
718 #[display("OP_DUP")]
719 Dup = OP_DUP,
720
721 /// Pushes 1 if the inputs are exactly equal, 0 otherwise.
722 #[display("OP_EQUAL")]
723 Equal = OP_EQUAL,
724
725 /// Returns success if the inputs are exactly equal, failure otherwise.
726 #[display("OP_EQUALVERIFY")]
727 EqualVerify = OP_EQUALVERIFY,
728
729 /// Pop the top stack item and push its RIPEMD160 hash.
730 #[display("OP_RIPEMD160")]
731 Ripemd160 = OP_RIPEMD160,
732
733 /// Pop the top stack item and push its SHA1 hash.
734 #[display("OP_SHA1")]
735 Sha1 = OP_SHA1,
736
737 /// Pop the top stack item and push its SHA256 hash.
738 #[display("OP_SHA256")]
739 Sha256 = OP_SHA256,
740
741 /// Pop the top stack item and push its RIPEMD(SHA256) hash.
742 #[display("OP_HASH160")]
743 Hash160 = OP_HASH160,
744
745 /// Pop the top stack item and push its SHA256(SHA256) hash.
746 #[display("OP_HASH256")]
747 Hash256 = OP_HASH256,
748
749 /// <https://en.bitcoin.it/wiki/OP_CHECKSIG> pushing 1/0 for success/failure.
750 #[display("OP_CHECKSIG")]
751 CheckSig = OP_CHECKSIG,
752
753 /// <https://en.bitcoin.it/wiki/OP_CHECKSIG> returning success/failure.
754 #[display("OP_CHECKSIGVERIFY")]
755 CheckSigVerify = OP_CHECKSIGVERIFY,
756}