23 case OP_0 :
return "0";
29 case OP_1 :
return "1";
30 case OP_2 :
return "2";
31 case OP_3 :
return "3";
32 case OP_4 :
return "4";
33 case OP_5 :
return "5";
34 case OP_6 :
return "6";
35 case OP_7 :
return "7";
36 case OP_8 :
return "8";
37 case OP_9 :
return "9";
38 case OP_10 :
return "10";
39 case OP_11 :
return "11";
40 case OP_12 :
return "12";
41 case OP_13 :
return "13";
42 case OP_14 :
return "14";
43 case OP_15 :
return "15";
44 case OP_16 :
return "16";
47 case OP_NOP :
return "OP_NOP";
48 case OP_VER :
return "OP_VER";
49 case OP_IF :
return "OP_IF";
53 case OP_ELSE :
return "OP_ELSE";
62 case OP_2DUP :
return "OP_2DUP";
63 case OP_3DUP :
return "OP_3DUP";
65 case OP_2ROT :
return "OP_2ROT";
69 case OP_DROP :
return "OP_DROP";
70 case OP_DUP :
return "OP_DUP";
71 case OP_NIP :
return "OP_NIP";
72 case OP_OVER :
return "OP_OVER";
73 case OP_PICK :
return "OP_PICK";
74 case OP_ROLL :
return "OP_ROLL";
75 case OP_ROT :
return "OP_ROT";
76 case OP_SWAP :
return "OP_SWAP";
77 case OP_TUCK :
return "OP_TUCK";
80 case OP_CAT :
return "OP_CAT";
82 case OP_LEFT :
return "OP_LEFT";
84 case OP_SIZE :
return "OP_SIZE";
88 case OP_AND :
return "OP_AND";
89 case OP_OR :
return "OP_OR";
90 case OP_XOR :
return "OP_XOR";
97 case OP_1ADD :
return "OP_1ADD";
98 case OP_1SUB :
return "OP_1SUB";
99 case OP_2MUL :
return "OP_2MUL";
100 case OP_2DIV :
return "OP_2DIV";
102 case OP_ABS :
return "OP_ABS";
103 case OP_NOT :
return "OP_NOT";
105 case OP_ADD :
return "OP_ADD";
106 case OP_SUB :
return "OP_SUB";
107 case OP_MUL :
return "OP_MUL";
108 case OP_DIV :
return "OP_DIV";
109 case OP_MOD :
return "OP_MOD";
121 case OP_MIN :
return "OP_MIN";
122 case OP_MAX :
return "OP_MAX";
127 case OP_SHA1 :
return "OP_SHA1";
138 case OP_NOP1 :
return "OP_NOP1";
141 case OP_NOP4 :
return "OP_NOP4";
142 case OP_NOP5 :
return "OP_NOP5";
143 case OP_NOP6 :
return "OP_NOP6";
144 case OP_NOP7 :
return "OP_NOP7";
145 case OP_NOP8 :
return "OP_NOP8";
146 case OP_NOP9 :
return "OP_NOP9";
167 if (!
GetOp(pc, opcode))
173 if (fAccurate && lastOpcode >=
OP_1 && lastOpcode <=
OP_16)
192 std::vector<unsigned char> vData;
193 while (pc < scriptSig.
end())
196 if (!scriptSig.
GetOp(pc, opcode, vData))
203 CScript subscript(vData.begin(), vData.end());
209 return (this->
size() == 4 &&
210 (*
this)[0] ==
OP_1 &&
211 (*
this)[1] == 0x02 &&
212 (*
this)[2] == 0x4e &&
218 return version == 1 &&
219 program.size() == 2 &&
220 program[0] == 0x4e &&
227 return (this->
size() == 23 &&
229 (*
this)[1] == 0x14 &&
236 return (this->
size() == 34 &&
237 (*
this)[0] ==
OP_0 &&
245 if (this->
size() < 4 || this->
size() > 42) {
248 if ((*
this)[0] !=
OP_0 && ((*
this)[0] <
OP_1 || (*
this)[0] >
OP_16)) {
251 if ((
size_t)((*
this)[1] + 2) == this->
size()) {
253 program = std::vector<unsigned char>(this->
begin() + 2, this->
end());
264 if (!
GetOp(pc, opcode))
283 std::string
ret =
"CScriptWitness(";
284 for (
unsigned int i = 0; i <
stack.size(); i++) {
298 std::vector<unsigned char> item;
317 unsigned int opcode = *pc++;
322 unsigned int nSize = 0;
347 if (end - pc < 0 || (
unsigned int)(end - pc) < nSize)
350 pvchRet->assign(pc, pc + nSize);
360 return opcode == 80 || opcode == 98 || (opcode >= 126 && opcode <= 129) ||
361 (opcode >= 131 && opcode <= 134) || (opcode >= 137 && opcode <= 138) ||
362 (opcode >= 141 && opcode <= 142) || (opcode >= 149 && opcode <= 153) ||
363 (opcode >= 187 && opcode <= 254);
369 if (
data.size() == 0) {
371 return opcode ==
OP_0;
372 }
else if (
data.size() == 1 &&
data[0] >= 1 &&
data[0] <= 16) {
375 }
else if (
data.size() == 1 &&
data[0] == 0x81) {
378 }
else if (
data.size() <= 75) {
380 return opcode ==
data.size();
381 }
else if (
data.size() <= 255) {
384 }
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 IsPayToAnchor() const
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
bool IsWitnessProgram(int &version, std::vector< unsigned char > &program) const
uint16_t ReadLE16(const B *ptr)
uint32_t ReadLE32(const B *ptr)
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
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