On this page
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
minimumAmountand / ormaximumAmount, the user’s provider should enforce that the user generate an invoice with an amount field constrained by that amount - When no explicit
amountis set, the user can choose an amount within any requested bounds.
Amounts are denominated in satoshis. JavaScript numbers represent integers exactly only up to Number.MAX_SAFE_INTEGER (2^53 - 1). Use a decimal string for values that exceed this range; the API accepts both strings and numbers.
Method
declare function makeInvoice(args: RequestInvoiceArgs): Promise<RequestInvoiceResponse>;Params
args— requiredobjectamount— optionalstring|numberthe satoshis to senddefaultAmount— optionalstring|numberminimumAmount— optionalstring|numbermaximumAmount— optionalstring|numberdefaultMemo— optionalstring
interface RequestInvoiceArgs {
amount?: string | number; // unit is sats
defaultAmount?: string | number; // unit is sats
minimumAmount?: string | number; // unit is sats
maximumAmount?: string | number; // unit is sats
defaultMemo?: string;
}Response
interface RequestInvoiceResponse {
paymentRequest: string;
paymentHash: string;
rHash: string;
}Example
const provider = (window.$onekey && window.$onekey.webln) || window.webln;
await provider.enable();
const invoice = await provider.makeInvoice({
amount: 1000,
});Demo
Last updated on