RecoveryService
public final class RecoveryService : @unchecked Sendable
Implements SEP-0030 - Account Recovery: Multi-Party Recovery of Stellar Accounts.
This class provides account recovery functionality allowing users to regain access to their Stellar accounts through registered identities. Multiple recovery methods can be configured as a safety net if primary authentication is lost.
Typical Usage
let service = RecoveryService(serviceAddress: "https://recovery.example.com")
// Register account with recovery identities
let request = Sep30Request()
request.identities = [
Sep30Identity(role: "owner", authMethods: [...])
]
let result = await service.registerAccount(
address: accountId,
request: request,
jwt: jwtToken
)
// Sign transaction for recovery
let signResult = await service.signTransaction(
address: accountId,
signingAddress: signerAddress,
transaction: transactionXdr,
jwt: jwtToken
)
See also:
- SEP-0030 Specification
- [WebAuthenticator] for SEP-10 authentication
-
The base URL of the SEP-30 account recovery service endpoint for multi-party account recovery.
Declaration
Swift
public let serviceAddress: String -
Creates a RecoveryService instance with a direct service endpoint URL.
Declaration
Swift
public init(serviceAddress: String)Parameters
serviceAddressThe URL of the SEP-30 recovery server (e.g., “https://recovery.example.com”)
-
registerAccount(address:Asynchronousrequest: jwt: ) Registers an account with the recovery service.
See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0030.md#post-accountsaddress
Declaration
Swift
public func registerAccount(address: String, request: Sep30Request, jwt: String) async -> Sep30AccountResponseEnumParameters
addressThe Stellar account address (G…) to register
requestSep30Request containing the identities and authentication methods for recovery
jwtJWT token obtained from SEP-10 authentication
Return Value
Sep30AccountResponseEnum with account details, or an error
-
updateIdentitiesForAccount(address:Asynchronousrequest: jwt: ) Updates the identities for the account.
The identities should be entirely replaced with the identities provided in the request, and not merged. Either owner or other or both should be set. If one is currently set and the request does not include it, it is removed.
See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0030.md#put-accountsaddress
Declaration
Swift
public func updateIdentitiesForAccount(address: String, request: Sep30Request, jwt: String) async -> Sep30AccountResponseEnumParameters
addressThe Stellar account address (G…) to update
requestSep30Request containing the new identities to replace existing ones
jwtJWT token obtained from SEP-10 authentication
Return Value
Sep30AccountResponseEnum with updated account details, or an error
-
Signs a transaction using the recovery service’s signer.
Declaration
Swift
public func signTransaction(address: String, signingAddress: String, transaction: String, jwt: String) async -> Sep30SignatureResponseEnumParameters
addressThe Stellar account address (G…) that the transaction is for
signingAddressThe address of the signer on the recovery service that should sign
transactionThe transaction envelope XDR (base64 encoded) to sign
jwtJWT token obtained from SEP-10 authentication
Return Value
Sep30SignatureResponseEnum with the signature and network passphrase, or an error
-
accountDetails(address:Asynchronousjwt: ) Returns the registered account’s details.
See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0030.md#get-accountsaddress
Declaration
Swift
public func accountDetails(address: String, jwt: String) async -> Sep30AccountResponseEnumParameters
addressThe Stellar account address (G…) to retrieve
jwtJWT token obtained from SEP-10 authentication
Return Value
Sep30AccountResponseEnum with account details including identities and signers, or an error
-
deleteAccount(address:Asynchronousjwt: ) Deletes the record for an account. This should be irrecoverable.
See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0030.md#delete-accountsaddress
Declaration
Swift
public func deleteAccount(address: String, jwt: String) async -> Sep30AccountResponseEnumParameters
addressThe Stellar account address (G…) to delete
jwtJWT token obtained from SEP-10 authentication
Return Value
Sep30AccountResponseEnum with the deleted account details, or an error
-
accounts(jwt:Asynchronousafter: ) Returns a list of accounts that the JWT allows access to.
See: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0030.md#get-accounts
Declaration
Swift
public func accounts(jwt: String, after: String? = nil) async -> Sep30AccountsResponseEnumParameters
jwtJWT token obtained from SEP-10 authentication
afterOptional account address for pagination (returns accounts after this address)
Return Value
Sep30AccountsResponseEnum with list of accessible accounts, or an error
View on GitHub
Install in Dash