| 62 | } |
| 63 | |
| 64 | std::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 | |
| 100 | const std::map<unsigned char, std::string> mapSigHashTypes = { |
| 101 | {static_cast<unsigned char>(SIGHASH_ALL), std::string("ALL")}, |