StrictReceivePathsRequestBuilder

class StrictReceivePathsRequestBuilder(httpClient: HttpClient, serverUri: Url) : RequestBuilder

Builds requests connected to strict receive paths.

The strict receive path finding endpoint lists the possible payment paths that can be taken to arrive at a specific destination asset and amount. This is useful when you know how much you want to receive and want to find out what sources can provide it.

You must specify:

  • Either a source account OR a list of source assets (what you're sending from)

  • Destination asset (what you want to receive)

  • Destination amount (how much you want to receive)

Example usage:

val server = HorizonServer("https://horizon.stellar.org")

// Find paths to receive 50 USD from a specific account
val paths = server.strictReceivePaths()
.sourceAccount("GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B")
.destinationAsset("credit_alphanum4", "USD", "ISSUER_ID")
.destinationAmount("50.0")
.execute()

// Find paths to receive 100 EUR from accounts holding XLM or USD
val paths2 = server.strictReceivePaths()
.sourceAssets(listOf(
Triple("native", null, null),
Triple("credit_alphanum4", "USD", "ISSUER_ID")
))
.destinationAsset("credit_alphanum4", "EUR", "ISSUER_ID")
.destinationAmount("100.0")
.execute()

See also

Constructors

Link copied to clipboard
constructor(httpClient: HttpClient, serverUri: Url)

Functions

Link copied to clipboard
open override fun cursor(cursor: String): StrictReceivePathsRequestBuilder

Sets the cursor parameter for pagination.

Link copied to clipboard

Sets the destination account for the path search. This is optional - paths can be found without specifying a destination account.

Link copied to clipboard

Sets the destination amount for the path search. This is the amount you want to receive.

Link copied to clipboard
fun destinationAsset(assetType: String, assetCode: String? = null, assetIssuer: String? = null): StrictReceivePathsRequestBuilder

Sets the destination asset for the path search. This is the asset you want to receive.

Link copied to clipboard
suspend fun execute(): Page<PathResponse>

Build and execute request to get a page of paths.

Link copied to clipboard
open override fun limit(number: Int): StrictReceivePathsRequestBuilder

Sets the limit parameter defining maximum number of paths to return.

Link copied to clipboard

Sets the order parameter defining the order in which to return paths.

Link copied to clipboard

Sets the source account for the path search. Cannot be used together with sourceAssets().

Link copied to clipboard

Sets the list of source assets for the path search. Cannot be used together with sourceAccount().

Link copied to clipboard
fun <T : Response> stream(serializer: KSerializer<T>, listener: EventListener<T>, reconnectTimeout: Duration = SSEStream.DEFAULT_RECONNECT_TIMEOUT): SSEStream<T>

Creates a Server-Sent Events (SSE) stream for this request. The stream will automatically reconnect on connection loss and resume from the last received event.