annotate src/script.h @ 776:f64d738664f8 draft

fix warnings: expression result unused [-Wunused-value] In the assert()s take advantage of the fact that string constants ("string") are effectively of type 'const char []', which when used in an expression yield a non-NULL pointer. An assertion that should always fail can thus be formulated as: assert(!"fail); An assertion where a text message should be added to the expression can be written as such: assert("message" && expression); Signed-off-by: Giel van Schijndel <me@mortis.eu>
author Giel van Schijndel <me@mortis.eu>
date Fri, 24 Jun 2011 19:56:23 +0200
parents 389b559a397f
children 62b46930aaa4 69323e942d0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
2 // Distributed under the MIT/X11 software license, see the accompanying
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
3 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
4 #ifndef H_BITCOIN_SCRIPT
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
5 #define H_BITCOIN_SCRIPT
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
6
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
7 #include "base58.h"
689
9df222fa1ef1 move wallet code to separate file
Pieter Wuille <pieter.wuille@gmail.com>
parents: 595
diff changeset
8 #include "keystore.h"
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
9
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
10 #include <string>
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
11 #include <vector>
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
12
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
13 class CTransaction;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
14
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
15 enum
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
16 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
17 SIGHASH_ALL = 1,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
18 SIGHASH_NONE = 2,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
19 SIGHASH_SINGLE = 3,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
20 SIGHASH_ANYONECANPAY = 0x80,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
21 };
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
22
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
23
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
24
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
25 enum opcodetype
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
26 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
27 // push value
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
28 OP_0=0,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
29 OP_FALSE=OP_0,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
30 OP_PUSHDATA1=76,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
31 OP_PUSHDATA2,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
32 OP_PUSHDATA4,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
33 OP_1NEGATE,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
34 OP_RESERVED,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
35 OP_1,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
36 OP_TRUE=OP_1,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
37 OP_2,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
38 OP_3,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
39 OP_4,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
40 OP_5,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
41 OP_6,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
42 OP_7,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
43 OP_8,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
44 OP_9,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
45 OP_10,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
46 OP_11,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
47 OP_12,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
48 OP_13,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
49 OP_14,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
50 OP_15,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
51 OP_16,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
52
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
53 // control
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
54 OP_NOP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
55 OP_VER,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
56 OP_IF,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
57 OP_NOTIF,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
58 OP_VERIF,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
59 OP_VERNOTIF,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
60 OP_ELSE,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
61 OP_ENDIF,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
62 OP_VERIFY,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
63 OP_RETURN,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
64
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
65 // stack ops
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
66 OP_TOALTSTACK,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
67 OP_FROMALTSTACK,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
68 OP_2DROP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
69 OP_2DUP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
70 OP_3DUP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
71 OP_2OVER,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
72 OP_2ROT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
73 OP_2SWAP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
74 OP_IFDUP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
75 OP_DEPTH,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
76 OP_DROP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
77 OP_DUP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
78 OP_NIP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
79 OP_OVER,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
80 OP_PICK,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
81 OP_ROLL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
82 OP_ROT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
83 OP_SWAP,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
84 OP_TUCK,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
85
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
86 // splice ops
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
87 OP_CAT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
88 OP_SUBSTR,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
89 OP_LEFT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
90 OP_RIGHT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
91 OP_SIZE,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
92
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
93 // bit logic
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
94 OP_INVERT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
95 OP_AND,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
96 OP_OR,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
97 OP_XOR,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
98 OP_EQUAL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
99 OP_EQUALVERIFY,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
100 OP_RESERVED1,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
101 OP_RESERVED2,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
102
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
103 // numeric
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
104 OP_1ADD,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
105 OP_1SUB,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
106 OP_2MUL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
107 OP_2DIV,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
108 OP_NEGATE,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
109 OP_ABS,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
110 OP_NOT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
111 OP_0NOTEQUAL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
112
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
113 OP_ADD,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
114 OP_SUB,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
115 OP_MUL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
116 OP_DIV,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
117 OP_MOD,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
118 OP_LSHIFT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
119 OP_RSHIFT,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
120
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
121 OP_BOOLAND,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
122 OP_BOOLOR,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
123 OP_NUMEQUAL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
124 OP_NUMEQUALVERIFY,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
125 OP_NUMNOTEQUAL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
126 OP_LESSTHAN,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
127 OP_GREATERTHAN,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
128 OP_LESSTHANOREQUAL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
129 OP_GREATERTHANOREQUAL,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
130 OP_MIN,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
131 OP_MAX,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
132
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
133 OP_WITHIN,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
134
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
135 // crypto
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
136 OP_RIPEMD160,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
137 OP_SHA1,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
138 OP_SHA256,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
139 OP_HASH160,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
140 OP_HASH256,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
141 OP_CODESEPARATOR,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
142 OP_CHECKSIG,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
143 OP_CHECKSIGVERIFY,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
144 OP_CHECKMULTISIG,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
145 OP_CHECKMULTISIGVERIFY,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
146
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
147 // expansion
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
148 OP_NOP1,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
149 OP_NOP2,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
150 OP_NOP3,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
151 OP_NOP4,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
152 OP_NOP5,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
153 OP_NOP6,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
154 OP_NOP7,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
155 OP_NOP8,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
156 OP_NOP9,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
157 OP_NOP10,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
158
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
159
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
160
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
161 // template matching params
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
162 OP_PUBKEYHASH = 0xfd,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
163 OP_PUBKEY = 0xfe,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
164
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
165 OP_INVALIDOPCODE = 0xff,
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
166 };
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
167
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
168
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
169
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
170
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
171
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
172
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
173
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
174
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
175 inline const char* GetOpName(opcodetype opcode)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
176 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
177 switch (opcode)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
178 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
179 // push value
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
180 case OP_0 : return "0";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
181 case OP_PUSHDATA1 : return "OP_PUSHDATA1";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
182 case OP_PUSHDATA2 : return "OP_PUSHDATA2";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
183 case OP_PUSHDATA4 : return "OP_PUSHDATA4";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
184 case OP_1NEGATE : return "-1";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
185 case OP_RESERVED : return "OP_RESERVED";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
186 case OP_1 : return "1";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
187 case OP_2 : return "2";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
188 case OP_3 : return "3";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
189 case OP_4 : return "4";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
190 case OP_5 : return "5";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
191 case OP_6 : return "6";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
192 case OP_7 : return "7";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
193 case OP_8 : return "8";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
194 case OP_9 : return "9";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
195 case OP_10 : return "10";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
196 case OP_11 : return "11";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
197 case OP_12 : return "12";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
198 case OP_13 : return "13";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
199 case OP_14 : return "14";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
200 case OP_15 : return "15";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
201 case OP_16 : return "16";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
202
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
203 // control
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
204 case OP_NOP : return "OP_NOP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
205 case OP_VER : return "OP_VER";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
206 case OP_IF : return "OP_IF";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
207 case OP_NOTIF : return "OP_NOTIF";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
208 case OP_VERIF : return "OP_VERIF";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
209 case OP_VERNOTIF : return "OP_VERNOTIF";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
210 case OP_ELSE : return "OP_ELSE";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
211 case OP_ENDIF : return "OP_ENDIF";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
212 case OP_VERIFY : return "OP_VERIFY";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
213 case OP_RETURN : return "OP_RETURN";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
214
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
215 // stack ops
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
216 case OP_TOALTSTACK : return "OP_TOALTSTACK";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
217 case OP_FROMALTSTACK : return "OP_FROMALTSTACK";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
218 case OP_2DROP : return "OP_2DROP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
219 case OP_2DUP : return "OP_2DUP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
220 case OP_3DUP : return "OP_3DUP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
221 case OP_2OVER : return "OP_2OVER";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
222 case OP_2ROT : return "OP_2ROT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
223 case OP_2SWAP : return "OP_2SWAP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
224 case OP_IFDUP : return "OP_IFDUP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
225 case OP_DEPTH : return "OP_DEPTH";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
226 case OP_DROP : return "OP_DROP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
227 case OP_DUP : return "OP_DUP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
228 case OP_NIP : return "OP_NIP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
229 case OP_OVER : return "OP_OVER";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
230 case OP_PICK : return "OP_PICK";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
231 case OP_ROLL : return "OP_ROLL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
232 case OP_ROT : return "OP_ROT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
233 case OP_SWAP : return "OP_SWAP";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
234 case OP_TUCK : return "OP_TUCK";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
235
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
236 // splice ops
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
237 case OP_CAT : return "OP_CAT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
238 case OP_SUBSTR : return "OP_SUBSTR";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
239 case OP_LEFT : return "OP_LEFT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
240 case OP_RIGHT : return "OP_RIGHT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
241 case OP_SIZE : return "OP_SIZE";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
242
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
243 // bit logic
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
244 case OP_INVERT : return "OP_INVERT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
245 case OP_AND : return "OP_AND";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
246 case OP_OR : return "OP_OR";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
247 case OP_XOR : return "OP_XOR";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
248 case OP_EQUAL : return "OP_EQUAL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
249 case OP_EQUALVERIFY : return "OP_EQUALVERIFY";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
250 case OP_RESERVED1 : return "OP_RESERVED1";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
251 case OP_RESERVED2 : return "OP_RESERVED2";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
252
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
253 // numeric
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
254 case OP_1ADD : return "OP_1ADD";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
255 case OP_1SUB : return "OP_1SUB";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
256 case OP_2MUL : return "OP_2MUL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
257 case OP_2DIV : return "OP_2DIV";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
258 case OP_NEGATE : return "OP_NEGATE";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
259 case OP_ABS : return "OP_ABS";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
260 case OP_NOT : return "OP_NOT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
261 case OP_0NOTEQUAL : return "OP_0NOTEQUAL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
262 case OP_ADD : return "OP_ADD";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
263 case OP_SUB : return "OP_SUB";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
264 case OP_MUL : return "OP_MUL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
265 case OP_DIV : return "OP_DIV";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
266 case OP_MOD : return "OP_MOD";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
267 case OP_LSHIFT : return "OP_LSHIFT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
268 case OP_RSHIFT : return "OP_RSHIFT";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
269 case OP_BOOLAND : return "OP_BOOLAND";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
270 case OP_BOOLOR : return "OP_BOOLOR";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
271 case OP_NUMEQUAL : return "OP_NUMEQUAL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
272 case OP_NUMEQUALVERIFY : return "OP_NUMEQUALVERIFY";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
273 case OP_NUMNOTEQUAL : return "OP_NUMNOTEQUAL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
274 case OP_LESSTHAN : return "OP_LESSTHAN";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
275 case OP_GREATERTHAN : return "OP_GREATERTHAN";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
276 case OP_LESSTHANOREQUAL : return "OP_LESSTHANOREQUAL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
277 case OP_GREATERTHANOREQUAL : return "OP_GREATERTHANOREQUAL";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
278 case OP_MIN : return "OP_MIN";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
279 case OP_MAX : return "OP_MAX";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
280 case OP_WITHIN : return "OP_WITHIN";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
281
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
282 // crypto
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
283 case OP_RIPEMD160 : return "OP_RIPEMD160";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
284 case OP_SHA1 : return "OP_SHA1";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
285 case OP_SHA256 : return "OP_SHA256";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
286 case OP_HASH160 : return "OP_HASH160";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
287 case OP_HASH256 : return "OP_HASH256";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
288 case OP_CODESEPARATOR : return "OP_CODESEPARATOR";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
289 case OP_CHECKSIG : return "OP_CHECKSIG";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
290 case OP_CHECKSIGVERIFY : return "OP_CHECKSIGVERIFY";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
291 case OP_CHECKMULTISIG : return "OP_CHECKMULTISIG";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
292 case OP_CHECKMULTISIGVERIFY : return "OP_CHECKMULTISIGVERIFY";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
293
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
294 // expanson
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
295 case OP_NOP1 : return "OP_NOP1";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
296 case OP_NOP2 : return "OP_NOP2";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
297 case OP_NOP3 : return "OP_NOP3";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
298 case OP_NOP4 : return "OP_NOP4";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
299 case OP_NOP5 : return "OP_NOP5";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
300 case OP_NOP6 : return "OP_NOP6";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
301 case OP_NOP7 : return "OP_NOP7";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
302 case OP_NOP8 : return "OP_NOP8";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
303 case OP_NOP9 : return "OP_NOP9";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
304 case OP_NOP10 : return "OP_NOP10";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
305
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
306
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
307
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
308 // template matching params
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
309 case OP_PUBKEYHASH : return "OP_PUBKEYHASH";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
310 case OP_PUBKEY : return "OP_PUBKEY";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
311
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
312 case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
313 default:
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
314 return "OP_UNKNOWN";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
315 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
316 };
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
317
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
318
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
319
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
320
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
321 inline std::string ValueString(const std::vector<unsigned char>& vch)
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
322 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
323 if (vch.size() <= 4)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
324 return strprintf("%d", CBigNum(vch).getint());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
325 else
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
326 return HexStr(vch);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
327 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
328
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
329 inline std::string StackString(const std::vector<std::vector<unsigned char> >& vStack)
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
330 {
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
331 std::string str;
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
332 BOOST_FOREACH(const std::vector<unsigned char>& vch, vStack)
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
333 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
334 if (!str.empty())
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
335 str += " ";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
336 str += ValueString(vch);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
337 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
338 return str;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
339 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
340
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
341
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
342
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
343
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
344
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
345
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
346
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
347
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
348
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
349 class CScript : public std::vector<unsigned char>
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
350 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
351 protected:
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
352 CScript& push_int64(int64 n)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
353 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
354 if (n == -1 || (n >= 1 && n <= 16))
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
355 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
356 push_back(n + (OP_1 - 1));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
357 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
358 else
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
359 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
360 CBigNum bn(n);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
361 *this << bn.getvch();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
362 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
363 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
364 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
365
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
366 CScript& push_uint64(uint64 n)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
367 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
368 if (n >= 1 && n <= 16)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
369 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
370 push_back(n + (OP_1 - 1));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
371 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
372 else
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
373 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
374 CBigNum bn(n);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
375 *this << bn.getvch();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
376 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
377 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
378 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
379
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
380 public:
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
381 CScript() { }
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
382 CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
383 CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { }
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
384 #ifndef _MSC_VER
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
385 CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { }
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
386 #endif
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
387
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
388 CScript& operator+=(const CScript& b)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
389 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
390 insert(end(), b.begin(), b.end());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
391 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
392 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
393
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
394 friend CScript operator+(const CScript& a, const CScript& b)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
395 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
396 CScript ret = a;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
397 ret += b;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
398 return ret;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
399 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
400
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
401
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
402 explicit CScript(char b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
403 explicit CScript(short b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
404 explicit CScript(int b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
405 explicit CScript(long b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
406 explicit CScript(int64 b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
407 explicit CScript(unsigned char b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
408 explicit CScript(unsigned int b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
409 explicit CScript(unsigned short b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
410 explicit CScript(unsigned long b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
411 explicit CScript(uint64 b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
412
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
413 explicit CScript(opcodetype b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
414 explicit CScript(const uint256& b) { operator<<(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
415 explicit CScript(const CBigNum& b) { operator<<(b); }
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
416 explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
417
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
418
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
419 CScript& operator<<(char b) { return push_int64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
420 CScript& operator<<(short b) { return push_int64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
421 CScript& operator<<(int b) { return push_int64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
422 CScript& operator<<(long b) { return push_int64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
423 CScript& operator<<(int64 b) { return push_int64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
424 CScript& operator<<(unsigned char b) { return push_uint64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
425 CScript& operator<<(unsigned int b) { return push_uint64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
426 CScript& operator<<(unsigned short b) { return push_uint64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
427 CScript& operator<<(unsigned long b) { return push_uint64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
428 CScript& operator<<(uint64 b) { return push_uint64(b); }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
429
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
430 CScript& operator<<(opcodetype opcode)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
431 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
432 if (opcode < 0 || opcode > 0xff)
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
433 throw std::runtime_error("CScript::operator<<() : invalid opcode");
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
434 insert(end(), (unsigned char)opcode);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
435 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
436 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
437
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
438 CScript& operator<<(const uint160& b)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
439 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
440 insert(end(), sizeof(b));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
441 insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
442 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
443 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
444
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
445 CScript& operator<<(const uint256& b)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
446 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
447 insert(end(), sizeof(b));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
448 insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
449 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
450 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
451
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
452 CScript& operator<<(const CBigNum& b)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
453 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
454 *this << b.getvch();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
455 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
456 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
457
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
458 CScript& operator<<(const std::vector<unsigned char>& b)
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
459 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
460 if (b.size() < OP_PUSHDATA1)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
461 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
462 insert(end(), (unsigned char)b.size());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
463 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
464 else if (b.size() <= 0xff)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
465 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
466 insert(end(), OP_PUSHDATA1);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
467 insert(end(), (unsigned char)b.size());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
468 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
469 else if (b.size() <= 0xffff)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
470 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
471 insert(end(), OP_PUSHDATA2);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
472 unsigned short nSize = b.size();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
473 insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
474 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
475 else
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
476 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
477 insert(end(), OP_PUSHDATA4);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
478 unsigned int nSize = b.size();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
479 insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
480 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
481 insert(end(), b.begin(), b.end());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
482 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
483 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
484
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
485 CScript& operator<<(const CScript& b)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
486 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
487 // I'm not sure if this should push the script or concatenate scripts.
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
488 // If there's ever a use for pushing a script onto a script, delete this member fn
776
f64d738664f8 fix warnings: expression result unused [-Wunused-value]
Giel van Schijndel <me@mortis.eu>
parents: 690
diff changeset
489 assert(!"warning: pushing a CScript onto a CScript with << is probably not intended, use + to concatenate");
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
490 return *this;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
491 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
492
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
493
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
494 bool GetOp(iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet)
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
495 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
496 // Wrapper so it can be called with either iterator or const_iterator
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
497 const_iterator pc2 = pc;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
498 bool fRet = GetOp2(pc2, opcodeRet, &vchRet);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
499 pc = begin() + (pc2 - begin());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
500 return fRet;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
501 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
502
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
503 bool GetOp(iterator& pc, opcodetype& opcodeRet)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
504 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
505 const_iterator pc2 = pc;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
506 bool fRet = GetOp2(pc2, opcodeRet, NULL);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
507 pc = begin() + (pc2 - begin());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
508 return fRet;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
509 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
510
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
511 bool GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet) const
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
512 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
513 return GetOp2(pc, opcodeRet, &vchRet);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
514 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
515
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
516 bool GetOp(const_iterator& pc, opcodetype& opcodeRet) const
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
517 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
518 return GetOp2(pc, opcodeRet, NULL);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
519 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
520
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
521 bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet) const
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
522 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
523 opcodeRet = OP_INVALIDOPCODE;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
524 if (pvchRet)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
525 pvchRet->clear();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
526 if (pc >= end())
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
527 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
528
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
529 // Read instruction
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
530 if (end() - pc < 1)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
531 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
532 unsigned int opcode = *pc++;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
533
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
534 // Immediate operand
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
535 if (opcode <= OP_PUSHDATA4)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
536 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
537 unsigned int nSize;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
538 if (opcode < OP_PUSHDATA1)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
539 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
540 nSize = opcode;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
541 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
542 else if (opcode == OP_PUSHDATA1)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
543 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
544 if (end() - pc < 1)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
545 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
546 nSize = *pc++;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
547 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
548 else if (opcode == OP_PUSHDATA2)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
549 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
550 if (end() - pc < 2)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
551 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
552 nSize = 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
553 memcpy(&nSize, &pc[0], 2);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
554 pc += 2;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
555 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
556 else if (opcode == OP_PUSHDATA4)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
557 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
558 if (end() - pc < 4)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
559 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
560 memcpy(&nSize, &pc[0], 4);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
561 pc += 4;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
562 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
563 if (end() - pc < nSize)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
564 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
565 if (pvchRet)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
566 pvchRet->assign(pc, pc + nSize);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
567 pc += nSize;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
568 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
569
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
570 opcodeRet = (opcodetype)opcode;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
571 return true;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
572 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
573
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
574
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
575 void FindAndDelete(const CScript& b)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
576 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
577 if (b.empty())
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
578 return;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
579 iterator pc = begin();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
580 opcodetype opcode;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
581 do
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
582 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
583 while (end() - pc >= b.size() && memcmp(&pc[0], &b[0], b.size()) == 0)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
584 erase(pc, pc + b.size());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
585 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
586 while (GetOp(pc, opcode));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
587 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
588
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
589
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
590 int GetSigOpCount() const
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
591 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
592 int n = 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
593 const_iterator pc = begin();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
594 while (pc < end())
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
595 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
596 opcodetype opcode;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
597 if (!GetOp(pc, opcode))
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
598 break;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
599 if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
600 n++;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
601 else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
602 n += 20;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
603 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
604 return n;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
605 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
606
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
607
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
608 bool IsPushOnly() const
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
609 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
610 if (size() > 200)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
611 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
612 const_iterator pc = begin();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
613 while (pc < end())
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
614 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
615 opcodetype opcode;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
616 if (!GetOp(pc, opcode))
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
617 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
618 if (opcode > OP_16)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
619 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
620 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
621 return true;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
622 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
623
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
624
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
625 uint160 GetBitcoinAddressHash160() const
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
626 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
627 opcodetype opcode;
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
628 std::vector<unsigned char> vch;
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
629 CScript::const_iterator pc = begin();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
630 if (!GetOp(pc, opcode, vch) || opcode != OP_DUP) return 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
631 if (!GetOp(pc, opcode, vch) || opcode != OP_HASH160) return 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
632 if (!GetOp(pc, opcode, vch) || vch.size() != sizeof(uint160)) return 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
633 uint160 hash160 = uint160(vch);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
634 if (!GetOp(pc, opcode, vch) || opcode != OP_EQUALVERIFY) return 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
635 if (!GetOp(pc, opcode, vch) || opcode != OP_CHECKSIG) return 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
636 if (pc != end()) return 0;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
637 return hash160;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
638 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
639
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
640 std::string GetBitcoinAddress() const
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
641 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
642 uint160 hash160 = GetBitcoinAddressHash160();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
643 if (hash160 == 0)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
644 return "";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
645 return Hash160ToAddress(hash160);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
646 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
647
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
648 void SetBitcoinAddress(const uint160& hash160)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
649 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
650 this->clear();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
651 *this << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
652 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
653
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
654 void SetBitcoinAddress(const std::vector<unsigned char>& vchPubKey)
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
655 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
656 SetBitcoinAddress(Hash160(vchPubKey));
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
657 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
658
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
659 bool SetBitcoinAddress(const std::string& strAddress)
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
660 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
661 this->clear();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
662 uint160 hash160;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
663 if (!AddressToHash160(strAddress, hash160))
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
664 return false;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
665 SetBitcoinAddress(hash160);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
666 return true;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
667 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
668
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
669
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
670 void PrintHex() const
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
671 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
672 printf("CScript(%s)\n", HexStr(begin(), end(), true).c_str());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
673 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
674
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
675 std::string ToString() const
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
676 {
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
677 std::string str;
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
678 opcodetype opcode;
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
679 std::vector<unsigned char> vch;
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
680 const_iterator pc = begin();
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
681 while (pc < end())
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
682 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
683 if (!str.empty())
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
684 str += " ";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
685 if (!GetOp(pc, opcode, vch))
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
686 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
687 str += "[error]";
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
688 return str;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
689 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
690 if (0 <= opcode && opcode <= OP_PUSHDATA4)
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
691 str += ValueString(vch);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
692 else
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
693 str += GetOpName(opcode);
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
694 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
695 return str;
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
696 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
697
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
698 void print() const
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
699 {
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
700 printf("%s\n", ToString().c_str());
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
701 }
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
702 };
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
703
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
704
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
705
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
706
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
707
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
708
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
709
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
710
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
711 bool IsStandard(const CScript& scriptPubKey);
690
389b559a397f CWallet class
Pieter Wuille <pieter.wuille@gmail.com>
parents: 689
diff changeset
712 bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey);
389b559a397f CWallet class
Pieter Wuille <pieter.wuille@gmail.com>
parents: 689
diff changeset
713 bool ExtractPubKey(const CScript& scriptPubKey, const CKeyStore* pkeystore, std::vector<unsigned char>& vchPubKeyRet);
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
714 bool ExtractHash160(const CScript& scriptPubKey, uint160& hash160Ret);
690
389b559a397f CWallet class
Pieter Wuille <pieter.wuille@gmail.com>
parents: 689
diff changeset
715 bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL, CScript scriptPrereq=CScript());
575
1a0476fe825f directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff changeset
716 bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int nHashType=0);
595
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
717
e630bbb11629 make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents: 575
diff changeset
718 #endif