BitcoinAndLightningLayerSpecs / WebBTC

11 stars 1 forks source link

Feature: makeInvoice #10

Closed gr0kchain closed 2 years ago

gr0kchain commented 2 years ago

Get a new address and or invoice

Parameters

BIP21

bitcoin:address?amount=0&label=label1&message=message1

Parameters WebLN

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.

Returns

WebLN

Onchain

Example

WebLN

await window.webln.makeInvoice({})
{paymentRequest: 'lnbc10n1p3x9thxpp59xj4cmm26jnpnrfekgncyj42e9lxredz…734s07kxt8hl2s6wuv20kh7kw7h5lurtmyscsrwgkgptn4z2j', rHash: '29a55c6f6ad4a6198d39b227824aaac97e61e5a2428db7dab7f8b097ae5d28ca'}

OnChain

window.bitcoin.makeInvoice({amount:1})
'bitcoin:n1nk1j5DKmmWWuV2TvzhUb3AYBtnqAK1u1?amount=1'

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)[https://en.bitcoin.it/wiki/Invoice_address] (Meno proposal)[https://github.com/lightning/blips/pull/11/files?short_path=1efcc79#diff-1efcc7957e02dad2d5a9deea7032635c9f19100d5a7ee08be166cb1dc9b4d690] (Payment Requests)[https://doc.clickup.com/18307877/d/h/hept5-1721/f06e5c5e4eba551/hept5-421]

Separate Meno into name and description

Label = The who Message = The what