Compare commits

...

9 Commits

Author SHA1 Message Date
Mayukha Vadari
e78ab82996 Fix syntax error in Payment.cpp 2026-03-19 14:37:33 -04:00
Mayukha Vadari
253918c168 explicitly initialize sfBalance in Payment.cpp 2026-03-19 14:27:27 -04:00
Mayukha Vadari
a43de47f13 whoops 2026-03-18 18:25:09 -04:00
Mayukha Vadari
c78a68f218 Merge branch 'develop' into mvadari/payment-fixes 2026-03-18 17:56:51 -04:00
Mayukha Vadari
1dcbc503d8 add assertion to validate transfer fee does not exceed maximum allowed value 2026-03-18 17:50:04 -04:00
Mayukha Vadari
346fbbd3ac fix incorrect emplace result check logic 2026-03-18 17:44:20 -04:00
Mayukha Vadari
a2a66f68ad remove dead code 2026-03-18 17:41:14 -04:00
Mayukha Vadari
04c141cba5 fix reversed naming of variables 2026-03-18 17:35:58 -04:00
Mayukha Vadari
4cdc8561cd Refactor ledger open check in OfferCreate.cpp 2026-03-18 17:30:24 -04:00
6 changed files with 22 additions and 35 deletions

View File

@@ -58,8 +58,8 @@ private:
{
explicit Value() = default;
STAmount lowAcctCredits;
STAmount highAcctCredits;
STAmount lowAcctDebits;
STAmount highAcctDebits;
STAmount lowAcctOrigBalance;
};

View File

@@ -501,14 +501,6 @@ public:
{
return cur_.size();
}
void
removeIndex(std::size_t i)
{
if (i >= next_.size())
return;
next_.erase(next_.begin() + i);
}
};
/// @endcond
@@ -633,11 +625,6 @@ flow(
std::optional<BestStrand> best;
if (flowDebugInfo)
flowDebugInfo->newLiquidityPass();
// Index of strand to mark as inactive (remove from the active list) if
// the liquidity is used. This is used for strands that consume too many
// offers Constructed as `false,0` to workaround a gcc warning about
// uninitialized variables
std::optional<std::size_t> markInactiveOnUse;
for (size_t strandIndex = 0, sie = activeStrands.size(); strandIndex != sie; ++strandIndex)
{
Strand const* strand = activeStrands.get(strandIndex);
@@ -701,11 +688,6 @@ flow(
if (best)
{
if (markInactiveOnUse)
{
activeStrands.removeIndex(*markInactiveOnUse);
markInactiveOnUse.reset();
}
savedIns.insert(best->in);
savedOuts.insert(best->out);
remainingOut = outReq - sum(savedOuts);

View File

@@ -37,14 +37,14 @@ DeferredCredits::credit(
if (sender < receiver)
{
v.highAcctCredits = amount;
v.lowAcctCredits = amount.zeroed();
v.lowAcctDebits = amount;
v.highAcctDebits = amount.zeroed();
v.lowAcctOrigBalance = preCreditSenderBalance;
}
else
{
v.highAcctCredits = amount.zeroed();
v.lowAcctCredits = amount;
v.lowAcctDebits = amount.zeroed();
v.highAcctDebits = amount;
v.lowAcctOrigBalance = -preCreditSenderBalance;
}
@@ -56,11 +56,11 @@ DeferredCredits::credit(
auto& v = i->second;
if (sender < receiver)
{
v.highAcctCredits += amount;
v.lowAcctDebits += amount;
}
else
{
v.lowAcctCredits += amount;
v.highAcctDebits += amount;
}
}
}
@@ -104,11 +104,11 @@ DeferredCredits::adjustments(
if (main < other)
{
result.emplace(v.highAcctCredits, v.lowAcctCredits, v.lowAcctOrigBalance);
result.emplace(v.lowAcctDebits, v.highAcctDebits, v.lowAcctOrigBalance);
return result;
}
result.emplace(v.lowAcctCredits, v.highAcctCredits, -v.lowAcctOrigBalance);
result.emplace(v.highAcctDebits, v.lowAcctDebits, -v.lowAcctOrigBalance);
return result;
}
@@ -122,8 +122,8 @@ DeferredCredits::apply(DeferredCredits& to)
{
auto& toVal = r.first->second;
auto const& fromVal = i.second;
toVal.lowAcctCredits += fromVal.lowAcctCredits;
toVal.highAcctCredits += fromVal.highAcctCredits;
toVal.lowAcctDebits += fromVal.lowAcctDebits;
toVal.highAcctDebits += fromVal.highAcctDebits;
// Do not update the orig balance, it's already correct
}
}
@@ -349,14 +349,14 @@ PaymentSandbox::balanceChanges(ReadView const& view) const
auto const cur = newBalance.getCurrency();
result[std::make_tuple(lowID, highID, cur)] = delta;
auto r = result.emplace(std::make_tuple(lowID, lowID, cur), delta);
if (r.second)
if (!r.second)
{
r.first->second += delta;
}
delta.negate();
r = result.emplace(std::make_tuple(highID, highID, cur), delta);
if (r.second)
if (!r.second)
{
r.first->second += delta;
}

View File

@@ -800,7 +800,11 @@ transferRate(ReadView const& view, MPTID const& issuanceID)
// which represents 50% of 1,000,000,000
if (auto const sle = view.read(keylet::mptIssuance(issuanceID));
sle && sle->isFieldPresent(sfTransferFee))
return Rate{1'000'000'000u + 10'000 * sle->getFieldU16(sfTransferFee)};
{
auto const fee = sle->getFieldU16(sfTransferFee);
XRPL_ASSERT(fee <= maxTransferFee, "xrpl::transferRate : fee is too large");
return Rate{1'000'000'000u + 10'000 * fee};
}
return parityRate;
}

View File

@@ -562,7 +562,6 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel)
return {tecEXPIRED, true};
}
bool const bOpenLedger = sb.open();
bool crossed = false;
if (isTesSuccess(result))
@@ -648,7 +647,8 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel)
stream << " out: " << format_amount(place_offer.out);
}
if (result == tecFAILED_PROCESSING && bOpenLedger)
bool const isLedgerOpen = sb.open();
if (result == tecFAILED_PROCESSING && isLedgerOpen)
result = telFAILED_PROCESSING;
if (!isTesSuccess(result))

View File

@@ -383,6 +383,7 @@ Payment::doApply()
sleDst = std::make_shared<SLE>(k);
sleDst->setAccountID(sfAccount, dstAccountID);
sleDst->setFieldU32(sfSequence, view().seq());
sleDst->setFieldAmount(sfBalance, XRPAmount(beast::zero));
view().insert(sleDst);
}