19 #include <boost/algorithm/string/classification.hpp>
20 #include <boost/algorithm/string/predicate.hpp>
21 #include <boost/algorithm/string/replace.hpp>
22 #include <boost/algorithm/string/split.hpp>
23 #include <boost/assign/list_of.hpp>
30 static std::map<std::string, opcodetype> mapOpNames;
32 std::vector<std::string> words;
33 boost::algorithm::split(words, s, boost::algorithm::is_any_of(
" \t\n"), boost::algorithm::token_compress_on);
35 for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w) {
38 }
else if (all(*w, boost::algorithm::is_digit()) ||
39 (boost::algorithm::starts_with(*w,
"-") && all(std::string(w->begin() + 1, w->end()), boost::algorithm::is_digit()))) {
43 }
else if (boost::algorithm::starts_with(*w,
"0x") && (w->begin() + 2 != w->end()) &&
IsHex(std::string(w->begin() + 2, w->end()))) {
45 std::vector<unsigned char> raw =
ParseHex(std::string(w->begin() + 2, w->end()));
46 result.
insert(result.
end(), raw.begin(), raw.end());
47 }
else if (w->size() >= 2 && boost::algorithm::starts_with(*w,
"'") && boost::algorithm::ends_with(*w,
"'")) {
50 std::vector<unsigned char> value(w->begin() + 1, w->end() - 1);
52 }
else if (mapOpNames.count(*w)) {
54 result << mapOpNames[*w];
56 throw std::runtime_error(
"script parse error");
68 std::vector<unsigned char> txData(
ParseHex(strHexTx));
72 }
catch (
const std::exception&) {
81 if (!
IsHex(strHexBlk))
84 std::vector<unsigned char> blockData(
ParseHex(strHexBlk));
88 }
catch (
const std::exception&) {
106 throw std::runtime_error(strName +
" must be hexadecimal string (not '" + strHex +
"')");
119 throw std::runtime_error(strName +
" must be hexadecimal string (not '" + strHex +
"')");