diff --git a/src/cpp/ripple/PaymentTransactor.cpp b/src/cpp/ripple/PaymentTransactor.cpp index c4aba28712..e5e27a057c 100644 --- a/src/cpp/ripple/PaymentTransactor.cpp +++ b/src/cpp/ripple/PaymentTransactor.cpp @@ -141,9 +141,10 @@ TER PaymentTransactor::doApply() 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. - if (saSrcXRPBalance < saDstAmount + uReserve) // Reserve is not scaled by fee. + // 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. { // Vote no. However, transaction might succeed, if applied in a different order. cLog(lsINFO) << ""; diff --git a/src/cpp/ripple/TransactionEngine.cpp b/src/cpp/ripple/TransactionEngine.cpp index 1a7c40f859..c2eca65f33 100644 --- a/src/cpp/ripple/TransactionEngine.cpp +++ b/src/cpp/ripple/TransactionEngine.cpp @@ -113,9 +113,13 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa cLog(lsINFO) << "applyTransaction: terResult=" << strToken << " : " << terResult << " : " << strHuman; if (terResult == tesSUCCESS) + { didApply = true; + } else if (isTepPartial(terResult) && !isSetBit(params, tapRETRY)) + { didApply = true; + } else if (isTecClaim(terResult) && !isSetBit(params, tapRETRY)) { // only claim the transaction fee cLog(lsINFO) << "Reprocessing to only claim fee"; @@ -138,11 +142,13 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa } else { - STAmount fee = txn.getTransactionFee(); - STAmount balance = txnAcct->getFieldAmount(sfBalance); + STAmount fee = txn.getTransactionFee(); + STAmount balance = txnAcct->getFieldAmount(sfBalance); if (balance < fee) + { terResult = terINSUF_FEE_B; + } else { txnAcct->setFieldAmount(sfBalance, balance - fee);