diff --git a/src/cpp/ripple/OfferCreateTransactor.cpp b/src/cpp/ripple/OfferCreateTransactor.cpp index 0743b36380..c415522b28 100644 --- a/src/cpp/ripple/OfferCreateTransactor.cpp +++ b/src/cpp/ripple/OfferCreateTransactor.cpp @@ -436,6 +436,12 @@ TER OfferCreateTransactor::doApply() terResult = temREDUNDANT; } + else if (CURRENCY_BAD == uPaysCurrency || CURRENCY_BAD == uGetsCurrency) + { + cLog(lsWARNING) << "OfferCreate: Malformed offer: Bad currency."; + + terResult = temBAD_CURRENCY; + } else if (saTakerPays.isNative() != !uPaysIssuerID || saTakerGets.isNative() != !uGetsIssuerID) { cLog(lsWARNING) << "OfferCreate: Malformed offer: bad issuer"; diff --git a/src/cpp/ripple/PaymentTransactor.cpp b/src/cpp/ripple/PaymentTransactor.cpp index 3a5f12a504..65c4aedf37 100644 --- a/src/cpp/ripple/PaymentTransactor.cpp +++ b/src/cpp/ripple/PaymentTransactor.cpp @@ -55,6 +55,12 @@ TER PaymentTransactor::doApply() return temBAD_AMOUNT; } + else if (CURRENCY_BAD == uSrcCurrency || CURRENCY_BAD == uDstCurrency) + { + cLog(lsINFO) << "Payment: Malformed transaction: Bad currency."; + + return temBAD_CURRENCY; + } else if (mTxnAccountID == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths) { cLog(lsINFO) << boost::str(boost::format("Payment: Malformed transaction: Redundant transaction: src=%s, dst=%s, src_cur=%s, dst_cur=%s") diff --git a/src/cpp/ripple/SerializedTypes.h b/src/cpp/ripple/SerializedTypes.h index 562886bfe0..4025274f3c 100644 --- a/src/cpp/ripple/SerializedTypes.h +++ b/src/cpp/ripple/SerializedTypes.h @@ -39,9 +39,10 @@ static inline const uint160& get_u160_zero() { return u160_zero; } static inline const uint160& get_u160_one() { return u160_one; } #define CURRENCY_XRP get_u160_zero() -#define CURRENCY_ONE get_u160_one() // Used as a place holder +#define CURRENCY_ONE get_u160_one() // Used as a place holder. +#define CURRENCY_BAD uint160(0x5852500000000000) // Do not allow XRP as an IOU currency. #define ACCOUNT_XRP get_u160_zero() -#define ACCOUNT_ONE get_u160_one() // Used as a place holder +#define ACCOUNT_ONE get_u160_one() // Used as a place holder. DEFINE_INSTANCE(SerializedValue); diff --git a/src/cpp/ripple/TransactionErr.cpp b/src/cpp/ripple/TransactionErr.cpp index 1709cfc368..d75ff2366a 100644 --- a/src/cpp/ripple/TransactionErr.cpp +++ b/src/cpp/ripple/TransactionErr.cpp @@ -33,12 +33,12 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman) { tefBAD_GEN_AUTH, "tefBAD_GEN_AUTH", "Not authorized to claim generator." }, { tefBAD_LEDGER, "tefBAD_LEDGER", "Ledger in unexpected state." }, { tefCLAIMED, "tefCLAIMED", "Can not claim a previously claimed account." }, - { tefEXCEPTION, "tefEXCEPTION", "Unexpected program state." }, { tefCREATED, "tefCREATED", "Can't add an already created account." }, + { tefEXCEPTION, "tefEXCEPTION", "Unexpected program state." }, { tefGEN_IN_USE, "tefGEN_IN_USE", "Generator already in use." }, + { tefINTERNAL, "tefINTERNAL", "Internal error." }, { tefNO_AUTH_REQUIRED, "tefNO_AUTH_REQUIRED", "Auth is not required." }, { tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." }, - { tefINTERNAL, "tefINTERNAL", "Internal error." }, { telLOCAL_ERROR, "telLOCAL_ERROR", "Local failure." }, { telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." }, @@ -51,6 +51,7 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman) { temMALFORMED, "temMALFORMED", "Malformed transaction." }, { temBAD_AMOUNT, "temBAD_AMOUNT", "Can only send positive amounts." }, { temBAD_AUTH_MASTER, "temBAD_AUTH_MASTER", "Auth for unclaimed account needs correct master key." }, + { temBAD_CURRENCY, "temBAD_CURRENCY", "Malformed: Bad currency." }, { temBAD_FEE, "temBAD_FEE", "Invalid fee, negative or not XRP." }, { temBAD_EXPIRATION, "temBAD_EXPIRATION", "Malformed: Bad expiration." }, { temBAD_ISSUER, "temBAD_ISSUER", "Malformed: Bad issuer." }, diff --git a/src/cpp/ripple/TransactionErr.h b/src/cpp/ripple/TransactionErr.h index 186aa3c145..f64943a03c 100644 --- a/src/cpp/ripple/TransactionErr.h +++ b/src/cpp/ripple/TransactionErr.h @@ -31,6 +31,7 @@ enum TER // aka TransactionEngineResult temMALFORMED = -299, temBAD_AMOUNT, temBAD_AUTH_MASTER, + temBAD_CURRENCY, temBAD_FEE, temBAD_EXPIRATION, temBAD_ISSUER, @@ -79,9 +80,9 @@ enum TER // aka TransactionEngineResult tefCREATED, tefEXCEPTION, tefGEN_IN_USE, + tefINTERNAL, tefNO_AUTH_REQUIRED, // Can't set auth if auth is not required. tefPAST_SEQ, - tefINTERNAL, // -99 .. -1: R Retry (sequence too high, no funds for txn fee, originating account non-existent) // Causes: diff --git a/src/cpp/ripple/TrustSetTransactor.cpp b/src/cpp/ripple/TrustSetTransactor.cpp index a8f9f7a487..062778815f 100644 --- a/src/cpp/ripple/TrustSetTransactor.cpp +++ b/src/cpp/ripple/TrustSetTransactor.cpp @@ -248,9 +248,9 @@ TER TrustSetTransactor::doApply() if (uFlagsIn != uFlagsOut) sleRippleState->setFieldU32(sfFlags, uFlagsOut); - if (bDefault) + if (bDefault || CURRENCY_BAD == uCurrencyID) { - // Can delete. + // Delete. terResult = mEngine->getNodes().trustDelete(sleRippleState, uLowAccountID, uHighAccountID); } @@ -285,6 +285,10 @@ TER TrustSetTransactor::doApply() // Another transaction could create the account and then this transaction would succeed. terResult = tecNO_LINE_INSUF_RESERVE; } + else if (CURRENCY_BAD == uCurrencyID) + { + terResult = temBAD_CURRENCY; + } else { STAmount saBalance = STAmount(uCurrencyID, ACCOUNT_ONE); // Zero balance in currency.