Skip to main content
Methods for depositing Bitcoin funds into your Spark wallet.

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.
async getSingleUseDepositAddress(): Promise<string>
Returns:
  • Promise<string>: A Bitcoin address for depositing funds

getUnusedDepositAddresses()

Gets all unused deposit addresses for the wallet.
async getUnusedDepositAddresses(): Promise<string[]>
Returns:
  • 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.
async getStaticDepositAddress(): Promise<string>
Returns:
  • Promise<string>: A reusable Bitcoin address for depositing funds

claimDeposit(txId: string)

Claims a Bitcoin deposit made to a single-use deposit address.
async claimDeposit(txId: string): Promise<WalletLeaf[]>
Parameters:
  • txId: The transaction ID of the Bitcoin deposit.
Returns:
  • 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.
async getClaimStaticDepositQuote(
  txId: string,
  outputIndex?: number
): Promise<{
  txId: string;
  outputIndex: number;
  creditAmountSats: number;
  sspSignature: string;
}>
Parameters:
  • txId: The Bitcoin transaction ID of the deposit transaction.
  • outputIndex: (Optional) The index of the output
Returns:
  • 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.
async claimStaticDeposit({
  transactionId,
  creditAmountSats,
  sspSignature,
  outputIndex,
}: {
  transactionId: string;
  creditAmountSats: number;
  sspSignature: string;
  outputIndex?: number;
}): Promise<ClaimStaticDepositOutput | null>
Parameters:
  • params: Object containing:
    • transactionId: The Bitcoin transaction ID from the quote
    • creditAmountSats: The amount of sats from the quote
    • sspSignature: The SSP signature from the quote
    • outputIndex: (Optional) The index of the output
Returns:
  • 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.
async refundStaticDeposit(
  depositTxId: string, 
  destinationAddress: string, 
  feeSats: number
): Promise<string>
Parameters:
  • depositTxId: The transaction ID of the original deposit
  • destinationAddress: The Bitcoin address to send the refund to
  • feeSats: The fee to pay for the refund transaction (minimum 300 sats)
Returns:
  • 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.
async advancedDeposit(txHex: string): Promise<TreeNode[]>
Parameters:
  • txHex: The hex string of the transaction to deposit.
Returns:
  • Promise<TreeNode[]>: The nodes resulting from the deposit.