compiling

This commit is contained in:
Richard Holland
2023-12-22 22:57:23 +00:00
parent 43c4616e32
commit 2484491736
2 changed files with 18 additions and 10 deletions

View File

@@ -441,7 +441,7 @@ EscrowFinish::preflight(PreflightContext const& ctx)
if ((!ctx.tx.isFieldPresent(sfEscrowID) && if ((!ctx.tx.isFieldPresent(sfEscrowID) &&
!ctx.tx.isFieldPresent(sfOfferSequence)) || !ctx.tx.isFieldPresent(sfOfferSequence)) ||
ctx.isFieldPresent(sfEscrowID) && ctx.isFieldPresent(sfOfferSequence)) ctx.tx.isFieldPresent(sfEscrowID) && ctx.tx.isFieldPresent(sfOfferSequence))
return temMALFORMED; return temMALFORMED;
return tesSUCCESS; return tesSUCCESS;

View File

@@ -144,7 +144,7 @@ URIToken::preflight(PreflightContext const& ctx)
TER TER
URIToken::preclaim(PreclaimContext const& ctx) URIToken::preclaim(PreclaimContext const& ctx)
{ {
bool const fixV1 = ctx.view.enabled(fixXahauV1); bool const fixV1 = ctx.view.rules().enabled(fixXahauV1);
std::shared_ptr<SLE const> sleU; std::shared_ptr<SLE const> sleU;
uint32_t leFlags; uint32_t leFlags;
@@ -153,7 +153,6 @@ URIToken::preclaim(PreclaimContext const& ctx)
std::optional<STAmount> saleAmount; std::optional<STAmount> saleAmount;
std::optional<AccountID> dest; std::optional<AccountID> dest;
std::shared_ptr<SLE const> sleOwner; std::shared_ptr<SLE const> sleOwner;
std::shared_ptr <
if (ctx.tx.isFieldPresent(sfURITokenID)) if (ctx.tx.isFieldPresent(sfURITokenID))
{ {
@@ -183,7 +182,7 @@ URIToken::preclaim(PreclaimContext const& ctx)
AccountID const acc = ctx.tx.getAccountID(sfAccount); AccountID const acc = ctx.tx.getAccountID(sfAccount);
uint16_t tt = ctx.tx.getFieldU16(sfTransactionType); uint16_t tt = ctx.tx.getFieldU16(sfTransactionType);
auto const sle = sb.read(keylet::account(account_)); auto const sle = ctx.view.read(keylet::account(ctx.tx.getAccountID(sfAccount)));
if (!sle) if (!sle)
return tefINTERNAL; return tefINTERNAL;
@@ -237,7 +236,7 @@ URIToken::preclaim(PreclaimContext const& ctx)
if (purchaseAmount.native() && saleAmount->native()) if (purchaseAmount.native() && saleAmount->native())
{ {
if (!ctx.view.enabled(fixXahauV1)) if (!fixV1)
{ {
if (purchaseAmount > if (purchaseAmount >
(sleOwner->getFieldAmount(sfBalance) - ctx.tx[sfFee])) (sleOwner->getFieldAmount(sfBalance) - ctx.tx[sfFee]))
@@ -245,10 +244,10 @@ URIToken::preclaim(PreclaimContext const& ctx)
} }
else else
{ {
STAmount const needed{sb.fees().accountReserve( STAmount needed{ctx.view.fees().accountReserve(
sle->getFieldU32(sfOwnerCount) + 1)}; sle->getFieldU32(sfOwnerCount) + 1)};
STAmount const fee = ctx_.tx.getFieldAmount(sfFee).xrp(); STAmount const fee = ctx.tx.getFieldAmount(sfFee).xrp();
if (needed + fee < needed) if (needed + fee < needed)
return tecINTERNAL; return tecINTERNAL;
@@ -258,10 +257,19 @@ URIToken::preclaim(PreclaimContext const& ctx)
if (needed + purchaseAmount < needed) if (needed + purchaseAmount < needed)
return tecINTERNAL; return tecINTERNAL;
if (needed > mPriorBalance) if (needed > sle->getFieldAmount(sfBalance))
return tecINSUFFICIENT_FUNDS; return tecINSUFFICIENT_FUNDS;
} }
} }
else if (fixV1)
{
if (!purchaseAmount.native() && !saleAmount->native())
{
// pass IOU
}
else
return tecINTERNAL;
}
// execution to here means it's an IOU sale // execution to here means it's an IOU sale
// check if the buyer has the right trustline with an adequate // check if the buyer has the right trustline with an adequate
@@ -462,7 +470,7 @@ URIToken::doApply()
// if it's an xrp sale/purchase then no trustline needed // if it's an xrp sale/purchase then no trustline needed
if (purchaseAmount.native()) if (purchaseAmount.native())
{ {
STAmount const needed{sb.fees().accountReserve( STAmount needed{sb.fees().accountReserve(
sle->getFieldU32(sfOwnerCount) + 1)}; sle->getFieldU32(sfOwnerCount) + 1)};
STAmount const fee = ctx_.tx.getFieldAmount(sfFee).xrp(); STAmount const fee = ctx_.tx.getFieldAmount(sfFee).xrp();