17 case OP_0 :
return "0";
23 case OP_1 :
return "1";
24 case OP_2 :
return "2";
25 case OP_3 :
return "3";
26 case OP_4 :
return "4";
27 case OP_5 :
return "5";
28 case OP_6 :
return "6";
29 case OP_7 :
return "7";
30 case OP_8 :
return "8";
31 case OP_9 :
return "9";
32 case OP_10 :
return "10";
33 case OP_11 :
return "11";
34 case OP_12 :
return "12";
35 case OP_13 :
return "13";
36 case OP_14 :
return "14";
37 case OP_15 :
return "15";
38 case OP_16 :
return "16";
41 case OP_NOP :
return "OP_NOP";
42 case OP_VER :
return "OP_VER";
43 case OP_IF :
return "OP_IF";
47 case OP_ELSE :
return "OP_ELSE";
56 case OP_2DUP :
return "OP_2DUP";
57 case OP_3DUP :
return "OP_3DUP";
59 case OP_2ROT :
return "OP_2ROT";
63 case OP_DROP :
return "OP_DROP";
64 case OP_DUP :
return "OP_DUP";
65 case OP_NIP :
return "OP_NIP";
66 case OP_OVER :
return "OP_OVER";
67 case OP_PICK :
return "OP_PICK";
68 case OP_ROLL :
return "OP_ROLL";
69 case OP_ROT :
return "OP_ROT";
70 case OP_SWAP :
return "OP_SWAP";
71 case OP_TUCK :
return "OP_TUCK";
74 case OP_CAT :
return "OP_CAT";
76 case OP_LEFT :
return "OP_LEFT";
78 case OP_SIZE :
return "OP_SIZE";
82 case OP_AND :
return "OP_AND";
83 case OP_OR :
return "OP_OR";
84 case OP_XOR :
return "OP_XOR";
91 case OP_1ADD :
return "OP_1ADD";
92 case OP_1SUB :
return "OP_1SUB";
93 case OP_2MUL :
return "OP_2MUL";
94 case OP_2DIV :
return "OP_2DIV";
96 case OP_ABS :
return "OP_ABS";
97 case OP_NOT :
return "OP_NOT";
99 case OP_ADD :
return "OP_ADD";
100 case OP_SUB :
return "OP_SUB";
101 case OP_MUL :
return "OP_MUL";
102 case OP_DIV :
return "OP_DIV";
103 case OP_MOD :
return "OP_MOD";
115 case OP_MIN :
return "OP_MIN";
116 case OP_MAX :
return "OP_MAX";
121 case OP_SHA1 :
return "OP_SHA1";
132 case OP_NOP1 :
return "OP_NOP1";
135 case OP_NOP4 :
return "OP_NOP4";
136 case OP_NOP5 :
return "OP_NOP5";
137 case OP_NOP6 :
return "OP_NOP6";
138 case OP_NOP7 :
return "OP_NOP7";
139 case OP_NOP8 :
return "OP_NOP8";
140 case OP_NOP9 :
return "OP_NOP9";
161 if (!
GetOp(pc, opcode))
167 if (fAccurate && lastOpcode >=
OP_1 && lastOpcode <=
OP_16)
186 std::vector<unsigned char> vData;
187 while (pc < scriptSig.
end())
190 if (!scriptSig.
GetOp(pc, opcode, vData))
197 CScript subscript(vData.begin(), vData.end());
204 return (this->
size() == 23 &&
206 (*
this)[1] == 0x14 &&
213 return (this->
size() == 34 &&
214 (*
this)[0] ==
OP_0 &&
222 if (this->
size() < 4 || this->
size() > 42) {
225 if ((*
this)[0] !=
OP_0 && ((*
this)[0] <
OP_1 || (*
this)[0] >
OP_16)) {
228 if ((
size_t)((*
this)[1] + 2) == this->
size()) {
230 program = std::vector<unsigned char>(this->
begin() + 2, this->
end());
241 if (!
GetOp(pc, opcode))
260 std::string
ret =
"CScriptWitness(";
261 for (
unsigned int i = 0; i <
stack.size(); i++) {
275 std::vector<unsigned char> item;
294 unsigned int opcode = *pc++;
299 unsigned int nSize = 0;
324 if (end - pc < 0 || (
unsigned int)(end - pc) < nSize)
327 pvchRet->assign(pc, pc + nSize);
337 return opcode == 80 || opcode == 98 || (opcode >= 126 && opcode <= 129) ||
338 (opcode >= 131 && opcode <= 134) || (opcode >= 137 && opcode <= 138) ||
339 (opcode >= 141 && opcode <= 142) || (opcode >= 149 && opcode <= 153) ||
340 (opcode >= 187 && opcode <= 254);
346 if (data.size() == 0) {
348 return opcode ==
OP_0;
349 }
else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) {
352 }
else if (data.size() == 1 && data[0] == 0x81) {
355 }
else if (data.size() <= 75) {
357 return opcode == data.size();
358 }
else if (data.size() <= 255) {
361 }
else if (data.size() <= 65535) {
Serialized script, used inside transaction inputs and outputs.
bool IsPayToScriptHash() const
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
bool IsPayToWitnessScriptHash() const
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
bool HasValidOps() const
Check if the script contains valid OP_CODES.
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
static uint16_t ReadLE16(const unsigned char *ptr)
static uint32_t ReadLE32(const unsigned char *ptr)
std::string GetOpName(opcodetype opcode)
bool CheckMinimalPush(const std::vector< unsigned char > &data, opcodetype opcode)
bool GetScriptOp(CScriptBase::const_iterator &pc, CScriptBase::const_iterator end, opcodetype &opcodeRet, std::vector< unsigned char > *pvchRet)
bool IsOpSuccess(const opcodetype &opcode)
Test for OP_SUCCESSx opcodes as defined by BIP342.
static const unsigned int MAX_OPCODE
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
opcodetype
Script opcodes.
static const int MAX_PUBKEYS_PER_MULTISIG
std::string ToString() const
std::vector< std::vector< unsigned char > > stack
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.