mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix bugs in pathfinding with XRP as the source currency
This commit is contained in:
@@ -515,7 +515,9 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast)
|
||||
if (rc.result () == tesSUCCESS)
|
||||
{
|
||||
Json::Value jvEntry (Json::objectValue);
|
||||
rc.actualAmountIn.setIssuer (sourceAccount);
|
||||
|
||||
if (!isXRP (currIssuer.currency))
|
||||
rc.actualAmountIn.setIssuer (sourceAccount);
|
||||
|
||||
jvEntry["source_amount"] = rc.actualAmountIn.getJson (0);
|
||||
jvEntry["paths_computed"] = spsPaths.getJson (0);
|
||||
|
||||
@@ -172,7 +172,8 @@ Pathfinder::Pathfinder (
|
||||
mDstAmount (saDstAmount),
|
||||
mSrcCurrency (uSrcCurrency),
|
||||
mSrcIssuer (uSrcIssuer),
|
||||
mSrcAmount ({uSrcCurrency, uSrcIssuer}, 1u, 0, true),
|
||||
mSrcAmount ({uSrcCurrency,
|
||||
isXRP (uSrcCurrency) ? xrpAccount() : uSrcIssuer }, 1u, 0, true),
|
||||
mLedger (cache->getLedger ()),
|
||||
mRLCache (cache)
|
||||
{
|
||||
@@ -188,7 +189,8 @@ Pathfinder::Pathfinder (
|
||||
mDstAccount (uDstAccount),
|
||||
mDstAmount (saDstAmount),
|
||||
mSrcCurrency (uSrcCurrency),
|
||||
mSrcAmount ({uSrcCurrency, uSrcAccount}, 1u, 0, true),
|
||||
mSrcAmount ({uSrcCurrency,
|
||||
isXRP (uSrcCurrency) ? xrpAccount() : uSrcAccount }, 1u, 0, true),
|
||||
mLedger (cache->getLedger ()),
|
||||
mRLCache (cache)
|
||||
{
|
||||
|
||||
@@ -228,8 +228,9 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
}
|
||||
|
||||
STPath fullLiquidityPath;
|
||||
bool sourceIsXrp = isXRP (uSrcCurrencyID);
|
||||
auto valid = fp.findPathsForIssue (
|
||||
{uSrcCurrencyID, uSrcIssuerID},
|
||||
{uSrcCurrencyID, sourceIsXrp ? xrpAccount() : uSrcIssuerID},
|
||||
spsComputed,
|
||||
fullLiquidityPath);
|
||||
if (!valid)
|
||||
@@ -298,6 +299,9 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
// anyway to produce the canonical. (At least unless we
|
||||
// make a direct canonical.)
|
||||
|
||||
if (!sourceIsXrp)
|
||||
rc.actualAmountIn.setIssuer (issuer);
|
||||
|
||||
jvEntry["source_amount"] = rc.actualAmountIn.getJson (0);
|
||||
jvEntry["paths_canonical"] = Json::arrayValue;
|
||||
jvEntry["paths_computed"] = spsComputed.getJson (0);
|
||||
|
||||
Reference in New Issue
Block a user