bc/
tapcode.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::opcodes::*;
23use crate::LIB_NAME_BITCOIN;
24
25#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, Display)]
26#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
27#[strict_type(lib = LIB_NAME_BITCOIN, tags = repr, into_u8, try_from_u8)]
28#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
29#[non_exhaustive]
30#[repr(u8)]
31pub enum TapCode {
32    /// Push an empty array onto the stack.
33    ///
34    /// Also, a synonym for `OP_0` and `OP_FALSE`.
35    #[display("OP_PUSH_BYTES0")]
36    PushBytes0 = OP_PUSHBYTES_0,
37    /// Push the next byte as an array onto the stack.
38    #[display("OP_PUSH_BYTES1")]
39    PushBytes1 = OP_PUSHBYTES_1,
40    /// Push the next 2 bytes as an array onto the stack.
41    #[display("OP_PUSH_BYTES2")]
42    PushBytes2 = OP_PUSHBYTES_2,
43    /// Push the next 3 bytes as an array onto the stack.
44    #[display("OP_PUSH_BYTES3")]
45    PushBytes3 = OP_PUSHBYTES_3,
46    /// Push the next 4 bytes as an array onto the stack.
47    #[display("OP_PUSH_BYTES4")]
48    PushBytes4 = OP_PUSHBYTES_4,
49    /// Push the next 5 bytes as an array onto the stack.
50    #[display("OP_PUSH_BYTES5")]
51    PushBytes5 = OP_PUSHBYTES_5,
52    /// Push the next 6 bytes as an array onto the stack.
53    #[display("OP_PUSH_BYTES6")]
54    PushBytes6 = OP_PUSHBYTES_6,
55    /// Push the next 7 bytes as an array onto the stack.
56    #[display("OP_PUSH_BYTES7")]
57    PushBytes7 = OP_PUSHBYTES_7,
58    /// Push the next 8 bytes as an array onto the stack.
59    #[display("OP_PUSH_BYTES8")]
60    PushBytes8 = OP_PUSHBYTES_8,
61    /// Push the next 9 bytes as an array onto the stack.
62    #[display("OP_PUSH_BYTES9")]
63    PushBytes9 = OP_PUSHBYTES_9,
64    /// Push the next 10 bytes as an array onto the stack.
65    #[display("OP_PUSH_BYTES10")]
66    PushBytes10 = OP_PUSHBYTES_10,
67    /// Push the next 11 bytes as an array onto the stack.
68    #[display("OP_PUSH_BYTES11")]
69    PushBytes11 = OP_PUSHBYTES_11,
70    /// Push the next 12 bytes as an array onto the stack.
71    #[display("OP_PUSH_BYTES12")]
72    PushBytes12 = OP_PUSHBYTES_12,
73    /// Push the next 13 bytes as an array onto the stack.
74    #[display("OP_PUSH_BYTES13")]
75    PushBytes13 = OP_PUSHBYTES_13,
76    /// Push the next 14 bytes as an array onto the stack.
77    #[display("OP_PUSH_BYTES14")]
78    PushBytes14 = OP_PUSHBYTES_14,
79    /// Push the next 15 bytes as an array onto the stack.
80    #[display("OP_PUSH_BYTES15")]
81    PushBytes15 = OP_PUSHBYTES_15,
82    /// Push the next 16 bytes as an array onto the stack.
83    #[display("OP_PUSH_BYTES16")]
84    PushBytes16 = OP_PUSHBYTES_16,
85    /// Push the next 17 bytes as an array onto the stack.
86    #[display("OP_PUSH_BYTES17")]
87    PushBytes17 = OP_PUSHBYTES_17,
88    /// Push the next 18 bytes as an array onto the stack.
89    #[display("OP_PUSH_BYTES18")]
90    PushBytes18 = OP_PUSHBYTES_18,
91    /// Push the next 19 bytes as an array onto the stack.
92    #[display("OP_PUSH_BYTES19")]
93    PushBytes19 = OP_PUSHBYTES_19,
94    /// Push the next 20 bytes as an array onto the stack.
95    #[display("OP_PUSH_BYTES20")]
96    PushBytes20 = OP_PUSHBYTES_20,
97    /// Push the next 21 bytes as an array onto the stack.
98    #[display("OP_PUSH_BYTES21")]
99    PushBytes21 = OP_PUSHBYTES_21,
100    /// Push the next 22 bytes as an array onto the stack.
101    #[display("OP_PUSH_BYTES22")]
102    PushBytes22 = OP_PUSHBYTES_22,
103    /// Push the next 23 bytes as an array onto the stack.
104    #[display("OP_PUSH_BYTES23")]
105    PushBytes23 = OP_PUSHBYTES_23,
106    /// Push the next 24 bytes as an array onto the stack.
107    #[display("OP_PUSH_BYTES24")]
108    PushBytes24 = OP_PUSHBYTES_24,
109    /// Push the next 25 bytes as an array onto the stack.
110    #[display("OP_PUSH_BYTES25")]
111    PushBytes25 = OP_PUSHBYTES_25,
112    /// Push the next 26 bytes as an array onto the stack.
113    #[display("OP_PUSH_BYTES26")]
114    PushBytes26 = OP_PUSHBYTES_26,
115    /// Push the next 27 bytes as an array onto the stack.
116    #[display("OP_PUSH_BYTES27")]
117    PushBytes27 = OP_PUSHBYTES_27,
118    /// Push the next 28 bytes as an array onto the stack.
119    #[display("OP_PUSH_BYTES28")]
120    PushBytes28 = OP_PUSHBYTES_28,
121    /// Push the next 29 bytes as an array onto the stack.
122    #[display("OP_PUSH_BYTES29")]
123    PushBytes29 = OP_PUSHBYTES_29,
124    /// Push the next 30 bytes as an array onto the stack.
125    #[display("OP_PUSH_BYTES30")]
126    PushBytes30 = OP_PUSHBYTES_30,
127    /// Push the next 31 byte as an array onto the stack.
128    #[display("OP_PUSH_BYTES31")]
129    PushBytes31 = OP_PUSHBYTES_31,
130    /// Push the next 32 bytes as an array onto the stack.
131    #[display("OP_PUSH_BYTES32")]
132    PushBytes32 = OP_PUSHBYTES_32,
133    /// Push the next 33 bytes as an array onto the stack.
134    #[display("OP_PUSH_BYTES33")]
135    PushBytes33 = OP_PUSHBYTES_33,
136    /// Push the next 34 bytes as an array onto the stack.
137    #[display("OP_PUSH_BYTES34")]
138    PushBytes34 = OP_PUSHBYTES_34,
139    /// Push the next 35 bytes as an array onto the stack.
140    #[display("OP_PUSH_BYTES35")]
141    PushBytes35 = OP_PUSHBYTES_35,
142    /// Push the next 36 bytes as an array onto the stack.
143    #[display("OP_PUSH_BYTES36")]
144    PushBytes36 = OP_PUSHBYTES_36,
145    /// Push the next 37 bytes as an array onto the stack.
146    #[display("OP_PUSH_BYTES37")]
147    PushBytes37 = OP_PUSHBYTES_37,
148    /// Push the next 38 bytes as an array onto the stack.
149    #[display("OP_PUSH_BYTES38")]
150    PushBytes38 = OP_PUSHBYTES_38,
151    /// Push the next 39 bytes as an array onto the stack.
152    #[display("OP_PUSH_BYTES39")]
153    PushBytes39 = OP_PUSHBYTES_39,
154    /// Push the next 40 bytes as an array onto the stack.
155    #[display("OP_PUSH_BYTES40")]
156    PushBytes40 = OP_PUSHBYTES_40,
157    /// Push the next 41 bytes as an array onto the stack.
158    #[display("OP_PUSH_BYTES41")]
159    PushBytes41 = OP_PUSHBYTES_41,
160    /// Push the next 42 bytes as an array onto the stack.
161    #[display("OP_PUSH_BYTES42")]
162    PushBytes42 = OP_PUSHBYTES_42,
163    /// Push the next 43 bytes as an array onto the stack.
164    #[display("OP_PUSH_BYTES43")]
165    PushBytes43 = OP_PUSHBYTES_43,
166    /// Push the next 44 bytes as an array onto the stack.
167    #[display("OP_PUSH_BYTES44")]
168    PushBytes44 = OP_PUSHBYTES_44,
169    /// Push the next 45 bytes as an array onto the stack.
170    #[display("OP_PUSH_BYTES45")]
171    PushBytes45 = OP_PUSHBYTES_45,
172    /// Push the next 46 bytes as an array onto the stack.
173    #[display("OP_PUSH_BYTES46")]
174    PushBytes46 = OP_PUSHBYTES_46,
175    /// Push the next 47 bytes as an array onto the stack.
176    #[display("OP_PUSH_BYTES47")]
177    PushBytes47 = OP_PUSHBYTES_47,
178    /// Push the next 48 bytes as an array onto the stack.
179    #[display("OP_PUSH_BYTES48")]
180    PushBytes48 = OP_PUSHBYTES_48,
181    /// Push the next 49 bytes as an array onto the stack.
182    #[display("OP_PUSH_BYTES49")]
183    PushBytes49 = OP_PUSHBYTES_49,
184    /// Push the next 50 bytes as an array onto the stack.
185    #[display("OP_PUSH_BYTES50")]
186    PushBytes50 = OP_PUSHBYTES_50,
187    /// Push the next 51 bytes as an array onto the stack.
188    #[display("OP_PUSH_BYTES51")]
189    PushBytes51 = OP_PUSHBYTES_51,
190    /// Push the next 52 bytes as an array onto the stack.
191    #[display("OP_PUSH_BYTES52")]
192    PushBytes52 = OP_PUSHBYTES_52,
193    /// Push the next 53 bytes as an array onto the stack.
194    #[display("OP_PUSH_BYTES53")]
195    PushBytes53 = OP_PUSHBYTES_53,
196    /// Push the next 54 bytes as an array onto the stack.
197    #[display("OP_PUSH_BYTES54")]
198    PushBytes54 = OP_PUSHBYTES_54,
199    /// Push the next 55 bytes as an array onto the stack.
200    #[display("OP_PUSH_BYTES55")]
201    PushBytes55 = OP_PUSHBYTES_55,
202    /// Push the next 56 bytes as an array onto the stack.
203    #[display("OP_PUSH_BYTES56")]
204    PushBytes56 = OP_PUSHBYTES_56,
205    /// Push the next 57 bytes as an array onto the stack.
206    #[display("OP_PUSH_BYTES57")]
207    PushBytes57 = OP_PUSHBYTES_57,
208    /// Push the next 58 bytes as an array onto the stack.
209    #[display("OP_PUSH_BYTES58")]
210    PushBytes58 = OP_PUSHBYTES_58,
211    /// Push the next 59 bytes as an array onto the stack.
212    #[display("OP_PUSH_BYTES59")]
213    PushBytes59 = OP_PUSHBYTES_59,
214    /// Push the next 60 bytes as an array onto the stack.
215    #[display("OP_PUSH_BYTES60")]
216    PushBytes60 = OP_PUSHBYTES_60,
217    /// Push the next 61 bytes as an array onto the stack.
218    #[display("OP_PUSH_BYTES61")]
219    PushBytes61 = OP_PUSHBYTES_61,
220    /// Push the next 62 bytes as an array onto the stack.
221    #[display("OP_PUSH_BYTES62")]
222    PushBytes62 = OP_PUSHBYTES_62,
223    /// Push the next 63 bytes as an array onto the stack.
224    #[display("OP_PUSH_BYTES63")]
225    PushBytes63 = OP_PUSHBYTES_63,
226    /// Push the next 64 bytes as an array onto the stack.
227    #[display("OP_PUSH_BYTES64")]
228    PushBytes64 = OP_PUSHBYTES_64,
229    /// Push the next 65 bytes as an array onto the stack.
230    #[display("OP_PUSH_BYTES65")]
231    PushBytes65 = OP_PUSHBYTES_65,
232    /// Push the next 66 bytes as an array onto the stack.
233    #[display("OP_PUSH_BYTES66")]
234    PushBytes66 = OP_PUSHBYTES_66,
235    /// Push the next 67 bytes as an array onto the stack.
236    #[display("OP_PUSH_BYTES67")]
237    PushBytes67 = OP_PUSHBYTES_67,
238    /// Push the next 68 bytes as an array onto the stack.
239    #[display("OP_PUSH_BYTES68")]
240    PushBytes68 = OP_PUSHBYTES_68,
241    /// Push the next 69 bytes as an array onto the stack.
242    #[display("OP_PUSH_BYTES69")]
243    PushBytes69 = OP_PUSHBYTES_69,
244    /// Push the next 70 bytes as an array onto the stack.
245    #[display("OP_PUSH_BYTES70")]
246    PushBytes70 = OP_PUSHBYTES_70,
247    /// Push the next 71 bytes as an array onto the stack.
248    #[display("OP_PUSH_BYTES71")]
249    PushBytes71 = OP_PUSHBYTES_71,
250    /// Push the next 72 bytes as an array onto the stack.
251    #[display("OP_PUSH_BYTES72")]
252    PushBytes72 = OP_PUSHBYTES_72,
253    /// Push the next 73 bytes as an array onto the stack.
254    #[display("OP_PUSH_BYTES73")]
255    PushBytes73 = OP_PUSHBYTES_73,
256    /// Push the next 74 bytes as an array onto the stack.
257    #[display("OP_PUSH_BYTES74")]
258    PushByte764 = OP_PUSHBYTES_74,
259    /// Push the next 75 bytes as an array onto the stack.
260    #[display("OP_PUSH_BYTES75")]
261    PushBytes75 = OP_PUSHBYTES_75,
262
263    /// Read the next byte as N; push the next N bytes as an array onto the
264    /// stack.
265    #[display("OP_PUSH_DATA1")]
266    PushData1 = OP_PUSHDATA1,
267    /// Read the next 2 bytes as N; push the next N bytes as an array onto the
268    /// stack.
269    #[display("OP_PUSH_DATA2")]
270    PushData2 = OP_PUSHDATA2,
271    /// Read the next 4 bytes as N; push the next N bytes as an array onto the
272    /// stack.
273    #[display("OP_PUSH_DATA3")]
274    PushData4 = OP_PUSHDATA4,
275
276    /// Push the array `0x81` onto the stack.
277    #[display("OP_PUSHNUM_NEG1")]
278    PushNumNeg1 = OP_PUSHNUM_NEG1,
279
280    /// One of `OP_SUCCESSx` op-codes.
281    #[display("OP_SUCCESS80")]
282    Success80 = OP_RESERVED,
283
284    /// Push the array `0x01` onto the stack.
285    ///
286    /// Also, a synonym for `OP_1` and `OP_TRUE`.
287    #[display("OP_PUSHNUM_1")]
288    PushNum1 = OP_PUSHNUM_1,
289    /// Push the array `0x02` onto the stack.
290    #[display("OP_PUSHNUM_2")]
291    PushNum2 = OP_PUSHNUM_2,
292    /// Push the array `0x03` onto the stack.
293    #[display("OP_PUSHNUM_3")]
294    PushNum3 = OP_PUSHNUM_3,
295    /// Push the array `0x04` onto the stack.
296    #[display("OP_PUSHNUM_4")]
297    PushNum4 = OP_PUSHNUM_4,
298    /// Push the array `0x05` onto the stack.
299    #[display("OP_PUSHNUM_5")]
300    PushNum5 = OP_PUSHNUM_5,
301    /// Push the array `0x06` onto the stack.
302    #[display("OP_PUSHNUM_6")]
303    PushNum6 = OP_PUSHNUM_6,
304    /// Push the array `0x07` onto the stack.
305    #[display("OP_PUSHNUM_7")]
306    PushNum7 = OP_PUSHNUM_7,
307    /// Push the array `0x08` onto the stack.
308    #[display("OP_PUSHNUM_8")]
309    PushNum8 = OP_PUSHNUM_8,
310    /// Push the array `0x09` onto the stack.
311    #[display("OP_PUSHNUM_9")]
312    PushNum9 = OP_PUSHNUM_9,
313    /// Push the array `0x0A` onto the stack.
314    #[display("OP_PUSHNUM_10")]
315    PushNum10 = OP_PUSHNUM_10,
316    /// Push the array `0x0B` onto the stack.
317    #[display("OP_PUSHNUM_11")]
318    PushNum11 = OP_PUSHNUM_11,
319    /// Push the array `0x0C` onto the stack.
320    #[display("OP_PUSHNUM_12")]
321    PushNum12 = OP_PUSHNUM_12,
322    /// Push the array `0x0D` onto the stack.
323    #[display("OP_PUSHNUM_13")]
324    PushNum13 = OP_PUSHNUM_13,
325    /// Push the array `0x0E` onto the stack.
326    #[display("OP_PUSHNUM_14")]
327    PushNum14 = OP_PUSHNUM_14,
328    /// Push the array `0x0F` onto the stack.
329    #[display("OP_PUSHNUM_15")]
330    PushNum15 = OP_PUSHNUM_15,
331    /// Push the array `0x10` onto the stack.
332    #[display("OP_PUSHNUM_16")]
333    PushNum16 = OP_PUSHNUM_16,
334
335    /// Does nothing.
336    #[display("OP_NOP")]
337    Nop = OP_NOP,
338
339    /// One of `OP_SUCCESSx` op-codes.
340    #[display("OP_SUCCESS98")]
341    Success98 = OP_VER,
342
343    /// Pop and execute the next statements if a nonzero element was popped.
344    #[display("OP_IF")]
345    If = OP_IF,
346    /// Pop and execute the next statements if a zero element was popped.
347    #[display("OP_NOTIF")]
348    NotIf = OP_NOTIF,
349    /// Fail the script unconditionally, does not even need to be executed.
350    #[display("OP_VERIF")]
351    VerIf = OP_VERIF,
352    /// Fail the script unconditionally, does not even need to be executed.
353    #[display("OP_VERNOTIF")]
354    VerNotIf = OP_VERNOTIF,
355    /// Execute statements if those after the previous OP_IF were not, and
356    /// vice versa. If there is no previous OP_IF, this acts as an OP_RETURN.
357    #[display("OP_ELSE")]
358    Else = OP_ELSE,
359    /// Pop and execute the next statements if a zero element was popped.
360    #[display("OP_ENDIF")]
361    EndIf = OP_ENDIF,
362    /// If the top value is zero or the stack is empty, fail; otherwise, pop the
363    /// stack.
364    #[display("OP_VERIFY")]
365    Verify = OP_VERIFY,
366
367    /// Fail the script immediately.
368    #[display("OP_RETURN")]
369    #[strict_type(dumb)]
370    Return = OP_RETURN,
371
372    #[display("OP_TOALTSTACK")]
373    ToAltStack = OP_TOALTSTACK,
374    /// Pop one element from the alt stack onto the main stack.
375    #[display("OP_FROMALTSTACK")]
376    FromAltStack = OP_FROMALTSTACK,
377    /// Drops the top two stack items.
378    #[display("OP_2DROP")]
379    Drop2 = OP_2DROP,
380    /// Duplicates the top two stack items as AB -> ABAB.
381    #[display("OP_2DUP")]
382    Dup2 = OP_2DUP,
383    /// Duplicates the two three stack items as ABC -> ABCABC.
384    #[display("OP_3DUP")]
385    Dup3 = OP_3DUP,
386    /// Copies the two stack items of items two spaces back to the front, as xxAB ->
387    /// ABxxAB.
388    #[display("OP_2OVER")]
389    Over2 = OP_2OVER,
390    /// Moves the two stack items four spaces back to the front, as xxxxAB ->
391    /// ABxxxx.
392    #[display("OP_2ROT")]
393    Rot2 = OP_2ROT,
394    /// Swaps the top two pairs, as ABCD -> CDAB.
395    #[display("OP_2SWAP")]
396    Swap2 = OP_2SWAP,
397    /// Duplicate the top stack element unless it is zero.
398    #[display("OP_IFDUP")]
399    IfDup = OP_IFDUP,
400    /// Push the current number of stack items onto the stack.
401    #[display("OP_DEPTH")]
402    Depth = OP_DEPTH,
403    /// Drops the top stack item.
404    #[display("OP_DROP")]
405    Drop = OP_DROP,
406    /// Duplicates the top stack item.
407    #[display("OP_DUP")]
408    Dup = OP_DUP,
409    /// Drops the second-to-top stack item.
410    #[display("OP_NIP")]
411    Nip = OP_NIP,
412    /// Copies the second-to-top stack item, as xA -> AxA.
413    #[display("OP_OVER")]
414    Over = OP_OVER,
415    /// Pop the top stack element as N. Copy the Nth stack element to the top.
416    #[display("OP_PICK")]
417    Pick = OP_PICK,
418    /// Pop the top stack element as N. Move the Nth stack element to the top.
419    #[display("OP_ROLL")]
420    Roll = OP_ROLL,
421    /// Rotate the top three stack items, as [top next1 next2] -> [next2 top next1].
422    #[display("OP_ROT")]
423    Rot = OP_ROT,
424    /// Swap the top two stack items.
425    #[display("OP_SWAP")]
426    Swap = OP_SWAP,
427    /// Copy the top stack item to before the second item, as [top next] -> [top
428    /// next top].
429    #[display("OP_TUCK")]
430    Tuck = OP_TUCK,
431
432    /// One of `OP_SUCCESSx` op-codes.
433    #[display("OP_SUCCESS126")]
434    Success126 = OP_CAT,
435    /// One of `OP_SUCCESSx` op-codes.
436    #[display("OP_SUCCESS127")]
437    Success127 = OP_SUBSTR,
438    /// One of `OP_SUCCESSx` op-codes.
439    #[display("OP_SUCCESS128")]
440    Success128 = OP_LEFT,
441    /// One of `OP_SUCCESSx` op-codes.
442    #[display("OP_SUCCESS129")]
443    Success129 = OP_RIGHT,
444
445    /// Pushes the length of the top stack item onto the stack.
446    #[display("OP_SIZE")]
447    Size = OP_SIZE,
448
449    /// One of `OP_SUCCESSx` op-codes.
450    #[display("OP_SUCCESS131")]
451    Success131 = OP_INVERT,
452    /// One of `OP_SUCCESSx` op-codes.
453    #[display("OP_SUCCESS132")]
454    Success132 = OP_AND,
455    /// One of `OP_SUCCESSx` op-codes.
456    #[display("OP_SUCCESS133")]
457    Success133 = OP_OR,
458    /// One of `OP_SUCCESSx` op-codes.
459    #[display("OP_SUCCESS134")]
460    Success134 = OP_XOR,
461
462    /// Pushes 1 if the inputs are exactly equal, 0 otherwise.
463    #[display("OP_EQUAL")]
464    Equal = OP_EQUAL,
465    /// Returns success if the inputs are exactly equal, failure otherwise.
466    #[display("OP_EQUALVERIFY")]
467    EqualVerify = OP_EQUALVERIFY,
468
469    /// One of `OP_SUCCESSx` op-codes.
470    #[display("OP_SUCCESS137")]
471    Success137 = OP_RESERVED1,
472    /// One of `OP_SUCCESSx` op-codes.
473    #[display("OP_SUCCESS138")]
474    Success138 = OP_RESERVED2,
475
476    /// Increment the top stack element in place.
477    #[display("OP_1ADD")]
478    Add1 = OP_1ADD,
479    /// Decrement the top stack element in place.
480    #[display("OP_1SUB")]
481    Sub1 = OP_1SUB,
482
483    /// One of `OP_SUCCESSx` op-codes.
484    #[display("OP_SUCCESS141")]
485    Success141 = OP_2MUL,
486    /// One of `OP_SUCCESSx` op-codes.
487    #[display("OP_SUCCESS141")]
488    Success142 = OP_2DIV,
489
490    /// Multiply the top stack item by -1 in place.
491    #[display("OP_NEGATE")]
492    Negate = OP_NEGATE,
493    /// Absolute value the top stack item in place.
494    #[display("OP_ABS")]
495    Abs = OP_ABS,
496    /// Map 0 to 1 and everything else to 0, in place.
497    #[display("OP_NOT")]
498    Not = OP_NOT,
499    /// Map 0 to 0 and everything else to 1, in place.
500    #[display("OP_0NOTEQUAL")]
501    NotEqual0 = OP_0NOTEQUAL,
502    /// Pop two stack items and push their sum.
503    #[display("OP_ADD")]
504    Add = OP_ADD,
505    /// Pop two stack items and push the second minus the top.
506    #[display("OP_SUB")]
507    Sub = OP_SUB,
508
509    /// One of `OP_SUCCESSx` op-codes.
510    #[display("OP_SUCCESS149")]
511    Success149 = OP_MUL,
512    /// One of `OP_SUCCESSx` op-codes.
513    #[display("OP_SUCCESS150")]
514    Success150 = OP_DIV,
515    /// One of `OP_SUCCESSx` op-codes.
516    #[display("OP_SUCCESS151")]
517    Success151 = OP_MOD,
518    /// One of `OP_SUCCESSx` op-codes.
519    #[display("OP_SUCCESS152")]
520    Success152 = OP_LSHIFT,
521    /// One of `OP_SUCCESSx` op-codes.
522    #[display("OP_SUCCESS153")]
523    Success153 = OP_RSHIFT,
524
525    /// Pop the top two stack items and push 1 if both are nonzero, else push 0.
526    #[display("OP_BOOLAND")]
527    BoolAnd = OP_BOOLAND,
528    /// Pop the top two stack items and push 1 if either is nonzero, else push 0.
529    #[display("OP_BOOLOR")]
530    BoolOr = OP_BOOLOR,
531
532    /// Pop the top two stack items and push 1 if both are numerically equal, else
533    /// push 0.
534    #[display("OP_NUMEQUAL")]
535    NumEqual = OP_NUMEQUAL,
536    /// Pop the top two stack items and return success if both are numerically
537    /// equal, else return failure.
538    #[display("OP_NUMEQUALVERIFY")]
539    NumEqualVerify = OP_NUMEQUALVERIFY,
540    /// Pop the top two stack items and push 0 if both are numerically equal, else
541    /// push 1.
542    #[display("OP_NUMNOTEQUAL")]
543    NumNotEqual = OP_NUMNOTEQUAL,
544    /// Pop the top two items; push 1 if the second is less than the top, 0
545    /// otherwise.
546    #[display("OP_LESSTHAN")]
547    LessThan = OP_LESSTHAN,
548    /// Pop the top two items; push 1 if the second is greater than the top, 0
549    /// otherwise.
550    #[display("OP_GREATERTHAN")]
551    GreaterThan = OP_GREATERTHAN,
552    /// Pop the top two items; push 1 if the second is <= the top, 0 otherwise.
553    #[display("OP_LESSTHANOREQUAL")]
554    LessThanOrEqual = OP_LESSTHANOREQUAL,
555    /// Pop the top two items; push 1 if the second is >= the top, 0 otherwise.
556    #[display("OP_GREATERTHANOREQUAL")]
557    GreaterThanOrEqual = OP_GREATERTHANOREQUAL,
558    /// Pop the top two items; push the smaller.
559    #[display("OP_MIN")]
560    Min = OP_MIN,
561    /// Pop the top two items; push the larger.
562    #[display("OP_MAX")]
563    Max = OP_MAX,
564    /// Pop the top three items; if the top is >= the second and < the third, push
565    /// 1, otherwise push 0.
566    #[display("OP_WITHIN")]
567    Within = OP_WITHIN,
568
569    /// Pop the top stack item and push its RIPEMD160 hash.
570    #[display("OP_RIPEMD160")]
571    Ripemd160 = OP_RIPEMD160,
572    /// Pop the top stack item and push its SHA1 hash.
573    #[display("OP_SHA1")]
574    Sha1 = OP_SHA1,
575    /// Pop the top stack item and push its SHA256 hash.
576    #[display("OP_SHA256")]
577    Sha256 = OP_SHA256,
578    /// Pop the top stack item and push its RIPEMD(SHA256) hash.
579    #[display("OP_HASH160")]
580    Hash160 = OP_HASH160,
581    /// Pop the top stack item and push its SHA256(SHA256) hash.
582    #[display("OP_HASH256")]
583    Hash256 = OP_HASH256,
584
585    /// Ignore this and everything preceding when deciding what to sign when
586    /// signature-checking.
587    #[display("OP_CODESEPARATOR")]
588    CodeSeparator = OP_CODESEPARATOR,
589
590    /// <https://en.bitcoin.it/wiki/OP_CHECKSIG> pushing 1/0 for success/failure.
591    #[display("OP_CHECKSIG")]
592    CheckSig = OP_CHECKSIG,
593    /// <https://en.bitcoin.it/wiki/OP_CHECKSIG> returning success/failure.
594    #[display("OP_CHECKSIGVERIFY")]
595    CheckSigVerify = OP_CHECKSIGVERIFY,
596
597    /// Does nothing.
598    #[display("OP_NOP1")]
599    Nop1 = OP_NOP1,
600    /// <https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki>
601    #[display("OP_CLTV")]
602    Cltv = OP_CLTV,
603    /// <https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki>
604    #[display("OP_CSV")]
605    Csv = OP_CSV,
606    /// Does nothing.
607    #[display("OP_NOP4")]
608    Nop4 = OP_NOP4,
609    /// Does nothing.
610    #[display("OP_NOP5")]
611    Nop5 = OP_NOP5,
612    /// Does nothing.
613    #[display("OP_NOP6")]
614    Nop6 = OP_NOP6,
615    /// Does nothing.
616    #[display("OP_NOP7")]
617    Nop7 = OP_NOP7,
618    /// Does nothing.
619    #[display("OP_NOP8")]
620    Nop8 = OP_NOP8,
621    /// Does nothing.
622    #[display("OP_NOP9")]
623    Nop9 = OP_NOP9,
624    /// Does nothing.
625    #[display("OP_NOP10")]
626    Nop10 = OP_NOP10,
627    /// OP_CHECKSIGADD post tapscript.
628    #[display("OP_CHECKSIGADD")]
629    CheckSigAdd = OP_CHECKSIGADD,
630
631    // Every other opcode acts as OP_SUCCESSx
632    /// Synonym for OP_RETURN.
633    #[display("OP_INVALIDOPCODE")]
634    InvalidOpCode = OP_INVALIDOPCODE,
635}