Enforce SendMax restrictions in transaction engine.

This commit is contained in:
Arthur Britto
2012-08-14 13:31:46 -07:00
parent 11f02ba798
commit 07f5bf2612
3 changed files with 11 additions and 1 deletions

View File

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

View File

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

View File

@@ -41,6 +41,7 @@ enum TransactionEngineResult
// Invalid: Ledger won't allow.
tenCLAIMED = -200,
tenBAD_RIPPLE,
tenCREATED,
tenEXPIRED,
tenMSG_SET,
terALREADY,