You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This builds on prior commits by adding the ability to fetch an invoice from an
always-online node on behalf of an often-offline recipient, e.g. a mobile node.
The idea is that often-offline recipients will supply some always-online node
such as their wallet vendor with a static (i.e. `payment_hash`-less) invoice to
return on its behalf. The recipient will then publish an offer containing
blinded paths that terminate at this always-online node, who payers can request
the invoice from if the recipient is offline at the time. After receiving the
static invoice, payers will commence the protocol outlined in [1] to send the
HTLC asynchronously.
[1]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2021-October/003307.html
Copy file name to clipboardExpand all lines: 12-offer-encoding.md
+58-19Lines changed: 58 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ Here we use "user" as shorthand for the individual user's lightning
42
42
node and "merchant" as the shorthand for the node of someone who is
43
43
selling or has sold something.
44
44
45
-
There are two basic payment flows supported by BOLT 12:
45
+
There are three basic payment flows supported by BOLT 12:
46
46
47
47
The general user-pays-merchant flow is:
48
48
1. A merchant publishes an *offer*, such as on a web page or a QR code.
@@ -58,6 +58,18 @@ The merchant-pays-user flow (e.g. ATM or refund):
58
58
3. The merchant confirms the *invoice_node_id* to ensure it's about to pay the correct
59
59
person, and makes a payment to the invoice.
60
60
61
+
The pay-mobile-user flow (e.g. paying a friend back to their mobile node):
62
+
1. The mobile user supplies some always-online node with a static (i.e.
63
+
`payment_hash`-less) invoice to return on its behalf. This always-online node may
64
+
be the mobile user's channel counterparty, wallet vendor, or another node on the
65
+
network that it has an out-of-band relationship with.
66
+
2. The mobile user publishes an offer that contains blinded paths that terminate
67
+
at the always-online node.
68
+
3. The payer sends an `invoice_request` to the always-online node, who replies with the static
69
+
invoice previously provided by the mobile user and forwards the `invoice_request` to the mobile
70
+
user in case they happen to be online.
71
+
4. The payer makes a payment to the mobile user as indicated by the invoice.
72
+
61
73
## Payment Proofs and Payer Proofs
62
74
63
75
Note that the normal lightning "proof of payment" can only demonstrate that an
@@ -70,6 +82,9 @@ to request the invoice. In addition, the Merkle construction of the BOLT 12
70
82
invoice signature allows the user to reveal invoice fields in case
71
83
of a dispute selectively.
72
84
85
+
Payers will not get proofs in the case that they received a static invoice from the
86
+
payee, see the pay-mobile-user flow above.
87
+
73
88
# Encoding
74
89
75
90
Each of the forms documented here are in
@@ -126,7 +141,7 @@ Each form is signed using one or more *signature TLV elements*: TLV
126
141
types 240 through 1000 (inclusive). For these,
127
142
the tag is "lightning" || `messagename` || `fieldname`, and `msg` is the
128
143
Merkle-root; "lightning" is the literal 9-byte ASCII string,
129
-
`messagename` is the name of the TLV stream being signed (i.e. "invoice_request"or "invoice") and the `fieldname` is the TLV field containing the
144
+
`messagename` is the name of the TLV stream being signed (i.e. "invoice_request", "invoice", or "static_invoice") and the `fieldname` is the TLV field containing the
130
145
signature (e.g. "signature").
131
146
132
147
The formulation of the Merkle tree is similar to that proposed in
@@ -261,8 +276,9 @@ A writer of an offer:
261
276
after midnight 1 January 1970, UTC that invoice_request should not be
262
277
attempted.
263
278
- if it is connected only by private channels:
264
-
- MUST include `offer_paths` containing one or more paths to the node from
265
-
publicly reachable nodes.
279
+
- MUST include `offer_paths` containing one or more paths to the node
280
+
that will reply to the `invoice_request`, using introduction nodes that are
281
+
publicly reachable.
266
282
- otherwise:
267
283
- MAY include `offer_paths`.
268
284
- if it includes `offer_paths`:
@@ -282,6 +298,8 @@ A writer of an offer:
282
298
- MUST set `offer_quantity_max` to 0.
283
299
- otherwise:
284
300
- MUST NOT set `offer_quantity_max`.
301
+
- if it is often-offline and the invoice may be provided by another node on their behalf:
302
+
- MUST NOT include more than 1 chain in `offer_chains`.
285
303
286
304
A reader of an offer:
287
305
- if the offer contains any TLV fields outside the inclusive ranges: 1 to 79 and 1000000000 to 1999999999:
@@ -543,6 +561,9 @@ The reader:
543
561
- if `invreq_bip_353_name` is present:
544
562
- MUST reject the invoice request if `name` or `domain` contain any bytes which are not
545
563
`0`-`9`, `a`-`z`, `A`-`Z`, `-`, `_` or `.`.
564
+
- if receiving the `invoice_request` on behalf of an often-offline payee:
565
+
- SHOULD forward the `invoice_request` to the payee
566
+
- SHOULD reply with the static invoice previously provided by the payee
546
567
547
568
## Rationale
548
569
@@ -573,10 +594,11 @@ The requirement to use `offer_paths` if present, ensures a node does not reveal
573
594
574
595
# Invoices
575
596
576
-
Invoices are a payment request, and when the payment is made,
577
-
the payment preimage can be combined with the invoice to form a cryptographic receipt.
597
+
Invoices are a payment request. If `invoice_payment_hash` is set, then when the
598
+
payment is made, the payment preimage can be combined with the invoice to form a
599
+
cryptographic receipt.
578
600
579
-
The recipient sends an `invoice`in response to an `invoice_request` using
601
+
The recipient creates an `invoice`for responding to an `invoice_request` using
580
602
the `onion_message``invoice` field.
581
603
582
604
1.`tlv_stream`: `invoice`
@@ -671,6 +693,9 @@ the `onion_message` `invoice` field.
671
693
1. type: 176 (`invoice_node_id`)
672
694
2. data:
673
695
*[`point`:`node_id`]
696
+
1. type: 178 (`static_invoice_message_paths`)
697
+
2. data:
698
+
*[`...*blinded_path`:`paths`]
674
699
1. type: 240 (`signature`)
675
700
2. data:
676
701
*[`bip340sig`:`sig`]
@@ -709,17 +734,28 @@ may (due to capacity limits on a single channel) require it.
709
734
A writer of an invoice:
710
735
- MUST set `invoice_created_at` to the number of seconds since Midnight 1
711
736
January 1970, UTC when the invoice was created.
712
-
- MUST set `invoice_amount` to the minimum amount it will accept, in units of
713
-
the minimal lightning-payable unit (e.g. milli-satoshis for bitcoin) for
714
-
`invreq_chain`.
715
-
- if the invoice is in response to an `invoice_request`:
737
+
- if `invoice_payment_hash` is set and the invoice is in response to an `invoice_request`:
716
738
- MUST copy all non-signature fields from the invoice request (including unknown fields).
717
739
- if `invreq_amount` is present:
718
740
- MUST set `invoice_amount` to `invreq_amount`
719
741
- otherwise:
720
742
- MUST set `invoice_amount` to the *expected amount*.
721
-
- MUST set `invoice_payment_hash` to the SHA256 hash of the
722
-
`payment_preimage` that will be given in return for payment.
743
+
- if the expiry for accepting payment is not 7200 seconds after `invoice_created_at`:
744
+
- MUST set `invoice_relative_expiry`.`seconds_from_creation` to the number of
745
+
seconds after `invoice_created_at` that payment of this invoice should not be attempted.
746
+
- if the invoice is intended to be provided by a node other than the recipient (i.e. a static
747
+
invoice):
748
+
- MUST NOT set `invoice_payment_hash`.
749
+
- MUST NOT set `invoice_amount`.
750
+
- MUST include `static_invoice_message_paths` containing at least two paths to
751
+
the recipient.
752
+
- MUST NOT set any `invoice_request` TLV fields
753
+
- if the expiry for accepting payment is not 2 weeks after `invoice_created_at`:
754
+
- MUST set `invoice_relative_expiry`.`seconds_from_creation` to the number of
755
+
seconds after `invoice_created_at` that payment of this invoice should not be attempted.
756
+
- otherwise:
757
+
- MUST set `invoice_payment_hash` to the SHA256 hash of the
758
+
`payment_preimage` that will be given in return for payment.
723
759
- if `offer_issuer_id` is present:
724
760
- MUST set `invoice_node_id` to the `offer_issuer_id`
725
761
- otherwise, if `offer_paths` is present:
@@ -730,9 +766,6 @@ A writer of an invoice:
730
766
- MUST set `invoice_features`.`features` bit `MPP/compulsory`
731
767
- or if it allows multiple parts to pay the invoice:
732
768
- MUST set `invoice_features`.`features` bit `MPP/optional`
733
-
- if the expiry for accepting payment is not 7200 seconds after `invoice_created_at`:
734
-
- MUST set `invoice_relative_expiry`.`seconds_from_creation` to the number of
735
-
seconds after `invoice_created_at` that payment of this invoice should not be attempted.
736
769
- if it accepts onchain payments:
737
770
- MAY specify `invoice_fallbacks`
738
771
- SHOULD specify `invoice_fallbacks` in order of most-preferred to least-preferred
@@ -745,11 +778,11 @@ A writer of an invoice:
745
778
- MUST include `invoice_blindedpay` with exactly one `blinded_payinfo` for each `blinded_path` in `paths`, in order.
746
779
- MUST set `features` in each `blinded_payinfo` to match `encrypted_data_tlv`.`allowed_features` (or empty, if no `allowed_features`).
747
780
- SHOULD ignore any payment which does not use one of the paths.
781
+
- if providing invoices on behalf of an often offline recipient:
782
+
- MAY reuse the previous invoice.
748
783
749
784
A reader of an invoice:
750
-
- MUST reject the invoice if `invoice_amount` is not present.
751
785
- MUST reject the invoice if `invoice_created_at` is not present.
752
-
- MUST reject the invoice if `invoice_payment_hash` is not present.
753
786
- MUST reject the invoice if `invoice_node_id` is not present.
754
787
- if `invreq_chain` is not present:
755
788
- MUST reject the invoice if bitcoin is not a supported chain.
@@ -771,7 +804,9 @@ A reader of an invoice:
771
804
- MUST NOT use the corresponding `invoice_paths`.`path` if `payinfo`.`features` has any unknown even bits set.
772
805
- MUST reject the invoice if this leaves no usable paths.
773
806
- if the invoice is a response to an `invoice_request`:
774
-
- MUST reject the invoice if all fields in ranges 0 to 159 and 1000000000 to 2999999999 (inclusive) do not exactly match the invoice request.
807
+
- if `invoice_payment_hash` is set:
808
+
- MUST reject the invoice if `invoice_amount` is not present.
809
+
- MUST reject the invoice if all fields in ranges 0 to 159 and 1000000000 to 2999999999 (inclusive) do not exactly match the invoice request.
775
810
- if `offer_issuer_id` is present (invoice_request for an offer):
776
811
- MUST reject the invoice if `invoice_node_id` is not equal to `offer_issuer_id`
777
812
- otherwise, if `offer_paths` is present (invoice_request for an offer without id):
@@ -800,6 +835,10 @@ A reader of an invoice:
800
835
- MUST reject the invoice if it arrived via a blinded path.
801
836
- otherwise (derived from an offer):
802
837
- MUST reject the invoice if it did not arrive via invoice request `onionmsg_tlv``reply_path`.
838
+
- if `invoice_payment_hash` is unset:
839
+
- MUST reject the invoice if `static_invoice_message_paths` is not present or is empty.
840
+
- MUST pay asynchronously using the `held_htlc_available` onion message
841
+
flow, where the onion message is sent over `static_invoice_message_paths`.
0 commit comments