Changeset View
Changeset View
Standalone View
Standalone View
src/core_read.cpp
Show All 13 Lines | |||||
#include "version.h" | #include "version.h" | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <boost/algorithm/string/classification.hpp> | #include <boost/algorithm/string/classification.hpp> | ||||
#include <boost/algorithm/string/predicate.hpp> | #include <boost/algorithm/string/predicate.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 <boost/lexical_cast.hpp> | |||||
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++) { | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | for (const auto &w : words) { | ||||
throw std::runtime_error("Error parsing script: " + s); | throw std::runtime_error("Error parsing script: " + s); | ||||
next: | next: | ||||
size_t size_change = result.size() - script_size; | size_t size_change = result.size() - script_size; | ||||
// If push_size is set, ensure have added the right amount of stuff. | // If push_size is set, ensure have added the right amount of stuff. | ||||
if (push_size != 0 && size_change != push_size) { | if (push_size != 0 && size_change != push_size) { | ||||
throw std::runtime_error("Wrong number of bytes being pushed."); | throw std::runtime_error( | ||||
"Wrong number of bytes being pushed. Expected:" + | |||||
boost::lexical_cast<std::string>(push_size) + | |||||
" Pushed:" + boost::lexical_cast<std::string>(size_change)); | |||||
} | } | ||||
// If push_size is set, and we have push_data_size set, then we have a | // If push_size is set, and we have push_data_size set, then we have a | ||||
// PUSHDATAX opcode. We need to read it's push size as a LE value for | // PUSHDATAX opcode. We need to read it's push size as a LE value for | ||||
// the next iteration of this loop. | // the next iteration of this loop. | ||||
if (push_size != 0 && push_data_size != 0) { | if (push_size != 0 && push_data_size != 0) { | ||||
auto offset = &result[script_size]; | auto offset = &result[script_size]; | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |