Fix calculation of XRP available after reserve.

This commit is contained in:
Arthur Britto
2013-02-11 22:59:50 -08:00
parent dce8a65fbc
commit b05c5c3892

View File

@@ -1072,25 +1072,31 @@ STAmount LedgerEntrySet::accountHolds(const uint160& uAccountID, const uint160&
SLE::pointer sleAccount = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uAccountID));
uint64 uReserve = mLedger->getReserve(sleAccount->getFieldU32(sfOwnerCount));
saAmount = sleAccount->getFieldAmount(sfBalance)-uReserve;
STAmount saBalance = sleAccount->getFieldAmount(sfBalance);
if (saAmount < uReserve)
if (saBalance < uReserve)
{
saAmount.zero();
}
else
{
saAmount -= uReserve;
saAmount = saBalance-uReserve;
}
cLog(lsINFO) << boost::str(boost::format("accountHolds: uAccountID=%s saAmount=%s saBalance=%s uReserve=%d")
% RippleAddress::createHumanAccountID(uAccountID)
% saAmount.getFullText()
% saBalance.getFullText()
% uReserve);
}
else
{
saAmount = rippleHolds(uAccountID, uCurrencyID, uIssuerID);
}
cLog(lsINFO) << boost::str(boost::format("accountHolds: uAccountID=%s saAmount=%s")
% RippleAddress::createHumanAccountID(uAccountID)
% saAmount.getFullText());
cLog(lsINFO) << boost::str(boost::format("accountHolds: uAccountID=%s saAmount=%s")
% RippleAddress::createHumanAccountID(uAccountID)
% saAmount.getFullText());
}
return saAmount;
}