Guest User

Untitled

a guest
Apr 21st, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <assert.h>
  3.  
  4. enum opcodetype
  5. {
  6.     // push value
  7.     OP_0=0,
  8.     OP_FALSE=OP_0,
  9.     OP_PUSHDATA1=76,
  10.     OP_PUSHDATA2,
  11.     OP_PUSHDATA4,
  12.     OP_1NEGATE,
  13.     OP_RESERVED,
  14.     OP_1,
  15.     OP_TRUE=OP_1,
  16.     OP_2,
  17.     OP_3,
  18.     OP_4,
  19.     OP_5,
  20.     OP_6,
  21.     OP_7,
  22.     OP_8,
  23.     OP_9,
  24.     OP_10,
  25.     OP_11,
  26.     OP_12,
  27.     OP_13,
  28.     OP_14,
  29.     OP_15,
  30.     OP_16,
  31.  
  32.     // control
  33.     OP_NOP,
  34.     OP_VER,
  35.     OP_IF,
  36.     OP_NOTIF,
  37.     OP_VERIF,
  38.     OP_VERNOTIF,
  39.     OP_ELSE,
  40.     OP_ENDIF,
  41.     OP_VERIFY,
  42.     OP_RETURN,
  43.  
  44.     // stack ops
  45.     OP_TOALTSTACK,
  46.     OP_FROMALTSTACK,
  47.     OP_2DROP,
  48.     OP_2DUP,
  49.     OP_3DUP,
  50.     OP_2OVER,
  51.     OP_2ROT,
  52.     OP_2SWAP,
  53.     OP_IFDUP,
  54.     OP_DEPTH,
  55.     OP_DROP,
  56.     OP_DUP,
  57.     OP_NIP,
  58.     OP_OVER,
  59.     OP_PICK,
  60.     OP_ROLL,
  61.     OP_ROT,
  62.     OP_SWAP,
  63.     OP_TUCK,
  64.  
  65.     // splice ops
  66.     OP_CAT,
  67.     OP_SUBSTR,
  68.     OP_LEFT,
  69.     OP_RIGHT,
  70.     OP_SIZE,
  71.  
  72.     // bit logic
  73.     OP_INVERT,
  74.     OP_AND,
  75.     OP_OR,
  76.     OP_XOR,
  77.     OP_EQUAL,
  78.     OP_EQUALVERIFY,
  79.     OP_RESERVED1,
  80.     OP_RESERVED2,
  81.  
  82.     // numeric
  83.     OP_1ADD,
  84.     OP_1SUB,
  85.     OP_2MUL,
  86.     OP_2DIV,
  87.     OP_NEGATE,
  88.     OP_ABS,
  89.     OP_NOT,
  90.     OP_0NOTEQUAL,
  91.  
  92.     OP_ADD,
  93.     OP_SUB,
  94.     OP_MUL,
  95.     OP_DIV,
  96.     OP_MOD,
  97.     OP_LSHIFT,
  98.     OP_RSHIFT,
  99.  
  100.     OP_BOOLAND,
  101.     OP_BOOLOR,
  102.     OP_NUMEQUAL,
  103.     OP_NUMEQUALVERIFY,
  104.     OP_NUMNOTEQUAL,
  105.     OP_LESSTHAN,
  106.     OP_GREATERTHAN,
  107.     OP_LESSTHANOREQUAL,
  108.     OP_GREATERTHANOREQUAL,
  109.     OP_MIN,
  110.     OP_MAX,
  111.  
  112.     OP_WITHIN,
  113.  
  114.     // crypto
  115.     OP_RIPEMD160,
  116.     OP_SHA1,
  117.     OP_SHA256,
  118.     OP_HASH160,
  119.     OP_HASH256,
  120.     OP_CODESEPARATOR,
  121.     OP_CHECKSIG,
  122.     OP_CHECKSIGVERIFY,
  123.     OP_CHECKMULTISIG,
  124.     OP_CHECKMULTISIGVERIFY,
  125.  
  126.     // expansion
  127.     OP_NOP1,
  128.     OP_NOP2,
  129.     OP_NOP3,
  130.     OP_NOP4,
  131.     OP_NOP5,
  132.     OP_NOP6,
  133.     OP_NOP7,
  134.     OP_NOP8,
  135.     OP_NOP9,
  136.     OP_NOP10,
  137.  
  138.  
  139.  
  140.     // template matching params
  141.     OP_SMALLINTEGER = 0xfa,
  142.     OP_PUBKEYS = 0xfb,
  143.     OP_PUBKEYHASH = 0xfd,
  144.     OP_PUBKEY = 0xfe,
  145.  
  146.     OP_INVALIDOPCODE = 0xff,
  147. };
  148.  
  149. enum opcodetype_new
  150. {
  151.     // push value
  152.     NEW_OP_0 = 0x00,
  153.     NEW_OP_FALSE = NEW_OP_0,
  154.     NEW_OP_PUSHDATA1 = 0x4c,
  155.     NEW_OP_PUSHDATA2 = 0x4d,
  156.     NEW_OP_PUSHDATA4 = 0x4e,
  157.     NEW_OP_1NEGATE = 0x4f,
  158.     NEW_OP_RESERVED = 0x50,
  159.     NEW_OP_1 = 0x51,
  160.     NEW_OP_TRUE=NEW_OP_1,
  161.     NEW_OP_2 = 0x52,
  162.     NEW_OP_3 = 0x53,
  163.     NEW_OP_4 = 0x54,
  164.     NEW_OP_5 = 0x55,
  165.     NEW_OP_6 = 0x56,
  166.     NEW_OP_7 = 0x57,
  167.     NEW_OP_8 = 0x58,
  168.     NEW_OP_9 = 0x59,
  169.     NEW_OP_10 = 0x5a,
  170.     NEW_OP_11 = 0x5b,
  171.     NEW_OP_12 = 0x5c,
  172.     NEW_OP_13 = 0x5d,
  173.     NEW_OP_14 = 0x5e,
  174.     NEW_OP_15 = 0x5f,
  175.     NEW_OP_16 = 0x60,
  176.  
  177.     // control
  178.     NEW_OP_NOP = 0x61,
  179.     NEW_OP_VER = 0x62,
  180.     NEW_OP_IF = 0x63,
  181.     NEW_OP_NOTIF = 0x64,
  182.     NEW_OP_VERIF = 0x65,
  183.     NEW_OP_VERNOTIF = 0x66,
  184.     NEW_OP_ELSE = 0x67,
  185.     NEW_OP_ENDIF = 0x68,
  186.     NEW_OP_VERIFY = 0x69,
  187.     NEW_OP_RETURN = 0x6a,
  188.  
  189.     // stack ops
  190.     NEW_OP_TOALTSTACK = 0x6b,
  191.     NEW_OP_FROMALTSTACK = 0x6c,
  192.     NEW_OP_2DROP = 0x6d,
  193.     NEW_OP_2DUP = 0x6e,
  194.     NEW_OP_3DUP = 0x6f,
  195.     NEW_OP_2OVER = 0x70,
  196.     NEW_OP_2ROT = 0x71,
  197.     NEW_OP_2SWAP = 0x72,
  198.     NEW_OP_IFDUP = 0x73,
  199.     NEW_OP_DEPTH = 0x74,
  200.     NEW_OP_DROP = 0x75,
  201.     NEW_OP_DUP = 0x76,
  202.     NEW_OP_NIP = 0x77,
  203.     NEW_OP_OVER = 0x78,
  204.     NEW_OP_PICK = 0x79,
  205.     NEW_OP_ROLL = 0x7a,
  206.     NEW_OP_ROT = 0x7b,
  207.     NEW_OP_SWAP = 0x7c,
  208.     NEW_OP_TUCK = 0x7d,
  209.  
  210.     // splice ops
  211.     NEW_OP_CAT = 0x7e,
  212.     NEW_OP_SUBSTR = 0x7f,
  213.     NEW_OP_LEFT = 0x80,
  214.     NEW_OP_RIGHT = 0x81,
  215.     NEW_OP_SIZE = 0x82,
  216.  
  217.     // bit logic
  218.     NEW_OP_INVERT = 0x83,
  219.     NEW_OP_AND = 0x84,
  220.     NEW_OP_OR = 0x85,
  221.     NEW_OP_XOR = 0x86,
  222.     NEW_OP_EQUAL = 0x87,
  223.     NEW_OP_EQUALVERIFY = 0x88,
  224.     NEW_OP_RESERVED1 = 0x89,
  225.     NEW_OP_RESERVED2 = 0x8a,
  226.  
  227.     // numeric
  228.     NEW_OP_1ADD = 0x8b,
  229.     NEW_OP_1SUB = 0x8c,
  230.     NEW_OP_2MUL = 0x8d,
  231.     NEW_OP_2DIV = 0x8e,
  232.     NEW_OP_NEGATE = 0x8f,
  233.     NEW_OP_ABS = 0x90,
  234.     NEW_OP_NOT = 0x91,
  235.     NEW_OP_0NOTEQUAL = 0x92,
  236.  
  237.     NEW_OP_ADD = 0x93,
  238.     NEW_OP_SUB = 0x94,
  239.     NEW_OP_MUL = 0x95,
  240.     NEW_OP_DIV = 0x96,
  241.     NEW_OP_MOD = 0x97,
  242.     NEW_OP_LSHIFT = 0x98,
  243.     NEW_OP_RSHIFT = 0x99,
  244.  
  245.     NEW_OP_BOOLAND = 0x9a,
  246.     NEW_OP_BOOLOR = 0x9b,
  247.     NEW_OP_NUMEQUAL = 0x9c,
  248.     NEW_OP_NUMEQUALVERIFY = 0x9d,
  249.     NEW_OP_NUMNOTEQUAL = 0x9e,
  250.     NEW_OP_LESSTHAN = 0x9f,
  251.     NEW_OP_GREATERTHAN = 0xa0,
  252.     NEW_OP_LESSTHANOREQUAL = 0xa1,
  253.     NEW_OP_GREATERTHANOREQUAL = 0xa2,
  254.     NEW_OP_MIN = 0xa3,
  255.     NEW_OP_MAX = 0xa4,
  256.  
  257.     NEW_OP_WITHIN = 0xa5,
  258.  
  259.     // crypto
  260.     NEW_OP_RIPEMD160 = 0xa6,
  261.     NEW_OP_SHA1 = 0xa7,
  262.     NEW_OP_SHA256 = 0xa8,
  263.     NEW_OP_HASH160 = 0xa9,
  264.     NEW_OP_HASH256 = 0xaa,
  265.     NEW_OP_CODESEPARATOR = 0xab,
  266.     NEW_OP_CHECKSIG = 0xac,
  267.     NEW_OP_CHECKSIGVERIFY = 0xad,
  268.     NEW_OP_CHECKMULTISIG = 0xae,
  269.     NEW_OP_CHECKMULTISIGVERIFY = 0xaf,
  270.  
  271.     // expansion
  272.     NEW_OP_NOP1 = 0xb0,
  273.     NEW_OP_NOP2 = 0xb1,
  274.     NEW_OP_NOP3 = 0xb2,
  275.     NEW_OP_NOP4 = 0xb3,
  276.     NEW_OP_NOP5 = 0xb4,
  277.     NEW_OP_NOP6 = 0xb5,
  278.     NEW_OP_NOP7 = 0xb6,
  279.     NEW_OP_NOP8 = 0xb7,
  280.     NEW_OP_NOP9 = 0xb8,
  281.     NEW_OP_NOP10 = 0xb9,
  282.  
  283.  
  284.  
  285.     // template matching params
  286.     NEW_OP_SMALLINTEGER = 0xfa,
  287.     NEW_OP_PUBKEYS = 0xfb,
  288.     NEW_OP_PUBKEYHASH = 0xfd,
  289.     NEW_OP_PUBKEY = 0xfe,
  290.  
  291.     NEW_OP_INVALIDOPCODE = 0xff,
  292. };
  293.  
  294.  
  295. int main()
  296. {
  297.     assert(NEW_OP_0 == OP_0);
  298.     assert(NEW_OP_FALSE == OP_FALSE);
  299.     assert(NEW_OP_PUSHDATA1 == OP_PUSHDATA1);
  300.     assert(NEW_OP_PUSHDATA2 == OP_PUSHDATA2);
  301.     assert(NEW_OP_PUSHDATA4 == OP_PUSHDATA4);
  302.     assert(NEW_OP_1NEGATE == OP_1NEGATE);
  303.     assert(NEW_OP_RESERVED == OP_RESERVED);
  304.     assert(NEW_OP_1 == OP_1);
  305.     assert(NEW_OP_TRUE == OP_TRUE);
  306.     assert(NEW_OP_2 == OP_2);
  307.     assert(NEW_OP_3 == OP_3);
  308.     assert(NEW_OP_4 == OP_4);
  309.     assert(NEW_OP_5 == OP_5);
  310.     assert(NEW_OP_6 == OP_6);
  311.     assert(NEW_OP_7 == OP_7);
  312.     assert(NEW_OP_8 == OP_8);
  313.     assert(NEW_OP_9 == OP_9);
  314.     assert(NEW_OP_10 == OP_10);
  315.     assert(NEW_OP_11 == OP_11);
  316.     assert(NEW_OP_12 == OP_12);
  317.     assert(NEW_OP_13 == OP_13);
  318.     assert(NEW_OP_14 == OP_14);
  319.     assert(NEW_OP_15 == OP_15);
  320.     assert(NEW_OP_16 == OP_16);
  321.  
  322.     // control
  323.     assert(NEW_OP_NOP == OP_NOP);
  324.     assert(NEW_OP_VER == OP_VER);
  325.     assert(NEW_OP_IF == OP_IF);
  326.     assert(NEW_OP_NOTIF == OP_NOTIF);
  327.     assert(NEW_OP_VERIF == OP_VERIF);
  328.     assert(NEW_OP_VERNOTIF == OP_VERNOTIF);
  329.     assert(NEW_OP_ELSE == OP_ELSE);
  330.     assert(NEW_OP_ENDIF == OP_ENDIF);
  331.     assert(NEW_OP_VERIFY == OP_VERIFY);
  332.     assert(NEW_OP_RETURN == OP_RETURN);
  333.  
  334.     // stack ops
  335.     assert(NEW_OP_TOALTSTACK == OP_TOALTSTACK);
  336.     assert(NEW_OP_FROMALTSTACK == OP_FROMALTSTACK);
  337.     assert(NEW_OP_2DROP == OP_2DROP);
  338.     assert(NEW_OP_2DUP == OP_2DUP);
  339.     assert(NEW_OP_3DUP == OP_3DUP);
  340.     assert(NEW_OP_2OVER == OP_2OVER);
  341.     assert(NEW_OP_2ROT == OP_2ROT);
  342.     assert(NEW_OP_2SWAP == OP_2SWAP);
  343.     assert(NEW_OP_IFDUP == OP_IFDUP);
  344.     assert(NEW_OP_DEPTH == OP_DEPTH);
  345.     assert(NEW_OP_DROP == OP_DROP);
  346.     assert(NEW_OP_DUP == OP_DUP);
  347.     assert(NEW_OP_NIP == OP_NIP);
  348.     assert(NEW_OP_OVER == OP_OVER);
  349.     assert(NEW_OP_PICK == OP_PICK);
  350.     assert(NEW_OP_ROLL == OP_ROLL);
  351.     assert(NEW_OP_ROT == OP_ROT);
  352.     assert(NEW_OP_SWAP == OP_SWAP);
  353.     assert(NEW_OP_TUCK == OP_TUCK);
  354.  
  355.     // splice ops
  356.     assert(NEW_OP_CAT == OP_CAT);
  357.     assert(NEW_OP_SUBSTR == OP_SUBSTR);
  358.     assert(NEW_OP_LEFT == OP_LEFT);
  359.     assert(NEW_OP_RIGHT == OP_RIGHT);
  360.     assert(NEW_OP_SIZE == OP_SIZE);
  361.  
  362.     // bit logic
  363.     assert(NEW_OP_INVERT == OP_INVERT);
  364.     assert(NEW_OP_AND == OP_AND);
  365.     assert(NEW_OP_OR == OP_OR);
  366.     assert(NEW_OP_XOR == OP_XOR);
  367.     assert(NEW_OP_EQUAL == OP_EQUAL);
  368.     assert(NEW_OP_EQUALVERIFY == OP_EQUALVERIFY);
  369.     assert(NEW_OP_RESERVED1 == OP_RESERVED1);
  370.     assert(NEW_OP_NEGATE == OP_NEGATE);
  371.     assert(NEW_OP_ABS == OP_ABS);
  372.     assert(NEW_OP_NOT == OP_NOT);
  373.     assert(NEW_OP_0NOTEQUAL == OP_0NOTEQUAL);
  374.  
  375.     assert(NEW_OP_ADD == OP_ADD);
  376.     assert(NEW_OP_SUB == OP_SUB);
  377.     assert(NEW_OP_MUL == OP_MUL);
  378.     assert(NEW_OP_DIV == OP_DIV);
  379.     assert(NEW_OP_MOD == OP_MOD);
  380.     assert(NEW_OP_LSHIFT == OP_LSHIFT);
  381.     assert(NEW_OP_RSHIFT == OP_RSHIFT);
  382.  
  383.     assert(NEW_OP_BOOLAND == OP_BOOLAND);
  384.     assert(NEW_OP_BOOLOR == OP_BOOLOR);
  385.     assert(NEW_OP_NUMEQUAL == OP_NUMEQUAL);
  386.     assert(NEW_OP_NUMEQUALVERIFY == OP_NUMEQUALVERIFY);
  387.     assert(NEW_OP_NUMNOTEQUAL == OP_NUMNOTEQUAL);
  388.     assert(NEW_OP_LESSTHAN == OP_LESSTHAN);
  389.     assert(NEW_OP_GREATERTHAN == OP_GREATERTHAN);
  390.     assert(NEW_OP_LESSTHANOREQUAL == OP_LESSTHANOREQUAL);
  391.     assert(NEW_OP_GREATERTHANOREQUAL == OP_GREATERTHANOREQUAL);
  392.     assert(NEW_OP_MIN == OP_MIN);
  393.     assert(NEW_OP_MAX == OP_MAX);
  394.  
  395.     assert(NEW_OP_WITHIN == OP_WITHIN);
  396.  
  397.     // crypto
  398.     assert(NEW_OP_RIPEMD160 == OP_RIPEMD160);
  399.     assert(NEW_OP_SHA1 == OP_SHA1);
  400.     assert(NEW_OP_SHA256 == OP_SHA256);
  401.     assert(NEW_OP_HASH160 == OP_HASH160);
  402.     assert(NEW_OP_HASH256 == OP_HASH256);
  403.     assert(NEW_OP_CODESEPARATOR == OP_CODESEPARATOR);
  404.     assert(NEW_OP_CHECKSIG == OP_CHECKSIG);
  405.     assert(NEW_OP_CHECKSIGVERIFY == OP_CHECKSIGVERIFY);
  406.     assert(NEW_OP_CHECKMULTISIG == OP_CHECKMULTISIG);
  407.     assert(NEW_OP_CHECKMULTISIGVERIFY == OP_CHECKMULTISIGVERIFY);
  408.  
  409.     // expansion
  410.     assert(NEW_OP_NOP1 == OP_NOP1);
  411.     assert(NEW_OP_NOP2 == OP_NOP2);
  412.     assert(NEW_OP_NOP3 == OP_NOP3);
  413.     assert(NEW_OP_NOP4 == OP_NOP4);
  414.     assert(NEW_OP_NOP5 == OP_NOP5);
  415.     assert(NEW_OP_NOP6 == OP_NOP6);
  416.     assert(NEW_OP_NOP7 == OP_NOP7);
  417.     assert(NEW_OP_NOP8 == OP_NOP8);
  418.     assert(NEW_OP_NOP9 == OP_NOP9);
  419.     assert(NEW_OP_NOP10 == OP_NOP10);
  420.  
  421.  
  422.  
  423.     // template matching params
  424.     assert(NEW_OP_SMALLINTEGER == OP_SMALLINTEGER);
  425.     assert(NEW_OP_PUBKEYS == OP_PUBKEYS);
  426.     assert(NEW_OP_PUBKEYHASH == OP_PUBKEYHASH);
  427.     assert(NEW_OP_PUBKEY == OP_PUBKEY);
  428.  
  429.     assert(NEW_OP_INVALIDOPCODE == OP_INVALIDOPCODE);
  430.  
  431.  
  432.     printf("success\n");
  433. }
Advertisement
Add Comment
Please, Sign In to add comment