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

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/

Link to this section Summary

Functions

List Payment Paths

List Strict Receive Payment Paths

List Strict Send Payment Paths

Link to this section 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()}

Link to this section Functions

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

List Payment Paths

parameters

Parameters

  • source_account: The Stellar address of the sender.
  • destination_asset_type: The type for the destination asset.
  • destination_amount: The amount of the destination asset that should be received.

options

Options

  • destination_account: The Stellar address of the reciever.
  • destination_asset_issuer: The Stellar address of the issuer of the destination asset. Required if the destination_asset_type is not native
  • destination_asset_code: The code for the destination asset. Required if the destination_asset_type is not native.

examples

Examples

iex> PaymentPaths.list_paths(source_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C",

                           destination_asset_type: :native,
                           destination_amount: 5
                          )

, ...]}}

# list with destination_account iex> PaymentPaths.list_paths(source_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C",

                           destination_asset_type: :native,
                           destination_amount: 5,
                           destination_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C"
                          )

, ...]}}

# list with more options iex> PaymentPaths.list_paths(source_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C",

                           destination_asset_type: "credit_alphanum4",
                           destination_amount: 5,
                           destination_account: "GBRSLTT74SKP62KJ7ENTMP5V4R7UGB6E5UQESNIIRWUNRCCUO4ZMFM4C",
                           destination_asset_code: "TEST",
                           destination_asset_issuer: "GA654JC6QLA3ZH4O5V7X5NPM7KEWHKRG5GJA4PETK4SOFBUJLCCN74KQ"
                          )

, ...]}}

Link to this function

list_receive_paths(args \\ [])

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

List Strict Receive Payment Paths

parameters

Parameters

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

  • destination_asset_type: The type for the destination asset.
  • destination_amount: The amount of the destination asset that should be received.

options

Options

  • source_account: The Stellar address of the sender.
  • source_assets: A comma-separated list of assets available to the sender.
  • destination_asset_issuer: The Stellar address of the issuer of the destination asset. Required if the destination_asset_type is not native
  • destination_asset_code: The code for the destination asset. Required if the destination_asset_type is not native.

examples

Examples

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


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

# list with more options
iex> PaymentPaths.list_receive_paths(destination_asset_type: :credit_alphanum4,
                                     destination_amount: 5,
                                     destination_asset_code: "BB1",
                                     destination_asset_issuer: "GD5J6HLF5666X4AZLTFTXLY46J5SW7EXRKBLEYPJP33S33MXZGV6CWFN",
                                     source_assets: "CNY:GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX"
                                    )
{: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

Parameters

Using either `destination_account` or `destination_assets` as an argument is required for strict send path payments.
* `source_asset_type`: The type for the source asset
* `source_amount`: The amount of the source asset that should be sent.

options

Options

* `source_asset_issuer`: The Stellar address of the issuer of the source asset. Required if the `source_asset_type` is not native.
* `source_asset_code`: The code for the source asset. Required if the `source_asset_type` is not native.
* `destination_account`: The Stellar address of the reciever.
* `destination_assets`: A comma-separated list of assets that the recipient can receive.

examples

Examples

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

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

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