mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-27 09:00:32 +00:00
Address a couple of feedback items from @Tapanito and @shawnxie999:
- Call verifyDepositAuth in VaultWithdraw and LoanBrokerCoverWithdraw to a destination. - Update a couple of impossible error returns to log a message, but exclude from coverage. - Fail if the LoanBroker.LoanSequence overflows to 0.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include <xrpld/app/misc/LendingHelpers.h>
|
||||
#include <xrpld/app/tx/detail/Payment.h>
|
||||
|
||||
#include <xrpl/ledger/CredentialHelpers.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
bool
|
||||
@@ -59,7 +61,12 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx)
|
||||
}
|
||||
auto const vault = ctx.view.read(keylet::vault(sleBroker->at(sfVaultID)));
|
||||
if (!vault)
|
||||
return tefBAD_LEDGER; // LCOV_EXCL_LINE
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(ctx.j.fatal()) << "Vault is missing for Broker " << brokerID;
|
||||
return tefBAD_LEDGER;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
auto const vaultAsset = vault->at(sfAsset);
|
||||
if (amount.asset() != vaultAsset)
|
||||
@@ -158,6 +165,13 @@ LoanBrokerCoverWithdraw::doApply()
|
||||
!isTesSuccess(ter) && ter != tecDUPLICATE)
|
||||
return ter;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dstSle = view().peek(keylet::account(dstAcct));
|
||||
if (auto err =
|
||||
verifyDepositPreauth(tx, view(), account_, dstAcct, dstSle, j_))
|
||||
return err;
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
if (accountHolds(
|
||||
|
||||
@@ -609,6 +609,10 @@ LoanSet::doApply()
|
||||
// and is distinct from the broker's pseudo-account's owner count
|
||||
adjustOwnerCount(view, brokerSle, 1, j_);
|
||||
loanSequenceProxy += 1;
|
||||
// The sequence should be extremely unlikely to roll over, but fail if it
|
||||
// does
|
||||
if (loanSequenceProxy == 0)
|
||||
return tecMAX_SEQUENCE_REACHED;
|
||||
view.update(brokerSle);
|
||||
|
||||
// Put the loan into the pseudo-account's directory
|
||||
|
||||
@@ -245,6 +245,13 @@ VaultWithdraw::doApply()
|
||||
!isTesSuccess(ter) && ter != tecDUPLICATE)
|
||||
return ter;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dstSle = view().peek(keylet::account(dstAcct));
|
||||
if (auto err = verifyDepositPreauth(
|
||||
ctx_.tx, view(), account_, dstAcct, dstSle, j_))
|
||||
return err;
|
||||
}
|
||||
|
||||
// Transfer assets from vault to depositor or destination account.
|
||||
if (auto const ter = accountSend(
|
||||
|
||||
Reference in New Issue
Block a user