20 case OP_0 :
return "0";
26 case OP_1 :
return "1";
27 case OP_2 :
return "2";
28 case OP_3 :
return "3";
29 case OP_4 :
return "4";
30 case OP_5 :
return "5";
31 case OP_6 :
return "6";
32 case OP_7 :
return "7";
33 case OP_8 :
return "8";
34 case OP_9 :
return "9";
35 case OP_10 :
return "10";
36 case OP_11 :
return "11";
37 case OP_12 :
return "12";
38 case OP_13 :
return "13";
39 case OP_14 :
return "14";
40 case OP_15 :
return "15";
41 case OP_16 :
return "16";
44 case OP_NOP :
return "OP_NOP";
45 case OP_VER :
return "OP_VER";
46 case OP_IF :
return "OP_IF";
50 case OP_ELSE :
return "OP_ELSE";
59 case OP_2DUP :
return "OP_2DUP";
60 case OP_3DUP :
return "OP_3DUP";
62 case OP_2ROT :
return "OP_2ROT";
66 case OP_DROP :
return "OP_DROP";
67 case OP_DUP :
return "OP_DUP";
68 case OP_NIP :
return "OP_NIP";
69 case OP_OVER :
return "OP_OVER";
70 case OP_PICK :
return "OP_PICK";
71 case OP_ROLL :
return "OP_ROLL";
72 case OP_ROT :
return "OP_ROT";
73 case OP_SWAP :
return "OP_SWAP";
74 case OP_TUCK :
return "OP_TUCK";
77 case OP_CAT :
return "OP_CAT";
79 case OP_LEFT :
return "OP_LEFT";
81 case OP_SIZE :
return "OP_SIZE";
85 case OP_AND :
return "OP_AND";
86 case OP_OR :
return "OP_OR";
87 case OP_XOR :
return "OP_XOR";
94 case OP_1ADD :
return "OP_1ADD";
95 case OP_1SUB :
return "OP_1SUB";
96 case OP_2MUL :
return "OP_2MUL";
97 case OP_2DIV :
return "OP_2DIV";
99 case OP_ABS :
return "OP_ABS";
100 case OP_NOT :
return "OP_NOT";
102 case OP_ADD :
return "OP_ADD";
103 case OP_SUB :
return "OP_SUB";
104 case OP_MUL :
return "OP_MUL";
105 case OP_DIV :
return "OP_DIV";
106 case OP_MOD :
return "OP_MOD";
118 case OP_MIN :
return "OP_MIN";
119 case OP_MAX :
return "OP_MAX";
124 case OP_SHA1 :
return "OP_SHA1";
135 case OP_NOP1 :
return "OP_NOP1";
138 case OP_NOP4 :
return "OP_NOP4";
139 case OP_NOP5 :
return "OP_NOP5";
140 case OP_NOP6 :
return "OP_NOP6";
141 case OP_NOP7 :
return "OP_NOP7";
142 case OP_NOP8 :
return "OP_NOP8";
143 case OP_NOP9 :
return "OP_NOP9";
164 if (!
GetOp(pc, opcode))
170 if (fAccurate && lastOpcode >=
OP_1 && lastOpcode <=
OP_16)
189 std::vector<unsigned char> vData;
190 while (pc < scriptSig.
end())
193 if (!scriptSig.
GetOp(pc, opcode, vData))
200 CScript subscript(vData.begin(), vData.end());
207 return (this->
size() == 23 &&
209 (*
this)[1] == 0x14 &&
216 return (this->
size() == 34 &&
217 (*
this)[0] ==
OP_0 &&
225 if (this->
size() < 4 || this->
size() > 42) {
228 if ((*
this)[0] !=
OP_0 && ((*
this)[0] <
OP_1 || (*
this)[0] >
OP_16)) {
231 if ((
size_t)((*
this)[1] + 2) == this->
size()) {
233 program = std::vector<unsigned char>(this->
begin() + 2, this->
end());
244 if (!
GetOp(pc, opcode))
263 std::string
ret =
"CScriptWitness(";
264 for (
unsigned int i = 0; i <
stack.size(); i++) {
278 std::vector<unsigned char> item;
297 unsigned int opcode = *pc++;
302 unsigned int nSize = 0;
327 if (end - pc < 0 || (
unsigned int)(end - pc) < nSize)
330 pvchRet->assign(pc, pc + nSize);
340 return opcode == 80 || opcode == 98 || (opcode >= 126 && opcode <= 129) ||
341 (opcode >= 131 && opcode <= 134) || (opcode >= 137 && opcode <= 138) ||
342 (opcode >= 141 && opcode <= 142) || (opcode >= 149 && opcode <= 153) ||
343 (opcode >= 187 && opcode <= 254);
349 if (data.size() == 0) {
351 return opcode ==
OP_0;
352 }
else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) {
355 }
else if (data.size() == 1 && data[0] == 0x81) {
358 }
else if (data.size() <= 75) {
360 return opcode == data.size();
361 }
else if (data.size() <= 255) {
364 }
else if (data.size() <= 65535) {
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
static int DecodeOP_N(opcodetype opcode)
Encode/decode small integers:
bool CheckMinimalPush(const std::vector< unsigned char > &data, opcodetype opcode)
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
bool IsPayToScriptHash() const
bool GetScriptOp(CScriptBase::const_iterator &pc, CScriptBase::const_iterator end, opcodetype &opcodeRet, std::vector< unsigned char > *pvchRet)
std::vector< std::vector< unsigned char > > stack
bool HasValidOps() const
Check if the script contains valid OP_CODES.
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
static const int MAX_PUBKEYS_PER_MULTISIG
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
opcodetype
Script opcodes.
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
std::string GetOpName(opcodetype opcode)
Serialized script, used inside transaction inputs and outputs.
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
static uint32_t ReadLE32(const unsigned char *ptr)
static uint16_t ReadLE16(const unsigned char *ptr)
static const unsigned int MAX_OPCODE
std::string ToString() const
bool IsOpSuccess(const opcodetype &opcode)
Test for OP_SUCCESSx opcodes as defined by BIP342.
bool IsPayToWitnessScriptHash() const