Bitcoin ABC 0.32.4
P2P Digital Currency
script.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_SCRIPT_SCRIPT_H
7#define BITCOIN_SCRIPT_SCRIPT_H
8
9#include <attributes.h>
10#include <crypto/common.h>
11#include <prevector.h>
12#include <script/intmath.h>
13#include <serialize.h>
14
15#include <cassert>
16#include <climits>
17#include <cstdint>
18#include <cstring>
19#include <limits>
20#include <stdexcept>
21#include <string>
22#include <vector>
23
24// Maximum number of bytes pushable to the stack
25static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520;
26
27// Maximum number of non-push operations per script
28static const int MAX_OPS_PER_SCRIPT = 201;
29
30// Maximum number of public keys per multisig
31static const int MAX_PUBKEYS_PER_MULTISIG = 20;
32
33// Maximum script length in bytes
34static const int MAX_SCRIPT_SIZE = 10000;
35
36// Maximum number of values on script interpreter stack
37static const int MAX_STACK_SIZE = 1000;
38
39// Maximum byte size of integers for arithmetic opcodes when interpreting Script
40constexpr size_t MAX_SCRIPTNUM_BYTE_SIZE = 8;
41
42// Threshold for nLockTime: below this value it is interpreted as block number,
43// otherwise as UNIX timestamp. Thresold is Tue Nov 5 00:53:20 1985 UTC
44static const unsigned int LOCKTIME_THRESHOLD = 500000000;
45
46template <typename T> std::vector<uint8_t> ToByteVector(const T &in) {
47 return std::vector<uint8_t>(in.begin(), in.end());
48}
49
52 // push value
53 OP_0 = 0x00,
58 OP_1NEGATE = 0x4f,
60 OP_1 = 0x51,
62 OP_2 = 0x52,
63 OP_3 = 0x53,
64 OP_4 = 0x54,
65 OP_5 = 0x55,
66 OP_6 = 0x56,
67 OP_7 = 0x57,
68 OP_8 = 0x58,
69 OP_9 = 0x59,
70 OP_10 = 0x5a,
71 OP_11 = 0x5b,
72 OP_12 = 0x5c,
73 OP_13 = 0x5d,
74 OP_14 = 0x5e,
75 OP_15 = 0x5f,
76 OP_16 = 0x60,
77
78 // control
79 OP_NOP = 0x61,
80 OP_VER = 0x62,
81 OP_IF = 0x63,
82 OP_NOTIF = 0x64,
83 OP_VERIF = 0x65,
85 OP_ELSE = 0x67,
86 OP_ENDIF = 0x68,
87 OP_VERIFY = 0x69,
88 OP_RETURN = 0x6a,
89
90 // stack ops
93 OP_2DROP = 0x6d,
94 OP_2DUP = 0x6e,
95 OP_3DUP = 0x6f,
96 OP_2OVER = 0x70,
97 OP_2ROT = 0x71,
98 OP_2SWAP = 0x72,
99 OP_IFDUP = 0x73,
100 OP_DEPTH = 0x74,
101 OP_DROP = 0x75,
102 OP_DUP = 0x76,
103 OP_NIP = 0x77,
104 OP_OVER = 0x78,
105 OP_PICK = 0x79,
106 OP_ROLL = 0x7a,
107 OP_ROT = 0x7b,
108 OP_SWAP = 0x7c,
109 OP_TUCK = 0x7d,
110
111 // splice ops
112 OP_CAT = 0x7e,
113 OP_SPLIT = 0x7f, // after monolith upgrade (May 2018)
114 OP_NUM2BIN = 0x80, // after monolith upgrade (May 2018)
115 OP_BIN2NUM = 0x81, // after monolith upgrade (May 2018)
116 OP_SIZE = 0x82,
117
118 // bit logic
119 OP_INVERT = 0x83,
120 OP_AND = 0x84,
121 OP_OR = 0x85,
122 OP_XOR = 0x86,
123 OP_EQUAL = 0x87,
127
128 // numeric
129 OP_1ADD = 0x8b,
130 OP_1SUB = 0x8c,
131 OP_2MUL = 0x8d,
132 OP_2DIV = 0x8e,
133 OP_NEGATE = 0x8f,
134 OP_ABS = 0x90,
135 OP_NOT = 0x91,
137
138 OP_ADD = 0x93,
139 OP_SUB = 0x94,
140 OP_MUL = 0x95,
141 OP_DIV = 0x96,
142 OP_MOD = 0x97,
143 OP_LSHIFT = 0x98,
144 OP_RSHIFT = 0x99,
145
147 OP_BOOLOR = 0x9b,
155 OP_MIN = 0xa3,
156 OP_MAX = 0xa4,
157
158 OP_WITHIN = 0xa5,
159
160 // crypto
162 OP_SHA1 = 0xa7,
163 OP_SHA256 = 0xa8,
171
172 // expansion
173 OP_NOP1 = 0xb0,
178 OP_NOP4 = 0xb3,
179 OP_NOP5 = 0xb4,
180 OP_NOP6 = 0xb5,
181 OP_NOP7 = 0xb6,
182 OP_NOP8 = 0xb7,
183 OP_NOP9 = 0xb8,
184 OP_NOP10 = 0xb9,
185
186 // More crypto
189
190 // additional byte string operations
192
193 // The first op_code value after all defined opcodes
195
196 // multi-byte opcodes
199
201};
202
203// Maximum value that an opcode can be
204static const unsigned int MAX_OPCODE = FIRST_UNDEFINED_OP_VALUE - 1;
205
206std::string GetOpName(opcodetype opcode);
207
212bool CheckMinimalPush(const std::vector<uint8_t> &data, opcodetype opcode);
213
214struct scriptnum_overflow_error : public std::runtime_error {
215 explicit scriptnum_overflow_error(const std::string &str)
216 : std::runtime_error(str) {}
217};
218
219struct scriptnum_encoding_error : public std::runtime_error {
220 explicit scriptnum_encoding_error(const std::string &str)
221 : std::runtime_error(str) {}
222};
223
234public:
235 explicit CScriptNum(const int64_t &n) { m_value = n; }
236
237 explicit CScriptNum(const std::vector<uint8_t> &vch, bool fRequireMinimal,
238 const size_t nMaxNumSize) {
239 if (vch.size() > nMaxNumSize) {
240 throw scriptnum_overflow_error("script number overflow");
241 }
242 if (fRequireMinimal && !IsMinimallyEncoded(vch, nMaxNumSize)) {
244 "non-minimally encoded script number");
245 }
246 m_value = set_vch(vch);
247 }
248
249 static bool IsMinimallyEncoded(const std::vector<uint8_t> &vch,
250 const size_t nMaxNumSize);
251
252 static bool MinimallyEncode(std::vector<uint8_t> &data);
253
254 inline bool operator==(const int64_t &rhs) const { return m_value == rhs; }
255 inline bool operator!=(const int64_t &rhs) const { return m_value != rhs; }
256 inline bool operator<=(const int64_t &rhs) const { return m_value <= rhs; }
257 inline bool operator<(const int64_t &rhs) const { return m_value < rhs; }
258 inline bool operator>=(const int64_t &rhs) const { return m_value >= rhs; }
259 inline bool operator>(const int64_t &rhs) const { return m_value > rhs; }
260
261 inline bool operator==(const CScriptNum &rhs) const {
262 return operator==(rhs.m_value);
263 }
264 inline bool operator!=(const CScriptNum &rhs) const {
265 return operator!=(rhs.m_value);
266 }
267 inline bool operator<=(const CScriptNum &rhs) const {
268 return operator<=(rhs.m_value);
269 }
270 inline bool operator<(const CScriptNum &rhs) const {
271 return operator<(rhs.m_value);
272 }
273 inline bool operator>=(const CScriptNum &rhs) const {
274 return operator>=(rhs.m_value);
275 }
276 inline bool operator>(const CScriptNum &rhs) const {
277 return operator>(rhs.m_value);
278 }
279
280 inline CScriptNum operator+(const int64_t &rhs) const {
281 int64_t result;
282 if (AddInt63Overflow(m_value, rhs, result)) {
283 throw scriptnum_overflow_error("script number overflow");
284 }
285 return CScriptNum(result);
286 }
287 inline CScriptNum operator-(const int64_t &rhs) const {
288 int64_t result;
289 if (SubInt63Overflow(m_value, rhs, result)) {
290 throw scriptnum_overflow_error("script number overflow");
291 }
292 return CScriptNum(result);
293 }
294 inline CScriptNum operator+(const CScriptNum &rhs) const {
295 return operator+(rhs.m_value);
296 }
297 inline CScriptNum operator-(const CScriptNum &rhs) const {
298 return operator-(rhs.m_value);
299 }
300
301 inline CScriptNum operator/(const int64_t &rhs) const {
302 return CScriptNum(m_value / rhs);
303 }
304 inline CScriptNum operator/(const CScriptNum &rhs) const {
305 return operator/(rhs.m_value);
306 }
307
308 inline CScriptNum operator%(const int64_t &rhs) const {
309 return CScriptNum(m_value % rhs);
310 }
311 inline CScriptNum operator%(const CScriptNum &rhs) const {
312 return operator%(rhs.m_value);
313 }
314
315 inline CScriptNum &operator+=(const CScriptNum &rhs) {
316 return operator+=(rhs.m_value);
317 }
318 inline CScriptNum &operator-=(const CScriptNum &rhs) {
319 return operator-=(rhs.m_value);
320 }
321
322 inline CScriptNum operator&(const int64_t &rhs) const {
323 return CScriptNum(m_value & rhs);
324 }
325 inline CScriptNum operator&(const CScriptNum &rhs) const {
326 return operator&(rhs.m_value);
327 }
328
329 inline CScriptNum &operator&=(const CScriptNum &rhs) {
330 return operator&=(rhs.m_value);
331 }
332
333 inline CScriptNum operator-() const {
334 assert(m_value != std::numeric_limits<int64_t>::min());
335 return CScriptNum(-m_value);
336 }
337
338 inline CScriptNum &operator=(const int64_t &rhs) {
339 m_value = rhs;
340 return *this;
341 }
342
343 inline CScriptNum &operator+=(const int64_t &rhs) {
344 assert(m_value != std::numeric_limits<int64_t>::min());
345 *this = *this + CScriptNum(rhs);
346 return *this;
347 }
348
349 inline CScriptNum &operator-=(const int64_t &rhs) {
350 assert(m_value != std::numeric_limits<int64_t>::min());
351 *this = *this - CScriptNum(rhs);
352 return *this;
353 }
354
355 inline CScriptNum &operator&=(const int64_t &rhs) {
356 m_value &= rhs;
357 return *this;
358 }
359
360 int64_t getint() const { return m_value; }
361
362 std::vector<uint8_t> getvch() const { return serialize(m_value); }
363
364 static std::vector<uint8_t> serialize(const int64_t &value) {
365 if (value == 0) {
366 return {};
367 }
368
369 std::vector<uint8_t> result;
370 const bool neg = value < 0;
371 uint64_t absvalue = neg ? ~static_cast<uint64_t>(value) + 1
372 : static_cast<uint64_t>(value);
373
374 while (absvalue) {
375 result.push_back(absvalue & 0xff);
376 absvalue >>= 8;
377 }
378
379 // - If the most significant byte is >= 0x80 and the value is positive,
380 // push a new zero-byte to make the significant byte < 0x80 again.
381 // - If the most significant byte is >= 0x80 and the value is negative,
382 // push a new 0x80 byte that will be popped off when converting to an
383 // integral.
384 // - If the most significant byte is < 0x80 and the value is negative,
385 // add 0x80 to it, since it will be subtracted and interpreted as a
386 // negative when converting to an integral.
387 if (result.back() & 0x80) {
388 result.push_back(neg ? 0x80 : 0);
389 } else if (neg) {
390 result.back() |= 0x80;
391 }
392
393 return result;
394 }
395
396private:
397 static int64_t set_vch(const std::vector<uint8_t> &vch) {
398 if (vch.empty()) {
399 return 0;
400 }
401
402 int64_t result = 0;
403 for (size_t i = 0; i != vch.size(); ++i) {
404 result |= int64_t(vch[i]) << 8 * i;
405 }
406
407 // If the input vector's most significant byte is 0x80, remove it from
408 // the result's msb and return a negative.
409 if (vch.back() & 0x80) {
410 return -int64_t(result & ~(0x80ULL << (8 * (vch.size() - 1))));
411 }
412
413 return result;
414 }
415
416 int64_t m_value;
417};
418
426
429 std::vector<uint8_t> *pvchRet);
430
432class CScript : public CScriptBase {
433protected:
434 CScript &push_int64(int64_t n) {
435 if (n == -1 || (n >= 1 && n <= 16)) {
436 push_back(n + (OP_1 - 1));
437 } else if (n == 0) {
439 } else {
440 *this << CScriptNum::serialize(n);
441 }
442 return *this;
443 }
444
445public:
448 : CScriptBase(pbegin, pend) {}
449 CScript(std::vector<uint8_t>::const_iterator pbegin,
450 std::vector<uint8_t>::const_iterator pend)
451 : CScriptBase(pbegin, pend) {}
452 CScript(const uint8_t *pbegin, const uint8_t *pend)
453 : CScriptBase(pbegin, pend) {}
454
456
457 explicit CScript(int64_t b) { operator<<(b); }
458 explicit CScript(opcodetype b) { operator<<(b); }
459 explicit CScript(const CScriptNum &b) { operator<<(b); }
460 // delete non-existent constructor to defend against future introduction
461 // e.g. via prevector
462 explicit CScript(const std::vector<uint8_t> &b) = delete;
463
465 CScript &operator<<(const CScript &b) = delete;
466
467 CScript &operator<<(int64_t b) LIFETIMEBOUND { return push_int64(b); }
468
470 if (opcode < 0 || opcode > 0xff) {
471 throw std::runtime_error("CScript::operator<<(): invalid opcode");
472 }
473 insert(end(), uint8_t(opcode));
474 return *this;
475 }
476
478 *this << b.getvch();
479 return *this;
480 }
481
482 CScript &operator<<(const std::vector<uint8_t> &b) LIFETIMEBOUND {
483 if (b.size() < OP_PUSHDATA1) {
484 insert(end(), uint8_t(b.size()));
485 } else if (b.size() <= 0xff) {
487 insert(end(), uint8_t(b.size()));
488 } else if (b.size() <= 0xffff) {
490 uint8_t _data[2];
491 WriteLE16(_data, b.size());
492 insert(end(), _data, _data + sizeof(_data));
493 } else {
495 uint8_t _data[4];
496 WriteLE32(_data, b.size());
497 insert(end(), _data, _data + sizeof(_data));
498 }
499 insert(end(), b.begin(), b.end());
500 return *this;
501 }
502
503 bool GetOp(const_iterator &pc, opcodetype &opcodeRet,
504 std::vector<uint8_t> &vchRet) const {
505 return GetScriptOp(pc, end(), opcodeRet, &vchRet);
506 }
507
508 bool GetOp(const_iterator &pc, opcodetype &opcodeRet) const {
509 return GetScriptOp(pc, end(), opcodeRet, nullptr);
510 }
511
513 static int DecodeOP_N(opcodetype opcode) {
514 if (opcode == OP_0) {
515 return 0;
516 }
517
518 assert(opcode >= OP_1 && opcode <= OP_16);
519 return int(opcode) - int(OP_1 - 1);
520 }
521 static opcodetype EncodeOP_N(int n) {
522 assert(n >= 0 && n <= 16);
523 if (n == 0) {
524 return OP_0;
525 }
526
527 return (opcodetype)(OP_1 + n - 1);
528 }
529
530 bool IsPayToScriptHash() const;
531 bool IsWitnessProgram(int &version, std::vector<uint8_t> &program) const;
532 bool IsWitnessProgram() const;
533
538 bool IsPushOnly(const_iterator pc) const;
539 bool IsPushOnly() const;
540
542 bool HasValidOps() const;
543
549 bool IsUnspendable() const {
550 return (size() > 0 && *begin() == OP_RETURN) ||
551 (size() > MAX_SCRIPT_SIZE);
552 }
553
554 void clear() {
555 // The default prevector::clear() does not release memory
558 }
559};
560
561#endif // BITCOIN_SCRIPT_SCRIPT_H
#define LIFETIMEBOUND
Definition: attributes.h:16
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:432
CScript(const_iterator pbegin, const_iterator pend)
Definition: script.h:447
bool IsPayToScriptHash() const
Definition: script.cpp:373
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
Definition: script.h:549
CScript & operator<<(const CScript &b)=delete
Delete non-existent operator to defend against future introduction.
CScript(const CScriptNum &b)
Definition: script.h:459
CScript(const uint8_t *pbegin, const uint8_t *pend)
Definition: script.h:452
CScript & push_int64(int64_t n)
Definition: script.h:434
CScript(int64_t b)
Definition: script.h:457
SERIALIZE_METHODS(CScript, obj)
Definition: script.h:455
CScript(std::vector< uint8_t >::const_iterator pbegin, std::vector< uint8_t >::const_iterator pend)
Definition: script.h:449
void clear()
Definition: script.h:554
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
Definition: script.h:513
bool IsPushOnly() const
Definition: script.cpp:422
bool IsWitnessProgram() const
Definition: script.cpp:398
CScript(opcodetype b)
Definition: script.h:458
CScript()
Definition: script.h:446
CScript & operator<<(const std::vector< uint8_t > &b) LIFETIMEBOUND
Definition: script.h:482
bool HasValidOps() const
Check if the script contains valid OP_CODES.
Definition: script.cpp:480
bool GetOp(const_iterator &pc, opcodetype &opcodeRet) const
Definition: script.h:508
CScript & operator<<(opcodetype opcode) LIFETIMEBOUND
Definition: script.h:469
CScript & operator<<(const CScriptNum &b) LIFETIMEBOUND
Definition: script.h:477
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< uint8_t > &vchRet) const
Definition: script.h:503
CScript(const std::vector< uint8_t > &b)=delete
CScript & operator<<(int64_t b) LIFETIMEBOUND
Definition: script.h:467
static opcodetype EncodeOP_N(int n)
Definition: script.h:521
int64_t m_value
Definition: script.h:416
CScriptNum & operator-=(const CScriptNum &rhs)
Definition: script.h:318
CScriptNum & operator-=(const int64_t &rhs)
Definition: script.h:349
CScriptNum operator-(const int64_t &rhs) const
Definition: script.h:287
bool operator<(const CScriptNum &rhs) const
Definition: script.h:270
CScriptNum operator+(const int64_t &rhs) const
Definition: script.h:280
CScriptNum & operator+=(const CScriptNum &rhs)
Definition: script.h:315
CScriptNum operator-(const CScriptNum &rhs) const
Definition: script.h:297
bool operator>(const CScriptNum &rhs) const
Definition: script.h:276
bool operator==(const CScriptNum &rhs) const
Definition: script.h:261
int64_t getint() const
Definition: script.h:360
static std::vector< uint8_t > serialize(const int64_t &value)
Definition: script.h:364
CScriptNum(const std::vector< uint8_t > &vch, bool fRequireMinimal, const size_t nMaxNumSize)
Definition: script.h:237
CScriptNum & operator&=(const CScriptNum &rhs)
Definition: script.h:329
std::vector< uint8_t > getvch() const
Definition: script.h:362
bool operator<=(const CScriptNum &rhs) const
Definition: script.h:267
bool operator==(const int64_t &rhs) const
Definition: script.h:254
bool operator<(const int64_t &rhs) const
Definition: script.h:257
static bool IsMinimallyEncoded(const std::vector< uint8_t > &vch, const size_t nMaxNumSize)
Definition: script.cpp:299
CScriptNum operator%(const int64_t &rhs) const
Definition: script.h:308
CScriptNum operator&(const int64_t &rhs) const
Definition: script.h:322
CScriptNum operator&(const CScriptNum &rhs) const
Definition: script.h:325
CScriptNum & operator+=(const int64_t &rhs)
Definition: script.h:343
bool operator>=(const int64_t &rhs) const
Definition: script.h:258
bool operator<=(const int64_t &rhs) const
Definition: script.h:256
CScriptNum operator%(const CScriptNum &rhs) const
Definition: script.h:311
CScriptNum(const int64_t &n)
Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.
Definition: script.h:235
static bool MinimallyEncode(std::vector< uint8_t > &data)
Definition: script.cpp:327
bool operator!=(const int64_t &rhs) const
Definition: script.h:255
bool operator>=(const CScriptNum &rhs) const
Definition: script.h:273
bool operator>(const int64_t &rhs) const
Definition: script.h:259
CScriptNum & operator&=(const int64_t &rhs)
Definition: script.h:355
static int64_t set_vch(const std::vector< uint8_t > &vch)
Definition: script.h:397
CScriptNum operator/(const CScriptNum &rhs) const
Definition: script.h:304
CScriptNum operator/(const int64_t &rhs) const
Definition: script.h:301
CScriptNum operator-() const
Definition: script.h:333
bool operator!=(const CScriptNum &rhs) const
Definition: script.h:264
CScriptNum & operator=(const int64_t &rhs)
Definition: script.h:338
CScriptNum operator+(const CScriptNum &rhs) const
Definition: script.h:294
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition: prevector.h:38
void shrink_to_fit()
Definition: prevector.h:449
void clear()
Definition: prevector.h:451
size_type size() const
Definition: prevector.h:396
iterator begin()
Definition: prevector.h:400
iterator end()
Definition: prevector.h:402
iterator insert(iterator pos, const T &value)
Definition: prevector.h:453
void push_back(const T &value)
Definition: prevector.h:541
static void WriteLE16(uint8_t *ptr, uint16_t x)
Definition: common.h:35
static void WriteLE32(uint8_t *ptr, uint32_t x)
Definition: common.h:40
bool AddInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a + b and stores it in result.
Definition: intmath.cpp:27
bool SubInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a - b and stores it in result.
Definition: intmath.cpp:51
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition: rcu.h:259
static const unsigned int LOCKTIME_THRESHOLD
Definition: script.h:44
static const unsigned int MAX_OPCODE
Definition: script.h:204
std::string GetOpName(opcodetype opcode)
Definition: script.cpp:14
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
Definition: script.h:25
static const int MAX_SCRIPT_SIZE
Definition: script.h:34
opcodetype
Script opcodes.
Definition: script.h:51
@ OP_NUMNOTEQUAL
Definition: script.h:150
@ OP_RESERVED1
Definition: script.h:125
@ OP_SPLIT
Definition: script.h:113
@ OP_2
Definition: script.h:62
@ OP_SHA256
Definition: script.h:163
@ OP_PUSHDATA4
Definition: script.h:57
@ OP_NOP5
Definition: script.h:179
@ OP_CHECKDATASIG
Definition: script.h:187
@ OP_BOOLAND
Definition: script.h:146
@ OP_CHECKMULTISIG
Definition: script.h:169
@ OP_NEGATE
Definition: script.h:133
@ OP_IF
Definition: script.h:81
@ OP_13
Definition: script.h:73
@ OP_ROT
Definition: script.h:107
@ OP_SWAP
Definition: script.h:108
@ OP_1NEGATE
Definition: script.h:58
@ OP_VERNOTIF
Definition: script.h:84
@ OP_CHECKSIG
Definition: script.h:167
@ OP_CHECKLOCKTIMEVERIFY
Definition: script.h:174
@ OP_LESSTHAN
Definition: script.h:151
@ OP_16
Definition: script.h:76
@ OP_14
Definition: script.h:74
@ OP_CHECKDATASIGVERIFY
Definition: script.h:188
@ OP_NOP10
Definition: script.h:184
@ OP_2DIV
Definition: script.h:132
@ OP_INVALIDOPCODE
Definition: script.h:200
@ OP_NOT
Definition: script.h:135
@ OP_EQUAL
Definition: script.h:123
@ OP_NUMEQUAL
Definition: script.h:148
@ OP_MOD
Definition: script.h:142
@ OP_NOTIF
Definition: script.h:82
@ OP_4
Definition: script.h:64
@ OP_10
Definition: script.h:70
@ OP_SIZE
Definition: script.h:116
@ OP_3DUP
Definition: script.h:95
@ FIRST_UNDEFINED_OP_VALUE
Definition: script.h:194
@ OP_ENDIF
Definition: script.h:86
@ OP_NOP1
Definition: script.h:173
@ OP_DUP
Definition: script.h:102
@ OP_GREATERTHAN
Definition: script.h:152
@ OP_NOP
Definition: script.h:79
@ OP_NOP2
Definition: script.h:175
@ OP_NUM2BIN
Definition: script.h:114
@ OP_VERIF
Definition: script.h:83
@ OP_TOALTSTACK
Definition: script.h:91
@ OP_CODESEPARATOR
Definition: script.h:166
@ OP_RIPEMD160
Definition: script.h:161
@ OP_MIN
Definition: script.h:155
@ OP_HASH256
Definition: script.h:165
@ OP_MAX
Definition: script.h:156
@ OP_1SUB
Definition: script.h:130
@ OP_PREFIX_BEGIN
Definition: script.h:197
@ OP_FROMALTSTACK
Definition: script.h:92
@ OP_SUB
Definition: script.h:139
@ OP_FALSE
Definition: script.h:54
@ OP_NUMEQUALVERIFY
Definition: script.h:149
@ OP_OVER
Definition: script.h:104
@ OP_NOP8
Definition: script.h:182
@ OP_DIV
Definition: script.h:141
@ OP_HASH160
Definition: script.h:164
@ OP_2DUP
Definition: script.h:94
@ OP_NIP
Definition: script.h:103
@ OP_2MUL
Definition: script.h:131
@ OP_NOP4
Definition: script.h:178
@ OP_NOP3
Definition: script.h:177
@ OP_1
Definition: script.h:60
@ OP_LESSTHANOREQUAL
Definition: script.h:153
@ OP_2DROP
Definition: script.h:93
@ OP_TRUE
Definition: script.h:61
@ OP_DEPTH
Definition: script.h:100
@ OP_NOP9
Definition: script.h:183
@ OP_BIN2NUM
Definition: script.h:115
@ OP_VER
Definition: script.h:80
@ OP_VERIFY
Definition: script.h:87
@ OP_RESERVED2
Definition: script.h:126
@ OP_12
Definition: script.h:72
@ OP_ADD
Definition: script.h:138
@ OP_CHECKMULTISIGVERIFY
Definition: script.h:170
@ OP_NOP7
Definition: script.h:181
@ OP_8
Definition: script.h:68
@ OP_BOOLOR
Definition: script.h:147
@ OP_XOR
Definition: script.h:122
@ OP_DROP
Definition: script.h:101
@ OP_MUL
Definition: script.h:140
@ OP_WITHIN
Definition: script.h:158
@ OP_ELSE
Definition: script.h:85
@ OP_15
Definition: script.h:75
@ OP_CHECKSIGVERIFY
Definition: script.h:168
@ OP_PUSHDATA1
Definition: script.h:55
@ OP_TUCK
Definition: script.h:109
@ OP_2OVER
Definition: script.h:96
@ OP_0NOTEQUAL
Definition: script.h:136
@ OP_9
Definition: script.h:69
@ OP_3
Definition: script.h:63
@ OP_11
Definition: script.h:71
@ OP_PREFIX_END
Definition: script.h:198
@ OP_SHA1
Definition: script.h:162
@ OP_GREATERTHANOREQUAL
Definition: script.h:154
@ OP_RSHIFT
Definition: script.h:144
@ OP_2SWAP
Definition: script.h:98
@ OP_PUSHDATA2
Definition: script.h:56
@ OP_2ROT
Definition: script.h:97
@ OP_6
Definition: script.h:66
@ OP_INVERT
Definition: script.h:119
@ OP_0
Definition: script.h:53
@ OP_ABS
Definition: script.h:134
@ OP_LSHIFT
Definition: script.h:143
@ OP_RETURN
Definition: script.h:88
@ OP_IFDUP
Definition: script.h:99
@ OP_PICK
Definition: script.h:105
@ OP_AND
Definition: script.h:120
@ OP_EQUALVERIFY
Definition: script.h:124
@ OP_CAT
Definition: script.h:112
@ OP_REVERSEBYTES
Definition: script.h:191
@ OP_RESERVED
Definition: script.h:59
@ OP_1ADD
Definition: script.h:129
@ OP_7
Definition: script.h:67
@ OP_OR
Definition: script.h:121
@ OP_ROLL
Definition: script.h:106
@ OP_NOP6
Definition: script.h:180
@ OP_5
Definition: script.h:65
@ OP_CHECKSEQUENCEVERIFY
Definition: script.h:176
static const int MAX_STACK_SIZE
Definition: script.h:37
static const int MAX_OPS_PER_SCRIPT
Definition: script.h:28
bool CheckMinimalPush(const std::vector< uint8_t > &data, opcodetype opcode)
Check whether the given stack element data would be minimally pushed using the given opcode.
Definition: script.cpp:268
static const int MAX_PUBKEYS_PER_MULTISIG
Definition: script.h:31
constexpr size_t MAX_SCRIPTNUM_BYTE_SIZE
Definition: script.h:40
std::vector< uint8_t > ToByteVector(const T &in)
Definition: script.h:46
bool GetScriptOp(CScriptBase::const_iterator &pc, CScriptBase::const_iterator end, opcodetype &opcodeRet, std::vector< uint8_t > *pvchRet)
Definition: script.cpp:426
#define READWRITEAS(type, obj)
Definition: serialize.h:169
scriptnum_encoding_error(const std::string &str)
Definition: script.h:220
scriptnum_overflow_error(const std::string &str)
Definition: script.h:215
assert(!tx.IsCoinBase())