Skip to content

API ​

Every method the guides use: signature, parameters, return value and errors.

This section has one page for each method that the guides call. Each page shows the signature, the parameters, the return value, the error codes it can throw, an example, and the guide steps that use it.

Many calls in the bindings take a last optional parameter, asyncOpts_, for an abort signal. The signatures on this page leave it out.

useSession is not part of the package. It is guide code from the Session page.

Session ​

Open the SDK, close it, and follow it with hooks.

MethodSignature
openSdkopenSdk(options: OpenOptions): Promise<SdkSession>
SdkSession.closeclose(): Promise<void>
useSessionuseSession(): SdkSession
useBalanceuseBalance(federation: FederationLike | undefined, onError?: (err: unknown) => void): Amount | undefined
useOperationuseOperation<S>(operation: ObservableOperation<S> | undefined, onError?: (err: unknown) => void): S | undefined

Sdk ​

Methods of SdkLike, the type of session.sdk.

MethodSignature
SdkLike.previewpreview(invite: InviteCodeLike): Promise<FederationPreview>
SdkLike.joinjoin(invite: InviteCodeLike): Promise<FederationLike>
SdkLike.recoverrecover(invite: InviteCodeLike): Promise<RecoveryHandle>
SdkLike.resumeRecoveryresumeRecovery(id: FederationId): Promise<RecoveryHandle>
SdkLike.recoveryStatusrecoveryStatus(id: FederationId): Promise<RecoveryState | undefined>
SdkLike.federationfederation(id: FederationId): FederationLike | undefined
SdkLike.federationsfederations(): Array<FederationLike>
SdkLike.storedFederationsstoredFederations(): Array<FederationInfo>
SdkLike.reopenFederationreopenFederation(id: FederationId): Promise<FederationLike>
SdkLike.exportMnemonicexportMnemonic(): MnemonicLike

Federation ​

Methods of FederationLike, the handle you get from join, federation and reopenFederation.

MethodSignature
FederationLike.idid(): FederationId
FederationLike.namename(): string | undefined
FederationLike.networknetwork(): Network
FederationLike.balancebalance(): Promise<Amount>
FederationLike.balanceUpdatesbalanceUpdates(): BalanceUpdatesLike
FederationLike.activityactivity(cursor: Cursor | undefined, limit: number): Promise<ActivityPage>
FederationLike.operationoperation(id: OperationId): Promise<AnyOperationLike | undefined>
FederationLike.ecashecash(): EcashLike | undefined
FederationLike.lightninglightning(): LightningLike | undefined
FederationLike.capabilitiescapabilities(): Capabilities
FederationLike.inviteCodeinviteCode(): InviteCodeLike
FederationLike.metameta(): MetaLike
FederationLike.onchainonchain(): OnchainLike | undefined

Ecash ​

Methods of EcashLike, from federation.ecash(), and of the quote it returns.

MethodSignature
EcashLike.quotequote(amount: Amount): Promise<EcashQuoteLike>
EcashLike.sendsend(quote: EcashQuoteLike): Promise<EcashSendHandle>
EcashLike.receivereceive(notes: NotesLike): Promise<EcashReceiveOperationLike>
EcashQuoteLike.requestedAmountrequestedAmount(): Amount
EcashQuoteLike.notesValuenotesValue(): Amount
EcashQuoteLike.feefee(): Amount
EcashQuoteLike.totaltotal(): Amount

Lightning ​

Methods of LightningLike, from federation.lightning(), and of the quote it returns.

MethodSignature
LightningLike.quotequote(invoice: Bolt11Invoice): Promise<LnQuoteLike>
LightningLike.sendsend(quote: LnQuoteLike): Promise<LnSendOperationLike>
LightningLike.receivereceive(amount: Amount, description: string): Promise<LnReceiveHandle>
LnQuoteLike.invoiceAmountinvoiceAmount(): Amount
LnQuoteLike.feefee(): Amount
LnQuoteLike.totaltotal(): Amount

Operation ​

The handles EcashSendOperationLike, EcashReceiveOperationLike, LnReceiveOperationLike, LnSendOperationLike and RecoveryOperationLike share the same state methods. AnyOperationLike is the untyped handle. The signatures below use EcashSendOperationLike. Each other handle uses its own state type in place of EcashSendState.

MethodSignature
EcashSendOperationLike.statestate(): Promise<EcashSendState>
EcashSendOperationLike.updatesupdates(): EcashSendOperationUpdatesLike
EcashSendOperationLike.awaitFinalawaitFinal(): Promise<EcashSendState>
EcashSendOperationLike.requestCancelrequestCancel(): Promise<void>
AnyOperationLike.asEcashSendasEcashSend(): EcashSendOperationLike | undefined
AnyOperationLike.kindkind(): OperationKind
EcashSendOperationLike.detailsdetails(): Promise<EcashSendDetails>

Values ​

Parse strings into checked values, and read seed words.

MethodSignature
InviteCode.parseInviteCode.parse(code: string): InviteCodeLike
InviteCodeLike.federationIdfederationId(): FederationId
Notes.parseNotes.parse(notes: string): NotesLike
NotesLike.valuevalue(): Amount
NotesLike.displaydisplay(): string
MnemonicLike.wordswords(): Array<string>

Errors (Exception) ​

Read the Exception that the SDK throws. Each code of ErrorCode is described in the table on the Errors page.

MethodSignature
Exception.hasInnerException.hasInner(obj_: any): obj_ is UniffiThrownObject<Exception>
Exception.getInnerException.getInner(err: UniffiThrownObject<Exception>): Exception
ExceptionLike.codecode(): ErrorCode
ExceptionLike.reasonreason(): string
ExceptionLike.detailsdetails(): RawErrorDetails | undefined