mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Compare commits
22 Commits
ximinez/le
...
ximinez/le
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3783861578 | ||
|
|
8eabad42dd | ||
|
|
89de2b55f6 | ||
|
|
06689d9cb5 | ||
|
|
3eaddcc2bc | ||
|
|
d9a44dbbbc | ||
|
|
d5d6b0c7cb | ||
|
|
f665463050 | ||
|
|
c7d73fb938 | ||
|
|
c6ff9882f8 | ||
|
|
f9027bb88f | ||
|
|
992a62a95a | ||
|
|
1484ec6640 | ||
|
|
0d119161cf | ||
|
|
a224e089e6 | ||
|
|
295c8bddae | ||
|
|
c2b3cd4069 | ||
|
|
ef3fa22144 | ||
|
|
e961d85819 | ||
|
|
12ceb8bc86 | ||
|
|
078afb51d9 | ||
|
|
bfac68e308 |
@@ -3176,6 +3176,24 @@ requireAuth(
|
||||
!isTesSuccess(err))
|
||||
return err;
|
||||
}
|
||||
|
||||
// requireAuth is also recursive if the _account_ is a vault
|
||||
auto const sleAccount = view.read(keylet::account(account));
|
||||
if (!sleAccount)
|
||||
return tefINTERNAL; // LCOV_EXCL_LINE
|
||||
|
||||
if (sleAccount->isFieldPresent(sfVaultID))
|
||||
{
|
||||
auto const sleVault =
|
||||
view.read(keylet::vault(sleAccount->getFieldH256(sfVaultID)));
|
||||
if (!sleVault)
|
||||
return tefINTERNAL; // LCOV_EXCL_LINE
|
||||
auto const ownerAcct = sleVault->getAccountID(sfOwner);
|
||||
if (auto const err =
|
||||
requireAuth(view, mptIssue, ownerAcct, authType, depth + 1);
|
||||
!isTesSuccess(err))
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
auto const mptokenID = keylet::mptoken(mptID.key, account);
|
||||
|
||||
@@ -2738,12 +2738,8 @@ protected:
|
||||
broker.params.managementFeeRate);
|
||||
|
||||
BEAST_EXPECT(
|
||||
paymentComponents.trackedValueDelta ==
|
||||
roundedPeriodicPayment ||
|
||||
(paymentComponents.specialCase ==
|
||||
detail::PaymentSpecialCase::final &&
|
||||
paymentComponents.trackedValueDelta <
|
||||
roundedPeriodicPayment));
|
||||
paymentComponents.trackedValueDelta <=
|
||||
roundedPeriodicPayment);
|
||||
|
||||
ripple::LoanState const nextTrueState = computeRawLoanState(
|
||||
state.periodicPayment,
|
||||
|
||||
@@ -2358,6 +2358,18 @@ class Vault_test : public beast::unit_test::suite
|
||||
.amount = asset(100)});
|
||||
env(tx, ter(tecNO_AUTH));
|
||||
|
||||
// Withdrawal to other (authorized) accounts doesn't work.
|
||||
// Issuer would have to VaultClawback
|
||||
tx[sfDestination] = issuer.human();
|
||||
env(tx, ter(tecNO_AUTH));
|
||||
tx[sfDestination] = owner.human();
|
||||
env(tx, ter(tecNO_AUTH));
|
||||
env.close();
|
||||
|
||||
// Issuer reauthorizes
|
||||
mptt.authorize({.account = issuer, .holder = depositor});
|
||||
env.close();
|
||||
|
||||
// Withdrawal to other (authorized) accounts works
|
||||
tx[sfDestination] = issuer.human();
|
||||
env(tx);
|
||||
@@ -2368,6 +2380,13 @@ class Vault_test : public beast::unit_test::suite
|
||||
env.close();
|
||||
}
|
||||
|
||||
// Re-unauthorize
|
||||
mptt.authorize(
|
||||
{.account = issuer,
|
||||
.holder = depositor,
|
||||
.flags = tfMPTUnauthorize});
|
||||
env.close();
|
||||
|
||||
{
|
||||
// Cannot deposit some more
|
||||
auto tx = vault.deposit(
|
||||
|
||||
@@ -1075,23 +1075,6 @@ computePaymentComponents(
|
||||
"ripple::detail::computePaymentComponents",
|
||||
"excess non-negative");
|
||||
};
|
||||
auto giveTo =
|
||||
[](Number& component, Number& shortage, Number const& maximum) {
|
||||
if (shortage > beast::zero)
|
||||
{
|
||||
// Put as much of the shortage as we can into the provided part
|
||||
// and the total
|
||||
auto part = std::min(maximum - component, shortage);
|
||||
component += part;
|
||||
shortage -= part;
|
||||
}
|
||||
// If the shortage goes negative, we put too much, which should be
|
||||
// impossible
|
||||
XRPL_ASSERT_PARTS(
|
||||
shortage >= beast::zero,
|
||||
"ripple::detail::computePaymentComponents",
|
||||
"excess non-negative");
|
||||
};
|
||||
// Helper to reduce deltas when they collectively exceed a limit.
|
||||
// Order matters: we prefer to reduce interest first (most flexible),
|
||||
// then management fee, then principal (least flexible).
|
||||
@@ -1101,19 +1084,6 @@ computePaymentComponents(
|
||||
takeFrom(deltas.managementFee, excess);
|
||||
takeFrom(deltas.principal, excess);
|
||||
};
|
||||
// Helper to increase deltas when they collectively do not reach an
|
||||
// expected value.
|
||||
// Order matters: we prefer to increase interest first (most flexible),
|
||||
// then management fee, then principal (least flexible).
|
||||
auto addressShortage = [&giveTo](
|
||||
LoanDeltas& deltas,
|
||||
Number& shortage,
|
||||
LoanState const& current) {
|
||||
giveTo(deltas.interestDueDelta, shortage, current.interestDue);
|
||||
giveTo(
|
||||
deltas.managementFeeDueDelta, shortage, current.managementFeeDue);
|
||||
giveTo(deltas.principalDelta, shortage, current.principalOutstanding);
|
||||
};
|
||||
|
||||
// Check if deltas exceed the total outstanding value. This should never
|
||||
// happen due to earlier caps, but handle it defensively.
|
||||
@@ -1145,19 +1115,12 @@ computePaymentComponents(
|
||||
addressExcess(deltas, excess);
|
||||
shortage = -excess;
|
||||
}
|
||||
else if (shortage > beast::zero && totalOverpayment < beast::zero)
|
||||
{
|
||||
// If there's a shortage, and there's room in the loan itself, we can
|
||||
// top up the parts to make the payment correct.
|
||||
shortage = std::min(-totalOverpayment, shortage);
|
||||
addressShortage(deltas, shortage, currentLedgerState);
|
||||
}
|
||||
|
||||
// At this point, shortage >= 0 means we're paying less than the full
|
||||
// periodic payment (due to rounding or component caps).
|
||||
// shortage < 0 means mean we're trying to pay more than allowed (bug).
|
||||
// shortage < 0 would mean we're trying to pay more than allowed (bug).
|
||||
XRPL_ASSERT_PARTS(
|
||||
shortage == beast::zero,
|
||||
shortage >= beast::zero,
|
||||
"ripple::detail::computePaymentComponents",
|
||||
"no shortage or excess");
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <xrpld/app/tx/detail/VaultWithdraw.h>
|
||||
//
|
||||
#include <xrpld/app/tx/detail/Payment.h>
|
||||
|
||||
#include <xrpl/ledger/CredentialHelpers.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
@@ -197,7 +199,7 @@ VaultWithdraw::doApply()
|
||||
assetsAvailable -= assetsWithdrawn;
|
||||
view().update(vault);
|
||||
|
||||
auto const& vaultAccount = vault->at(sfAccount);
|
||||
AccountID const& vaultAccount = vault->at(sfAccount);
|
||||
// Transfer shares from depositor to vault.
|
||||
if (auto const ter = accountSend(
|
||||
view(),
|
||||
|
||||
Reference in New Issue
Block a user