pathFind method

Future<Map<String, dynamic>> pathFind(
  1. PathFindSubcommand subcommand,
  2. String sourceAccount,
  3. String destinationAccount,
  4. XRP destinationAmount, {
  5. List<List<PathStep>>? paths,
  6. XRP? sendMax,
})

WebSocket API only! The path_find method searches for a path along which a transaction can possibly be made, and periodically sends updates when the path changes over time. For a simpler version that is supported by JSON-RPC, see the ripple_path_find method. For payments occurring strictly in XRP, it is not necessary to find a path, because XRP can be sent directly to any account. Although the rippled server tries to find the cheapest path or combination of paths for making a payment, it is not guaranteed that the paths returned by this method are, in fact, the best paths. Due to server load, pathfinding may not find the best results. Additionally, you should be careful with the pathfinding results from untrusted servers. A server could be modified to return less-than-optimal paths to earn money for its operators. If you do not have your own server that you can trust with pathfinding, you should compare the results of pathfinding from multiple servers run by different parties, to minimize the risk of a single server returning poor results. (Note: A server returning less-than-optimal results is not necessarily proof of malicious behavior; it could also be a symptom of heavy server load.)

Implementation

/// Although the rippled server tries to find the cheapest path or combination
/// of paths for making a payment, it is not guaranteed that the paths returned
/// by this method are, in fact, the best paths. Due to server load,
/// pathfinding may not find the best results. Additionally, you should be
/// careful with the pathfinding results from untrusted servers. A server
/// could be modified to return less-than-optimal paths to earn money for its
/// operators. If you do not have your own server that you can trust with
/// pathfinding, you should compare the results of pathfinding from multiple
/// servers run by different parties, to minimize the risk of a single server
/// returning poor results. (Note: A server returning less-than-optimal
/// results is not necessarily proof of malicious behavior; it could also be
/// a symptom of heavy server load.)
Future<Map<String, dynamic>> pathFind(
  PathFindSubcommand subcommand,
  String sourceAccount,
  String destinationAccount,
  XRP destinationAmount, {
  List<List<PathStep>>? paths,
  XRP? sendMax,
}) async {
  final Map<String, dynamic> configParams = {};
  _createRpcConfig(configParams, "subcommand", subcommand.value);
  _createRpcConfig(configParams, "source_account", sourceAccount);
  _createRpcConfig(configParams, "destination_account", destinationAccount);
  _createRpcConfig(
      configParams, "destination_amount", destinationAmount.toJson());
  _createRpcConfig(configParams, "send_max", sendMax?.toJson());
  _createRpcConfig(configParams, "paths",
      paths?.map((e) => e.map((e) => e.toJson()).toList()).toList());
  final response =
      await makeCustomCall<Map<String, dynamic>>("path_find", [configParams]);
  return response;
}