Deposit Methods
getSingleUseDepositAddress()
Generates a new single-use deposit address for receiving bitcoin funds. Note that this function returns a bitcoin address, not a Spark Address. Once used, this address should not be used again.
For Layer 1 Bitcoin deposits, Spark generates Pay to Taproot (P2TR) addresses. These addresses start with “bc1p” and can be used to receive Bitcoin from any wallet.
Promise<string>: A Bitcoin address for depositing funds
getUnusedDepositAddresses()
Gets all unused deposit addresses for the wallet.
Promise<string[]>: Array of unused deposit addresses
getStaticDepositAddress()
Returns a Bitcoin address that users can deposit funds to as many times as they like. Currently Spark only supports one static deposit address per wallet. If you try to create a second address, it will return your existing static deposit address.
Promise<string>: A reusable Bitcoin address for depositing funds
claimDeposit(txId: string)
Claims a Bitcoin deposit made to a single-use deposit address.
txId: The transaction ID of the Bitcoin deposit.
Promise<WalletLeaf[]>: The wallet leaves resulting from the claim operation.
getClaimStaticDepositQuote(txId: string, outputIndex?: number)
Gets a quote for claiming a deposit made to a static deposit address. This method returns the transaction details, output index, credit amount in satoshis, and the SSP signature required for claiming.
txId: The Bitcoin transaction ID of the deposit transaction.outputIndex: (Optional) The index of the output
Promise<object>: Object containing transaction details and claiming information
claimStaticDeposit(params)
Claims a deposit made to a static deposit address using the quote information from getClaimStaticDepositQuote.
params: Object containing:transactionId: The Bitcoin transaction ID from the quotecreditAmountSats: The amount of sats from the quotesspSignature: The SSP signature from the quoteoutputIndex: (Optional) The index of the output
Promise<ClaimStaticDepositOutput | null>: The claim result or null if the operation fails
refundStaticDeposit(depositTxId: string, destinationAddress: string, feeSats: number)
Refunds a deposit made to a static deposit address back to a specified Bitcoin address. The minimum fee is 300 satoshis.
depositTxId: The transaction ID of the original depositdestinationAddress: The Bitcoin address to send the refund tofeeSats: The fee to pay for the refund transaction (minimum 300 sats)
Promise<string>: The refund transaction as a hex string that needs to be broadcast
advancedDeposit(txHex: string)
Non-trusty flow for depositing funds to the wallet. Construct the tx spending from an L1 wallet to the Spark address.
txHex: The hex string of the transaction to deposit.
Promise<TreeNode[]>: The nodes resulting from the deposit.
Withdrawal Methods
withdraw(params)
Initiates a withdrawal to move funds from the Spark network to an on-chain Bitcoin address.
params: An object with the following properties:onchainAddress: (Required) The Bitcoin address where the funds should be sent.exitSpeed: (Required) The desired speed of the exit (FAST, MEDIUM, SLOW).amountSats: (Optional) The amount in satoshis to withdraw. If not specified, attempts to withdraw all available funds.feeQuote: (Required) The fee quote object returned bygetWithdrawalFeeQuote. Must be used before it expires.deductFeeFromWithdrawalAmount: (Optional, default:true) Whentrue, fees are deducted from the withdrawal amount. Whenfalse, fees are deducted from the remaining wallet balance.
Promise<CoopExitRequest | null | undefined>: The withdrawal request details, or null/undefined if the request cannot be completed.
getWithdrawalFeeQuote(params)
Gets a fee quote for a cooperative exit (on-chain withdrawal). The quote includes options for different speeds and an expiry time and must be passed to withdraw before it expires.
params: Object containing:amountSats: The amount in satoshis to withdraw.withdrawalAddress: The Bitcoin address where the funds should be sent.
Promise<WithdrawalFeeQuote | null>: A fee quote for the withdrawal, or null if not available.
getCoopExitRequest(id: string)
Gets a cooperative exit request by ID.
id: The ID of the cooperative exit request.
Promise<CoopExitRequest | null>: The cooperative exit request details or null if not found.