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
Setting `static_invoice_pay` indicates that the payer supports receiving a
438
+
`payment_hash`-less invoice in response to their `invoice_request`, and
439
+
subsequently setting `sender_provided_payment_preimage` in their payment onion.
440
+
441
+
Useful if the payee is often offline and the invoice is being returned on
442
+
their behalf by another node, to avoid trusting that other node to not reuse a
443
+
`payment_hash`.
444
+
412
445
## Requirements for Invoice Requests
413
446
414
447
The writer:
@@ -486,7 +519,14 @@ The reader:
486
519
- MUST fail the request if bitcoin is not a supported chain.
487
520
- otherwise:
488
521
- MUST fail the request if `invreq_chain`.`chain` is not a supported chain.
489
-
522
+
- if receiving the `invoice_request` on behalf of an often-offline payee:
523
+
- if the payee is online:
524
+
- MUST forward the `invoice_request` to the payee
525
+
- otherwise (payee is offline):
526
+
- if `invreq_features` supports `static_invoice_pay`:
527
+
- MUST reply with the static invoice previously provided by the payee
528
+
- otherwise:
529
+
- MUST reply with `invoice_error`
490
530
491
531
## Rationale
492
532
@@ -515,10 +555,11 @@ informative for the payer to know how the sender claims
515
555
516
556
# Invoices
517
557
518
-
Invoices are a payment request, and when the payment is made,
519
-
it can be combined with the invoice to form a cryptographic receipt.
558
+
Invoices are a payment request. If `invoice_payment_hash` is set, then when the
559
+
payment is made, the payment preimage can be combined with the invoice to form a
560
+
cryptographic receipt.
520
561
521
-
The recipient sends an `invoice`in response to an `invoice_request` using
562
+
The recipient creates an `invoice`for responding to an `invoice_request` using
522
563
the `onion_message``invoice` field.
523
564
524
565
1.`tlv_stream`: `invoice`
@@ -604,6 +645,9 @@ the `onion_message` `invoice` field.
604
645
1. type: 176 (`invoice_node_id`)
605
646
2. data:
606
647
*[`point`:`node_id`]
648
+
1. type: 178 (`invoice_message_paths`)
649
+
2. data:
650
+
*[`...*blinded_path`:`paths`]
607
651
1. type: 240 (`signature`)
608
652
2. data:
609
653
*[`bip340sig`:`sig`]
@@ -642,21 +686,25 @@ may (due to capacity limits on a single channel) require it.
642
686
A writer of an invoice:
643
687
- MUST set `invoice_created_at` to the number of seconds since Midnight 1
644
688
January 1970, UTC when the invoice was created.
645
-
- MUST set `invoice_amount` to the minimum amount it will accept, in units of
646
-
the minimal lightning-payable unit (e.g. milli-satoshis for bitcoin) for
647
-
`invreq_chain`.
648
-
- if the invoice is in response to an `invoice_request`:
689
+
- if `invoice_payment_hash` is set and the invoice is in response to an `invoice_request`:
649
690
- MUST copy all non-signature fields from the `invoice_request` (including unknown fields).
650
691
- if `invreq_amount` is present:
651
692
- MUST set `invoice_amount` to `invreq_amount`
652
693
- otherwise:
653
694
- MUST set `invoice_amount` to the *expected amount*.
654
-
- otherwise (invoice not requested, e.g. for user to scan directly):
695
+
- otherwise if the invoice was not requested (e.g. for user to scan directly):
655
696
- MUST set `invreq_chain` as it would for an invoice_request.
656
697
- MUST set `offer_description` as it would for an offer.
657
698
- MUST NOT set `invreq_payer_id` or `offer_node_id`.
658
-
- MUST set `invoice_payment_hash` to the SHA256 hash of the
659
-
`payment_preimage` that will be given in return for payment.
699
+
- if the invoice is intended to be provided by a node other than the recipient:
700
+
- MUST NOT set `invoice_payment_hash`.
701
+
- MUST NOT set `invoice_amount`.
702
+
- MUST include `invoice_message_paths` containing at least two paths to
703
+
the recipient, where the penultimate hop supports `option_om_mailbox`.
704
+
- MUST NOT set any `invoice_request` TLV fields (i.e. 0 or in the 80-159 range)
705
+
- otherwise:
706
+
- MUST set `invoice_payment_hash` to the SHA256 hash of the
707
+
`payment_preimage` that will be given in return for payment.
660
708
- if `offer_node_id` is present:
661
709
- MUST set `invoice_node_id` to `offer_node_id`.
662
710
- otherwise:
@@ -682,15 +730,16 @@ A writer of an invoice:
682
730
- MUST include `invoice_blindedpay` with exactly one `blinded_payinfo` for each `blinded_path` in `paths`, in order.
683
731
- MUST set `features` in each `blinded_payinfo` to match `encrypted_data_tlv`.`allowed_features` (or empty, if no `allowed_features`).
684
732
- SHOULD ignore any payment which does not use one of the paths.
685
-
- if `offer_node_id` is present, and `invreq_payer_id` is identical to a previous `invoice_request`:
686
-
- MAY simply reuse the previous invoice.
733
+
- if `offer_node_id` is present, and `invreq_payer_id` is identical to a previous `invoice_request`, or if providing invoices on behalf of an often offline recipient:
734
+
- MAY reuse the previous invoice.
687
735
- otherwise:
688
736
- MUST NOT reuse a previous invoice.
689
737
690
738
A reader of an invoice:
691
-
- MUST reject the invoice if `invoice_amount` is not present.
692
739
- MUST reject the invoice if `invoice_created_at` is not present.
693
-
- MUST reject the invoice if `invoice_payment_hash` is not present.
740
+
- if `static_invoice_pay` was not supported in `invreq_features`:
741
+
- MUST reject the invoice if `invoice_payment_hash` is not present.
742
+
- MUST reject the invoice if `invoice_amount` is not present.
694
743
- MUST reject the invoice if `invoice_node_id` is not present.
695
744
- if `invoice_features` contains unknown _odd_ bits that are non-zero:
696
745
- MUST ignore the bit.
@@ -707,7 +756,8 @@ A reader of an invoice:
707
756
- MUST NOT use the corresponding `invoice_paths`.`path` if `payinfo`.`features` has any unknown even bits set.
708
757
- MUST reject the invoice if this leaves no usable paths.
709
758
- if the invoice is a response to an `invoice_request`:
710
-
- MUST reject the invoice if all fields less than type 160 do not exactly match the `invoice_request`.
759
+
- if `invoice_payment_hash` is set:
760
+
- MUST reject the invoice if all fields less than type 160 do not exactly match the `invoice_request`.
711
761
- if `offer_node_id` is present (invoice_request for an offer):
712
762
- MUST reject the invoice if `invoice_node_id` is not equal to `offer_node_id`.
713
763
- otherwise (invoice_request without an offer):
@@ -727,6 +777,10 @@ A reader of an invoice:
727
777
- MUST ignore any `fallback_address` for which `version` is greater than 16.
728
778
- MUST ignore any `fallback_address` for which `address` is less than 2 or greater than 40 bytes.
729
779
- MUST ignore any `fallback_address` for which `address` does not meet known requirements for the given `version`
780
+
- if `invoice_payment_hash` is unset:
781
+
- MUST reject the invoice if `invoice_message_paths` is not present or is empty.
782
+
- MUST pay asynchronously using the `held_htlc_available` onion message
783
+
flow, where the onion message is sent over `invoice_message_paths`.
0 commit comments