Disallow and remove IOUs denominated in XRP.

This commit is contained in:
Arthur Britto
2013-04-09 01:21:26 -07:00
parent b2853161df
commit f2dd80c004
6 changed files with 26 additions and 7 deletions

View File

@@ -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";

View File

@@ -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")

View File

@@ -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);

View File

@@ -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." },

View File

@@ -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:

View File

@@ -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.