Dash Core  0.12.2.1
P2P Digital Currency
script.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 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 "crypto/common.h"
10 #include "prevector.h"
11 
12 #include <assert.h>
13 #include <climits>
14 #include <limits>
15 #include <stdexcept>
16 #include <stdint.h>
17 #include <string.h>
18 #include <string>
19 #include <vector>
20 
21 // Maximum number of bytes pushable to the stack
22 static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520;
23 
24 // Maximum number of non-push operations per script
25 static const int MAX_OPS_PER_SCRIPT = 201;
26 
27 // Maximum number of public keys per multisig
28 static const int MAX_PUBKEYS_PER_MULTISIG = 20;
29 
30 // Threshold for nLockTime: below this value it is interpreted as block number,
31 // otherwise as UNIX timestamp.
32 static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
33 
34 template <typename T>
35 std::vector<unsigned char> ToByteVector(const T& in)
36 {
37  return std::vector<unsigned char>(in.begin(), in.end());
38 }
39 
42 {
43  // push value
44  OP_0 = 0x00,
46  OP_PUSHDATA1 = 0x4c,
47  OP_PUSHDATA2 = 0x4d,
48  OP_PUSHDATA4 = 0x4e,
49  OP_1NEGATE = 0x4f,
50  OP_RESERVED = 0x50,
51  OP_1 = 0x51,
53  OP_2 = 0x52,
54  OP_3 = 0x53,
55  OP_4 = 0x54,
56  OP_5 = 0x55,
57  OP_6 = 0x56,
58  OP_7 = 0x57,
59  OP_8 = 0x58,
60  OP_9 = 0x59,
61  OP_10 = 0x5a,
62  OP_11 = 0x5b,
63  OP_12 = 0x5c,
64  OP_13 = 0x5d,
65  OP_14 = 0x5e,
66  OP_15 = 0x5f,
67  OP_16 = 0x60,
68 
69  // control
70  OP_NOP = 0x61,
71  OP_VER = 0x62,
72  OP_IF = 0x63,
73  OP_NOTIF = 0x64,
74  OP_VERIF = 0x65,
75  OP_VERNOTIF = 0x66,
76  OP_ELSE = 0x67,
77  OP_ENDIF = 0x68,
78  OP_VERIFY = 0x69,
79  OP_RETURN = 0x6a,
80 
81  // stack ops
82  OP_TOALTSTACK = 0x6b,
84  OP_2DROP = 0x6d,
85  OP_2DUP = 0x6e,
86  OP_3DUP = 0x6f,
87  OP_2OVER = 0x70,
88  OP_2ROT = 0x71,
89  OP_2SWAP = 0x72,
90  OP_IFDUP = 0x73,
91  OP_DEPTH = 0x74,
92  OP_DROP = 0x75,
93  OP_DUP = 0x76,
94  OP_NIP = 0x77,
95  OP_OVER = 0x78,
96  OP_PICK = 0x79,
97  OP_ROLL = 0x7a,
98  OP_ROT = 0x7b,
99  OP_SWAP = 0x7c,
100  OP_TUCK = 0x7d,
101 
102  // splice ops
103  OP_CAT = 0x7e,
104  OP_SUBSTR = 0x7f,
105  OP_LEFT = 0x80,
106  OP_RIGHT = 0x81,
107  OP_SIZE = 0x82,
108 
109  // bit logic
110  OP_INVERT = 0x83,
111  OP_AND = 0x84,
112  OP_OR = 0x85,
113  OP_XOR = 0x86,
114  OP_EQUAL = 0x87,
116  OP_RESERVED1 = 0x89,
117  OP_RESERVED2 = 0x8a,
118 
119  // numeric
120  OP_1ADD = 0x8b,
121  OP_1SUB = 0x8c,
122  OP_2MUL = 0x8d,
123  OP_2DIV = 0x8e,
124  OP_NEGATE = 0x8f,
125  OP_ABS = 0x90,
126  OP_NOT = 0x91,
127  OP_0NOTEQUAL = 0x92,
128 
129  OP_ADD = 0x93,
130  OP_SUB = 0x94,
131  OP_MUL = 0x95,
132  OP_DIV = 0x96,
133  OP_MOD = 0x97,
134  OP_LSHIFT = 0x98,
135  OP_RSHIFT = 0x99,
136 
137  OP_BOOLAND = 0x9a,
138  OP_BOOLOR = 0x9b,
139  OP_NUMEQUAL = 0x9c,
142  OP_LESSTHAN = 0x9f,
146  OP_MIN = 0xa3,
147  OP_MAX = 0xa4,
148 
149  OP_WITHIN = 0xa5,
150 
151  // crypto
152  OP_RIPEMD160 = 0xa6,
153  OP_SHA1 = 0xa7,
154  OP_SHA256 = 0xa8,
155  OP_HASH160 = 0xa9,
156  OP_HASH256 = 0xaa,
158  OP_CHECKSIG = 0xac,
162 
163  // expansion
164  OP_NOP1 = 0xb0,
169  OP_NOP4 = 0xb3,
170  OP_NOP5 = 0xb4,
171  OP_NOP6 = 0xb5,
172  OP_NOP7 = 0xb6,
173  OP_NOP8 = 0xb7,
174  OP_NOP9 = 0xb8,
175  OP_NOP10 = 0xb9,
176 
177 
178  // template matching params
180  OP_PUBKEYS = 0xfb,
182  OP_PUBKEY = 0xfe,
183 
185 };
186 
187 const char* GetOpName(opcodetype opcode);
188 
189 class scriptnum_error : public std::runtime_error
190 {
191 public:
192  explicit scriptnum_error(const std::string& str) : std::runtime_error(str) {}
193 };
194 
196 {
205 public:
206 
207  explicit CScriptNum(const int64_t& n)
208  {
209  m_value = n;
210  }
211 
212  static const size_t nDefaultMaxNumSize = 4;
213 
214  explicit CScriptNum(const std::vector<unsigned char>& vch, bool fRequireMinimal,
215  const size_t nMaxNumSize = nDefaultMaxNumSize)
216  {
217  if (vch.size() > nMaxNumSize) {
218  throw scriptnum_error("script number overflow");
219  }
220  if (fRequireMinimal && vch.size() > 0) {
221  // Check that the number is encoded with the minimum possible
222  // number of bytes.
223  //
224  // If the most-significant-byte - excluding the sign bit - is zero
225  // then we're not minimal. Note how this test also rejects the
226  // negative-zero encoding, 0x80.
227  if ((vch.back() & 0x7f) == 0) {
228  // One exception: if there's more than one byte and the most
229  // significant bit of the second-most-significant-byte is set
230  // it would conflict with the sign bit. An example of this case
231  // is +-255, which encode to 0xff00 and 0xff80 respectively.
232  // (big-endian).
233  if (vch.size() <= 1 || (vch[vch.size() - 2] & 0x80) == 0) {
234  throw scriptnum_error("non-minimally encoded script number");
235  }
236  }
237  }
238  m_value = set_vch(vch);
239  }
240 
241  inline bool operator==(const int64_t& rhs) const { return m_value == rhs; }
242  inline bool operator!=(const int64_t& rhs) const { return m_value != rhs; }
243  inline bool operator<=(const int64_t& rhs) const { return m_value <= rhs; }
244  inline bool operator< (const int64_t& rhs) const { return m_value < rhs; }
245  inline bool operator>=(const int64_t& rhs) const { return m_value >= rhs; }
246  inline bool operator> (const int64_t& rhs) const { return m_value > rhs; }
247 
248  inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); }
249  inline bool operator!=(const CScriptNum& rhs) const { return operator!=(rhs.m_value); }
250  inline bool operator<=(const CScriptNum& rhs) const { return operator<=(rhs.m_value); }
251  inline bool operator< (const CScriptNum& rhs) const { return operator< (rhs.m_value); }
252  inline bool operator>=(const CScriptNum& rhs) const { return operator>=(rhs.m_value); }
253  inline bool operator> (const CScriptNum& rhs) const { return operator> (rhs.m_value); }
254 
255  inline CScriptNum operator+( const int64_t& rhs) const { return CScriptNum(m_value + rhs);}
256  inline CScriptNum operator-( const int64_t& rhs) const { return CScriptNum(m_value - rhs);}
257  inline CScriptNum operator+( const CScriptNum& rhs) const { return operator+(rhs.m_value); }
258  inline CScriptNum operator-( const CScriptNum& rhs) const { return operator-(rhs.m_value); }
259 
260  inline CScriptNum& operator+=( const CScriptNum& rhs) { return operator+=(rhs.m_value); }
261  inline CScriptNum& operator-=( const CScriptNum& rhs) { return operator-=(rhs.m_value); }
262 
263  inline CScriptNum operator&( const int64_t& rhs) const { return CScriptNum(m_value & rhs);}
264  inline CScriptNum operator&( const CScriptNum& rhs) const { return operator&(rhs.m_value); }
265 
266  inline CScriptNum& operator&=( const CScriptNum& rhs) { return operator&=(rhs.m_value); }
267 
268  inline CScriptNum operator-() const
269  {
270  assert(m_value != std::numeric_limits<int64_t>::min());
271  return CScriptNum(-m_value);
272  }
273 
274  inline CScriptNum& operator=( const int64_t& rhs)
275  {
276  m_value = rhs;
277  return *this;
278  }
279 
280  inline CScriptNum& operator+=( const int64_t& rhs)
281  {
282  assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits<int64_t>::max() - rhs) ||
283  (rhs < 0 && m_value >= std::numeric_limits<int64_t>::min() - rhs));
284  m_value += rhs;
285  return *this;
286  }
287 
288  inline CScriptNum& operator-=( const int64_t& rhs)
289  {
290  assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits<int64_t>::min() + rhs) ||
291  (rhs < 0 && m_value <= std::numeric_limits<int64_t>::max() + rhs));
292  m_value -= rhs;
293  return *this;
294  }
295 
296  inline CScriptNum& operator&=( const int64_t& rhs)
297  {
298  m_value &= rhs;
299  return *this;
300  }
301 
302  int getint() const
303  {
304  if (m_value > std::numeric_limits<int>::max())
305  return std::numeric_limits<int>::max();
306  else if (m_value < std::numeric_limits<int>::min())
307  return std::numeric_limits<int>::min();
308  return m_value;
309  }
310 
311  std::vector<unsigned char> getvch() const
312  {
313  return serialize(m_value);
314  }
315 
316  static std::vector<unsigned char> serialize(const int64_t& value)
317  {
318  if(value == 0)
319  return std::vector<unsigned char>();
320 
321  std::vector<unsigned char> result;
322  const bool neg = value < 0;
323  uint64_t absvalue = neg ? -value : value;
324 
325  while(absvalue)
326  {
327  result.push_back(absvalue & 0xff);
328  absvalue >>= 8;
329  }
330 
331 // - If the most significant byte is >= 0x80 and the value is positive, push a
332 // new zero-byte to make the significant byte < 0x80 again.
333 
334 // - If the most significant byte is >= 0x80 and the value is negative, push a
335 // new 0x80 byte that will be popped off when converting to an integral.
336 
337 // - If the most significant byte is < 0x80 and the value is negative, add
338 // 0x80 to it, since it will be subtracted and interpreted as a negative when
339 // converting to an integral.
340 
341  if (result.back() & 0x80)
342  result.push_back(neg ? 0x80 : 0);
343  else if (neg)
344  result.back() |= 0x80;
345 
346  return result;
347  }
348 
349 private:
350  static int64_t set_vch(const std::vector<unsigned char>& vch)
351  {
352  if (vch.empty())
353  return 0;
354 
355  int64_t result = 0;
356  for (size_t i = 0; i != vch.size(); ++i)
357  result |= static_cast<int64_t>(vch[i]) << 8*i;
358 
359  // If the input vector's most significant byte is 0x80, remove it from
360  // the result's msb and return a negative.
361  if (vch.back() & 0x80)
362  return -((int64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1)))));
363 
364  return result;
365  }
366 
367  int64_t m_value;
368 };
369 
371 
373 class CScript : public CScriptBase
374 {
375 protected:
376  CScript& push_int64(int64_t n)
377  {
378  if (n == -1 || (n >= 1 && n <= 16))
379  {
380  push_back(n + (OP_1 - 1));
381  }
382  else if (n == 0)
383  {
384  push_back(OP_0);
385  }
386  else
387  {
388  *this << CScriptNum::serialize(n);
389  }
390  return *this;
391  }
392 public:
393  CScript() { }
394  CScript(const CScript& b) : CScriptBase(b.begin(), b.end()) { }
395  CScript(const_iterator pbegin, const_iterator pend) : CScriptBase(pbegin, pend) { }
396  CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
397  CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
398 
400  {
401  insert(end(), b.begin(), b.end());
402  return *this;
403  }
404 
405  friend CScript operator+(const CScript& a, const CScript& b)
406  {
407  CScript ret = a;
408  ret += b;
409  return ret;
410  }
411 
412  CScript(int64_t b) { operator<<(b); }
413 
414  explicit CScript(opcodetype b) { operator<<(b); }
415  explicit CScript(const CScriptNum& b) { operator<<(b); }
416  explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
417 
418 
419  CScript& operator<<(int64_t b) { return push_int64(b); }
420 
422  {
423  if (opcode < 0 || opcode > 0xff)
424  throw std::runtime_error("CScript::operator<<(): invalid opcode");
425  insert(end(), (unsigned char)opcode);
426  return *this;
427  }
428 
430  {
431  *this << b.getvch();
432  return *this;
433  }
434 
435  CScript& operator<<(const std::vector<unsigned char>& b)
436  {
437  if (b.size() < OP_PUSHDATA1)
438  {
439  insert(end(), (unsigned char)b.size());
440  }
441  else if (b.size() <= 0xff)
442  {
443  insert(end(), OP_PUSHDATA1);
444  insert(end(), (unsigned char)b.size());
445  }
446  else if (b.size() <= 0xffff)
447  {
448  insert(end(), OP_PUSHDATA2);
449  uint8_t data[2];
450  WriteLE16(data, b.size());
451  insert(end(), data, data + sizeof(data));
452  }
453  else
454  {
455  insert(end(), OP_PUSHDATA4);
456  uint8_t data[4];
457  WriteLE32(data, b.size());
458  insert(end(), data, data + sizeof(data));
459  }
460  insert(end(), b.begin(), b.end());
461  return *this;
462  }
463 
465  {
466  // I'm not sure if this should push the script or concatenate scripts.
467  // If there's ever a use for pushing a script onto a script, delete this member fn
468  assert(!"Warning: Pushing a CScript onto a CScript with << is probably not intended, use + to concatenate!");
469  return *this;
470  }
471 
472 
473  bool GetOp(iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet)
474  {
475  // Wrapper so it can be called with either iterator or const_iterator
476  const_iterator pc2 = pc;
477  bool fRet = GetOp2(pc2, opcodeRet, &vchRet);
478  pc = begin() + (pc2 - begin());
479  return fRet;
480  }
481 
482  bool GetOp(iterator& pc, opcodetype& opcodeRet)
483  {
484  const_iterator pc2 = pc;
485  bool fRet = GetOp2(pc2, opcodeRet, NULL);
486  pc = begin() + (pc2 - begin());
487  return fRet;
488  }
489 
490  bool GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet) const
491  {
492  return GetOp2(pc, opcodeRet, &vchRet);
493  }
494 
495  bool GetOp(const_iterator& pc, opcodetype& opcodeRet) const
496  {
497  return GetOp2(pc, opcodeRet, NULL);
498  }
499 
500  bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet) const
501  {
502  opcodeRet = OP_INVALIDOPCODE;
503  if (pvchRet)
504  pvchRet->clear();
505  if (pc >= end())
506  return false;
507 
508  // Read instruction
509  if (end() - pc < 1)
510  return false;
511  unsigned int opcode = *pc++;
512 
513  // Immediate operand
514  if (opcode <= OP_PUSHDATA4)
515  {
516  unsigned int nSize = 0;
517  if (opcode < OP_PUSHDATA1)
518  {
519  nSize = opcode;
520  }
521  else if (opcode == OP_PUSHDATA1)
522  {
523  if (end() - pc < 1)
524  return false;
525  nSize = *pc++;
526  }
527  else if (opcode == OP_PUSHDATA2)
528  {
529  if (end() - pc < 2)
530  return false;
531  nSize = ReadLE16(&pc[0]);
532  pc += 2;
533  }
534  else if (opcode == OP_PUSHDATA4)
535  {
536  if (end() - pc < 4)
537  return false;
538  nSize = ReadLE32(&pc[0]);
539  pc += 4;
540  }
541  if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize)
542  return false;
543  if (pvchRet)
544  pvchRet->assign(pc, pc + nSize);
545  pc += nSize;
546  }
547 
548  opcodeRet = (opcodetype)opcode;
549  return true;
550  }
551 
553  static int DecodeOP_N(opcodetype opcode)
554  {
555  if (opcode == OP_0)
556  return 0;
557  assert(opcode >= OP_1 && opcode <= OP_16);
558  return (int)opcode - (int)(OP_1 - 1);
559  }
560  static opcodetype EncodeOP_N(int n)
561  {
562  assert(n >= 0 && n <= 16);
563  if (n == 0)
564  return OP_0;
565  return (opcodetype)(OP_1+n-1);
566  }
567 
568  int FindAndDelete(const CScript& b)
569  {
570  int nFound = 0;
571  if (b.empty())
572  return nFound;
573  CScript result;
574  iterator pc = begin(), pc2 = begin();
575  opcodetype opcode;
576  do
577  {
578  result.insert(result.end(), pc2, pc);
579  while (static_cast<size_t>(end() - pc) >= b.size() && std::equal(b.begin(), b.end(), pc))
580  {
581  pc = pc + b.size();
582  ++nFound;
583  }
584  pc2 = pc;
585  }
586  while (GetOp(pc, opcode));
587 
588  if (nFound > 0) {
589  result.insert(result.end(), pc2, end());
590  *this = result;
591  }
592 
593  return nFound;
594  }
595  int Find(opcodetype op) const
596  {
597  int nFound = 0;
598  opcodetype opcode;
599  for (const_iterator pc = begin(); pc != end() && GetOp(pc, opcode);)
600  if (opcode == op)
601  ++nFound;
602  return nFound;
603  }
604 
612  unsigned int GetSigOpCount(bool fAccurate) const;
613 
618  unsigned int GetSigOpCount(const CScript& scriptSig) const;
619 
620  bool IsNormalPaymentScript() const;
621  bool IsPayToPublicKeyHash() const;
622 
623  bool IsPayToScriptHash() const;
624 
626  bool IsPushOnly(const_iterator pc) const;
627  bool IsPushOnly() const;
628 
634  bool IsUnspendable() const
635  {
636  return (size() > 0 && *begin() == OP_RETURN);
637  }
638 
639  void clear()
640  {
641  // The default std::vector::clear() does not release memory.
642  CScriptBase().swap(*this);
643  }
644 };
645 
647 {
648 public:
650  virtual void KeepScript() {}
652  virtual ~CReserveScript() {}
653 };
654 
655 #endif // BITCOIN_SCRIPT_SCRIPT_H
Definition: script.h:126
Definition: script.h:55
Definition: script.h:111
unsigned int GetSigOpCount(bool fAccurate) const
Definition: script.cpp:155
CScriptNum operator-(const CScriptNum &rhs) const
Definition: script.h:258
CReserveScript()
Definition: script.h:651
int64_t m_value
Definition: script.h:367
static const int MAX_PUBKEYS_PER_MULTISIG
Definition: script.h:28
CScript(const unsigned char *pbegin, const unsigned char *pend)
Definition: script.h:397
int Find(opcodetype op) const
Definition: script.h:595
bool IsPayToPublicKeyHash() const
Definition: script.cpp:227
Definition: script.h:94
Definition: script.h:147
Definition: script.h:86
iterator insert(iterator pos, const T &value)
Definition: prevector.h:323
static void WriteLE16(unsigned char *ptr, uint16_t x)
Definition: common.h:31
bool operator>(const int64_t &rhs) const
Definition: script.h:246
Definition: script.h:72
Definition: script.h:65
Definition: script.h:61
Definition: script.h:88
static std::vector< unsigned char > serialize(const int64_t &value)
Definition: script.h:316
Definition: script.h:125
Definition: script.h:99
Definition: script.h:53
Definition: script.h:132
Definition: script.h:59
static void WriteLE32(unsigned char *ptr, uint32_t x)
Definition: common.h:36
CScriptNum operator+(const int64_t &rhs) const
Definition: script.h:255
Definition: script.h:54
bool operator!=(const int64_t &rhs) const
Definition: script.h:242
bool operator==(const int64_t &rhs) const
Definition: script.h:241
CScriptNum(const std::vector< unsigned char > &vch, bool fRequireMinimal, const size_t nMaxNumSize=nDefaultMaxNumSize)
Definition: script.h:214
CScript & operator<<(const CScriptNum &b)
Definition: script.h:429
CScript & operator<<(int64_t b)
Definition: script.h:419
bool operator!=(const CScriptNum &rhs) const
Definition: script.h:249
bool IsPushOnly() const
Definition: script.cpp:264
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
Definition: script.h:22
Definition: script.h:146
std::vector< unsigned char > getvch() const
Definition: script.h:311
int FindAndDelete(const CScript &b)
Definition: script.h:568
static uint16_t ReadLE16(const unsigned char *ptr)
Definition: common.h:16
CScript(const_iterator pbegin, const_iterator pend)
Definition: script.h:395
Definition: script.h:67
bool GetOp(iterator &pc, opcodetype &opcodeRet)
Definition: script.h:482
Definition: script.h:63
static const int MAX_OPS_PER_SCRIPT
Definition: script.h:25
const char * GetOpName(opcodetype opcode)
Definition: script.cpp:12
Definition: script.h:112
virtual void KeepScript()
Definition: script.h:650
CScriptNum operator &(const int64_t &rhs) const
Definition: script.h:263
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
Definition: script.h:473
CScriptNum & operator=(const int64_t &rhs)
Definition: script.h:274
CScriptNum & operator-=(const CScriptNum &rhs)
Definition: script.h:261
Definition: script.h:56
bool IsUnspendable() const
Definition: script.h:634
iterator end()
Definition: prevector.h:272
bool GetOp2(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > *pvchRet) const
Definition: script.h:500
virtual ~CReserveScript()
Definition: script.h:652
Definition: script.h:133
void push_back(const T &value)
Definition: prevector.h:381
opcodetype
Definition: script.h:41
friend CScript operator+(const CScript &a, const CScript &b)
Definition: script.h:405
bool operator==(const CScriptNum &rhs) const
Definition: script.h:248
Definition: script.h:103
bool operator>=(const CScriptNum &rhs) const
Definition: script.h:252
CScriptNum & operator &=(const CScriptNum &rhs)
Definition: script.h:266
prevector< 28, unsigned char > CScriptBase
Definition: script.h:370
bool operator<(const int64_t &rhs) const
Definition: script.h:244
Definition: script.h:58
Definition: script.h:51
Definition: script.h:70
bool operator<=(const CScriptNum &rhs) const
Definition: script.h:250
Definition: script.h:96
Definition: script.h:95
bool IsNormalPaymentScript() const
Definition: script.cpp:203
scriptnum_error(const std::string &str)
Definition: script.h:192
Definition: script.h:130
CScript()
Definition: script.h:393
bool IsPayToScriptHash() const
Definition: script.cpp:238
CScript & operator<<(const CScript &b)
Definition: script.h:464
bool GetOp(const_iterator &pc, opcodetype &opcodeRet) const
Definition: script.h:495
Definition: script.h:98
Definition: script.h:131
Definition: script.h:76
CScript(int64_t b)
Definition: script.h:412
static uint32_t ReadLE32(const unsigned char *ptr)
Definition: common.h:21
CScript & operator<<(opcodetype opcode)
Definition: script.h:421
Definition: script.h:60
CScriptNum operator+(const CScriptNum &rhs) const
Definition: script.h:257
Definition: script.h:92
Definition: script.h:85
CScriptNum(const int64_t &n)
Definition: script.h:207
CScript(opcodetype b)
Definition: script.h:414
int getint() const
Definition: script.h:302
CScriptNum operator-(const int64_t &rhs) const
Definition: script.h:256
bool operator<=(const int64_t &rhs) const
Definition: script.h:243
CScriptNum & operator+=(const CScriptNum &rhs)
Definition: script.h:260
bool empty() const
Definition: prevector.h:266
CScript & operator+=(const CScript &b)
Definition: script.h:399
Definition: script.h:57
CScriptNum operator-() const
Definition: script.h:268
iterator begin()
Definition: prevector.h:270
size_type size() const
Definition: prevector.h:262
CScript(const CScriptNum &b)
Definition: script.h:415
CScriptNum & operator+=(const int64_t &rhs)
Definition: script.h:280
bool operator>=(const int64_t &rhs) const
Definition: script.h:245
CScript & push_int64(int64_t n)
Definition: script.h:376
Definition: script.h:64
Definition: script.h:97
static const unsigned int LOCKTIME_THRESHOLD
Definition: script.h:32
CScript(std::vector< unsigned char >::const_iterator pbegin, std::vector< unsigned char >::const_iterator pend)
Definition: script.h:396
void clear()
Definition: script.h:639
CScript(const CScript &b)
Definition: script.h:394
Definition: script.h:113
Definition: script.h:62
CScript(const std::vector< unsigned char > &b)
Definition: script.h:416
Definition: script.h:71
static int DecodeOP_N(opcodetype opcode)
Definition: script.h:553
CScriptNum & operator-=(const int64_t &rhs)
Definition: script.h:288
Definition: script.h:52
Definition: script.h:44
static opcodetype EncodeOP_N(int n)
Definition: script.h:560
Definition: script.h:129
static const size_t nDefaultMaxNumSize
Definition: script.h:212
Definition: script.h:66
static int64_t set_vch(const std::vector< unsigned char > &vch)
Definition: script.h:350
result
Definition: rpcuser.py:37
Definition: script.h:93
std::vector< unsigned char > ToByteVector(const T &in)
Definition: script.h:35
CScript reserveScript
Definition: script.h:649
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
Definition: script.h:490