mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Enforce SendMax restrictions in transaction engine.
This commit is contained in:
@@ -500,7 +500,7 @@ Transaction::pointer Transaction::setPayment(
|
||||
mTransaction->setITFieldAccount(sfDestination, naDstAccountID);
|
||||
mTransaction->setITFieldAmount(sfAmount, saAmount);
|
||||
|
||||
if (saAmount != saSendMax)
|
||||
if (saAmount != saSendMax || saAmount.getCurrency() != saSendMax.getCurrency())
|
||||
{
|
||||
mTransaction->setITFieldAmount(sfSendMax, saSendMax);
|
||||
}
|
||||
|
||||
@@ -3279,6 +3279,14 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
||||
|
||||
return tenREDUNDANT;
|
||||
}
|
||||
else if (bMax
|
||||
&& ((saMaxAmount == saDstAmount && saMaxAmount.getCurrency() == saDstAmount.getCurrency())
|
||||
|| (saDstAmount.isNative() && saMaxAmount.isNative())))
|
||||
{
|
||||
Log(lsINFO) << "doPayment: Invalid transaction: bad SendMax.";
|
||||
|
||||
return tenINVALID;
|
||||
}
|
||||
|
||||
SLE::pointer sleDst = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
|
||||
if (!sleDst)
|
||||
@@ -3309,6 +3317,7 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
||||
entryModify(sleDst);
|
||||
}
|
||||
|
||||
// XXX Should bMax be sufficient to imply ripple?
|
||||
bool bRipple = bPaths || bMax || !saDstAmount.isNative();
|
||||
|
||||
if (!bRipple)
|
||||
|
||||
@@ -41,6 +41,7 @@ enum TransactionEngineResult
|
||||
// Invalid: Ledger won't allow.
|
||||
tenCLAIMED = -200,
|
||||
tenBAD_RIPPLE,
|
||||
tenCREATED,
|
||||
tenEXPIRED,
|
||||
tenMSG_SET,
|
||||
terALREADY,
|
||||
|
||||
Reference in New Issue
Block a user