Skip to main content
Pays a Lightning invoice via the SparkWallet.

Method Signature

interface PayLightningInvoiceParams {
  invoice: string;
  maxFeeSats: number;
  preferSpark?: boolean;
  amountSatsToSend?: number;
}

async payLightningInvoice(params: PayLightningInvoiceParams): Promise<LightningSendRequest>

Parameters

invoice
string
required
The BOLT11-encoded Lightning invoice to pay
maxFeeSats
number
required
Maximum fee in satoshis to pay for the invoice
preferSpark
boolean
When true, initiate a Spark transfer if a valid Spark address is found in the invoice (default: false)
amountSatsToSend
number
Amount in satoshis to send for zero-amount invoices

Returns

request
LightningSendRequest
required
The Lightning payment request details

Examples

// Pay a regular invoice
const payment_response = await wallet.payLightningInvoice({
  invoice: "lnbc100n...", // Regular Lightning invoice with amount
  maxFeeSats: 5,
});
console.log("Payment Response:", payment_response);

// Pay a zero-amount invoice
const zeroAmountPayment = await wallet.payLightningInvoice({
  invoice: "lnbc...", // Zero-amount Lightning invoice
  maxFeeSats: 5,
  amountSatsToSend: 1000, // Specify amount for zero-amount invoice
});
console.log("Zero-amount Payment Response:", zeroAmountPayment);