View Source Stellar.Horizon.PaymentPaths (Elixir Stellar SDK v0.17.1)

Exposes functions to interact with Paths in Horizon.

You can:

  • Lists the paths a payment can take based on the amount of an asset you want the recipient to receive.
  • Lists the paths a payment can take based on the amount of an asset you want to send.

Horizon API reference: https://developers.stellar.org/api/aggregations/paths/

Summary

Functions

List Payment Paths

List Strict Receive Payment Paths

List Strict Send Payment Paths

Types

@type args() :: Keyword.t()
@type opt() :: atom()
@type path() :: String.t()
@type resource() :: Stellar.Horizon.Paths.t()
@type response() :: {:ok, resource()} | {:error, Stellar.Horizon.Error.t()}

Functions

@spec list_paths(args :: args()) :: response()

List Payment Paths

Parameters

  • source_account: The Stellar address of the sender.
  • destination_asset: :native or [code: "destination_asset_code", issuer: "destination_asset_issuer"]
  • destination_amount: The amount of the destination asset that should be received.

Options

  • destination_account: The Stellar address of the reciever.

Examples

iex> PaymentPaths.list_paths(source_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C",
                             destination_asset: :native,
                             destination_amount: 5
                            )
{:ok, %Paths{records: [%Path{}, ...]}}

# list with `destination_account`
iex> PaymentPaths.list_paths(source_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C",
                             destination_asset: :native,
                             destination_amount: 5,
                             destination_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C"
                            )
{:ok, %Paths{records: [%Path{}, ...]}}

# list with more options
iex> PaymentPaths.list_paths(source_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C",
                             destination_asset: [
                               code: "TEST",
                               issuer: "GA654JC6QLA3ZH4O5V7X5NPM7KEWHKRG5GJA4PETK4SOFBUJLCCN74KQ"
                             ],
                             destination_amount: 5,
                             destination_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C"
                            )
{:ok, %Paths{records: [%Path{}, ...]}}
Link to this function

list_receive_paths(args \\ [])

View Source
@spec list_receive_paths(args :: args()) :: response()

List Strict Receive Payment Paths

Parameters

Using either source_account or source_assets as an argument is required for strict receive path payments.

  • destination_asset: :native or [code: "destination_asset_code", issuer: "destination_asset_issuer"]
  • destination_amount: The amount of the destination asset that should be received.

Options

  • source_account: The Stellar address of the sender.
  • source_assets: A comma-separated list of assets available to the sender.

Examples

# list with `source_account`
iex> PaymentPaths.list_receive_paths(destination_asset: :native,
                                     destination_amount: 5,
                                     source_account: "GBTKSXOTFMC5HR25SNL76MOVQW7GA3F6CQEY622ASLUV4VMLITI6TCOO"
                                    )
{:ok, %Paths{records: [%Path{}, ...]}}


# list with `source_assets`
iex> PaymentPaths.list_receive_paths(destination_asset: :native,
                                     destination_amount: 5,
                                     source_assets: :native
                                    )
{:ok, %Paths{records: [%Path{}, ...]}}

# list with more options
iex> PaymentPaths.list_receive_paths(source_assets: "CNY:GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX",
                                     destination_asset: [
                                       code: "BB1",
                                       issuer: "GD5J6HLF5666X4AZLTFTXLY46J5SW7EXRKBLEYPJP33S33MXZGV6CWFN"
                                     ],
                                     destination_amount: 5
                                    )
{:ok, %Paths{records: [%Path{}, ...]}}
Link to this function

list_send_paths(args \\ [])

View Source
@spec list_send_paths(args :: args()) :: response()

List Strict Send Payment Paths

Parameters

Using either `destination_account` or `destination_assets` as an argument is required for strict send path payments.
* `source_asset`: `:native` or `[code: "source_asset_code", issuer: "source_asset_issuer"]`
* `source_amount`: The amount of the source asset that should be sent.

Options

* `destination_account`: The Stellar address of the reciever.
* `destination_assets`: A comma-separated list of assets that the recipient can receive.

Examples

* list with `destination_account`
iex> PaymentPaths.list_send_paths(source_asset: :native,
                                  source_amount: 5,
                                  destination_account: "GBTKSXOTFMC5HR25SNL76MOVQW7GA3F6CQEY622ASLUV4VMLITI6TCOO"
                                )
{:ok, %Paths{records: [%Path{}, ...]}}

* list with `destination_assets`
iex> PaymentPaths.list_send_paths(source_asset: :native,
                                  source_amount: 5,
                                  destination_assets: "TEST:GA654JC6QLA3ZH4O5V7X5NPM7KEWHKRG5GJA4PETK4SOFBUJLCCN74KQ"
                                )
{:ok, %Paths{records: [%Path{}, ...]}}

# list with more options
iex> PaymentPaths.list_send_paths(destination_account: "GAYOLLLUIZE4DZMBB2ZBKGBUBZLIOYU6XFLW37GBP2VZD3ABNXCW4BVA",
                                  source_asset: [
                                    code: "BRL",
                                    issuer: "GDVKY2GU2DRXWTBEYJJWSFXIGBZV6AZNBVVSUHEPZI54LIS6BA7DVVSP"
                                  ],
                                  source_amount: 400
                                )
{:ok, %Paths{records: [%Path{}, ...]}}