author: fiatjaf author: akumaigorodski discussion: https://t.me/lnurl/139 discussion: https://github.com/fiatjaf/lnurl-rfc/issues/9
The idea here is that a wallet can scan a static QR code or click on a static LNURL address and get back details about a payment that is expected. The details may include much more extensive metadata than a normal Lightning invoice. And the amounts may be fixed or within a range. Then, once the user accepts the terms (and choose an amount, if that is not fixed), the wallet will call the service and get a Lightning invoice specific for that payment, containing a hash of the metadata as its
h tag (description_hash) and proceed to pay the invoice if it matches the expected amount and hash.
Pay to static QR/NFC/link
Wallet to service interaction flow:
-
User scans a LNURL QR code or pastes/shares an
lightning:LNURL..link withLN WALLETandLN WALLETdecodes LNURL. -
LN WALLETmakes a GET request toLN SERVICEusing the decoded LNURL. -
LN WALLETgets JSON response fromLN SERVICEof form:ormetadatajson array must contain onetext/plainentry, all other types of entries are optional.metadatajson array must contain either oneimage/png;base64entry or oneimage/jpeg;base64entry or neither. Themetadatajson array is only allowed to contain arrays. The first item of an array inside themetadataarray is always a string representing the metadata type while any item that follows can be of any JSON type. Implementors MUST NOT assume it will always be a string.and be sent as a string: -
LN WALLETdisplays a payment dialog where user can specify an exact sum to be sent which would be bounded by:Additionally, a payment dialog must include:- Domain name extracted from
LNURLquery string. - A way to view the metadata sent of
text/plainformat.
- An image element with the contents of
image/pngorimage/jpeg.
- Domain name extracted from
-
LN WALLETmakes a GET request usingamountbeing the amount specified by the user in millisatoshis. -
LN Servicetakes the GET request and returns JSON response of form:or -
LN WALLETVerifies thathtag in provided invoice is a hash ofmetadatastring converted to byte array in UTF-8 encoding. -
LN WALLETVerifies that amount in provided invoice equals the amount previously specified by user. -
LN WALLETpays the invoice, no additional user confirmation is required at this point.
Notes on metadata for server-side LNURL-PAY
When client makes a first call:
Construct a metadata object, turn it into json, then include it into parent json as a string.When client makes a second call
- Make a hash as follows:
sha256(utf8ByteArray(unescaped_metadata_string)). - Generate a payment request using an obtained hash.