Be stricter with payment options.

This commit is contained in:
Arthur Britto
2013-01-20 20:08:24 -08:00
parent 49a3536125
commit 931bd332df
3 changed files with 37 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ TER PaymentTransactor::doApply()
: STAmount(saDstAmount.getCurrency(), mTxnAccountID, saDstAmount.getMantissa(), saDstAmount.getExponent(), saDstAmount.isNegative()); : STAmount(saDstAmount.getCurrency(), mTxnAccountID, saDstAmount.getMantissa(), saDstAmount.getExponent(), saDstAmount.isNegative());
const uint160 uSrcCurrency = saMaxAmount.getCurrency(); const uint160 uSrcCurrency = saMaxAmount.getCurrency();
const uint160 uDstCurrency = saDstAmount.getCurrency(); const uint160 uDstCurrency = saDstAmount.getCurrency();
const bool bXRPDirect = uSrcCurrency.isZero() && uDstCurrency.isZero();
cLog(lsINFO) << boost::str(boost::format("Payment> saMaxAmount=%s saDstAmount=%s") cLog(lsINFO) << boost::str(boost::format("Payment> saMaxAmount=%s saDstAmount=%s")
% saMaxAmount.getFullText() % saMaxAmount.getFullText()
@@ -70,11 +71,35 @@ TER PaymentTransactor::doApply()
return temREDUNDANT_SEND_MAX; return temREDUNDANT_SEND_MAX;
} }
else if (bMax && (saDstAmount.isNative() && saMaxAmount.isNative())) else if (bXRPDirect && bMax)
{ {
cLog(lsINFO) << "Payment: Malformed transaction: SendMax not allowed for XRP."; cLog(lsINFO) << "Payment: Malformed transaction: SendMax not allowed for XRP.";
return temBAD_SEND_MAX_XRP; return temBAD_SEND_XRP_MAX;
}
else if (bXRPDirect && bPaths)
{
cLog(lsINFO) << "Payment: Malformed transaction: Paths specfied for XRP to XRP.";
return temBAD_SEND_XRP_PATHS;
}
else if (bXRPDirect && bPartialPayment)
{
cLog(lsINFO) << "Payment: Malformed transaction: Partial payment specfied for XRP to XRP.";
return temBAD_SEND_XRP_PARTIAL;
}
else if (bXRPDirect && bLimitQuality)
{
cLog(lsINFO) << "Payment: Malformed transaction: Limit quality specfied for XRP to XRP.";
return temBAD_SEND_XRP_LIMIT;
}
else if (bXRPDirect && bNoRippleDirect)
{
cLog(lsINFO) << "Payment: Malformed transaction: No ripple direct specfied for XRP to XRP.";
return temBAD_SEND_XRP_NO_DIRECT;
} }
SLE::pointer sleDst = mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID)); SLE::pointer sleDst = mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));

View File

@@ -59,7 +59,11 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
{ temBAD_SRC_ACCOUNT, "temBAD_SRC_ACCOUNT", "Malformed: Bad source account." }, { temBAD_SRC_ACCOUNT, "temBAD_SRC_ACCOUNT", "Malformed: Bad source account." },
{ temBAD_TRANSFER_RATE, "temBAD_TRANSFER_RATE", "Malformed: Transfer rate must be >= 1.0" }, { temBAD_TRANSFER_RATE, "temBAD_TRANSFER_RATE", "Malformed: Transfer rate must be >= 1.0" },
{ temBAD_SEQUENCE, "temBAD_SEQUENCE", "Malformed: Sequence is not in the past." }, { temBAD_SEQUENCE, "temBAD_SEQUENCE", "Malformed: Sequence is not in the past." },
{ temBAD_SEND_MAX_XRP, "temBAD_SEND_MAX_XRP", "Malformed: Send max is not allowed for XRP." }, { temBAD_SEND_XRP_LIMIT, "temBAD_SEND_XRP_LIMIT", "Malformed: Limit quality is not allowed for XRP to XRP." },
{ temBAD_SEND_XRP_MAX, "temBAD_SEND_XRP_MAX", "Malformed: Send max is not allowed for XRP." },
{ temBAD_SEND_XRP_NO_DIRECT, "temBAD_SEND_XRP_NO_DIRECT", "Malformed: No Ripple direct is not allowed for XRP to XRP." },
{ temBAD_SEND_XRP_PARTIAL, "temBAD_SEND_XRP_PARTIAL", "Malformed: Partial payment is not allowed for XRP to XRP." },
{ temBAD_SEND_XRP_PATHS, "temBAD_SEND_XRP_PATHS", "Malformed: Paths are not allowed for XRP to XRP." },
{ temDST_IS_SRC, "temDST_IS_SRC", "Destination may not be source." }, { temDST_IS_SRC, "temDST_IS_SRC", "Destination may not be source." },
{ temDST_NEEDED, "temDST_NEEDED", "Destination not specified." }, { temDST_NEEDED, "temDST_NEEDED", "Destination not specified." },
{ temDST_TAG_NEEDED, "temDST_TAG_NEEDED", "Destination tag required." }, { temDST_TAG_NEEDED, "temDST_TAG_NEEDED", "Destination tag required." },

View File

@@ -39,7 +39,11 @@ enum TER // aka TransactionEngineResult
temBAD_PATH_LOOP, temBAD_PATH_LOOP,
temBAD_PUBLISH, temBAD_PUBLISH,
temBAD_TRANSFER_RATE, temBAD_TRANSFER_RATE,
temBAD_SEND_MAX_XRP, temBAD_SEND_XRP_LIMIT,
temBAD_SEND_XRP_MAX,
temBAD_SEND_XRP_NO_DIRECT,
temBAD_SEND_XRP_PARTIAL,
temBAD_SEND_XRP_PATHS,
temBAD_SIGNATURE, temBAD_SIGNATURE,
temBAD_SRC_ACCOUNT, temBAD_SRC_ACCOUNT,
temBAD_SEQUENCE, temBAD_SEQUENCE,