MCPcopy Create free account
hub / github.com/LUX-Core/lux / FormatScript

Function FormatScript

src/core_write.cpp:33–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

GetJSONMethod · 0.85
ScriptToStringFunction · 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