Use deferred credits in XRPEndpointStep:

The XRPEndpointStep bypassed the logic in deferred credits and
incorrectly counted funds acquired during a payment as available for
use in the payment. It also incorrectly used the current ownerCount when
calculating the reserve instead of the owner count as it was at the
beginning of the payment (reducing the owner count is analogous to
acquiring funds during a payment.)
This commit is contained in:
seelabs
2016-08-16 15:07:31 -04:00
parent fc73fbd050
commit b92a7d415e
6 changed files with 82 additions and 54 deletions

View File

@@ -139,15 +139,8 @@ static
XRPAmount
xrpLiquid (ReadView& sb, AccountID const& src)
{
if (auto sle = sb.read (keylet::account (src)))
{
auto const reserve = sb.fees ().accountReserve ((*sle)[sfOwnerCount]);
auto const balance = (*sle)[sfBalance].xrp ();
if (balance < reserve)
return XRPAmount (beast::zero);
return balance - reserve;
}
return XRPAmount (beast::zero);
return accountHolds(
sb, src, xrpCurrency(), xrpAccount(), fhIGNORE_FREEZE, {}).xrp();
}