From 8d22409ab507542fa4e23e9060c31d825b8ccb2c Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Mon, 10 Nov 2025 20:25:57 -0500 Subject: [PATCH] review feedback: Use the specific type in the "SendMulti" functions --- src/libxrpl/ledger/View.cpp | 72 +++++++++++++------------------------ 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/src/libxrpl/ledger/View.cpp b/src/libxrpl/ledger/View.cpp index 84e3073465..0ddea91c5d 100644 --- a/src/libxrpl/ledger/View.cpp +++ b/src/libxrpl/ledger/View.cpp @@ -2113,26 +2113,26 @@ static TER rippleSendMultiIOU( ApplyView& view, AccountID const& senderID, - Asset const& asset, + Issue const& issue, MultiplePaymentDestinations const& receivers, STAmount& actual, beast::Journal j, WaiveTransferFee waiveFee) { - auto const issuer = asset.getIssuer(); + auto const issuer = issue.getIssuer(); XRPL_ASSERT( !isXRP(senderID), "ripple::rippleSendMultiIOU : sender is not XRP"); // These may diverge - STAmount takeFromSender{asset}; + STAmount takeFromSender{issue}; actual = takeFromSender; // Failures return immediately. for (auto const& r : receivers) { auto const& receiverID = r.first; - STAmount amount{asset, r.second}; + STAmount amount{issue, r.second}; /* If we aren't sending anything or if the sender is the same as the * receiver then we don't need to do anything. @@ -2315,7 +2315,7 @@ static TER accountSendMultiIOU( ApplyView& view, AccountID const& senderID, - Asset const& asset, + Issue const& issue, MultiplePaymentDestinations const& receivers, beast::Journal j, WaiveTransferFee waiveFee) @@ -2325,27 +2325,14 @@ accountSendMultiIOU( "ripple::accountSendMultiIOU", "multiple recipients provided"); - if (view.rules().enabled(fixAMMv1_1)) - { - if (asset.holds()) - { - return tecINTERNAL; - } - } - else - { - XRPL_ASSERT( - !asset.holds(), "ripple::accountSendMultiIOU : not MPT"); - } - - if (!asset.native()) + if (!issue.native()) { STAmount actual; JLOG(j.trace()) << "accountSendMultiIOU: " << to_string(senderID) << " sending " << receivers.size() << " IOUs"; return rippleSendMultiIOU( - view, senderID, asset, receivers, actual, j, waiveFee); + view, senderID, issue, receivers, actual, j, waiveFee); } /* XRP send which does not check reserve and can do pure adjustment. @@ -2370,24 +2357,15 @@ accountSendMultiIOU( } // Failures return immediately. - STAmount takeFromSender{asset}; + STAmount takeFromSender{issue}; for (auto const& r : receivers) { auto const& receiverID = r.first; - STAmount amount{asset, r.second}; + STAmount amount{issue, r.second}; - if (view.rules().enabled(fixAMMv1_1)) + if (amount < beast::zero) { - if (amount < beast::zero) - { - return tecINTERNAL; - } - } - else - { - XRPL_ASSERT( - amount >= beast::zero, - "ripple::accountSendMultiIOU : minimum amount"); + return tecINTERNAL; // LCOV_EXCL_LINE } /* If we aren't sending anything or if the sender is the same as the @@ -2603,7 +2581,7 @@ static TER rippleSendMultiMPT( ApplyView& view, AccountID const& senderID, - Asset const& asset, + MPTIssue const& mptIssue, MultiplePaymentDestinations const& receivers, STAmount& actual, beast::Journal j, @@ -2611,25 +2589,25 @@ rippleSendMultiMPT( { // Safe to get MPT since rippleSendMultiMPT is only called by // accountSendMultiMPT - auto const issuer = asset.getIssuer(); + auto const issuer = mptIssue.getIssuer(); - auto const sle = - view.read(keylet::mptIssuance(asset.get().getMptID())); + auto const sle = view.read(keylet::mptIssuance(mptIssue.getMptID())); if (!sle) return tecOBJECT_NOT_FOUND; // These may diverge - STAmount takeFromSender{asset}; + STAmount takeFromSender{mptIssue}; actual = takeFromSender; for (auto const& r : receivers) { auto const& receiverID = r.first; - STAmount amount{asset, r.second}; + STAmount amount{mptIssue, r.second}; - XRPL_ASSERT( - amount >= beast::zero, - "ripple::rippleSendMultiMPT : minimum amount "); + if (amount < beast::zero) + { + return tecINTERNAL; // LCOV_EXCL_LINE + } /* If we aren't sending anything or if the sender is the same as the * receiver then we don't need to do anything. @@ -2720,17 +2698,15 @@ static TER accountSendMultiMPT( ApplyView& view, AccountID const& senderID, - Asset const& asset, + MPTIssue const& mptIssue, MultiplePaymentDestinations const& receivers, beast::Journal j, WaiveTransferFee waiveFee) { - XRPL_ASSERT(asset.holds(), "ripple::accountSendMultiMPT : MPT"); - STAmount actual; return rippleSendMultiMPT( - view, senderID, asset, receivers, actual, j, waiveFee); + view, senderID, mptIssue, receivers, actual, j, waiveFee); } TER @@ -2771,10 +2747,10 @@ accountSendMulti( [&](TIss const& issue) { if constexpr (std::is_same_v) return accountSendMultiIOU( - view, senderID, asset, receivers, j, waiveFee); + view, senderID, issue, receivers, j, waiveFee); else return accountSendMultiMPT( - view, senderID, asset, receivers, j, waiveFee); + view, senderID, issue, receivers, j, waiveFee); }, asset.value()); }