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