Fix dir describer when an offer is added to a directory.

Check all amounts for orders, fees, and payments to make sure they're network legal.
This commit is contained in:
JoelKatz
2013-06-06 23:07:33 -07:00
parent f94169af78
commit 6b4b239e72
5 changed files with 19 additions and 7 deletions

View File

@@ -367,6 +367,9 @@ TER OfferCreateTransactor::doApply()
STAmount saTakerPays = mTxn.getFieldAmount(sfTakerPays);
STAmount saTakerGets = mTxn.getFieldAmount(sfTakerGets);
if (!saTakerPays.isLegalNet() || !saTakerGets.isLegalNet())
return temBAD_AMOUNT;
WriteLog (lsTRACE, OfferCreateTransactor) << boost::str(boost::format("OfferCreate: saTakerPays=%s saTakerGets=%s")
% saTakerPays.getFullText()
% saTakerGets.getFullText());
@@ -587,8 +590,7 @@ TER OfferCreateTransactor::doApply()
// Add offer to owner's directory.
terResult = lesActive.dirAdd(uOwnerNode, Ledger::getOwnerDirIndex(mTxnAccountID), uLedgerIndex,
BIND_TYPE(&Ledger::qualityDirDescriber, P_1, saTakerPays.getCurrency(), uPaysIssuerID,
saTakerGets.getCurrency(), uGetsIssuerID, uRate));
BIND_TYPE(&Ledger::ownerDirDescriber, P_1, mTxnAccountID));
if (tesSUCCESS == terResult)

View File

@@ -27,6 +27,9 @@ TER PaymentTransactor::doApply()
% saMaxAmount.getFullText()
% saDstAmount.getFullText());
if (!saDstAmount.isLegalNet() || !saMaxAmount.isLegalNet())
return temBAD_AMOUNT;
if (uTxFlags & tfPaymentMask)
{
WriteLog (lsINFO, PaymentTransactor) << "Payment: Malformed transaction: Invalid flags set.";

View File

@@ -48,6 +48,8 @@ uint64 Transactor::calculateBaseFee()
TER Transactor::payFee()
{
STAmount saPaid = mTxn.getTransactionFee();
if (!saPaid.isLegalNet())
return temBAD_AMOUNT;
// Only check fee is sufficient when the ledger is open.
if (isSetBit(mParams, tapOPEN_LEDGER) && saPaid < mFeeDue)

View File

@@ -16,6 +16,9 @@ TER TrustSetTransactor::doApply()
uint32 uQualityIn = bQualityIn ? mTxn.getFieldU32(sfQualityIn) : 0;
uint32 uQualityOut = bQualityOut ? mTxn.getFieldU32(sfQualityOut) : 0;
if (!saLimitAmount.isLegalNet())
return temBAD_AMOUNT;
if (bQualityIn && QUALITY_ONE == uQualityIn)
uQualityIn = 0;