initialize({ mnemonicOrSeed, signer, options }: SparkWalletProps)
Creates and initializes a new SparkWallet instance.
props: Object containing:mnemonicOrSeed: (Optional) BIP-39 mnemonic phrase or raw seedaccountNumber: (Optional) number used to generate multiple identity keys from the same mnemonicsigner: (Optional) Custom signer implementationoptions: (Optional) Wallet configuration options
If no account number is provided, our JS-SDK defaults
accountNumber to 1
to support backwards compatability for mainnet wallets created with earlier
versions of the SDK.- Object containing:
wallet: The initialized SparkWallet instancemnemonic: The mnemonic if one was generated (undefined for raw seed)
getIdentityPublicKey()
Gets the identity public key of the wallet.
Promise<string>: The identity public key as a hex string
getSparkAddress()
Gets the Spark Address of the wallet.
Promise<SparkAddressFormat>: The Spark Address
getBalance()
Gets the current balance of the wallet. You can use the forceRefetch option to synchronize your wallet and claim any pending incoming lightning payment, spark transfer, or bitcoin deposit before returning the balance.
- Object containing:
balance: The wallet’s current balance in satoshistokenBalances: Map of token public keys to token balances with Bech32m token identifiers
getTransfers(limit?: number, offset?: number)
Gets all transfers for the wallet.
limit: (Optional, default: 20) Maximum number of transfers to returnoffset: (Optional, default: 0) Offset for pagination
Promise<{ transfers: WalletTransfer[]; offset: number; }>: Response containing the list of transfers and offset
cleanupConnections()
Cleans up connections and aborts any active streams.
Promise<void>