diff --git a/src/cpp/ripple/OfferCreateTransactor.cpp b/src/cpp/ripple/OfferCreateTransactor.cpp index 92a085e010..0d6ccfc3d3 100644 --- a/src/cpp/ripple/OfferCreateTransactor.cpp +++ b/src/cpp/ripple/OfferCreateTransactor.cpp @@ -326,6 +326,16 @@ TER OfferCreateTransactor::doApply() terResult = terUNFUNDED; } + else if (isSetBit(mParams, tapOPEN_LEDGER)) // Ledger is not final, can vote no. + { + const STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance); + const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount); + // The reserve required to create the line. + const uint64 uReserveCreate = theApp->scaleFeeBase(theConfig.FEE_ACCOUNT_RESERVE + uOwnerCount*theConfig.FEE_OWNER_RESERVE); + + if (saSrcXRPBalance.getNValue() < uReserveCreate) // Have enough reserve prior to creating offer? + terResult = terINSUF_RESERVE_OFFER; + } if (tesSUCCESS == terResult && !saTakerPays.isNative()) { @@ -384,16 +394,10 @@ TER OfferCreateTransactor::doApply() // Log(lsWARNING) << "doOfferCreate: takeOffers: uPaysIssuerID=" << RippleAddress::createHumanAccountID(uPaysIssuerID); // Log(lsWARNING) << "doOfferCreate: takeOffers: uGetsIssuerID=" << RippleAddress::createHumanAccountID(uGetsIssuerID); - const STAmount saSrcXRPBalance = mTxnAccount->getFieldAmount(sfBalance); - const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount); - // The reserve required to create the line. - const uint64 uReserveCreate = theApp->scaleFeeBase(theConfig.FEE_ACCOUNT_RESERVE + (uOwnerCount+1)* theConfig.FEE_OWNER_RESERVE); - if (tesSUCCESS == terResult && saTakerPays // Still wanting something. && saTakerGets // Still offering something. - && mEngine->getNodes().accountFunds(mTxnAccountID, saTakerGets, true).isPositive() // Still funded. - && saSrcXRPBalance.getNValue() >= uReserveCreate) // Have enough reserve to create offer. + && mEngine->getNodes().accountFunds(mTxnAccountID, saTakerGets, true).isPositive()) // Still funded. { // We need to place the remainder of the offer into its order book. Log(lsINFO) << boost::str(boost::format("doOfferCreate: offer not fully consumed: saTakerPays=%s saTakerGets=%s") diff --git a/src/cpp/ripple/PaymentTransactor.cpp b/src/cpp/ripple/PaymentTransactor.cpp index c4d8a7c6f3..a911dfbe7c 100644 --- a/src/cpp/ripple/PaymentTransactor.cpp +++ b/src/cpp/ripple/PaymentTransactor.cpp @@ -83,7 +83,7 @@ TER PaymentTransactor::doApply() // Another transaction could create the account and then this transaction would succeed. return terNO_DST; } - else if (isSetBit(mParams, tapOPEN_LEDGER) // Ledger is not final, we can vote. + else if (isSetBit(mParams, tapOPEN_LEDGER) // Ledger is not final, can vote no. && saDstAmount.getNValue() < theApp->scaleFeeBase(theConfig.FEE_ACCOUNT_RESERVE)) // Reserve is not scaled by load. { Log(lsINFO) << "doPayment: Delay transaction: Destination account does not exist. Insufficent payment to create account."; diff --git a/src/cpp/ripple/TransactionErr.cpp b/src/cpp/ripple/TransactionErr.cpp index a36107e3b4..3b88387747 100644 --- a/src/cpp/ripple/TransactionErr.cpp +++ b/src/cpp/ripple/TransactionErr.cpp @@ -50,7 +50,8 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman) { terDIR_FULL, "terDIR_FULL", "Can not add entry to full dir." }, { terFUNDS_SPENT, "terFUNDS_SPENT", "Can't set password, password set funds already spent." }, { terINSUF_FEE_B, "terINSUF_FEE_B", "Account balance can't pay fee." }, - { terINSUF_RESERVE, "terINSUF_RESERVE", "Insufficent reserve to add trust line." }, + { terINSUF_RESERVE_LINE, "terINSUF_RESERVE_LINE", "Insufficent reserve to add trust line." }, + { terINSUF_RESERVE_OFFER, "terINSUF_RESERVE_OFFER", "Insufficent reserve to create offer." }, { terNO_ACCOUNT, "terNO_ACCOUNT", "The source account does not exist." }, { terNO_DST, "terNO_DST", "Destination does not exist. Send XRP to create it." }, { terNO_DST_INSUF_XRP, "terNO_DST_INSUF_XRP", "Destination does not exist. Too little XRP sent to create it." }, diff --git a/src/cpp/ripple/TransactionErr.h b/src/cpp/ripple/TransactionErr.h index 0a17405ec0..552b4fcb9d 100644 --- a/src/cpp/ripple/TransactionErr.h +++ b/src/cpp/ripple/TransactionErr.h @@ -80,7 +80,8 @@ enum TER // aka TransactionEngineResult terDIR_FULL, terFUNDS_SPENT, terINSUF_FEE_B, - terINSUF_RESERVE, + terINSUF_RESERVE_LINE, + terINSUF_RESERVE_OFFER, terNO_ACCOUNT, terNO_DST, terNO_DST_INSUF_XRP, diff --git a/src/cpp/ripple/TrustSetTransactor.cpp b/src/cpp/ripple/TrustSetTransactor.cpp index 0447e13e47..26d14fa9d2 100644 --- a/src/cpp/ripple/TrustSetTransactor.cpp +++ b/src/cpp/ripple/TrustSetTransactor.cpp @@ -239,7 +239,7 @@ TER TrustSetTransactor::doApply() Log(lsINFO) << "doTrustSet: Delay transaction: Insufficent reserve to add trust line."; // Another transaction could provide XRP to the account and then this transaction would succeed. - terResult = terINSUF_RESERVE; + terResult = terINSUF_RESERVE_LINE; } else {