

Lightning Withdrawal Flow
The complete process for withdrawing Bitcoin from Spark to the Lightning Network:1
Get Lightning Invoice
Obtain a fresh Lightning invoice from the recipient or Lightning service, and check its expiry before paying.
2
Estimate Fees
Get a fee estimate for the Lightning payment to understand costs.
3
Pay Invoice
Send the Lightning payment with appropriate fee limits.
4
Monitor Payment
Track the payment status until completion.
Check expiry before paying
Decode the BOLT11 invoice and reject it if its timestamp plus expiry is at or before the current time. Use the BOLT11 default expiry of 3,600 seconds when thex tag is absent. Check again immediately before calling payLightningInvoice() if the invoice has been sitting on a confirmation screen; request a fresh invoice when it expires.
For retryable integrations, generate and persist a transferId before the first attempt; see payLightningInvoice(). If a send fails after starting, retain the payment hash and any request or transfer IDs. Check the Lightning send request and the wallet’s available balance before retrying. Funds locked in an outgoing transfer can remain in owned while being excluded from available. Do not create a second payment just because the first call threw, or rely on a low-level CancelTransferRequest: the SDK has no public client cancellation method for this flow.
Pay Lightning Invoice
Send Bitcoin from your Spark wallet to any Lightning Network invoice. Pays a Lightning invoice using your Spark wallet balance.Get Fee Estimate
Estimate the fees for a Lightning payment before sending. Gets an estimated fee for sending a Lightning payment.Monitor Payment Status
Track the status of your Lightning payment. Gets a Lightning send request by ID to check payment status.Zero-Amount Invoices
Spark supports paying zero-amount Lightning invoices, which allow you to specify the amount when making the payment.Zero-amount invoices are not widely supported across the Lightning Network. Some exchanges, such as Binance, currently do not support them.
Paying Zero-Amount Invoices
When paying a zero-amount invoice, you need to specify the amount using theamountSatsToSend parameter:
Use
amountSatsToSend only for zero-amount invoices. The SDK rejects it when the invoice already specifies an amount.Spark Transfer Preference
When paying Lightning invoices, you can enable Spark transfer preference to automatically use Spark transfers when possible.preferSpark is set to true, Spark wallets will:
- Initiate a Spark transfer instead of a Lightning transfer if a valid Spark address is found in the invoice
- Fall back to regular Lightning payment if no Spark address is found
Real-time Payment Monitoring
Monitor Lightning payment status by polling.Fee Recommendations
We recommend setting the maximum routing fee to whichever is greater:- 5 sats (minimum fee)
- 17 bps × transaction amount (0.17% of the transaction)