| 294 | } |
| 295 | |
| 296 | std::string FormatScript(const CScript& script) |
| 297 | { |
| 298 | std::string ret; |
| 299 | CScript::const_iterator it = script.begin(); |
| 300 | opcodetype op; |
| 301 | while (it != script.end()) { |
| 302 | CScript::const_iterator it2 = it; |
| 303 | std::vector<unsigned char> vch; |
| 304 | if (script.GetOp(it, op, vch)) { |
| 305 | if (op == OP_0) { |
| 306 | ret += "0 "; |
| 307 | continue; |
| 308 | } else if ((op >= OP_1 && op <= OP_16) || op == OP_1NEGATE) { |
| 309 | ret += strprintf("%i ", op - OP_1NEGATE - 1); |
| 310 | continue; |
| 311 | } else if (op >= OP_NOP && op <= OP_NOP10) { |
| 312 | std::string str(GetOpName(op)); |
| 313 | if (str.substr(0, 3) == std::string("OP_")) { |
| 314 | ret += str.substr(3, std::string::npos) + " "; |
| 315 | continue; |
| 316 | } |
| 317 | } |
| 318 | if (vch.size() > 0) { |
| 319 | ret += strprintf("0x%x 0x%x ", HexStr(std::vector<uint8_t>(it2, it - vch.size())), |
| 320 | HexStr(std::vector<uint8_t>(it - vch.size(), it))); |
| 321 | } else { |
| 322 | ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, it))); |
| 323 | } |
| 324 | continue; |
| 325 | } |
| 326 | ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end()))); |
| 327 | break; |
| 328 | } |
| 329 | return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1); |
| 330 | } |
| 331 | |
| 332 | const std::map<unsigned char, std::string> mapSigHashTypes = { |
| 333 | {static_cast<unsigned char>(SIGHASH_ALL), std::string("ALL")}, |