Fabcoin Core  0.16.2
P2P Digital Currency
script.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 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 FABCOIN_SCRIPT_SCRIPT_H
7 #define FABCOIN_SCRIPT_SCRIPT_H
8 
9 #include "crypto/common.h"
10 #include "prevector.h"
11 #include "serialize.h"
12 
13 #include <assert.h>
14 #include <climits>
15 #include <limits>
16 #include <stdexcept>
17 #include <stdint.h>
18 #include <string.h>
19 #include <string>
20 #include <vector>
21 
22 // Maximum number of bytes pushable to the stack
23 static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 128000; //(128 kb)
24 
25 // Maximum number of non-push operations per script
26 static const int MAX_OPS_PER_SCRIPT = 201;
27 
28 // Maximum number of public keys per multisig
29 static const int MAX_PUBKEYS_PER_MULTISIG = 20;
30 
31 // Maximum script length in bytes
32 static const int MAX_SCRIPT_SIZE = 129000; // (129 kb)
33 
34 // Maximum number of values on script interpreter stack
35 static const int MAX_STACK_SIZE = 1000;
36 
37 // Threshold for nLockTime: below this value it is interpreted as block number,
38 // otherwise as UNIX timestamp.
39 static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
40 
41 template <typename T>
42 std::vector<unsigned char> ToByteVector(const T& in)
43 {
44  return std::vector<unsigned char>(in.begin(), in.end());
45 }
46 
49 {
50  // push value
51  OP_0 = 0x00,
53  OP_PUSHDATA1 = 0x4c,
54  OP_PUSHDATA2 = 0x4d,
55  OP_PUSHDATA4 = 0x4e,
56  OP_1NEGATE = 0x4f,
57  OP_RESERVED = 0x50,
58  OP_1 = 0x51,
60  OP_2 = 0x52,
61  OP_3 = 0x53,
62  OP_4 = 0x54,
63  OP_5 = 0x55,
64  OP_6 = 0x56,
65  OP_7 = 0x57,
66  OP_8 = 0x58,
67  OP_9 = 0x59,
68  OP_10 = 0x5a,
69  OP_11 = 0x5b,
70  OP_12 = 0x5c,
71  OP_13 = 0x5d,
72  OP_14 = 0x5e,
73  OP_15 = 0x5f,
74  OP_16 = 0x60,
75 
76  // control
77  OP_NOP = 0x61,
78  OP_VER = 0x62,
79  OP_IF = 0x63,
80  OP_NOTIF = 0x64,
81  OP_VERIF = 0x65,
82  OP_VERNOTIF = 0x66,
83  OP_ELSE = 0x67,
84  OP_ENDIF = 0x68,
85  OP_VERIFY = 0x69,
86  OP_RETURN = 0x6a,
87 
88  // stack ops
89  OP_TOALTSTACK = 0x6b,
91  OP_2DROP = 0x6d,
92  OP_2DUP = 0x6e,
93  OP_3DUP = 0x6f,
94  OP_2OVER = 0x70,
95  OP_2ROT = 0x71,
96  OP_2SWAP = 0x72,
97  OP_IFDUP = 0x73,
98  OP_DEPTH = 0x74,
99  OP_DROP = 0x75,
100  OP_DUP = 0x76,
101  OP_NIP = 0x77,
102  OP_OVER = 0x78,
103  OP_PICK = 0x79,
104  OP_ROLL = 0x7a,
105  OP_ROT = 0x7b,
106  OP_SWAP = 0x7c,
107  OP_TUCK = 0x7d,
108 
109  // splice ops
110  OP_CAT = 0x7e,
111  OP_SUBSTR = 0x7f,
112  OP_LEFT = 0x80,
113  OP_RIGHT = 0x81,
114  OP_SIZE = 0x82,
115 
116  // bit logic
117  OP_INVERT = 0x83,
118  OP_AND = 0x84,
119  OP_OR = 0x85,
120  OP_XOR = 0x86,
121  OP_EQUAL = 0x87,
123  OP_RESERVED1 = 0x89,
124  OP_RESERVED2 = 0x8a,
125 
126  // numeric
127  OP_1ADD = 0x8b,
128  OP_1SUB = 0x8c,
129  OP_2MUL = 0x8d,
130  OP_2DIV = 0x8e,
131  OP_NEGATE = 0x8f,
132  OP_ABS = 0x90,
133  OP_NOT = 0x91,
134  OP_0NOTEQUAL = 0x92,
135 
136  OP_ADD = 0x93,
137  OP_SUB = 0x94,
138  OP_MUL = 0x95,
139  OP_DIV = 0x96,
140  OP_MOD = 0x97,
141  OP_LSHIFT = 0x98,
142  OP_RSHIFT = 0x99,
143 
144  OP_BOOLAND = 0x9a,
145  OP_BOOLOR = 0x9b,
146  OP_NUMEQUAL = 0x9c,
149  OP_LESSTHAN = 0x9f,
153  OP_MIN = 0xa3,
154  OP_MAX = 0xa4,
155 
156  OP_WITHIN = 0xa5,
157 
158  // crypto
159  OP_RIPEMD160 = 0xa6,
160  OP_SHA1 = 0xa7,
161  OP_SHA256 = 0xa8,
162  OP_HASH160 = 0xa9,
163  OP_HASH256 = 0xaa,
165  OP_CHECKSIG = 0xac,
169 
170  // expansion
171  OP_NOP1 = 0xb0,
176  OP_NOP4 = 0xb3,
177  OP_NOP5 = 0xb4,
178  OP_NOP6 = 0xb5,
179  OP_NOP7 = 0xb6,
180  OP_NOP8 = 0xb7,
181  OP_NOP9 = 0xb8,
182  OP_NOP10 = 0xb9,
183 
184  // Execute EXT byte code.
185  OP_CREATE = 0xc1,
186  OP_CALL = 0xc2,
187  OP_SPEND = 0xc3,
188 
189  // template matching params
190  OP_GAS_PRICE = 0xf5,
191  OP_VERSION = 0xf6,
192  OP_GAS_LIMIT = 0xf7,
193  OP_DATA = 0xf8,
194 
195  // template matching params
197  OP_PUBKEYS = 0xfb,
199  OP_PUBKEY = 0xfe,
200 
202 };
203 
204 // Maximum value that an opcode can be
205 static const unsigned int MAX_OPCODE = OP_NOP10;
206 
207 const char* GetOpName(opcodetype opcode);
208 
209 class scriptnum_error : public std::runtime_error
210 {
211 public:
212  explicit scriptnum_error(const std::string& str) : std::runtime_error(str) {}
213 };
214 
216 {
225 public:
226 
227  explicit CScriptNum(const int64_t& n)
228  {
229  m_value = n;
230  }
231 
232  static const size_t nDefaultMaxNumSize = 4;
233 
234  explicit CScriptNum(const std::vector<unsigned char>& vch, bool fRequireMinimal,
235  const size_t nMaxNumSize = nDefaultMaxNumSize)
236  {
237  if (vch.size() > nMaxNumSize) {
238  throw scriptnum_error("script number overflow");
239  }
240  if (fRequireMinimal && vch.size() > 0) {
241  // Check that the number is encoded with the minimum possible
242  // number of bytes.
243  //
244  // If the most-significant-byte - excluding the sign bit - is zero
245  // then we're not minimal. Note how this test also rejects the
246  // negative-zero encoding, 0x80.
247  if ((vch.back() & 0x7f) == 0) {
248  // One exception: if there's more than one byte and the most
249  // significant bit of the second-most-significant-byte is set
250  // it would conflict with the sign bit. An example of this case
251  // is +-255, which encode to 0xff00 and 0xff80 respectively.
252  // (big-endian).
253  if (vch.size() <= 1 || (vch[vch.size() - 2] & 0x80) == 0) {
254  throw scriptnum_error("non-minimally encoded script number");
255  }
256  }
257  }
258  m_value = set_vch(vch);
259  }
260 
261  inline bool operator==(const int64_t& rhs) const { return m_value == rhs; }
262  inline bool operator!=(const int64_t& rhs) const { return m_value != rhs; }
263  inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; }
264  inline bool operator< (const int64_t& rhs) const { return m_value < rhs; }
265  inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; }
266  inline bool operator> (const int64_t& rhs) const { return m_value > rhs; }
267 
268  inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); }
269  inline bool operator!=(const CScriptNum& rhs) const { return operator!=(rhs.m_value); }
270  inline bool operator<=(const CScriptNum& rhs) const { return operator<=(rhs.m_value); }
271  inline bool operator< (const CScriptNum& rhs) const { return operator< (rhs.m_value); }
272  inline bool operator>=(const CScriptNum& rhs) const { return operator>=(rhs.m_value); }
273  inline bool operator> (const CScriptNum& rhs) const { return operator> (rhs.m_value); }
274 
275  inline CScriptNum operator+( const int64_t& rhs) const { return CScriptNum(m_value + rhs);}
276  inline CScriptNum operator-( const int64_t& rhs) const { return CScriptNum(m_value - rhs);}
277  inline CScriptNum operator+( const CScriptNum& rhs) const { return operator+(rhs.m_value); }
278  inline CScriptNum operator-( const CScriptNum& rhs) const { return operator-(rhs.m_value); }
279 
280  inline CScriptNum& operator+=( const CScriptNum& rhs) { return operator+=(rhs.m_value); }
281  inline CScriptNum& operator-=( const CScriptNum& rhs) { return operator-=(rhs.m_value); }
282 
283  inline CScriptNum operator&( const int64_t& rhs) const { return CScriptNum(m_value & rhs);}
284  inline CScriptNum operator&( const CScriptNum& rhs) const { return operator&(rhs.m_value); }
285 
286  inline CScriptNum& operator&=( const CScriptNum& rhs) { return operator&=(rhs.m_value); }
287 
288  inline CScriptNum operator-() const
289  {
291  return CScriptNum(-m_value);
292  }
293 
294  inline CScriptNum& operator=( const int64_t& rhs)
295  {
296  m_value = rhs;
297  return *this;
298  }
299 
300  inline CScriptNum& operator+=( const int64_t& rhs)
301  {
302  assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits<int64_t>::max() - rhs) ||
303  (rhs < 0 && m_value >= std::numeric_limits<int64_t>::min() - rhs));
304  m_value += rhs;
305  return *this;
306  }
307 
308  inline CScriptNum& operator-=( const int64_t& rhs)
309  {
310  assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits<int64_t>::min() + rhs) ||
311  (rhs < 0 && m_value <= std::numeric_limits<int64_t>::max() + rhs));
312  m_value -= rhs;
313  return *this;
314  }
315 
316  inline CScriptNum& operator&=( const int64_t& rhs)
317  {
318  m_value &= rhs;
319  return *this;
320  }
321 
322  int getint() const
323  {
324  if (m_value > std::numeric_limits<int>::max())
326  else if (m_value < std::numeric_limits<int>::min())
328  return m_value;
329  }
330 
331  std::vector<unsigned char> getvch() const
332  {
333  return serialize(m_value);
334  }
335 
337  static uint64_t vch_to_uint64(const std::vector<unsigned char>& vch)
338  {
339  if (vch.size() > 8) {
340  throw scriptnum_error("script number overflow");
341  }
342 
343  if (vch.empty())
344  return 0;
345 
346  uint64_t result = 0;
347  for (size_t i = 0; i != vch.size(); ++i)
348  result |= static_cast<uint64_t>(vch[i]) << 8*i;
349 
350  // If the input vector's most significant byte is 0x80, remove it from
351  // the result's msb and return a negative.
352  if (vch.back() & 0x80)
353  throw scriptnum_error("Negative gas value.");
354  // return -((uint64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1)))));
355 
356  return result;
357  }
359 
360  static std::vector<unsigned char> serialize(const int64_t& value)
361  {
362  if(value == 0)
363  return std::vector<unsigned char>();
364 
365  std::vector<unsigned char> result;
366  const bool neg = value < 0;
367  uint64_t absvalue = neg ? -value : value;
368 
369  while(absvalue)
370  {
371  result.push_back(absvalue & 0xff);
372  absvalue >>= 8;
373  }
374 
375 // - If the most significant byte is >= 0x80 and the value is positive, push a
376 // new zero-byte to make the significant byte < 0x80 again.
377 
378 // - If the most significant byte is >= 0x80 and the value is negative, push a
379 // new 0x80 byte that will be popped off when converting to an integral.
380 
381 // - If the most significant byte is < 0x80 and the value is negative, add
382 // 0x80 to it, since it will be subtracted and interpreted as a negative when
383 // converting to an integral.
384 
385  if (result.back() & 0x80)
386  result.push_back(neg ? 0x80 : 0);
387  else if (neg)
388  result.back() |= 0x80;
389 
390  return result;
391  }
392 
393 private:
394  static int64_t set_vch(const std::vector<unsigned char>& vch)
395  {
396  if (vch.empty())
397  return 0;
398 
399  int64_t result = 0;
400  for (size_t i = 0; i != vch.size(); ++i)
401  result |= static_cast<int64_t>(vch[i]) << 8*i;
402 
403  // If the input vector's most significant byte is 0x80, remove it from
404  // the result's msb and return a negative.
405  if (vch.back() & 0x80)
406  return -((int64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1)))));
407 
408  return result;
409  }
410 
411  int64_t m_value;
412 };
413 
415 
417 class CScript : public CScriptBase
418 {
419 protected:
420  CScript& push_int64(int64_t n)
421  {
422  if (n == -1 || (n >= 1 && n <= 16))
423  {
424  push_back(n + (OP_1 - 1));
425  }
426  else if (n == 0)
427  {
428  push_back(OP_0);
429  }
430  else
431  {
432  *this << CScriptNum::serialize(n);
433  }
434  return *this;
435  }
436 public:
437  CScript() { }
438  CScript(const_iterator pbegin, const_iterator pend) : CScriptBase(pbegin, pend) { }
439  CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
440  CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
441 
443 
444  template <typename Stream, typename Operation>
445  inline void SerializationOp(Stream& s, Operation ser_action) {
446  READWRITE(static_cast<CScriptBase&>(*this));
447  }
448 
450  {
451  insert(end(), b.begin(), b.end());
452  return *this;
453  }
454 
455  friend CScript operator+(const CScript& a, const CScript& b)
456  {
457  CScript ret = a;
458  ret += b;
459  return ret;
460  }
461 
462  CScript(int64_t b) { operator<<(b); }
463 
464  explicit CScript(opcodetype b) { operator<<(b); }
465  explicit CScript(const CScriptNum& b) { operator<<(b); }
466  explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
467 
468 
469  CScript& operator<<(int64_t b) { return push_int64(b); }
470 
472  {
473  if (opcode < 0 || opcode > 0xff)
474  throw std::runtime_error("CScript::operator<<(): invalid opcode");
475  insert(end(), (unsigned char)opcode);
476  return *this;
477  }
478 
480  {
481  *this << b.getvch();
482  return *this;
483  }
484 
485  CScript& operator<<(const std::vector<unsigned char>& b)
486  {
487  if (b.size() < OP_PUSHDATA1)
488  {
489  insert(end(), (unsigned char)b.size());
490  }
491  else if (b.size() <= 0xff)
492  {
493  insert(end(), OP_PUSHDATA1);
494  insert(end(), (unsigned char)b.size());
495  }
496  else if (b.size() <= 0xffff)
497  {
498  insert(end(), OP_PUSHDATA2);
499  uint8_t _data[2];
500  WriteLE16(_data, b.size());
501  insert(end(), _data, _data + sizeof(_data));
502  }
503  else
504  {
505  insert(end(), OP_PUSHDATA4);
506  uint8_t _data[4];
507  WriteLE32(_data, b.size());
508  insert(end(), _data, _data + sizeof(_data));
509  }
510  insert(end(), b.begin(), b.end());
511  return *this;
512  }
513 
515  {
516  // I'm not sure if this should push the script or concatenate scripts.
517  // If there's ever a use for pushing a script onto a script, delete this member fn
518  assert(!"Warning: Pushing a CScript onto a CScript with << is probably not intended, use + to concatenate!");
519  return *this;
520  }
521 
522 
523  bool GetOp(iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet)
524  {
525  // Wrapper so it can be called with either iterator or const_iterator
526  const_iterator pc2 = pc;
527  bool fRet = GetOp2(pc2, opcodeRet, &vchRet);
528  pc = begin() + (pc2 - begin());
529  return fRet;
530  }
531 
532  bool GetOp(iterator& pc, opcodetype& opcodeRet)
533  {
534  const_iterator pc2 = pc;
535  bool fRet = GetOp2(pc2, opcodeRet, nullptr);
536  pc = begin() + (pc2 - begin());
537  return fRet;
538  }
539 
540  bool GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet) const
541  {
542  return GetOp2(pc, opcodeRet, &vchRet);
543  }
544 
545  bool GetOp(const_iterator& pc, opcodetype& opcodeRet) const
546  {
547  return GetOp2(pc, opcodeRet, nullptr);
548  }
549 
550  bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet) const
551  {
552  opcodeRet = OP_INVALIDOPCODE;
553  if (pvchRet)
554  pvchRet->clear();
555  if (pc >= end())
556  return false;
557 
558  // Read instruction
559  if (end() - pc < 1)
560  return false;
561  unsigned int opcode = *pc++;
562 
563  // Immediate operand
564  if (opcode <= OP_PUSHDATA4)
565  {
566  unsigned int nSize = 0;
567  if (opcode < OP_PUSHDATA1)
568  {
569  nSize = opcode;
570  }
571  else if (opcode == OP_PUSHDATA1)
572  {
573  if (end() - pc < 1)
574  return false;
575  nSize = *pc++;
576  }
577  else if (opcode == OP_PUSHDATA2)
578  {
579  if (end() - pc < 2)
580  return false;
581  nSize = ReadLE16(&pc[0]);
582  pc += 2;
583  }
584  else if (opcode == OP_PUSHDATA4)
585  {
586  if (end() - pc < 4)
587  return false;
588  nSize = ReadLE32(&pc[0]);
589  pc += 4;
590  }
591  if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize)
592  return false;
593  if (pvchRet)
594  pvchRet->assign(pc, pc + nSize);
595  pc += nSize;
596  }
597 
598  opcodeRet = (opcodetype)opcode;
599  return true;
600  }
601 
603  static int DecodeOP_N(opcodetype opcode)
604  {
605  if (opcode == OP_0)
606  return 0;
607  assert(opcode >= OP_1 && opcode <= OP_16);
608  return (int)opcode - (int)(OP_1 - 1);
609  }
610  static opcodetype EncodeOP_N(int n)
611  {
612  assert(n >= 0 && n <= 16);
613  if (n == 0)
614  return OP_0;
615  return (opcodetype)(OP_1+n-1);
616  }
617 
618  int FindAndDelete(const CScript& b)
619  {
620  int nFound = 0;
621  if (b.empty())
622  return nFound;
623  CScript result;
624  iterator pc = begin(), pc2 = begin();
625  opcodetype opcode;
626  do
627  {
628  result.insert(result.end(), pc2, pc);
629  while (static_cast<size_t>(end() - pc) >= b.size() && std::equal(b.begin(), b.end(), pc))
630  {
631  pc = pc + b.size();
632  ++nFound;
633  }
634  pc2 = pc;
635  }
636  while (GetOp(pc, opcode));
637 
638  if (nFound > 0) {
639  result.insert(result.end(), pc2, end());
640  *this = result;
641  }
642 
643  return nFound;
644  }
645  int Find(opcodetype op) const
646  {
647  int nFound = 0;
648  opcodetype opcode;
649  for (const_iterator pc = begin(); pc != end() && GetOp(pc, opcode);)
650  if (opcode == op)
651  ++nFound;
652  return nFound;
653  }
654 
662  unsigned int GetSigOpCount(bool fAccurate) const;
663 
668  unsigned int GetSigOpCount(const CScript& scriptSig) const;
669 
670  bool IsPayToScriptHash() const;
672  bool IsPayToPubkey() const;
673  bool IsPayToPubkeyHash() const;
675  bool IsPayToWitnessScriptHash() const;
676  bool IsWitnessProgram(int& version, std::vector<unsigned char>& program) const;
677 
679  bool IsPushOnly(const_iterator pc) const;
680  bool IsPushOnly() const;
681 
683  bool HasValidOps() const;
684 
690  bool IsUnspendable() const
691  {
692  return (size() > 0 && *begin() == OP_RETURN) || (size() > MAX_SCRIPT_SIZE);
693  }
694 
695 
697  bool HasOpCreate() const
698  {
699  return Find(OP_CREATE) == 1;
700  }
701 
702  bool HasOpCall() const
703  {
704  return Find(OP_CALL) == 1;
705  }
706  bool HasOpSpend() const
707  {
708  return size()==1 && *begin() == OP_SPEND;
709  }
711 
712  void clear()
713  {
714  // The default prevector::clear() does not release memory
716  shrink_to_fit();
717  }
718 };
719 
721 {
722  // Note that this encodes the data elements being pushed, rather than
723  // encoding them as a CScript that pushes them.
724  std::vector<std::vector<unsigned char> > stack;
725 
726  // Some compilers complain without a default constructor
728 
729  bool IsNull() const { return stack.empty(); }
730 
731  void SetNull() { stack.clear(); stack.shrink_to_fit(); }
732 
733  std::string ToString() const;
734 };
735 
737 {
738 public:
740  virtual void KeepScript() {}
742  virtual ~CReserveScript() {}
743 };
744 
745 #endif // FABCOIN_SCRIPT_SCRIPT_H
Definition: script.h:133
Definition: script.h:62
Definition: script.h:118
bool operator!=(const int64_t &rhs) const
Definition: script.h:262
static int64_t set_vch(const std::vector< unsigned char > &vch)
Definition: script.h:394
ADD_SERIALIZE_METHODS
Definition: script.h:442
bool HasOpCreate() const
Definition: script.h:697
Definition: script.h:101
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
Definition: script.h:603
bool GetOp2(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > *pvchRet) const
Definition: script.h:550
CScriptNum operator-() const
Definition: script.h:288
Definition: script.h:154
Definition: script.h:93
#define READWRITE(obj)
Definition: serialize.h:179
iterator insert(iterator pos, const T &value)
Definition: prevector.h:343
void clear()
Definition: prevector.h:339
virtual ~CReserveScript()
Definition: script.h:742
CScriptNum(const int64_t &n)
Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.
Definition: script.h:227
Definition: script.h:79
Definition: script.h:72
Definition: script.h:68
#define T(i, x)
Definition: script.h:95
CScriptNum & operator-=(const int64_t &rhs)
Definition: script.h:308
Definition: script.h:132
CScriptNum operator&(const CScriptNum &rhs) const
Definition: script.h:284
Definition: script.h:60
Definition: script.h:139
Definition: script.h:66
Definition: script.h:61
CScript & push_int64(int64_t n)
Definition: script.h:420
std::vector< std::vector< unsigned char > > stack
Definition: script.h:724
bool empty() const
Definition: prevector.h:286
std::hash for asio::adress
Definition: Common.h:323
assert(len-trim+(2 *lenIndices)<=WIDTH)
bool IsNull() const
Definition: script.h:729
ExecStats::duration min
Definition: ExecStats.cpp:35
Definition: script.h:153
friend CScript operator+(const CScript &a, const CScript &b)
Definition: script.h:455
CScriptNum operator-(const CScriptNum &rhs) const
Definition: script.h:278
CScriptNum & operator=(const int64_t &rhs)
Definition: script.h:294
CScript(const std::vector< unsigned char > &b)
Definition: script.h:466
bool GetOp(const_iterator &pc, opcodetype &opcodeRet) const
Definition: script.h:545
void version()
Definition: main.cpp:53
Definition: script.h:74
static std::vector< unsigned char > serialize(const int64_t &value)
Definition: script.h:360
Definition: script.h:70
CScriptNum operator+(const CScriptNum &rhs) const
Definition: script.h:277
const char * GetOpName(opcodetype opcode)
Definition: script.cpp:11
CScript(opcodetype b)
Definition: script.h:464
Definition: script.h:119
CScriptNum & operator+=(const CScriptNum &rhs)
Definition: script.h:280
bool operator==(const CScriptNum &rhs) const
Definition: script.h:268
bool operator<=(const int64_t &rhs) const
Definition: script.h:263
CScriptNum & operator&=(const CScriptNum &rhs)
Definition: script.h:286
size_type size() const
Definition: prevector.h:282
#define a(i)
CScript & operator<<(const CScriptNum &b)
Definition: script.h:479
Definition: script.h:63
int getint() const
Definition: script.h:322
iterator end()
Definition: prevector.h:292
CScript & operator<<(opcodetype opcode)
Definition: script.h:471
CScript reserveScript
Definition: script.h:739
Definition: script.h:140
opcodetype
Script opcodes.
Definition: script.h:48
CScript(const CScriptNum &b)
Definition: script.h:465
CScript & operator<<(const CScript &b)
Definition: script.h:514
Definition: script.h:110
static uint64_t vch_to_uint64(const std::vector< unsigned char > &vch)
Definition: script.h:337
prevector< 28, unsigned char > CScriptBase
Definition: script.h:414
CScriptNum operator-(const int64_t &rhs) const
Definition: script.h:276
CScript(int64_t b)
Definition: script.h:462
ExecStats::duration max
Definition: ExecStats.cpp:36
Definition: script.h:65
bool HasOpSpend() const
Definition: script.h:706
bool HasOpCall() const
Definition: script.h:702
CScript(const unsigned char *pbegin, const unsigned char *pend)
Definition: script.h:440
bool operator==(const int64_t &rhs) const
Definition: script.h:261
Definition: script.h:58
Definition: script.h:77
CScriptWitness()
Definition: script.h:727
int64_t m_value
Definition: script.h:411
bool operator>=(const int64_t &rhs) const
Definition: script.h:265
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack...
Definition: script.h:690
scriptnum_error(const std::string &str)
Definition: script.h:212
CScriptNum(const std::vector< unsigned char > &vch, bool fRequireMinimal, const size_t nMaxNumSize=nDefaultMaxNumSize)
Definition: script.h:234
CScript()
Definition: script.h:437
Definition: script.h:137
bool GetOp(iterator &pc, opcodetype &opcodeRet)
Definition: script.h:532
Definition: script.h:105
CScriptNum & operator&=(const int64_t &rhs)
Definition: script.h:316
void SetNull()
Definition: script.h:731
Definition: script.h:138
Definition: script.h:83
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition: prevector.h:36
CScriptNum operator&(const int64_t &rhs) const
Definition: script.h:283
#define b(i, j)
std::ostream & operator<<(std::ostream &_out, bytes const &_e)
Definition: CommonIO.h:80
CScriptNum & operator-=(const CScriptNum &rhs)
Definition: script.h:281
Definition: script.h:67
Definition: script.h:99
Definition: script.h:92
CScript(const_iterator pbegin, const_iterator pend)
Definition: script.h:438
static opcodetype EncodeOP_N(int n)
Definition: script.h:610
uint8_t const size_t const size
Definition: sha3.h:20
bool operator<=(const CScriptNum &rhs) const
Definition: script.h:270
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:417
CScript & operator+=(const CScript &b)
Definition: script.h:449
bool operator>(const CryptoPP::PolynomialMod2 &a, const CryptoPP::PolynomialMod2 &b)
compares degree
Definition: gf2n.h:255
CScriptNum operator+(const int64_t &rhs) const
Definition: script.h:275
std::vector< unsigned char > getvch() const
Definition: script.h:331
int FindAndDelete(const CScript &b)
Definition: script.h:618
Definition: script.h:64
CScript & operator<<(int64_t b)
Definition: script.h:469
virtual void KeepScript()
Definition: script.h:740
iterator begin()
Definition: prevector.h:290
CScriptNum & operator+=(const int64_t &rhs)
Definition: script.h:300
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
Definition: script.h:540
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
Definition: script.h:523
Definition: script.h:71
bool operator!=(const CScriptNum &rhs) const
Definition: script.h:269
Definition: script.h:120
Definition: script.h:69
void SerializationOp(Stream &s, Operation ser_action)
Definition: script.h:445
Definition: script.h:78
bool operator>=(const CScriptNum &rhs) const
Definition: script.h:272
Definition: script.h:59
Definition: script.h:51
void clear()
Definition: script.h:712
CScript(std::vector< unsigned char >::const_iterator pbegin, std::vector< unsigned char >::const_iterator pend)
Definition: script.h:439
CReserveScript()
Definition: script.h:741
Definition: script.h:136
Definition: script.h:73
int Find(opcodetype op) const
Definition: script.h:645
bool operator<(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
Definition: asn.h:562
Definition: script.h:100
std::vector< unsigned char > ToByteVector(const T &in)
Definition: script.h:42