MCPcopy Create free account
hub / github.com/ElementsProject/elements / FormatScript

Function FormatScript

src/core_write.cpp:64–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64std::string FormatScript(const CScript& script)
65{
66 std::string ret;
67 CScript::const_iterator it = script.begin();
68 opcodetype op;
69 while (it != script.end()) {
70 CScript::const_iterator it2 = it;
71 std::vector<unsigned char> vch;
72 if (script.GetOp(it, op, vch)) {
73 if (op == OP_0) {
74 ret += "0 ";
75 continue;
76 } else if ((op >= OP_1 && op <= OP_16) || op == OP_1NEGATE) {
77 ret += strprintf("%i ", op - OP_1NEGATE - 1);
78 continue;
79 } else if (op >= OP_NOP && op <= OP_NOP10) {
80 std::string str(GetOpName(op));
81 if (str.substr(0, 3) == std::string("OP_")) {
82 ret += str.substr(3, std::string::npos) + " ";
83 continue;
84 }
85 }
86 if (vch.size() > 0) {
87 ret += strprintf("0x%x 0x%x ", HexStr(std::vector<uint8_t>(it2, it - vch.size())),
88 HexStr(std::vector<uint8_t>(it - vch.size(), it)));
89 } else {
90 ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, it)));
91 }
92 continue;
93 }
94 ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end())));
95 break;
96 }
97 return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
98}
99
100const std::map<unsigned char, std::string> mapSigHashTypes = {
101 {static_cast<unsigned char>(SIGHASH_ALL), std::string("ALL")},

Callers 2

GetJSONMethod · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 7

GetOpNameFunction · 0.85
GetOpMethod · 0.80
HexStrFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by 2

GetJSONMethod · 0.68
FUZZ_TARGET_INITFunction · 0.68