Make Payment use new mPriorBalance.

This commit is contained in:
Arthur Britto
2013-02-24 14:18:07 -08:00
parent 0c7d8136cf
commit 87844a6053
3 changed files with 15 additions and 15 deletions

View File

@@ -190,24 +190,22 @@ TER PaymentTransactor::doApply()
{
// Direct XRP payment.
const STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance);
const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount);
const uint64 uReserve = mEngine->getLedger()->getReserve(uOwnerCount);
STAmount saPaid = mTxn.getTransactionFee();
// Make sure have enough reserve to send. Allow final spend to use reserve for fee.
if (saSrcXRPBalance + saPaid < saDstAmount + uReserve) // Reserve is not scaled by fee.
if (mPriorBalance < saDstAmount + uReserve) // Reserve is not scaled by fee.
{
// Vote no. However, transaction might succeed, if applied in a different order.
cLog(lsINFO) << "";
cLog(lsINFO) << boost::str(boost::format("Payment: Delay transaction: Insufficient funds: %s / %s (%d)")
% saSrcXRPBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
% mPriorBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
terResult = tecUNFUNDED_PAYMENT;
}
else
{
mTxnAccount->setFieldAmount(sfBalance, saSrcXRPBalance - saDstAmount);
mTxnAccount->setFieldAmount(sfBalance, mSourceBalance - saDstAmount);
sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount);
// re-arm the password change fee if we can and need to