Skip to main content

Module zap

Module zap 

Source
Expand description

Zapping a note (NIP-57): asking its author’s Lightning address for an invoice that, once paid, their wallet service announces as a zap.

It takes two requests over https (LNURL-pay, LUD-06 and LUD-16). The first asks the address what it accepts: how little, how much, and whether it knows about zaps. The second asks for an invoice of an amount, and carries a signed zap request naming the note and the relays the receipt should go to. Paying the invoice is left to a wallet: the invoice is all this client produces.

Everything the address answers is somebody else’s word. The invoice is only shown if it asks for the amount that was chosen.

Structs§

Invoice
An invoice to pay.
PayInfo
What a Lightning address accepts.
ZapOrder
A zap to ask an invoice for.

Enums§

ZapError
Why there is no invoice.
Zapper
Who a zap is from.

Constants§

MAX_ANSWER_BYTES 🔒
How long what a Lightning address answers may be. Real answers are a few hundred bytes, and an invoice a few hundred more.

Functions§

invoice_millisats 🔒
What a Lightning invoice asks for, in millisats, read from the amount in its human-readable part: lnbc2500u1… is 2500 micro-bitcoin. None for an invoice that names no amount, or isn’t one.
invoice_url 🔒
Where an invoice for millisats is asked for: pay_info’s callback, with the amount and, for a zap, the signed request. A plain payment carries the comment instead, if the address takes one that long.
parse_answer 🔒
The JSON object in answer, unless it is LNURL’s way of saying no: {"status": "ERROR", "reason": "…"}.
parse_invoice 🔒
The invoice in the answer to the second request, if it is one for millisats.
parse_pay_info 🔒
What a Lightning address accepts, by its answer to the first request.
pay_info_url 🔒
Where the Lightning address name@domain is asked what it accepts (LUD-16). None if it isn’t an address.
request_invoice
Ask a Lightning address for the invoice of order, with signer signing for an account that zaps.
zap_request 🔒
The zap request for millisats to the author of note, yet to be signed: what the wallet service copies into its receipt, which is to go to relays.
zapper_key
The key the wallet service behind the Lightning address address signs its zap receipts with, as it says itself: none, of one that doesn’t do zaps. A receipt for a zap to that address counts when this key signed it (NIP-57).