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