mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add hack to show currency in Json for STAmount.
This commit is contained in:
@@ -44,7 +44,8 @@ bool STAmount::currencyFromString(uint160& uDstCurrency, const std::string& sCur
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
std::string STAmount::getCurrencyHuman()
|
||||
// XXX Broken for custom currencies?
|
||||
std::string STAmount::getCurrencyHuman() const
|
||||
{
|
||||
std::string sCurrency;
|
||||
|
||||
@@ -823,6 +824,20 @@ STAmount STAmount::deserialize(SerializerIterator& it)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value STAmount::getJson(int) const
|
||||
{
|
||||
Json::Value elem(Json::objectValue);
|
||||
|
||||
elem["value"] = getText();
|
||||
|
||||
// This is a hack, many places don't specify a currency. STAmount is used just as a value.
|
||||
if (!mIsNative)
|
||||
elem["currency"] = getCurrencyHuman();
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
// For unit tests:
|
||||
static STAmount serdes(const STAmount &s)
|
||||
{
|
||||
Serializer ser;
|
||||
@@ -834,7 +849,6 @@ static STAmount serdes(const STAmount &s)
|
||||
return STAmount::deserialize(sit);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(amount)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( setValue_test )
|
||||
|
||||
Reference in New Issue
Block a user