mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
Filter insufficient source funds paths from pathfind results
When pathfinding with source amount, we need to filter out paths where source
amount is not equal to the specified source amount. This is due to the behavior
of rippled when specifying a source amount during pathfinding.
Example:
{
"command": "ripple_path_find",
"source_account": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
"destination_account": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
"destination_amount": {
"currency": "EUR",
"issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
"value": -1
},
"send_max": {
"currency": "USD",
"issuer": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
"value": "1234567891"
},
"id": 2
}
{
"id": 2,
"result": {
"alternatives": [
{
"destination_amount": {
"currency": "EUR",
"issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
"value": "3999889.62127857"
},
"paths_canonical": [],
"paths_computed": [
[
{
"account": "rcsxQxEqU2qquAKp3tBUJy8Z2t19ioQPJ",
"type": 1,
"type_hex": "0000000000000001"
},
{
"currency": "EUR",
"issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
"type": 48,
"type_hex": "0000000000000030"
}
]
],
"source_amount": {
"currency": "USD",
"issuer": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
"value": "4170759.906037564"
}
}
],
"destination_account": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
"destination_amount": {
"currency": "EUR",
"issuer": "rp91GUd5R3Rk3ipqW7XBdtrUJcX8epzGyb",
"value": "-1"
},
"destination_currencies": [
"EUR",
"XRP"
],
"full_reply": true,
"id": 2,
"source_account": "rhFQQ4ATC6MDF9ghTq3qAoCsGbGtjnhcXF",
"status": "success"
},
"status": "success",
"type": "response"
}
This commit is contained in:
@@ -323,6 +323,8 @@ module.exports = function(port) {
|
||||
}
|
||||
if (request.source_account === addresses.NOTFOUND) {
|
||||
response = createResponse(request, fixtures.path_find.srcActNotFound);
|
||||
} else if (request.source_account === addresses.SOURCE_LOW_FUNDS) {
|
||||
response = createResponse(request, fixtures.path_find.sourceAmountLow);
|
||||
} else if (request.source_account === addresses.OTHER_ACCOUNT) {
|
||||
response = createResponse(request, fixtures.path_find.sendUSD);
|
||||
} else if (request.source_account === addresses.THIRD_ACCOUNT) {
|
||||
|
||||
Reference in New Issue
Block a user