mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Disallow invalid flags on payment transactions.
This commit is contained in:
@@ -40,27 +40,33 @@ TER PaymentTransactor::doApply()
|
|||||||
% saMaxAmount.getFullText()
|
% saMaxAmount.getFullText()
|
||||||
% saDstAmount.getFullText());
|
% saDstAmount.getFullText());
|
||||||
|
|
||||||
if (!uDstAccountID)
|
if (uTxFlags & tfPaymentMask)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "doPayment: Invalid transaction: Payment destination account not specified.";
|
Log(lsINFO) << "doPayment: Malformed transaction: Invalid flags set.";
|
||||||
|
|
||||||
|
return temINVALID_FLAG;
|
||||||
|
}
|
||||||
|
else if (!uDstAccountID)
|
||||||
|
{
|
||||||
|
Log(lsINFO) << "doPayment: Malformed transaction: Payment destination account not specified.";
|
||||||
|
|
||||||
return temDST_NEEDED;
|
return temDST_NEEDED;
|
||||||
}
|
}
|
||||||
else if (bMax && !saMaxAmount.isPositive())
|
else if (bMax && !saMaxAmount.isPositive())
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "doPayment: Invalid transaction: bad max amount: " << saMaxAmount.getFullText();
|
Log(lsINFO) << "doPayment: Malformed transaction: bad max amount: " << saMaxAmount.getFullText();
|
||||||
|
|
||||||
return temBAD_AMOUNT;
|
return temBAD_AMOUNT;
|
||||||
}
|
}
|
||||||
else if (!saDstAmount.isPositive())
|
else if (!saDstAmount.isPositive())
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "doPayment: Invalid transaction: bad dst amount: " << saDstAmount.getFullText();
|
Log(lsINFO) << "doPayment: Malformed transaction: bad dst amount: " << saDstAmount.getFullText();
|
||||||
|
|
||||||
return temBAD_AMOUNT;
|
return temBAD_AMOUNT;
|
||||||
}
|
}
|
||||||
else if (mTxnAccountID == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths)
|
else if (mTxnAccountID == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << boost::str(boost::format("doPayment: Invalid transaction: Redundant transaction: src=%s, dst=%s, src_cur=%s, dst_cur=%s")
|
Log(lsINFO) << boost::str(boost::format("doPayment: Malformed transaction: Redundant transaction: src=%s, dst=%s, src_cur=%s, dst_cur=%s")
|
||||||
% mTxnAccountID.ToString()
|
% mTxnAccountID.ToString()
|
||||||
% uDstAccountID.ToString()
|
% uDstAccountID.ToString()
|
||||||
% uSrcCurrency.ToString()
|
% uSrcCurrency.ToString()
|
||||||
@@ -72,7 +78,7 @@ TER PaymentTransactor::doApply()
|
|||||||
&& ((saMaxAmount == saDstAmount && saMaxAmount.getCurrency() == saDstAmount.getCurrency())
|
&& ((saMaxAmount == saDstAmount && saMaxAmount.getCurrency() == saDstAmount.getCurrency())
|
||||||
|| (saDstAmount.isNative() && saMaxAmount.isNative())))
|
|| (saDstAmount.isNative() && saMaxAmount.isNative())))
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "doPayment: Invalid transaction: bad SendMax.";
|
Log(lsINFO) << "doPayment: Malformed transaction: bad SendMax.";
|
||||||
|
|
||||||
return temINVALID;
|
return temINVALID;
|
||||||
}
|
}
|
||||||
@@ -84,7 +90,7 @@ TER PaymentTransactor::doApply()
|
|||||||
if (bCreate && !saDstAmount.isNative())
|
if (bCreate && !saDstAmount.isNative())
|
||||||
{
|
{
|
||||||
// This restriction could be relaxed.
|
// This restriction could be relaxed.
|
||||||
Log(lsINFO) << "doPayment: Invalid transaction: Create account may only fund XRP.";
|
Log(lsINFO) << "doPayment: Malformed transaction: Create account may only fund XRP.";
|
||||||
|
|
||||||
return temCREATEXRP;
|
return temCREATEXRP;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
|
|||||||
{ temDST_NEEDED, "temDST_NEEDED", "Destination not specified." },
|
{ temDST_NEEDED, "temDST_NEEDED", "Destination not specified." },
|
||||||
{ temINSUF_FEE_P, "temINSUF_FEE_P", "Fee not allowed." },
|
{ temINSUF_FEE_P, "temINSUF_FEE_P", "Fee not allowed." },
|
||||||
{ temINVALID, "temINVALID", "The transaction is ill-formed." },
|
{ temINVALID, "temINVALID", "The transaction is ill-formed." },
|
||||||
|
{ temINVALID_FLAG, "temINVALID_FLAG", "The transaction has an invalid flag." },
|
||||||
{ temREDUNDANT, "temREDUNDANT", "Sends same currency to self." },
|
{ temREDUNDANT, "temREDUNDANT", "Sends same currency to self." },
|
||||||
{ temRIPPLE_EMPTY, "temRIPPLE_EMPTY", "PathSet with no paths." },
|
{ temRIPPLE_EMPTY, "temRIPPLE_EMPTY", "PathSet with no paths." },
|
||||||
{ temUNCERTAIN, "temUNCERTAIN", "In process of determining result. Never returned." },
|
{ temUNCERTAIN, "temUNCERTAIN", "In process of determining result. Never returned." },
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ enum TER // aka TransactionEngineResult
|
|||||||
temDST_NEEDED,
|
temDST_NEEDED,
|
||||||
temINSUF_FEE_P,
|
temINSUF_FEE_P,
|
||||||
temINVALID,
|
temINVALID,
|
||||||
|
temINVALID_FLAG,
|
||||||
temREDUNDANT,
|
temREDUNDANT,
|
||||||
temRIPPLE_EMPTY,
|
temRIPPLE_EMPTY,
|
||||||
temUNCERTAIN, // An intermediate result used internally, should never be returned.
|
temUNCERTAIN, // An intermediate result used internally, should never be returned.
|
||||||
|
|||||||
@@ -63,5 +63,7 @@ const uint32 tfPartialPayment = 0x00020000;
|
|||||||
const uint32 tfLimitQuality = 0x00040000;
|
const uint32 tfLimitQuality = 0x00040000;
|
||||||
const uint32 tfNoRippleDirect = 0x00080000;
|
const uint32 tfNoRippleDirect = 0x00080000;
|
||||||
|
|
||||||
|
const uint32 tfPaymentMask = ~(tfCreateAccount|tfPartialPayment|tfLimitQuality|tfNoRippleDirect);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
Reference in New Issue
Block a user