API Reference
Complete API documentation for @tetherto/wdk-wallet-spark
Known Issue: Thread Hanging in Bare runtime Environments
There is a known issue with this module causing thread hanging when used in bare runtime environments. The module is not production-ready in bare runtime at this time.
For the latest updates and workarounds, please check the GitHub Issues.
Table of Contents
Main class for managing Spark wallets. Extends WalletManager from @tetherto/wdk-wallet.
Individual Spark wallet account implementation. Implements IWalletAccount.
WalletManagerSpark
The main class for managing Spark wallets.
Extends WalletManager from @tetherto/wdk-wallet.
Constructor
new WalletManagerSpark(seed, config)Parameters:
seed(string | Uint8Array): BIP-39 mnemonic seed phrase or seed bytesconfig(object, optional): Configuration objectnetwork(string, optional): 'MAINNET', 'TESTNET', or 'REGTEST' (default: 'MAINNET')
Methods
getAccount(index)
Returns a wallet account at the specified index
Promise<WalletAccountSpark>
getFeeRates()
Returns current fee rates for transactions (always zero for Spark)
Promise<{normal: number, fast: number}>
dispose()
Disposes all wallet accounts, clearing private keys from memory
void
getAccount(index)
Returns a wallet account at the specified index using BIP-44 derivation path.
Parameters:
index(number, optional): The index of the account to get (default: 0)
Returns: Promise<WalletAccountSpark> - The wallet account
Example:
Note: Uses derivation path pattern m/44'/998'/0'/0/{index} where 998 is the coin type for Liquid Bitcoin.
getFeeRates()
Returns current fee rates for transactions. On Spark network, transactions have zero fees.
Returns: Promise<{normal: number, fast: number}> - Object containing fee rates (always {normal: 0, fast: 0})
Example:
dispose()
Disposes all wallet accounts and clears sensitive data from memory.
Returns: void
Example:
Important Notes:
getAccountByPath(path)is not supported and will throw an errorCustom derivation paths are not available - only indexed accounts
All Spark transactions have zero fees
Network configuration is limited to predefined values
WalletAccountSpark
Represents an individual Spark wallet account. Implements IWalletAccount from @tetherto/wdk-wallet.
Note: WalletAccountSpark instances are created internally by WalletManagerSpark.getAccount() and are not intended to be constructed directly.
Methods
getAddress()
Returns the account's Spark address
Promise<string>
sign(message)
Signs a message using the account's identity key
Promise<string>
verify(message, signature)
Verifies a message signature
Promise<boolean>
sendTransaction(tx)
Sends a Spark transaction
Promise<{hash: string, fee: number}>
quoteSendTransaction(tx)
Estimates transaction fee (always 0)
Promise<{fee: number}>
getBalance()
Returns the native token balance in satoshis
Promise<number>
getTransfers(options?)
Returns the account's transfer history
Promise<Transfer[]>
getSingleUseDepositAddress()
Generates a single-use Bitcoin deposit address
Promise<string>
claimDeposit(txId)
Claims a Bitcoin deposit to the wallet
Promise<WalletLeaf[]>
withdraw({to, value})
Withdraws funds to a Bitcoin address
Promise<CoopExitRequest>
createLightningInvoice({value, memo?})
Creates a Lightning invoice
Promise<LightningReceiveRequest>
payLightningInvoice({invoice, maxFeeSats})
Pays a Lightning invoice
Promise<LightningSendRequest>
toReadOnlyAccount()
Creates a read-only version of this account
Promise<WalletAccountReadOnlySpark>
dispose()
Disposes the wallet account, clearing private keys
void
getAddress()
Returns the account's Spark network address.
Returns: Promise<string> - The Spark address
Example:
sign(message)
Signs a message using the account's identity key.
Parameters:
message(string): The message to sign
Returns: Promise<string> - The message signature
Example:
verify(message, signature)
Verifies a message signature against the account's identity key.
Parameters:
message(string): The original messagesignature(string): The signature to verify
Returns: Promise<boolean> - True if the signature is valid
Example:
sendTransaction({to, value})
Sends a Spark transaction.
Parameters:
to(string): Recipient's Spark addressvalue(number): Amount in satoshis
Returns: Promise<{hash: string, fee: number}> (fee is always 0)
Example:
quoteSendTransaction({to, value})
Estimates the fee for a Spark transaction (always returns 0).
Parameters:
to(string): Recipient's Spark addressvalue(number): Amount in satoshis
Returns: Promise<{fee: number}> - Fee estimate (always 0)
Example:
transfer(options)
Transfers tokens to another address. Not supported on Spark blockchain.
Parameters:
options(object): Transfer options
Throws: Error - "Not supported on Spark blockchain"
quoteTransfer(options)
Quotes the costs of a transfer operation. Not supported on Spark blockchain.
Parameters:
options(object): Transfer options
Throws: Error - "Not supported on Spark blockchain"
getBalance()
Returns the account's native token balance in satoshis.
Returns: Promise<number> - Balance in satoshis
Example:
getTokenBalance(tokenAddress)
Returns the balance for a specific token. Not supported on Spark blockchain.
Parameters:
tokenAddress(string): Token contract address
Throws: Error - "Not supported on Spark blockchain"
getTransactionReceipt(hash)
Gets the transaction receipt for a given transaction hash.
Parameters:
hash(string): Transaction hash
Returns: Promise<SparkTransactionReceipt> - Transaction receipt details
Example:
getTransfers(options?)
Returns the account's transfer history with filtering options.
Parameters:
options(object, optional): Filter optionsdirection(string): 'all', 'incoming', or 'outgoing' (default: 'all')limit(number): Maximum transfers to return (default: 10)skip(number): Number of transfers to skip (default: 0)
Returns: Promise<Transfer[]> - Array of transfer objects
Example:
getSingleUseDepositAddress()
Generates a single-use Bitcoin deposit address for funding the Spark wallet.
Returns: Promise<string> - Bitcoin deposit address
Example:
claimDeposit(txId)
Claims a Bitcoin deposit to add funds to the Spark wallet.
Parameters:
txId(string): Bitcoin transaction ID of the deposit
Returns: Promise<WalletLeaf[] | undefined> - Wallet leaves created from the deposit
Example:
getLatestDepositTxId(depositAddress)
Checks for a confirmed Bitcoin deposit to the specified address.
Parameters:
depositAddress(string): Bitcoin deposit address to check
Returns: Promise<string | null> - Transaction ID if found, null otherwise
Example:
withdraw({to, value})
Withdraws funds from the Spark network to an on-chain Bitcoin address.
Parameters:
to(string): Bitcoin address to withdraw tovalue(number): Amount in satoshis
Returns: Promise<CoopExitRequest | null | undefined> - Withdrawal request details
Example:
createLightningInvoice({value, memo?})
Creates a Lightning invoice for receiving payments.
Parameters:
value(number): Amount in satoshismemo(string, optional): Invoice description
Returns: Promise<LightningReceiveRequest> - Lightning invoice details
Example:
getLightningReceiveRequest(invoiceId)
Gets details of a previously created Lightning receive request.
Parameters:
invoiceId(string): Invoice ID
Returns: Promise<LightningReceiveRequest> - Invoice details
Example:
payLightningInvoice({invoice, maxFeeSats})
Pays a Lightning invoice.
Parameters:
invoice(string): BOLT11 Lightning invoicemaxFeeSats(number): Maximum fee willing to pay in satoshis
Returns: Promise<LightningSendRequest> - Payment details
Example:
getLightningSendFeeEstimate({invoice})
Estimates the fee for paying a Lightning invoice.
Parameters:
invoice(string): BOLT11 Lightning invoice
Returns: Promise<number> - Estimated fee in satoshis
Example:
toReadOnlyAccount()
Creates a read-only version of this account that can query data but not sign transactions.
Returns: Promise<WalletAccountReadOnlySpark> - Read-only account instance
Example:
cleanupConnections()
Cleans up network connections and resources.
Returns: Promise<void>
Example:
dispose()
Disposes the wallet account, securely erasing private keys from memory.
Returns: void
Example:
Properties
index
number
The derivation path index of this account
path
string
The full BIP-44 derivation path
keyPair
KeyPair
The account's public and private key pair

