aboutsummaryrefslogtreecommitdiff
path: root/src/core_read.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r--src/core_read.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp
index 85bb62c176..a8d667e3bc 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -20,13 +20,11 @@
#include <boost/algorithm/string/split.hpp>
#include <boost/assign/list_of.hpp>
-using namespace std;
-
CScript ParseScript(const std::string& s)
{
CScript result;
- static map<string, opcodetype> mapOpNames;
+ static std::map<std::string, opcodetype> mapOpNames;
if (mapOpNames.empty())
{
@@ -39,7 +37,7 @@ CScript ParseScript(const std::string& s)
const char* name = GetOpName((opcodetype)op);
if (strcmp(name, "OP_UNKNOWN") == 0)
continue;
- string strName(name);
+ std::string strName(name);
mapOpNames[strName] = (opcodetype)op;
// Convenience: OP_ADD and just ADD are both recognized:
boost::algorithm::replace_first(strName, "OP_", "");
@@ -47,7 +45,7 @@ CScript ParseScript(const std::string& s)
}
}
- vector<string> words;
+ std::vector<std::string> words;
boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);
for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
@@ -57,16 +55,16 @@ CScript ParseScript(const std::string& s)
// Empty string, ignore. (boost::split given '' will return one word)
}
else if (all(*w, boost::algorithm::is_digit()) ||
- (boost::algorithm::starts_with(*w, "-") && all(string(w->begin()+1, w->end()), boost::algorithm::is_digit())))
+ (boost::algorithm::starts_with(*w, "-") && all(std::string(w->begin()+1, w->end()), boost::algorithm::is_digit())))
{
// Number
int64_t n = atoi64(*w);
result << n;
}
- else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(string(w->begin()+2, w->end())))
+ else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(std::string(w->begin()+2, w->end())))
{
// Raw hex data, inserted NOT pushed onto stack:
- std::vector<unsigned char> raw = ParseHex(string(w->begin()+2, w->end()));
+ std::vector<unsigned char> raw = ParseHex(std::string(w->begin()+2, w->end()));
result.insert(result.end(), raw.begin(), raw.end());
}
else if (w->size() >= 2 && boost::algorithm::starts_with(*w, "'") && boost::algorithm::ends_with(*w, "'"))
@@ -83,7 +81,7 @@ CScript ParseScript(const std::string& s)
}
else
{
- throw runtime_error("script parse error");
+ throw std::runtime_error("script parse error");
}
}
@@ -95,7 +93,7 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& strHexTx, bool fTry
if (!IsHex(strHexTx))
return false;
- vector<unsigned char> txData(ParseHex(strHexTx));
+ std::vector<unsigned char> txData(ParseHex(strHexTx));
if (fTryNoWitness) {
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
@@ -113,6 +111,8 @@ bool DecodeHexTx(CMutableTransaction& tx, const std::string& strHexTx, bool fTry
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
try {
ssData >> tx;
+ if (!ssData.empty())
+ return false;
}
catch (const std::exception&) {
return false;
@@ -138,9 +138,9 @@ bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk)
return true;
}
-uint256 ParseHashUV(const UniValue& v, const string& strName)
+uint256 ParseHashUV(const UniValue& v, const std::string& strName)
{
- string strHex;
+ std::string strHex;
if (v.isStr())
strHex = v.getValStr();
return ParseHashStr(strHex, strName); // Note: ParseHashStr("") throws a runtime_error
@@ -149,19 +149,19 @@ uint256 ParseHashUV(const UniValue& v, const string& strName)
uint256 ParseHashStr(const std::string& strHex, const std::string& strName)
{
if (!IsHex(strHex)) // Note: IsHex("") is false
- throw runtime_error(strName+" must be hexadecimal string (not '"+strHex+"')");
+ throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
uint256 result;
result.SetHex(strHex);
return result;
}
-vector<unsigned char> ParseHexUV(const UniValue& v, const string& strName)
+std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName)
{
- string strHex;
+ std::string strHex;
if (v.isStr())
strHex = v.getValStr();
if (!IsHex(strHex))
- throw runtime_error(strName+" must be hexadecimal string (not '"+strHex+"')");
+ throw std::runtime_error(strName + " must be hexadecimal string (not '" + strHex + "')");
return ParseHex(strHex);
}