Types
The types the package exports, all with export type: they exist at compile time only. Import them with import type { ... } from "@loki-notfound/zephyr-ts". Result types describe frozen plain objects and arrays; amounts are bigint in atomic units (10^12 per coin). The error types are in the error reference.
Wallets#
ZephyrNetworkTypeInput#
type ZephyrNetworkTypeInput = 0 | 1 | 2 | "mainnet" | "testnet" | "stagenet";
A network type as a construction or validateAddress takes it: 0 mainnet, 1 testnet, 2 stagenet. getNetworkType() returns the number. Guide: Network types.
ZephyrWalletData#
interface ZephyrWalletData {
readonly keys: Uint8Array;
readonly cache: Uint8Array;
}
The wallet bytes getData() returns and openWalletData takes (as keysData and cacheData): the keys file and the cache, encrypted with the wallet password. Guide: Saving and opening wallet bytes.
ZephyrWalletConstructionOptions#
interface ZephyrWalletConstructionOptions {
readonly signal?: AbortSignal;
}
The second argument of a construction function. signal cancels that construction only: in worker mode an abort ends its worker and rejects with NATIVE_ERROR/CONSTRUCTION_ABORTED; in direct mode only an already aborted signal is honored. The signal is detached once the wallet is returned. Guide: Cancelling a construction.
ZephyrDaemonConnection#
interface ZephyrDaemonConnection {
readonly uri: string;
readonly trusted: true;
}
What getDaemonConnection() returns: the normalized address without credentials, and trusted, always true because the core treats every daemon as trusted. Guide: Every daemon is trusted.
ZephyrWalletSyncResult#
interface ZephyrWalletSyncResult {
readonly numBlocksFetched: number;
readonly receivedMoney: boolean;
}
The result of sync(): the number of blocks fetched and whether the wallet received money in them. Guide: Synchronizing.
Balances, accounts and subaddresses#
ZephyrAssetBalances#
type ZephyrAssetBalances = ReadonlyMap<string, bigint>;
A balance by asset name. getBalance() gives the core's keys with zeros included (eight assets for a new wallet); the maps of accounts and subaddresses hold only assets with outputs there. Guide: Balances.
ZephyrAccountBalances#
type ZephyrAccountBalances = ReadonlyMap<number, ZephyrAssetBalances>;
An account's balances by subaddress index, as getBalance(accountIdx) returns them; only subaddresses the core reports are present. Guide: Balances.
ZephyrAccount#
interface ZephyrAccount {
readonly index: number;
readonly primaryAddress: string;
readonly label: string;
readonly subaddressCount: number;
readonly balance: ZephyrAssetBalances;
readonly unlockedBalance: ZephyrAssetBalances;
readonly subaddresses?: ReadonlyArray<ZephyrSubaddress>;
}
One account of a full wallet. primaryAddress is the address of its subaddress 0 and label that subaddress's label ("Primary account" for account 0 of a new wallet, "" when none was set). subaddressCount is at least 1. balance and unlockedBalance sum over its subaddresses by asset. subaddresses is present only when requested with includeSubaddresses. Guide: Accounts and subaddresses.
ZephyrSubaddress#
interface ZephyrSubaddress {
readonly accountIndex: number;
readonly index: number;
readonly address: string;
readonly label: string;
readonly balance: ZephyrAssetBalances;
readonly unlockedBalance: ZephyrAssetBalances;
readonly isUsed: boolean;
readonly numUnspentOutputs: number;
}
One subaddress. label is "" when none was set; isUsed tells whether the wallet has received any output there; numUnspentOutputs counts its unspent outputs as the core counts them. Labels are untrusted display text. Guide: Labels are untrusted display text.
ZephyrAddressIndex#
interface ZephyrAddressIndex {
readonly accountIndex: number;
readonly subaddressIndex: number;
}
Where an address of the wallet belongs, as getAddressIndex returns it.
ZephyrAccountOptions#
interface ZephyrAccountOptions {
readonly includeSubaddresses?: boolean;
}
Options of getAccounts and getAccount. Other fields reject with INVALID_CONFIG/UNKNOWN_FIELD.
History#
ZephyrWalletTx#
interface ZephyrWalletTx {
readonly hash: string;
readonly height?: number;
readonly timestamp?: number;
readonly confirmations: number;
readonly isConfirmed: boolean;
readonly inPool: boolean;
readonly isFailed: boolean;
readonly isLocked: boolean;
readonly isMinerTx: boolean;
readonly fee?: bigint;
readonly feeAsset?: string;
readonly unlockTime: bigint;
readonly incomingTransfers: ReadonlyArray<ZephyrWalletTransfer>;
readonly outgoingTransfer?: ZephyrWalletTransfer;
readonly conversion?: ZephyrTxConversion;
}
One transaction of the wallet with all of its transfers. height and timestamp (seconds) are absent while unconfirmed; fee is absent when the core reports none; feeAsset is the outgoing transfer's asset and absent without one; conversion is present when the outgoing asset differs from its destinations' asset. Guide: Transactions.
ZephyrWalletTransfer#
interface ZephyrWalletTransfer {
readonly direction: ZephyrTransferDirection;
readonly asset?: string;
readonly amount: bigint;
readonly accountIndex: number;
readonly subaddressIndex?: number;
readonly subaddressIndices?: ReadonlyArray<number>;
readonly destinations?: ReadonlyArray<ZephyrTransferDestination>;
readonly txHash: string;
readonly height?: number;
readonly confirmations: number;
}
An incoming transfer to one subaddress (subaddressIndex) or the outgoing transfer of a transaction (subaddressIndices spent from, destinations as stored). asset is absent when the core reports none. Guide: Transfers.
ZephyrTransferDestination#
interface ZephyrTransferDestination {
readonly address?: string;
readonly amount: bigint;
readonly asset?: string;
}
One destination of an outgoing transfer as the sending wallet stored it. address is absent when the stored text does not have the form of an address, and is untrusted text otherwise; amount is in the destination asset. Guide: Transfers.
ZephyrTxConversion#
interface ZephyrTxConversion {
readonly sourceAsset: string;
readonly destinationAsset: string;
readonly sourceAmount: bigint;
readonly destinationAmount: bigint;
}
The conversion of a transaction: sourceAmount is the outgoing transfer's amount as the core computes it, destinationAmount the sum of the destinations' amounts in the destination asset. Guide: Conversions in the history.
ZephyrHistoryQuery#
interface ZephyrHistoryQuery {
readonly asset?: string;
readonly accountIndex?: number;
readonly subaddressIndex?: number;
readonly direction?: ZephyrTransferDirection;
readonly status?: ZephyrHistoryStatus;
readonly minHeight?: number;
readonly maxHeight?: number;
readonly hashes?: ReadonlyArray<string>;
}
The query of getTxs and getTransfers; every field is optional and unknown fields reject. Guide: The query.
ZephyrTransferDirection#
type ZephyrTransferDirection = "incoming" | "outgoing";
The direction of a transfer, and the direction filter of a query.
ZephyrHistoryStatus#
type ZephyrHistoryStatus = "confirmed" | "pool" | "failed";
The status filter of a query: confirmed transactions; own outgoing transactions in the pool and the incoming ones the last refreshPool saw; failed transactions. Guide: Own pending and failed transactions.
Building and relaying#
ZephyrTxPriority#
type ZephyrTxPriority = "default" | "unimportant" | "normal" | "elevated";
The fee priority: the core's own choice, then the first, second and third tier of the daemon's fee estimate. Guide: Fees and priorities.
ZephyrTransferDestinationInput#
interface ZephyrTransferDestinationInput {
readonly address: string;
readonly amount: bigint;
}
One destination of a transfer: an address of the wallet's network and an amount above zero.
ZephyrTransferConfig#
interface ZephyrTransferConfig {
readonly asset: string;
readonly destinationAsset?: string;
readonly destinations: ReadonlyArray<ZephyrTransferDestinationInput>;
readonly accountIndex: number;
readonly subaddressIndices?: ReadonlyArray<number>;
readonly priority?: ZephyrTxPriority;
}
The configuration of buildTransfer and prepareTransfer: a V2 asset, 1 to 15 destinations, the account to spend from, optionally the subaddresses to spend from and the priority. Guide: The configuration.
ZephyrBuiltTx#
interface ZephyrBuiltTx {
readonly hash: string;
readonly sourceAsset: string;
readonly destinationAsset: string;
readonly destinations?: ReadonlyArray<{
readonly address: string;
readonly amount: bigint;
}>;
readonly amount: bigint;
readonly fee: bigint;
readonly feeAsset: string;
readonly totalDebited: bigint;
readonly change: bigint;
readonly ringSize: number;
readonly inputs: number;
readonly outputs: number;
readonly weight: number;
readonly unlockTime: bigint;
}
One built transaction as the core built it. destinations is present only when the build needed one transaction; totalDebited is amount plus fee, in the source asset; outputs includes the change. Guide: Building to inspect.
ZephyrTransferBuild#
interface ZephyrTransferBuild {
readonly txs: ReadonlyArray<ZephyrBuiltTx>;
readonly multipleTxs: boolean;
}
The result of buildTransfer: the built transactions and whether more than one was needed.
ZephyrConversionDestinationInput#
interface ZephyrConversionDestinationInput {
readonly address: string;
readonly amount: bigint;
}
The destination of a conversion: an address and the amount converted, in atomic units of the source asset, a multiple of 10^8 (at most four decimals).
ZephyrConversionConfig#
interface ZephyrConversionConfig {
readonly sourceAsset: string;
readonly destinationAsset: string;
readonly destination: ZephyrConversionDestinationInput;
readonly accountIndex: number;
readonly subaddressIndices?: ReadonlyArray<number>;
readonly priority?: ZephyrTxPriority;
}
The configuration of buildConversion and prepareConversion: one of the six pairs and exactly one destination. Guide: The configuration.
ZephyrConversionBuild#
interface ZephyrConversionBuild {
readonly hash: string;
readonly sourceAsset: string;
readonly destinationAsset: string;
readonly destination: {
readonly address: string;
readonly amount: bigint;
};
readonly amountBurnt: bigint;
readonly amountMinted: bigint;
readonly fee: bigint;
readonly feeAsset: string;
readonly totalDebited: bigint;
readonly change: bigint;
readonly ringSize: number;
readonly inputs: number;
readonly outputs: number;
readonly weight: number;
readonly unlockTime: bigint;
readonly pricingRecordHeight: number;
}
The one transaction of a conversion: amountBurnt in the source asset and amountMinted in the destination asset, as the transaction states them; totalDebited is amountBurnt plus fee; outputs is four; pricingRecordHeight names the block whose pricing record sets the rate. The library computes no rate. Guide: What a conversion build describes.
ZephyrPreparedTransfer#
interface ZephyrPreparedTransfer {
readonly token: string;
readonly build: ZephyrTransferBuild;
}
The result of prepareTransfer: the token of the kept build (32 lowercase hexadecimal characters, not a secret) and its description. Guide: Preparing and relaying.
ZephyrPreparedConversion#
interface ZephyrPreparedConversion {
readonly token: string;
readonly build: ZephyrConversionBuild;
}
The result of prepareConversion. Guide: Relaying a conversion.
ZephyrRelayOutcome#
type ZephyrRelayOutcome = "accepted" | "rejected" | "unknown" | "notSent";
What happened to one kept transaction in a relay call: accepted by the daemon (now or by an earlier call with the same token), rejected by it, unknown (sent, no usable answer: it may have reached the network), or not sent (not attempted, refused before sending, or not processed by a busy daemon).
ZephyrRelayedTx#
interface ZephyrRelayedTx {
readonly hash: string;
readonly outcome: ZephyrRelayOutcome;
readonly notRelayed: boolean;
readonly code?: ZephyrWalletErrorCode;
readonly diagnostic?: ZephyrWalletErrorDiagnostic;
}
One entry of a relay result: the hash described at prepare time, the outcome, notRelayed (accepted, but the daemon kept it without relaying it), and on a failed entry, also an accepted one whose record failed in the wallet, its code and diagnostic.
ZephyrRelayResult#
interface ZephyrRelayResult {
readonly txs: ReadonlyArray<ZephyrRelayedTx>;
readonly complete: boolean;
}
The result of relayPrepared: one entry per kept transaction in the build's order; complete when every one was accepted. Guide: Outcomes of a relay.