ValidatorClient

class ValidatorClient(baseUrl: String, accessTokenProvider: suspend () -> String, http: OkHttpClient = OkHttpClient())

Client for a validator's user-facing wallet API (.../api/validator) — the onboarding, faucet, and traffic-purchase operations a wallet app drives against its own validator, authenticated as the end user.

Every call sends a bearer token from accessTokenProvider; the validator derives the ledger user from the token's subject claim. On LocalNet that is the unsafe HS256 JWT the integration harness mints; against a real validator it is the user's OAuth access token.

Unlike ScanClient (public network index) and TransferRegistryClient (registry choice contexts), this API is validator-local: it only answers for users of the validator behind baseUrl.

Constructors

Link copied to clipboard
constructor(baseUrl: String, accessTokenProvider: suspend () -> String, http: OkHttpClient = OkHttpClient())

Types

Link copied to clipboard
data class BuyTrafficRequest(val trackingId: String, val requestContractId: String)

A created buy-traffic request, identified for status polling.

Link copied to clipboard
sealed interface BuyTrafficStatus

Where a buy-traffic request stands (buyTrafficStatus).

Link copied to clipboard
data class WalletUserStatus(val partyId: String, val userOnboarded: Boolean, val userWalletInstalled: Boolean)

Onboarding state of the authenticated user on this validator.

Functions

Link copied to clipboard
suspend fun buyTraffic(trafficAmountBytes: Long, receivingValidatorPartyId: String, synchronizerId: String, trackingId: String = java.util.UUID.randomUUID().toString(), expiresAt: Instant = java.time.Instant.now().plusSeconds(600)): ValidatorClient.BuyTrafficRequest

Requests a synchronizer extra-traffic purchase (/v0/wallet/buy-traffic-requests), paid in Amulet from the authenticated user's wallet.

Link copied to clipboard

Where the buy-traffic request created under trackingId stands (/v0/wallet/buy-traffic-requests/{tracking_id}/status), or null if the validator knows no such request — not yet processed, or already beyond the wallet's transaction-log horizon.

Link copied to clipboard
suspend fun register(): String

Onboards the authenticated user onto this validator (/v0/register): allocates the ledger user and wallet party and installs the wallet contracts. Idempotent — an already-onboarded user just gets its party back.

Link copied to clipboard
suspend fun tap(amountUsd: BigDecimal, commandId: String? = null): String

Taps the faucet (/v0/wallet/tap): mints Amulet to the authenticated user's wallet party. Test networks only — DevNet and LocalNet validators expose the tap; on MainNet it fails.

Link copied to clipboard

The authenticated user's onboarding state (/v0/wallet/user-status).