From 2484491736e54a8a08ed8bec931cfea138648a7f Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Fri, 22 Dec 2023 22:57:23 +0000 Subject: [PATCH] compiling --- src/ripple/app/tx/impl/Escrow.cpp | 2 +- src/ripple/app/tx/impl/URIToken.cpp | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/ripple/app/tx/impl/Escrow.cpp b/src/ripple/app/tx/impl/Escrow.cpp index fd8ce28de..9abc42d19 100644 --- a/src/ripple/app/tx/impl/Escrow.cpp +++ b/src/ripple/app/tx/impl/Escrow.cpp @@ -441,7 +441,7 @@ EscrowFinish::preflight(PreflightContext const& ctx) if ((!ctx.tx.isFieldPresent(sfEscrowID) && !ctx.tx.isFieldPresent(sfOfferSequence)) || - ctx.isFieldPresent(sfEscrowID) && ctx.isFieldPresent(sfOfferSequence)) + ctx.tx.isFieldPresent(sfEscrowID) && ctx.tx.isFieldPresent(sfOfferSequence)) return temMALFORMED; return tesSUCCESS; diff --git a/src/ripple/app/tx/impl/URIToken.cpp b/src/ripple/app/tx/impl/URIToken.cpp index 20599b089..b5da83d8a 100644 --- a/src/ripple/app/tx/impl/URIToken.cpp +++ b/src/ripple/app/tx/impl/URIToken.cpp @@ -144,7 +144,7 @@ URIToken::preflight(PreflightContext const& ctx) TER URIToken::preclaim(PreclaimContext const& ctx) { - bool const fixV1 = ctx.view.enabled(fixXahauV1); + bool const fixV1 = ctx.view.rules().enabled(fixXahauV1); std::shared_ptr sleU; uint32_t leFlags; @@ -153,9 +153,8 @@ URIToken::preclaim(PreclaimContext const& ctx) std::optional saleAmount; std::optional dest; std::shared_ptr sleOwner; - std::shared_ptr < - if (ctx.tx.isFieldPresent(sfURITokenID)) + if (ctx.tx.isFieldPresent(sfURITokenID)) { sleU = ctx.view.read( Keylet{ltURI_TOKEN, ctx.tx.getFieldH256(sfURITokenID)}); @@ -183,7 +182,7 @@ URIToken::preclaim(PreclaimContext const& ctx) AccountID const acc = ctx.tx.getAccountID(sfAccount); 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) return tefINTERNAL; @@ -237,7 +236,7 @@ URIToken::preclaim(PreclaimContext const& ctx) if (purchaseAmount.native() && saleAmount->native()) { - if (!ctx.view.enabled(fixXahauV1)) + if (!fixV1) { if (purchaseAmount > (sleOwner->getFieldAmount(sfBalance) - ctx.tx[sfFee])) @@ -245,10 +244,10 @@ URIToken::preclaim(PreclaimContext const& ctx) } else { - STAmount const needed{sb.fees().accountReserve( + STAmount needed{ctx.view.fees().accountReserve( sle->getFieldU32(sfOwnerCount) + 1)}; - STAmount const fee = ctx_.tx.getFieldAmount(sfFee).xrp(); + STAmount const fee = ctx.tx.getFieldAmount(sfFee).xrp(); if (needed + fee < needed) return tecINTERNAL; @@ -258,10 +257,19 @@ URIToken::preclaim(PreclaimContext const& ctx) if (needed + purchaseAmount < needed) return tecINTERNAL; - if (needed > mPriorBalance) + if (needed > sle->getFieldAmount(sfBalance)) 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 // 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 (purchaseAmount.native()) { - STAmount const needed{sb.fees().accountReserve( + STAmount needed{sb.fees().accountReserve( sle->getFieldU32(sfOwnerCount) + 1)}; STAmount const fee = ctx_.tx.getFieldAmount(sfFee).xrp();