Changeset View
Changeset View
Standalone View
Standalone View
src/core_read.cpp
Show All 16 Lines | |||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <boost/algorithm/string/classification.hpp> | #include <boost/algorithm/string/classification.hpp> | ||||
#include <boost/algorithm/string/replace.hpp> | #include <boost/algorithm/string/replace.hpp> | ||||
#include <boost/algorithm/string/split.hpp> | #include <boost/algorithm/string/split.hpp> | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <string> | |||||
CScript ParseScript(const std::string &s) { | CScript ParseScript(const std::string &s) { | ||||
CScript result; | CScript result; | ||||
static std::map<std::string, opcodetype> mapOpNames; | static std::map<std::string, opcodetype> mapOpNames; | ||||
if (mapOpNames.empty()) { | if (mapOpNames.empty()) { | ||||
for (int op = 0; op < FIRST_UNDEFINED_OP_VALUE; op++) { | for (int op = 0; op < FIRST_UNDEFINED_OP_VALUE; op++) { | ||||
if (op < OP_PUSHDATA1) { | if (op < OP_PUSHDATA1) { | ||||
continue; | continue; | ||||
} | } | ||||
const char *name = GetOpName(static_cast<opcodetype>(op)); | std::string strName = GetOpName(static_cast<opcodetype>(op)); | ||||
if (strcmp(name, "OP_UNKNOWN") == 0) { | if (strName == "OP_UNKNOWN") { | ||||
continue; | continue; | ||||
} | } | ||||
std::string strName(name); | |||||
mapOpNames[strName] = static_cast<opcodetype>(op); | mapOpNames[strName] = static_cast<opcodetype>(op); | ||||
// Convenience: OP_ADD and just ADD are both recognized: | // Convenience: OP_ADD and just ADD are both recognized: | ||||
boost::algorithm::replace_first(strName, "OP_", ""); | boost::algorithm::replace_first(strName, "OP_", ""); | ||||
mapOpNames[strName] = static_cast<opcodetype>(op); | mapOpNames[strName] = static_cast<opcodetype>(op); | ||||
} | } | ||||
} | } | ||||
std::vector<std::string> words; | std::vector<std::string> words; | ||||
▲ Show 20 Lines • Show All 245 Lines • Show Last 20 Lines |