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

Function FormatScript

src/core_write.cpp:23–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

GetJSONMethod · 0.85

Calls 6

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

Tested by 1

GetJSONMethod · 0.68