diff --git a/src/SerializedObject.cpp b/src/SerializedObject.cpp index 4aea81b52b..f3700f5aef 100644 --- a/src/SerializedObject.cpp +++ b/src/SerializedObject.cpp @@ -939,7 +939,7 @@ std::auto_ptr STObject::parseJson(const Json::Value& object, SField::r case STI_UINT64: if (value.isString()) - data.push_back(new STUInt64(field, lexical_cast_st(value.asString()))); + data.push_back(new STUInt64(field, uintFromHex(value.asString()))); else if (value.isInt()) data.push_back(new STUInt64(field, range_check_cast(value.asInt(), 0, 18446744073709551615ull))); diff --git a/src/utils.cpp b/src/utils.cpp index 944a281139..979381c2c1 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -2,6 +2,7 @@ #include "uint256.h" #include +#include #include // @@ -67,6 +68,16 @@ std::vector strUnHex(const std::string& strSrc) return strCopy(strTmp); } +uint64_t uintFromHex(const std::string& strSrc) +{ + uint64_t uValue = 0; + + BOOST_FOREACH(char c, strSrc) + uValue = (uValue << 4) | charUnHex(c); + + return uValue; +} + // // Misc string // diff --git a/src/utils.h b/src/utils.h index 5b4d184e73..5dd4208055 100644 --- a/src/utils.h +++ b/src/utils.h @@ -162,6 +162,8 @@ bool isZero(Iterator first, int iSize) int charUnHex(char cDigit); void strUnHex(std::string& strDst, const std::string& strSrc); +uint64_t uintFromHex(const std::string& strSrc); + std::vector strUnHex(const std::string& strSrc); std::vector strCopy(const std::string& strSrc);