PathPaymentOperation

public class PathPaymentOperation : Operation, @unchecked Sendable

Represents a path payment operation. Sends an amount in a specific asset to a destination account through a path of offers. This allows the asset sent (e.g., 450 XLM) to be different from the asset received (e.g, 6 BTC). See Stellar developer docs

  • The asset deducted from the sender’s account.

    Declaration

    Swift

    public let sendAsset: Asset
  • The maximum amount of send asset to deduct, excluding fees.

    Declaration

    Swift

    public let sendMax: Decimal
  • The destination account that receives the payment.

    Declaration

    Swift

    public let destinationAccountId: String
  • The asset the destination account receives.

    Declaration

    Swift

    public let destAsset: Asset
  • The amount of destination asset the destination account receives.

    Declaration

    Swift

    public let destAmount: Decimal
  • The assets involved in the offers the path takes. Maximum of 5 assets.

    Declaration

    Swift

    public let path: [Asset]
  • Creates a new PathPaymentOperation object.

    Throws

    Throws StellarSDKError.invalidArgument if maximum number of assets in the path is > 5

    Declaration

    Swift

    public init(sourceAccountId: String?, sendAsset: Asset, sendMax: Decimal, destinationAccountId: String, destAsset: Asset, destAmount: Decimal, path: [Asset]) throws

    Parameters

    sourceAccountId

    (optional) source account Id, must be valid, otherwise it will be ignored.

    sendAsset

    The asset deducted from the sender’s account.

    sendMax

    The maximum amount of send asset to deduct (excluding fees).

    destinationAccountId

    Account address that receives the payment, must be valid, otherwise this will throw an exception.

    destAsset

    The asset the destination account receives.

    destAmount

    The amount of destination asset the destination account receives.

    path

    The assets (other than send asset and destination asset) involved in the offers the path takes. For example, if you can only find a path from USD to EUR through XLM and BTC, the path would be USD -> XLM -> BTC -> EUR and the path field would contain XLM and BTC. The maximum number of assets in the path is 5

  • Creates a new PathPaymentOperation object from the given PathPaymentOperationXDR object.

    Declaration

    Swift

    public init(fromXDR: PathPaymentOperationXDR, sourceAccountId: String?)

    Parameters

    fromXDR

    the PathPaymentOperationXDR object to be used to create a new PathPaymentOperation object.

    sourceAccountId

    (optional) source account Id, must be valid, otherwise it will be ignored.