2014-07-18 13:56:17 +00:00
|
|
|
// Rust Bitcoin Library
|
|
|
|
// Written in 2014 by
|
|
|
|
// Andrew Poelstra <apoelstra@wpsoftware.net>
|
|
|
|
//
|
|
|
|
// To the extent possible under law, the author(s) have dedicated all
|
|
|
|
// copyright and related and neighboring rights to this software to
|
|
|
|
// the public domain worldwide. This software is distributed without
|
|
|
|
// any warranty.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the CC0 Public Domain Dedication
|
|
|
|
// along with this software.
|
|
|
|
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
//
|
|
|
|
|
2018-08-08 21:38:50 +00:00
|
|
|
//! Opcodes
|
2014-07-18 13:56:17 +00:00
|
|
|
//!
|
|
|
|
//! Bitcoin's script uses a stack-based assembly language. This module defines
|
2014-08-06 02:08:06 +00:00
|
|
|
//! all of the opcodes
|
2014-07-18 13:56:17 +00:00
|
|
|
//!
|
|
|
|
|
2014-08-06 02:08:06 +00:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
2018-08-20 16:37:19 +00:00
|
|
|
#[cfg(feature = "serde")] use serde;
|
2014-08-06 02:08:06 +00:00
|
|
|
|
2018-11-11 22:09:21 +00:00
|
|
|
use std::fmt;
|
|
|
|
|
Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
instead
- Move network::serialize::Simple{En,De}coder to
consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
should never fail
2018-09-20 10:15:45 +00:00
|
|
|
use consensus::encode::{self, Decoder, Encoder};
|
|
|
|
use consensus::encode::{Decodable, Encodable};
|
2014-08-06 02:08:06 +00:00
|
|
|
|
2015-04-05 03:13:19 +00:00
|
|
|
// Note: I am deliberately not implementing PartialOrd or Ord on the
|
|
|
|
// opcode enum. If you want to check ranges of opcodes, etc.,
|
|
|
|
// write an #[inline] helper function which casts to u8s.
|
2014-08-06 02:08:06 +00:00
|
|
|
|
2015-04-05 03:13:19 +00:00
|
|
|
/// A script Opcode
|
2018-11-11 22:09:21 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
|
|
|
pub struct All(u8);
|
|
|
|
|
|
|
|
impl All {
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push an empty array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_0: All = All(0x0);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next byte as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_1: All = All(0x01);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 2 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_2: All = All(0x02);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 2 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_3: All = All(0x03);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 4 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_4: All = All(0x04);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 5 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_5: All = All(0x05);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 6 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_6: All = All(0x06);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 7 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_7: All = All(0x07);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 8 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_8: All = All(0x08);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 9 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_9: All = All(0x09);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 10 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_10: All = All(0x0a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 11 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_11: All = All(0x0b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 12 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_12: All = All(0x0c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 13 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_13: All = All(0x0d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 14 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_14: All = All(0x0e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 15 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_15: All = All(0x0f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 16 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_16: All = All(0x10);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 17 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_17: All = All(0x11);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 18 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_18: All = All(0x12);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 19 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_19: All = All(0x13);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 20 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_20: All = All(0x14);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 21 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_21: All = All(0x15);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 22 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_22: All = All(0x16);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 23 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_23: All = All(0x17);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 24 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_24: All = All(0x18);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 25 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_25: All = All(0x19);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 26 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_26: All = All(0x1a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 27 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_27: All = All(0x1b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 28 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_28: All = All(0x1c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 29 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_29: All = All(0x1d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 30 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_30: All = All(0x1e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 31 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_31: All = All(0x1f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 32 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_32: All = All(0x20);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 33 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_33: All = All(0x21);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 34 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_34: All = All(0x22);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 35 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_35: All = All(0x23);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 36 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_36: All = All(0x24);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 37 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_37: All = All(0x25);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 38 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_38: All = All(0x26);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 39 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_39: All = All(0x27);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 40 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_40: All = All(0x28);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 41 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_41: All = All(0x29);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 42 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_42: All = All(0x2a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 43 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_43: All = All(0x2b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 44 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_44: All = All(0x2c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 45 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_45: All = All(0x2d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 46 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_46: All = All(0x2e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 47 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_47: All = All(0x2f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 48 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_48: All = All(0x30);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 49 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_49: All = All(0x31);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 50 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_50: All = All(0x32);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 51 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_51: All = All(0x33);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 52 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_52: All = All(0x34);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 53 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_53: All = All(0x35);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 54 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_54: All = All(0x36);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 55 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_55: All = All(0x37);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 56 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_56: All = All(0x38);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 57 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_57: All = All(0x39);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 58 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_58: All = All(0x3a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 59 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_59: All = All(0x3b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 60 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_60: All = All(0x3c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 61 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_61: All = All(0x3d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 62 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_62: All = All(0x3e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 63 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_63: All = All(0x3f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 64 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_64: All = All(0x40);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 65 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_65: All = All(0x41);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 66 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_66: All = All(0x42);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 67 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_67: All = All(0x43);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 68 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_68: All = All(0x44);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 69 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_69: All = All(0x45);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 70 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_70: All = All(0x46);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 71 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_71: All = All(0x47);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 72 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_72: All = All(0x48);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 73 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_73: All = All(0x49);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 74 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_74: All = All(0x4a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the next 75 bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHBYTES_75: All = All(0x4b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Read the next byte as N; push the next N bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHDATA1: All = All(0x4c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Read the next 2 bytes as N; push the next N bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHDATA2: All = All(0x4d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Read the next 4 bytes as N; push the next N bytes as an array onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHDATA4: All = All(0x4e);
|
2018-08-05 21:11:16 +00:00
|
|
|
/// Push the array [0x81] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_NEG1: All = All(0x4f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RESERVED: All = All(0x50);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the array [0x01] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_1: All = All(0x51);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x02] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_2: All = All(0x52);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x03] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_3: All = All(0x53);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x04] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_4: All = All(0x54);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x05] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_5: All = All(0x55);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x06] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_6: All = All(0x56);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x07] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_7: All = All(0x57);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x08] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_8: All = All(0x58);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x09] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_9: All = All(0x59);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x0a] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_10: All = All(0x5a);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x0b] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_11: All = All(0x5b);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x0c] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_12: All = All(0x5c);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x0d] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_13: All = All(0x5d);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x0e] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_14: All = All(0x5e);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x0f] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_15: All = All(0x5f);
|
2014-08-13 05:50:40 +00:00
|
|
|
/// Push the array [0x10] onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PUSHNUM_16: All = All(0x60);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP: All = All(0x61);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_VER: All = All(0x62);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop and execute the next statements if a nonzero element was popped
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_IF: All = All(0x63);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop and execute the next statements if a zero element was popped
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOTIF: All = All(0x64);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_VERIF: All = All(0x65);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_VERNOTIF: All = All(0x66);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Execute statements if those after the previous OP_IF were not, and vice-versa.
|
|
|
|
/// If there is no previous OP_IF, this acts as a RETURN.
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_ELSE: All = All(0x67);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop and execute the next statements if a zero element was popped
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_ENDIF: All = All(0x68);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// If the top value is zero or the stack is empty, fail; otherwise, pop the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_VERIFY: All = All(0x69);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script immediately. (Must be executed.)
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN: All = All(0x6a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop one element from the main stack onto the alt stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_TOALTSTACK: All = All(0x6b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop one element from the alt stack onto the main stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_FROMALTSTACK: All = All(0x6c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Drops the top two stack items
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_2DROP: All = All(0x6d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Duplicates the top two stack items as AB -> ABAB
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_2DUP: All = All(0x6e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Duplicates the two three stack items as ABC -> ABCABC
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_3DUP: All = All(0x6f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Copies the two stack items of items two spaces back to
|
|
|
|
/// the front, as xxAB -> ABxxAB
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_2OVER: All = All(0x70);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Moves the two stack items four spaces back to the front,
|
|
|
|
/// as xxxxAB -> ABxxxx
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_2ROT: All = All(0x71);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Swaps the top two pairs, as ABCD -> CDAB
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_2SWAP: All = All(0x72);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Duplicate the top stack element unless it is zero
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_IFDUP: All = All(0x73);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Push the current number of stack items onto te stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_DEPTH: All = All(0x74);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Drops the top stack item
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_DROP: All = All(0x75);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Duplicates the top stack item
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_DUP: All = All(0x76);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Drops the second-to-top stack item
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NIP: All = All(0x77);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Copies the second-to-top stack item, as xA -> AxA
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_OVER: All = All(0x78);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top stack element as N. Copy the Nth stack element to the top
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_PICK: All = All(0x79);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top stack element as N. Move the Nth stack element to the top
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_ROLL: All = All(0x7a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Rotate the top three stack items, as [top next1 next2] -> [next2 top next1]
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_ROT: All = All(0x7b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Swap the top two stack items
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_SWAP: All = All(0x7c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Copy the top stack item to before the second item, as [top next] -> [top next top]
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_TUCK: All = All(0x7d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_CAT: All = All(0x7e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_SUBSTR: All = All(0x7f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_LEFT: All = All(0x80);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RIGHT: All = All(0x81);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pushes the length of the top stack item onto the stack
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_SIZE: All = All(0x82);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_INVERT: All = All(0x83);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_AND: All = All(0x84);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_OR: All = All(0x85);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_XOR: All = All(0x86);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pushes 1 if the inputs are exactly equal, 0 otherwise
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_EQUAL: All = All(0x87);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Returns success if the inputs are exactly equal, failure otherwise
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_EQUALVERIFY: All = All(0x88);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RESERVED1: All = All(0x89);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RESERVED2: All = All(0x8a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Increment the top stack element in place
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_1ADD: All = All(0x8b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Decrement the top stack element in place
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_1SUB: All = All(0x8c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_2MUL: All = All(0x8d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_2DIV: All = All(0x8e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Multiply the top stack item by -1 in place
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NEGATE: All = All(0x8f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Absolute value the top stack item in place
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_ABS: All = All(0x90);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Map 0 to 1 and everything else to 0, in place
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOT: All = All(0x91);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Map 0 to 0 and everything else to 1, in place
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_0NOTEQUAL: All = All(0x92);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop two stack items and push their sum
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_ADD: All = All(0x93);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop two stack items and push the second minus the top
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_SUB: All = All(0x94);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_MUL: All = All(0x95);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_DIV: All = All(0x96);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_MOD: All = All(0x97);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_LSHIFT: All = All(0x98);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fail the script unconditionally, does not even need to be executed
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RSHIFT: All = All(0x99);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two stack items and push 1 if both are nonzero, else push 0
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_BOOLAND: All = All(0x9a);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two stack items and push 1 if either is nonzero, else push 0
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_BOOLOR: All = All(0x9b);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two stack items and push 1 if both are numerically equal, else push 0
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NUMEQUAL: All = All(0x9c);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two stack items and return success if both are numerically equal, else return failure
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NUMEQUALVERIFY: All = All(0x9d);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two stack items and push 0 if both are numerically equal, else push 1
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NUMNOTEQUAL: All = All(0x9e);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two items; push 1 if the second is less than the top, 0 otherwise
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_LESSTHAN : All = All(0x9f);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two items; push 1 if the second is greater than the top, 0 otherwise
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_GREATERTHAN : All = All(0xa0);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two items; push 1 if the second is <= the top, 0 otherwise
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_LESSTHANOREQUAL : All = All(0xa1);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two items; push 1 if the second is >= the top, 0 otherwise
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_GREATERTHANOREQUAL : All = All(0xa2);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two items; push the smaller
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_MIN: All = All(0xa3);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top two items; push the larger
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_MAX: All = All(0xa4);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top three items; if the top is >= the second and < the third, push 1, otherwise push 0
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_WITHIN: All = All(0xa5);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top stack item and push its RIPEMD160 hash
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RIPEMD160: All = All(0xa6);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top stack item and push its SHA1 hash
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_SHA1: All = All(0xa7);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top stack item and push its SHA256 hash
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_SHA256: All = All(0xa8);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top stack item and push its RIPEMD(SHA256) hash
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_HASH160: All = All(0xa9);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop the top stack item and push its SHA256(SHA256) hash
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_HASH256: All = All(0xaa);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Ignore this and everything preceding when deciding what to sign when signature-checking
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_CODESEPARATOR: All = All(0xab);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// https://en.bitcoin.it/wiki/OP_CHECKSIG pushing 1/0 for success/failure
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_CHECKSIG: All = All(0xac);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// https://en.bitcoin.it/wiki/OP_CHECKSIG returning success/failure
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_CHECKSIGVERIFY: All = All(0xad);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pop N, N pubkeys, M, M signatures, a dummy (due to bug in reference code), and verify that all M signatures are valid.
|
|
|
|
/// Push 1 for "all valid", 0 otherwise
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_CHECKMULTISIG: All = All(0xae);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Like the above but return success/failure
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_CHECKMULTISIGVERIFY: All = All(0xaf);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP1: All = All(0xb0);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP2: All = All(0xb1);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP3: All = All(0xb2);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP4: All = All(0xb3);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP5: All = All(0xb4);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP6: All = All(0xb5);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP7: All = All(0xb6);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP8: All = All(0xb7);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP9: All = All(0xb8);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Does nothing
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_NOP10: All = All(0xb9);
|
2014-08-06 02:08:06 +00:00
|
|
|
// Every other opcode acts as OP_RETURN
|
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_186: All = All(0xba);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_187: All = All(0xbb);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_188: All = All(0xbc);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_189: All = All(0xbd);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_190: All = All(0xbe);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_191: All = All(0xbf);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_192: All = All(0xc0);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_193: All = All(0xc1);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_194: All = All(0xc2);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_195: All = All(0xc3);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_196: All = All(0xc4);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_197: All = All(0xc5);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_198: All = All(0xc6);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_199: All = All(0xc7);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_200: All = All(0xc8);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_201: All = All(0xc9);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_202: All = All(0xca);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_203: All = All(0xcb);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_204: All = All(0xcc);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_205: All = All(0xcd);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_206: All = All(0xce);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_207: All = All(0xcf);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_208: All = All(0xd0);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_209: All = All(0xd1);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_210: All = All(0xd2);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_211: All = All(0xd3);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_212: All = All(0xd4);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_213: All = All(0xd5);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_214: All = All(0xd6);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_215: All = All(0xd7);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_216: All = All(0xd8);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_217: All = All(0xd9);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_218: All = All(0xda);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_219: All = All(0xdb);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_220: All = All(0xdc);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_221: All = All(0xdd);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_222: All = All(0xde);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_223: All = All(0xdf);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_224: All = All(0xe0);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_225: All = All(0xe1);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_226: All = All(0xe2);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_227: All = All(0xe3);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_228: All = All(0xe4);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_229: All = All(0xe5);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_230: All = All(0xe6);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_231: All = All(0xe7);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_232: All = All(0xe8);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_233: All = All(0xe9);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_234: All = All(0xea);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_235: All = All(0xeb);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_236: All = All(0xec);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_237: All = All(0xed);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_238: All = All(0xee);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_239: All = All(0xef);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_240: All = All(0xf0);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_241: All = All(0xf1);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_242: All = All(0xf2);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_243: All = All(0xf3);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_244: All = All(0xf4);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_245: All = All(0xf5);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_246: All = All(0xf6);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_247: All = All(0xf7);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_248: All = All(0xf8);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_249: All = All(0xf9);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_250: All = All(0xfa);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_251: All = All(0xfb);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_252: All = All(0xfc);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_253: All = All(0xfd);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_254: All = All(0xfe);
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Synonym for OP_RETURN
|
2018-11-11 22:09:21 +00:00
|
|
|
pub const OP_RETURN_255: All = All(0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Debug for All {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.write_str("OP_")?;
|
|
|
|
match *self {
|
|
|
|
All(x) if x <= 75 => write!(f, "PUSHBYTES_{}", self.0),
|
|
|
|
All::OP_PUSHDATA1 => write!(f, "PUSHDATA1"),
|
|
|
|
All::OP_PUSHDATA2 => write!(f, "PUSHDATA2"),
|
|
|
|
All::OP_PUSHDATA4 => write!(f, "PUSHDATA4"),
|
|
|
|
All::OP_PUSHNUM_NEG1 => write!(f, "PUSHNUM_NEG1"),
|
|
|
|
All::OP_RESERVED => write!(f, "RESERVED"),
|
|
|
|
All(x) if x >= All::OP_PUSHNUM_1.0 && x <= All::OP_PUSHNUM_16.0 => write!(f, "PUSHNUM_{}", x - All::OP_PUSHNUM_1.0 + 1),
|
|
|
|
All::OP_NOP => write!(f, "NOP"),
|
|
|
|
All::OP_VER => write!(f, "VER"),
|
|
|
|
All::OP_IF => write!(f, "IF"),
|
|
|
|
All::OP_NOTIF => write!(f, "NOTIF"),
|
|
|
|
All::OP_VERIF => write!(f, "VERIF"),
|
|
|
|
All::OP_VERNOTIF => write!(f, "VERNOTIF"),
|
|
|
|
All::OP_ELSE => write!(f, "ELSE"),
|
|
|
|
All::OP_ENDIF => write!(f, "ENDIF"),
|
|
|
|
All::OP_VERIFY => write!(f, "VERIFY"),
|
|
|
|
All::OP_RETURN => write!(f, "RETURN"),
|
|
|
|
All::OP_TOALTSTACK => write!(f, "TOALTSTACK"),
|
|
|
|
All::OP_FROMALTSTACK => write!(f, "FROMALTSTACK"),
|
|
|
|
All::OP_2DROP => write!(f, "2DROP"),
|
|
|
|
All::OP_2DUP => write!(f, "2DUP"),
|
|
|
|
All::OP_3DUP => write!(f, "3DUP"),
|
|
|
|
All::OP_2OVER => write!(f, "2OVER"),
|
|
|
|
All::OP_2ROT => write!(f, "2ROT"),
|
|
|
|
All::OP_2SWAP => write!(f, "2SWAP"),
|
|
|
|
All::OP_IFDUP => write!(f, "IFDUP"),
|
|
|
|
All::OP_DEPTH => write!(f, "DEPTH"),
|
|
|
|
All::OP_DROP => write!(f, "DROP"),
|
|
|
|
All::OP_DUP => write!(f, "DUP"),
|
|
|
|
All::OP_NIP => write!(f, "NIP"),
|
|
|
|
All::OP_OVER => write!(f, "OVER"),
|
|
|
|
All::OP_PICK => write!(f, "PICK"),
|
|
|
|
All::OP_ROLL => write!(f, "ROLL"),
|
|
|
|
All::OP_ROT => write!(f, "ROT"),
|
|
|
|
All::OP_SWAP => write!(f, "SWAP"),
|
|
|
|
All::OP_TUCK => write!(f, "TUCK"),
|
|
|
|
All::OP_CAT => write!(f, "CAT"),
|
|
|
|
All::OP_SUBSTR => write!(f, "SUBSTR"),
|
|
|
|
All::OP_LEFT => write!(f, "LEFT"),
|
|
|
|
All::OP_RIGHT => write!(f, "RIGHT"),
|
|
|
|
All::OP_SIZE => write!(f, "SIZE"),
|
|
|
|
All::OP_INVERT => write!(f, "INVERT"),
|
|
|
|
All::OP_AND => write!(f, "AND"),
|
|
|
|
All::OP_OR => write!(f, "OR"),
|
|
|
|
All::OP_XOR => write!(f, "XOR"),
|
|
|
|
All::OP_EQUAL => write!(f, "EQUAL"),
|
|
|
|
All::OP_EQUALVERIFY => write!(f, "EQUALVERIFY"),
|
|
|
|
All::OP_RESERVED1 => write!(f, "RESERVED1"),
|
|
|
|
All::OP_RESERVED2 => write!(f, "RESERVED2"),
|
|
|
|
All::OP_1ADD => write!(f, "1ADD"),
|
|
|
|
All::OP_1SUB => write!(f, "1SUB"),
|
|
|
|
All::OP_2MUL => write!(f, "2MUL"),
|
|
|
|
All::OP_2DIV => write!(f, "2DIV"),
|
|
|
|
All::OP_NEGATE => write!(f, "NEGATE"),
|
|
|
|
All::OP_ABS => write!(f, "ABS"),
|
|
|
|
All::OP_NOT => write!(f, "NOT"),
|
|
|
|
All::OP_0NOTEQUAL => write!(f, "0NOTEQUAL"),
|
|
|
|
All::OP_ADD => write!(f, "ADD"),
|
|
|
|
All::OP_SUB => write!(f, "SUB"),
|
|
|
|
All::OP_MUL => write!(f, "MUL"),
|
|
|
|
All::OP_DIV => write!(f, "DIV"),
|
|
|
|
All::OP_MOD => write!(f, "MOD"),
|
|
|
|
All::OP_LSHIFT => write!(f, "LSHIFT"),
|
|
|
|
All::OP_RSHIFT => write!(f, "RSHIFT"),
|
|
|
|
All::OP_BOOLAND => write!(f, "BOOLAND"),
|
|
|
|
All::OP_BOOLOR => write!(f, "BOOLOR"),
|
|
|
|
All::OP_NUMEQUAL => write!(f, "NUMEQUAL"),
|
|
|
|
All::OP_NUMEQUALVERIFY => write!(f, "NUMEQUALVERIFY"),
|
|
|
|
All::OP_NUMNOTEQUAL => write!(f, "NUMNOTEQUAL"),
|
|
|
|
All::OP_LESSTHAN => write!(f, "LESSTHAN "),
|
|
|
|
All::OP_GREATERTHAN => write!(f, "GREATERTHAN "),
|
|
|
|
All::OP_LESSTHANOREQUAL => write!(f, "LESSTHANOREQUAL "),
|
|
|
|
All::OP_GREATERTHANOREQUAL => write!(f, "GREATERTHANOREQUAL "),
|
|
|
|
All::OP_MIN => write!(f, "MIN"),
|
|
|
|
All::OP_MAX => write!(f, "MAX"),
|
|
|
|
All::OP_WITHIN => write!(f, "WITHIN"),
|
|
|
|
All::OP_RIPEMD160 => write!(f, "RIPEMD160"),
|
|
|
|
All::OP_SHA1 => write!(f, "SHA1"),
|
|
|
|
All::OP_SHA256 => write!(f, "SHA256"),
|
|
|
|
All::OP_HASH160 => write!(f, "HASH160"),
|
|
|
|
All::OP_HASH256 => write!(f, "HASH256"),
|
|
|
|
All::OP_CODESEPARATOR => write!(f, "CODESEPARATOR"),
|
|
|
|
All::OP_CHECKSIG => write!(f, "CHECKSIG"),
|
|
|
|
All::OP_CHECKSIGVERIFY => write!(f, "CHECKSIGVERIFY"),
|
|
|
|
All::OP_CHECKMULTISIG => write!(f, "CHECKMULTISIG"),
|
|
|
|
All::OP_CHECKMULTISIGVERIFY => write!(f, "CHECKMULTISIGVERIFY"),
|
|
|
|
All(x) if x >= All::OP_NOP1.0 && x <= All::OP_NOP10.0 => write!(f, "NOP{}", x - All::OP_NOP1.0 + 1),
|
|
|
|
All(x) => write!(f, "RETURN_{}", x),
|
|
|
|
}
|
|
|
|
}
|
2015-04-05 03:13:19 +00:00
|
|
|
}
|
2014-08-06 02:08:06 +00:00
|
|
|
|
2015-04-05 03:13:19 +00:00
|
|
|
impl All {
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Classifies an Opcode into a broad class
|
|
|
|
#[inline]
|
2015-04-05 17:58:49 +00:00
|
|
|
pub fn classify(&self) -> Class {
|
2014-08-06 02:08:06 +00:00
|
|
|
// 17 opcodes
|
2015-04-05 03:13:19 +00:00
|
|
|
if *self == All::OP_VERIF || *self == All::OP_VERNOTIF ||
|
|
|
|
*self == All::OP_CAT || *self == All::OP_SUBSTR ||
|
|
|
|
*self == All::OP_LEFT || *self == All::OP_RIGHT ||
|
|
|
|
*self == All::OP_INVERT || *self == All::OP_AND ||
|
|
|
|
*self == All::OP_OR || *self == All::OP_XOR ||
|
|
|
|
*self == All::OP_2MUL || *self == All::OP_2DIV ||
|
|
|
|
*self == All::OP_MUL || *self == All::OP_DIV || *self == All::OP_MOD ||
|
|
|
|
*self == All::OP_LSHIFT || *self == All::OP_RSHIFT {
|
2015-04-05 17:58:49 +00:00
|
|
|
Class::IllegalOp
|
2014-08-06 02:08:06 +00:00
|
|
|
// 11 opcodes
|
2015-04-05 03:13:19 +00:00
|
|
|
} else if *self == All::OP_NOP ||
|
2018-11-11 22:09:21 +00:00
|
|
|
(All::OP_NOP1.0 <= self.0 &&
|
|
|
|
self.0 <= All::OP_NOP10.0) {
|
2015-04-05 17:58:49 +00:00
|
|
|
Class::NoOp
|
2014-08-06 02:08:06 +00:00
|
|
|
// 75 opcodes
|
2015-04-05 03:13:19 +00:00
|
|
|
} else if *self == All::OP_RESERVED || *self == All::OP_VER || *self == All::OP_RETURN ||
|
|
|
|
*self == All::OP_RESERVED1 || *self == All::OP_RESERVED2 ||
|
2018-11-11 22:09:21 +00:00
|
|
|
self.0 >= All::OP_RETURN_186.0 {
|
2015-04-05 17:58:49 +00:00
|
|
|
Class::ReturnOp
|
2014-08-06 02:08:06 +00:00
|
|
|
// 1 opcode
|
2015-04-05 03:13:19 +00:00
|
|
|
} else if *self == All::OP_PUSHNUM_NEG1 {
|
2015-04-05 17:58:49 +00:00
|
|
|
Class::PushNum(-1)
|
2014-08-06 02:08:06 +00:00
|
|
|
// 16 opcodes
|
2018-11-11 22:09:21 +00:00
|
|
|
} else if All::OP_PUSHNUM_1.0 <= self.0 &&
|
|
|
|
self.0 <= All::OP_PUSHNUM_16.0 {
|
|
|
|
Class::PushNum(1 + self.0 as i32 - All::OP_PUSHNUM_1.0 as i32)
|
2014-08-06 02:08:06 +00:00
|
|
|
// 76 opcodes
|
2018-11-11 22:09:21 +00:00
|
|
|
} else if self.0 <= All::OP_PUSHBYTES_75.0 {
|
|
|
|
Class::PushBytes(self.0 as u32)
|
2014-08-06 02:08:06 +00:00
|
|
|
// 60 opcodes
|
|
|
|
} else {
|
2018-11-11 22:19:05 +00:00
|
|
|
Class::Ordinary(Ordinary::try_from_all(*self).unwrap())
|
2014-08-06 02:08:06 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-11 22:09:21 +00:00
|
|
|
|
|
|
|
/// Encode as a byte
|
|
|
|
#[inline]
|
|
|
|
pub fn into_u8(&self) -> u8 {
|
|
|
|
self.0
|
|
|
|
}
|
2015-04-05 03:13:19 +00:00
|
|
|
}
|
2014-08-06 02:08:06 +00:00
|
|
|
|
2015-10-14 13:56:48 +00:00
|
|
|
impl From<u8> for All {
|
|
|
|
#[inline]
|
|
|
|
fn from(b: u8) -> All {
|
2018-11-11 22:09:21 +00:00
|
|
|
All(b)
|
2015-10-14 13:56:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-07 01:51:11 +00:00
|
|
|
display_from_debug!(All);
|
|
|
|
|
Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
instead
- Move network::serialize::Simple{En,De}coder to
consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
should never fail
2018-09-20 10:15:45 +00:00
|
|
|
impl<D: Decoder> Decodable<D> for All {
|
2014-08-06 02:08:06 +00:00
|
|
|
#[inline]
|
Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
instead
- Move network::serialize::Simple{En,De}coder to
consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
should never fail
2018-09-20 10:15:45 +00:00
|
|
|
fn consensus_decode(d: &mut D) -> Result<All, encode::Error> {
|
2018-08-12 16:47:31 +00:00
|
|
|
Ok(All::from(d.read_u8()?))
|
2014-08-06 02:08:06 +00:00
|
|
|
}
|
2015-04-05 03:13:19 +00:00
|
|
|
}
|
2014-08-06 02:08:06 +00:00
|
|
|
|
Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
instead
- Move network::serialize::Simple{En,De}coder to
consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
should never fail
2018-09-20 10:15:45 +00:00
|
|
|
impl<S: Encoder> Encodable<S> for All {
|
2014-08-06 02:08:06 +00:00
|
|
|
#[inline]
|
Move relevant names into consensus::encode
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
instead
- Move network::serialize::Simple{En,De}coder to
consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
should never fail
2018-09-20 10:15:45 +00:00
|
|
|
fn consensus_encode(&self, s: &mut S) -> Result<(), encode::Error> {
|
2018-11-11 22:09:21 +00:00
|
|
|
s.emit_u8(self.0)
|
2014-08-06 02:08:06 +00:00
|
|
|
}
|
2015-04-05 03:13:19 +00:00
|
|
|
}
|
2014-08-06 02:08:06 +00:00
|
|
|
|
2018-08-20 16:37:19 +00:00
|
|
|
#[cfg(feature = "serde")]
|
2015-04-06 00:10:37 +00:00
|
|
|
impl serde::Serialize for All {
|
2018-08-20 16:37:19 +00:00
|
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
|
where
|
|
|
|
S: serde::Serializer,
|
2015-04-06 00:10:37 +00:00
|
|
|
{
|
2018-08-20 16:37:19 +00:00
|
|
|
serializer.serialize_str(&self.to_string())
|
2015-04-06 00:10:37 +00:00
|
|
|
}
|
2014-08-06 02:08:06 +00:00
|
|
|
}
|
|
|
|
|
2015-04-05 03:13:19 +00:00
|
|
|
/// Empty stack is also FALSE
|
2015-04-05 19:43:44 +00:00
|
|
|
pub static OP_FALSE: All = All::OP_PUSHBYTES_0;
|
2015-04-05 03:13:19 +00:00
|
|
|
/// Number 1 is also TRUE
|
2015-04-05 19:43:44 +00:00
|
|
|
pub static OP_TRUE: All = All::OP_PUSHNUM_1;
|
2017-12-21 01:10:00 +00:00
|
|
|
/// check locktime verify
|
|
|
|
pub static OP_CLTV: All = All::OP_NOP2;
|
|
|
|
/// check sequence verify
|
|
|
|
pub static OP_CSV: All = All::OP_NOP3;
|
2015-04-05 03:13:19 +00:00
|
|
|
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Broad categories of opcodes with similar behavior
|
2015-04-10 23:15:57 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
2015-04-05 17:58:49 +00:00
|
|
|
pub enum Class {
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pushes the given number onto the stack
|
2015-04-07 22:51:57 +00:00
|
|
|
PushNum(i32),
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Pushes the given number of bytes onto the stack
|
2015-04-07 22:51:57 +00:00
|
|
|
PushBytes(u32),
|
2014-08-06 02:08:06 +00:00
|
|
|
/// Fails the script if executed
|
|
|
|
ReturnOp,
|
|
|
|
/// Fails the script even if not executed
|
|
|
|
IllegalOp,
|
|
|
|
/// Does nothing
|
|
|
|
NoOp,
|
|
|
|
/// Any opcode not covered above
|
2015-04-05 03:13:19 +00:00
|
|
|
Ordinary(Ordinary)
|
2014-08-06 02:08:06 +00:00
|
|
|
}
|
|
|
|
|
2015-04-07 01:51:11 +00:00
|
|
|
display_from_debug!(Class);
|
|
|
|
|
2018-08-20 16:37:19 +00:00
|
|
|
#[cfg(feature = "serde")]
|
2015-04-06 00:10:37 +00:00
|
|
|
impl serde::Serialize for Class {
|
2018-08-20 16:37:19 +00:00
|
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
|
where
|
|
|
|
S: serde::Serializer,
|
2015-04-06 00:10:37 +00:00
|
|
|
{
|
2018-08-20 16:37:19 +00:00
|
|
|
serializer.serialize_str(&self.to_string())
|
2014-08-17 02:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-18 18:16:01 +00:00
|
|
|
macro_rules! ordinary_opcode {
|
2014-08-06 02:08:06 +00:00
|
|
|
($($op:ident),*) => (
|
|
|
|
#[repr(u8)]
|
2014-08-10 19:58:15 +00:00
|
|
|
#[doc(hidden)]
|
2015-04-10 23:15:57 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
2015-04-05 03:13:19 +00:00
|
|
|
pub enum Ordinary {
|
2018-11-11 22:09:21 +00:00
|
|
|
$( $op = All::$op.0 ),*
|
2014-08-06 02:08:06 +00:00
|
|
|
}
|
2018-11-11 22:19:05 +00:00
|
|
|
|
|
|
|
impl Ordinary {
|
|
|
|
/// Try to create from an All
|
|
|
|
pub fn try_from_all(b: All) -> Option<Self> {
|
|
|
|
match b {
|
|
|
|
$( All::$op => { Some(Ordinary::$op) } ),*
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-06 02:08:06 +00:00
|
|
|
);
|
2015-01-18 18:16:01 +00:00
|
|
|
}
|
2014-08-06 02:08:06 +00:00
|
|
|
|
|
|
|
/// "Ordinary" opcodes -- should be 60 of these
|
2015-01-18 18:16:01 +00:00
|
|
|
ordinary_opcode! {
|
2014-08-06 02:08:06 +00:00
|
|
|
// pushdata
|
|
|
|
OP_PUSHDATA1, OP_PUSHDATA2, OP_PUSHDATA4,
|
|
|
|
// control flow
|
|
|
|
OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF, OP_VERIFY,
|
|
|
|
// stack
|
|
|
|
OP_TOALTSTACK, OP_FROMALTSTACK,
|
|
|
|
OP_2DROP, OP_2DUP, OP_3DUP, OP_2OVER, OP_2ROT, OP_2SWAP,
|
|
|
|
OP_DROP, OP_DUP, OP_NIP, OP_OVER, OP_PICK, OP_ROLL, OP_ROT, OP_SWAP, OP_TUCK,
|
|
|
|
OP_IFDUP, OP_DEPTH, OP_SIZE,
|
|
|
|
// equality
|
|
|
|
OP_EQUAL, OP_EQUALVERIFY,
|
|
|
|
// arithmetic
|
|
|
|
OP_1ADD, OP_1SUB, OP_NEGATE, OP_ABS, OP_NOT, OP_0NOTEQUAL,
|
|
|
|
OP_ADD, OP_SUB, OP_BOOLAND, OP_BOOLOR,
|
|
|
|
OP_NUMEQUAL, OP_NUMEQUALVERIFY, OP_NUMNOTEQUAL, OP_LESSTHAN,
|
|
|
|
OP_GREATERTHAN, OP_LESSTHANOREQUAL, OP_GREATERTHANOREQUAL,
|
|
|
|
OP_MIN, OP_MAX, OP_WITHIN,
|
|
|
|
// crypto
|
|
|
|
OP_RIPEMD160, OP_SHA1, OP_SHA256, OP_HASH160, OP_HASH256,
|
2014-08-11 04:37:12 +00:00
|
|
|
OP_CODESEPARATOR, OP_CHECKSIG, OP_CHECKSIGVERIFY,
|
|
|
|
OP_CHECKMULTISIG, OP_CHECKMULTISIGVERIFY
|
2015-01-18 18:16:01 +00:00
|
|
|
}
|
2014-07-18 13:56:17 +00:00
|
|
|
|
2018-11-11 22:09:21 +00:00
|
|
|
impl Ordinary {
|
|
|
|
/// Encode as a byte
|
|
|
|
#[inline]
|
|
|
|
pub fn into_u8(&self) -> u8 {
|
|
|
|
*self as u8
|
|
|
|
}
|
|
|
|
}
|