mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
JSON->Account
This commit is contained in:
@@ -897,7 +897,7 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
||||
else if (value.isInt())
|
||||
data.push_back(new STUInt32(field, range_check_cast<uint32>(value.asInt(), 0, 4294967295)));
|
||||
else if (value.isUInt())
|
||||
data.push_back(new STUInt32(field, static_cast<uint32>(value.asUInt(), 0, 4294967295)));
|
||||
data.push_back(new STUInt32(field, static_cast<uint32>(value.asUInt())));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
@@ -940,7 +940,7 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
||||
if (!value.isString())
|
||||
throw std::runtime_error("Incorrect type");
|
||||
data.push_back(new STVariableLength(field, strUnHex(value.asString())));
|
||||
break;
|
||||
break;
|
||||
|
||||
case STI_AMOUNT:
|
||||
// WRITEME
|
||||
@@ -950,9 +950,27 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
||||
|
||||
case STI_PATHSET:
|
||||
// WRITEME
|
||||
|
||||
break;
|
||||
case STI_ACCOUNT:
|
||||
// WRITEME
|
||||
{
|
||||
if (!value.isString())
|
||||
throw std::runtime_error("Incorrect type");
|
||||
std::string strValue = value.asString();
|
||||
if (value.size() == 40) // 160-bit hex account value
|
||||
{
|
||||
uint160 v;
|
||||
v.SetHex(strValue);
|
||||
data.push_back(new STAccount(field, v));
|
||||
}
|
||||
else
|
||||
{ // newcoin addres
|
||||
NewcoinAddress a;
|
||||
if (!a.setAccountPublic(strValue))
|
||||
throw std::runtime_error("Account invalid");
|
||||
data.push_back(new STAccount(field, a.getAccountID()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case STI_OBJECT:
|
||||
case STI_TRANSACTION:
|
||||
|
||||
@@ -231,9 +231,14 @@ bool STVector256::isEquivalent(const SerializedType& t) const
|
||||
// STAccount
|
||||
//
|
||||
|
||||
STAccount::STAccount(SField::ref n, const uint160& v) : STVariableLength(n)
|
||||
{
|
||||
peekValue().insert(peekValue().end(), v.begin(), v.end());
|
||||
}
|
||||
|
||||
bool STAccount::isValueH160() const
|
||||
{
|
||||
return peekValue().size() == (160/8);
|
||||
return peekValue().size() == (160 / 8);
|
||||
}
|
||||
|
||||
void STAccount::setValueH160(const uint160& v)
|
||||
|
||||
@@ -496,6 +496,7 @@ public:
|
||||
|
||||
STAccount(const std::vector<unsigned char>& v) : STVariableLength(v) { ; }
|
||||
STAccount(SField::ref n, const std::vector<unsigned char>& v) : STVariableLength(n, v) { ; }
|
||||
STAccount(SField::ref n, const uint160& v);
|
||||
STAccount(SField::ref n) : STVariableLength(n) { ; }
|
||||
STAccount() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
|
||||
Reference in New Issue
Block a user