Create a new invoice

The makeInvoice method is used to generate a new invoice.

Syntax

makeInvoice(Object)

Parameters

  • Object
    • amount : string | number Optional
    • defaultMemo : string Optional
    • label : string Optional
    • message : string Optional

NOTE:
Providing any of the above would result in a pre-populating a a prompt which requires the user to complete the rest of the information. e.g. Only providing the amount parameter might result in the following prompt.

Returns

  • Object
    • paymentRequest: string; LN Invoice
    • BIP21 address string; Onchain BIP 21 URI

Example

await window.webln.makeInvoice({})
  {
    paymentRequest: 'lnbc10n1p3x9thxpp59xj4cmm26jnpnrfekgncyj42e9lxredz…734s07kxt8hl2s6wuv20kh7kw7h5lurtmyscsrwgkgptn4z2j', rHash: '29a55c6f6ad4a6198d39b227824aaac97e61e5a2428db7dab7f8b097ae5d28ca'
  }
window.bitcoin.makeInvoice({amount:1, label: 'Label', message: 'Message'})

bitcoin:address?amount=0&label=Label&message=Message

Considerations

These parameters might not be required in the spec as they are used by the website for convenience purposes in setting up the invoice dialog.

defaultAmount?: string | number; minimumAmount?: string | number; maximumAmount?: string | number;

Notes

The amount parameter doesn't distinguish between bitcoin and satoshis

Reference

https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki

bitcoinurn     = "bitcoin:" bitcoinaddress [ "?" bitcoinparams ]
bitcoinaddress = *base58
bitcoinparams  = bitcoinparam [ "&" bitcoinparams ]
bitcoinparam   = [ amountparam / labelparam / messageparam / otherparam / reqparam ]
amountparam    = "amount=" *digit [ "." *digit ]
labelparam     = "label=" *qchar
messageparam   = "message=" *qchar
otherparam     = qchar *qchar [ "=" *qchar ]
reqparam       = "req-" qchar *qchar [ "=" *qchar ]

Invoice address description

Invoice Address Meno proposal Payment Requests

Separate Meno into name and description

Label = The who Message = The what