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

View File

@@ -202,8 +202,9 @@ TER Transactor::apply()
}
else
{
mSourceBalance = mTxnAccount->getFieldAmount(sfBalance);
mHasAuthKey = mTxnAccount->isFieldPresent(sfRegularKey);
mPriorBalance = mTxnAccount->getFieldAmount(sfBalance);
mSourceBalance = mPriorBalance;
mHasAuthKey = mTxnAccount->isFieldPresent(sfRegularKey);
}
terResult = checkSeq();

View File

@@ -10,15 +10,16 @@ class Transactor
{
protected:
const SerializedTransaction& mTxn;
TransactionEngine* mEngine;
TransactionEngineParams mParams;
TransactionEngine* mEngine;
TransactionEngineParams mParams;
uint160 mTxnAccountID;
STAmount mFeeDue;
STAmount mSourceBalance;
SLE::pointer mTxnAccount;
bool mHasAuthKey;
RippleAddress mSigningPubKey;
uint160 mTxnAccountID;
STAmount mFeeDue;
STAmount mPriorBalance; // Balance before fees.
STAmount mSourceBalance; // Balance after fees.
SLE::pointer mTxnAccount;
bool mHasAuthKey;
RippleAddress mSigningPubKey;
TER preCheck();
TER checkSeq();