mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 01:07:57 +00:00
Fix OfferCreate noticing unfunded source after fees.
This commit is contained in:
@@ -57,10 +57,12 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
{
|
{
|
||||||
SLE::pointer sleOfferDir;
|
SLE::pointer sleOfferDir;
|
||||||
uint64 uTipQuality = 0;
|
uint64 uTipQuality = 0;
|
||||||
|
STAmount saTakerFunds = mEngine->getNodes().accountFunds(uTakerAccountID, saTakerPays);
|
||||||
|
|
||||||
// Figure out next offer to take, if needed.
|
// Figure out next offer to take, if needed.
|
||||||
if (saTakerGot < saTakerGets // Have less than wanted.
|
if (saTakerFunds // Taker has funds available.
|
||||||
&& saTakerPaid < saTakerPays) // Didn't spend all funds.
|
&& saTakerGot < saTakerGets // Have less than wanted.
|
||||||
|
&& saTakerPaid < saTakerPays) // Didn't spend all funds allocated.
|
||||||
{
|
{
|
||||||
sleOfferDir = mEngine->entryCache(ltDIR_NODE, mEngine->getLedger()->getNextLedgerIndex(uTipIndex, uBookEnd));
|
sleOfferDir = mEngine->entryCache(ltDIR_NODE, mEngine->getLedger()->getNextLedgerIndex(uTipIndex, uBookEnd));
|
||||||
if (sleOfferDir)
|
if (sleOfferDir)
|
||||||
@@ -82,7 +84,15 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sleOfferDir // No offer directory to take.
|
if (!saTakerFunds) // Taker has no funds.
|
||||||
|
{
|
||||||
|
// Done. Ran out of funds on previous round. As fees aren't calculated directly in this routine, funds are checked here.
|
||||||
|
cLog(lsINFO) << "takeOffers: done: taker unfunded.";
|
||||||
|
|
||||||
|
bUnfunded = true; // Don't create an order.
|
||||||
|
terResult = tesSUCCESS;
|
||||||
|
}
|
||||||
|
else if (!sleOfferDir // No offer directory to take.
|
||||||
|| uTakeQuality < uTipQuality // No offers of sufficient quality available.
|
|| uTakeQuality < uTipQuality // No offers of sufficient quality available.
|
||||||
|| (bPassive && uTakeQuality == uTipQuality))
|
|| (bPassive && uTakeQuality == uTipQuality))
|
||||||
{
|
{
|
||||||
@@ -149,7 +159,6 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
cLog(lsINFO) << "takeOffers: saOfferPays=" << saOfferPays.getFullText();
|
cLog(lsINFO) << "takeOffers: saOfferPays=" << saOfferPays.getFullText();
|
||||||
|
|
||||||
STAmount saOfferFunds = mEngine->getNodes().accountFunds(uOfferOwnerID, saOfferPays);
|
STAmount saOfferFunds = mEngine->getNodes().accountFunds(uOfferOwnerID, saOfferPays);
|
||||||
STAmount saTakerFunds = mEngine->getNodes().accountFunds(uTakerAccountID, saTakerPays);
|
|
||||||
SLE::pointer sleOfferAccount; // Owner of offer.
|
SLE::pointer sleOfferAccount; // Owner of offer.
|
||||||
|
|
||||||
if (!saOfferFunds.isPositive()) // Includes zero.
|
if (!saOfferFunds.isPositive()) // Includes zero.
|
||||||
@@ -243,17 +252,13 @@ TER OfferCreateTransactor::takeOffers(
|
|||||||
|
|
||||||
if (!bUnfunded)
|
if (!bUnfunded)
|
||||||
{
|
{
|
||||||
terResult = mEngine->getNodes().accountSend(uOfferOwnerID, uTakerAccountID, saSubTakerGot); // Offer owner pays taker.
|
// Distribute funds. The sends charge appropriate fees which are implied by offer.
|
||||||
|
|
||||||
// if (tesSUCCESS == terResult)
|
terResult = mEngine->getNodes().accountSend(uOfferOwnerID, uTakerAccountID, saSubTakerGot); // Offer owner pays taker.
|
||||||
// terResult = mEngine->getNodes().accountSend(uOfferOwnerID, uTakerGetsAccountID, saOfferIssuerFee); // Offer owner pays issuer transfer fee.
|
|
||||||
|
|
||||||
if (tesSUCCESS == terResult)
|
if (tesSUCCESS == terResult)
|
||||||
terResult = mEngine->getNodes().accountSend(uTakerAccountID, uOfferOwnerID, saSubTakerPaid); // Taker pays offer owner.
|
terResult = mEngine->getNodes().accountSend(uTakerAccountID, uOfferOwnerID, saSubTakerPaid); // Taker pays offer owner.
|
||||||
|
|
||||||
// if (tesSUCCESS == terResult)
|
|
||||||
// terResult = mEngine->getNodes().accountSend(uTakerAccountID, uTakerPaysAccountID, saTakerIssuerFee); // Taker pays issuer transfer fee.
|
|
||||||
|
|
||||||
// Reduce amount considered paid by taker's rate (not actual cost).
|
// Reduce amount considered paid by taker's rate (not actual cost).
|
||||||
STAmount saPay = saTakerPays - saTakerPaid;
|
STAmount saPay = saTakerPays - saTakerPaid;
|
||||||
if (saTakerFunds < saPay)
|
if (saTakerFunds < saPay)
|
||||||
|
|||||||
Reference in New Issue
Block a user