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.
| Method | Signature |
|---|---|
openSdk | openSdk(options: OpenOptions): Promise<SdkSession> |
SdkSession.close | close(): Promise<void> |
useSession | useSession(): SdkSession |
useBalance | useBalance(federation: FederationLike | undefined, onError?: (err: unknown) => void): Amount | undefined |
useOperation | useOperation<S>(operation: ObservableOperation<S> | undefined, onError?: (err: unknown) => void): S | undefined |
Sdk
Methods of SdkLike, the type of session.sdk.
| Method | Signature |
|---|---|
SdkLike.preview | preview(invite: InviteCodeLike): Promise<FederationPreview> |
SdkLike.join | join(invite: InviteCodeLike): Promise<FederationLike> |
SdkLike.recover | recover(invite: InviteCodeLike): Promise<RecoveryHandle> |
SdkLike.resumeRecovery | resumeRecovery(id: FederationId): Promise<RecoveryHandle> |
SdkLike.recoveryStatus | recoveryStatus(id: FederationId): Promise<RecoveryState | undefined> |
SdkLike.federation | federation(id: FederationId): FederationLike | undefined |
SdkLike.federations | federations(): Array<FederationLike> |
SdkLike.storedFederations | storedFederations(): Array<FederationInfo> |
SdkLike.reopenFederation | reopenFederation(id: FederationId): Promise<FederationLike> |
SdkLike.exportMnemonic | exportMnemonic(): MnemonicLike |
Federation
Methods of FederationLike, the handle you get from join, federation and reopenFederation.
| Method | Signature |
|---|---|
FederationLike.id | id(): FederationId |
FederationLike.name | name(): string | undefined |
FederationLike.network | network(): Network |
FederationLike.balance | balance(): Promise<Amount> |
FederationLike.balanceUpdates | balanceUpdates(): BalanceUpdatesLike |
FederationLike.activity | activity(cursor: Cursor | undefined, limit: number): Promise<ActivityPage> |
FederationLike.operation | operation(id: OperationId): Promise<AnyOperationLike | undefined> |
FederationLike.ecash | ecash(): EcashLike | undefined |
FederationLike.lightning | lightning(): LightningLike | undefined |
FederationLike.capabilities | capabilities(): Capabilities |
FederationLike.inviteCode | inviteCode(): InviteCodeLike |
FederationLike.meta | meta(): MetaLike |
FederationLike.onchain | onchain(): OnchainLike | undefined |
Ecash
Methods of EcashLike, from federation.ecash(), and of the quote it returns.
| Method | Signature |
|---|---|
EcashLike.quote | quote(amount: Amount): Promise<EcashQuoteLike> |
EcashLike.send | send(quote: EcashQuoteLike): Promise<EcashSendHandle> |
EcashLike.receive | receive(notes: NotesLike): Promise<EcashReceiveOperationLike> |
EcashQuoteLike.requestedAmount | requestedAmount(): Amount |
EcashQuoteLike.notesValue | notesValue(): Amount |
EcashQuoteLike.fee | fee(): Amount |
EcashQuoteLike.total | total(): Amount |
Lightning
Methods of LightningLike, from federation.lightning(), and of the quote it returns.
| Method | Signature |
|---|---|
LightningLike.quote | quote(invoice: Bolt11Invoice): Promise<LnQuoteLike> |
LightningLike.send | send(quote: LnQuoteLike): Promise<LnSendOperationLike> |
LightningLike.receive | receive(amount: Amount, description: string): Promise<LnReceiveHandle> |
LnQuoteLike.invoiceAmount | invoiceAmount(): Amount |
LnQuoteLike.fee | fee(): Amount |
LnQuoteLike.total | total(): 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.
| Method | Signature |
|---|---|
EcashSendOperationLike.state | state(): Promise<EcashSendState> |
EcashSendOperationLike.updates | updates(): EcashSendOperationUpdatesLike |
EcashSendOperationLike.awaitFinal | awaitFinal(): Promise<EcashSendState> |
EcashSendOperationLike.requestCancel | requestCancel(): Promise<void> |
AnyOperationLike.asEcashSend | asEcashSend(): EcashSendOperationLike | undefined |
AnyOperationLike.kind | kind(): OperationKind |
EcashSendOperationLike.details | details(): Promise<EcashSendDetails> |
Values
Parse strings into checked values, and read seed words.
| Method | Signature |
|---|---|
InviteCode.parse | InviteCode.parse(code: string): InviteCodeLike |
InviteCodeLike.federationId | federationId(): FederationId |
Notes.parse | Notes.parse(notes: string): NotesLike |
NotesLike.value | value(): Amount |
NotesLike.display | display(): string |
MnemonicLike.words | words(): Array<string> |
Errors (Exception)
Read the Exception that the SDK throws. Each code of ErrorCode is described in the table on the Errors page.
| Method | Signature |
|---|---|
Exception.hasInner | Exception.hasInner(obj_: any): obj_ is UniffiThrownObject<Exception> |
Exception.getInner | Exception.getInner(err: UniffiThrownObject<Exception>): Exception |
ExceptionLike.code | code(): ErrorCode |
ExceptionLike.reason | reason(): string |
ExceptionLike.details | details(): RawErrorDetails | undefined |