webln.makeInvoice()
Request that the user creates an invoice to be used by the web app. This will return a BOLT-11 invoice. Invoices can be requested in a few forms:
- By specifying an explicit
amount
, the user's provider should enforce that the user generate an invoice with a specific amount - By specifying a
minimumAmount
and / ormaximumAmount
, the user's provider should enforce that the user generate an invoice with an amount field constrained by that amount - When an explicit
amount
is not set, the user can return an invoice that has no amount specified, allowing the payment maker to send any amount
Note that these constraints are enforced by the client's provider, and therefore should not be completely trusted. If you want to check the fields that come back, or otherwise use the data encoded in the invoice, you'll want to use a library to decode it such as the bolt11 npm package.
async function makeInvoice(args: RequestInvoiceArgs): RequestInvoiceResponse;
interface RequestInvoiceArgs {
amount?: string | number;
defaultAmount?: string | number;
minimumAmount?: string | number;
maximumAmount?: string | number;
defaultMemo?: string;
}
All amounts are denominated in sats.
interface RequestInvoiceResponse {
paymentRequest: string;
}
await webln.enable();
const invoice = await webln.makeInvoice({
amount: 1000,
});
Last modified 11mo ago