20 #include <ripple/app/paths/Credit.h>
21 #include <ripple/app/paths/Flow.h>
22 #include <ripple/app/paths/impl/AmountSpec.h>
23 #include <ripple/app/paths/impl/Steps.h>
24 #include <ripple/app/paths/impl/StrandFlow.h>
25 #include <ripple/basics/IOUAmount.h>
26 #include <ripple/basics/Log.h>
27 #include <ripple/basics/XRPAmount.h>
29 #include <boost/container/flat_set.hpp>
36 template <
class FlowResult>
40 Issue
const& srcIssue,
41 Issue
const& dstIssue,
44 path::RippleCalc::Output result;
48 result.removableOffers = std::move(f.removableOffers);
50 result.setResult(f.ter);
51 result.actualAmountIn =
toSTAmount(f.in, srcIssue);
52 result.actualAmountOut =
toSTAmount(f.out, dstIssue);
57 path::RippleCalc::Output
60 STAmount
const& deliver,
63 STPathSet
const& paths,
66 bool ownerPaysTransferFee,
71 path::detail::FlowDebugInfo* flowDebugInfo)
73 Issue
const srcIssue = [&] {
75 return sendMax->issue();
76 if (!
isXRP(deliver.issue().currency))
77 return Issue(deliver.issue().currency, src);
81 Issue
const dstIssue = deliver.issue();
85 sendMaxIssue = sendMax->issue();
105 path::RippleCalc::Output result;
106 result.setResult(toStrandsTer);
112 j.
trace() <<
"\nsrc: " << src <<
"\ndst: " << dst
113 <<
"\nsrcIssue: " << srcIssue <<
"\ndstIssue: " << dstIssue;
114 j.
trace() <<
"\nNumStrands: " << strands.size();
115 for (
auto const& curStrand : strands)
117 j.
trace() <<
"NumSteps: " << curStrand.size();
118 for (
auto const& step : curStrand)
120 j.
trace() <<
'\n' << *step <<
'\n';
125 const bool srcIsXRP =
isXRP(srcIssue.currency);
126 const bool dstIsXRP =
isXRP(dstIssue.currency);
133 if (srcIsXRP && dstIsXRP)
139 flow<XRPAmount, XRPAmount>(
151 if (srcIsXRP && !dstIsXRP)
157 flow<XRPAmount, IOUAmount>(
169 if (!srcIsXRP && dstIsXRP)
175 flow<IOUAmount, XRPAmount>(
187 assert(!srcIsXRP && !dstIsXRP);
192 flow<IOUAmount, IOUAmount>(
Stream trace() const
Severity stream access functions.
std::pair< TER, std::vector< Strand > > toStrands(ReadView const &view, AccountID const &src, AccountID const &dst, Issue const &deliver, std::optional< Quality > const &limitQuality, std::optional< Issue > const &sendMax, STPathSet const &paths, bool addDefaultPath, bool ownerPaysTransferFee, bool offerCrossing, beast::Journal j)
Create a Strand for each specified path (including the default path, if indicated)
path::RippleCalc::Output flow(PaymentSandbox &view, STAmount const &deliver, AccountID const &src, AccountID const &dst, STPathSet const &paths, bool defaultPaths, bool partialPayment, bool ownerPaysTransferFee, bool offerCrossing, std::optional< Quality > const &limitQuality, std::optional< STAmount > const &sendMax, beast::Journal j, path::detail::FlowDebugInfo *flowDebugInfo=nullptr)
Make a payment from the src account to the dst account.
AmountSpec toAmountSpec(STAmount const &amt)
STAmount toSTAmount(IOUAmount const &iou, Issue const &iss)
bool isXRP(AccountID const &c)
A generic endpoint for log messages.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.