MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FormatScript

Function FormatScript

src/core_write.cpp:29–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29std::string FormatScript(const CScript& script)
30{
31 std::string ret;
32 CScript::const_iterator it = script.begin();
33 opcodetype op;
34 while (it != script.end()) {
35 CScript::const_iterator it2 = it;
36 std::vector<unsigned char> vch;
37 if (script.GetOp(it, op, vch)) {
38 if (op == OP_0) {
39 ret += "0 ";
40 continue;
41 } else if ((op >= OP_1 && op <= OP_16) || op == OP_1NEGATE) {
42 ret += strprintf("%i ", op - OP_1NEGATE - 1);
43 continue;
44 } else if (op >= OP_NOP && op <= OP_NOP10) {
45 std::string str(GetOpName(op));
46 if (str.substr(0, 3) == std::string("OP_")) {
47 ret += str.substr(3, std::string::npos) + " ";
48 continue;
49 }
50 }
51 if (vch.size() > 0) {
52 ret += strprintf("0x%x 0x%x ", HexStr(it2, it - vch.size()), HexStr(it - vch.size(), it));
53 } else {
54 ret += strprintf("0x%x ", HexStr(it2, it));
55 }
56 continue;
57 }
58 ret += strprintf("0x%x ", HexStr(it2, script.end()));
59 break;
60 }
61 return ret.substr(0, ret.size() - 1);
62}
63
64const std::map<unsigned char, std::string> mapSigHashTypes = {
65 {static_cast<unsigned char>(SIGHASH_ALL), std::string("ALL")},

Callers 1

GetJSONMethod · 0.85

Calls 6

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

Tested by 1

GetJSONMethod · 0.68