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
Copy file name to clipboardExpand all lines: 12-offer-encoding.md
+31-14Lines changed: 31 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -229,7 +229,11 @@ The human-readable prefix for offers is `lno`.
229
229
1. type: 22 (`offer_issuer_id`)
230
230
2. data:
231
231
*[`point`:`id`]
232
-
1. type: 24 (`offer_recurrence`)
232
+
1. type: 24 (`offer_recurrence_compulsory`)
233
+
2. data:
234
+
*[`byte`:`time_unit`]
235
+
*[`tu32`:`period`]
236
+
1. type: 25 (`offer_recurrence_optional`)
233
237
2. data:
234
238
*[`byte`:`time_unit`]
235
239
*[`tu32`:`period`]
@@ -273,6 +277,8 @@ Thus, each offer containing a recurring payment has:
273
277
274
278
Note that the `offer_absolute_expiry` field already covers the case where an offer is no longer valid after January 1st 2021.
275
279
280
+
For wallets which don't (yet) support recurrence, the basic recurrence field comes in two variants: `offer_recurrence_compulsory` if they should not attempt a payment, and `offer_recurrence_optional` if it still makes sense for them to attempt a single payment.
281
+
276
282
### Offer Period Calculation
277
283
278
284
Each period has a zero-based index, and a start time and an end time. Because the periods can be in non-seconds units, the duration of a period can depend on when it starts. The period with index N+1 begins immediately following the end of period with index N.
@@ -356,8 +362,11 @@ A writer of an offer:
356
362
- MUST set `offer_quantity_max` to 0.
357
363
- otherwise:
358
364
- MUST NOT set `offer_quantity_max`.
359
-
- MAY include `offer_recurrence` to indicate offer should trigger time-spaced invoice requests.
360
-
- if it includes `offer_recurrence`:
365
+
- If an offer MAY trigger time-spaced invoice requests:
366
+
- MUST include exactly one of `offer_recurrence_optional` or `offer_recurrence_compulsory`.
367
+
- MAY use `offer_recurrence_optional` if a payment of a single period would be useful (compatibility with pre-recurrence readers).
368
+
- MUST NOT use `offer_recurrence_optional` if `offer_recurrence_base` is present.
369
+
- if it includes either `offer_recurrence_optional` or `offer_recurrence_compulsory`:
361
370
- MUST set `time_unit` to 0 (seconds), 1 (days), 2 (months) or 3 (years).
362
371
- MUST set `period` to how often (in `time-unit`) it wants to be paid.
363
372
- if there is a maximum number of payments:
@@ -418,13 +427,13 @@ A reader of an offer:
418
427
- MUST warn the user if the received `invoice_amount` differs significantly
419
428
from that estimate.
420
429
- if the current time is after `offer_absolute_expiry`:
421
-
- MUST NOT make an initial response to the offer (i.e. continuing an existing offer with `offer_recurrence` is ok)
422
-
- if `offer_recurrence` is set:
430
+
- MUST NOT make an initial response to the offer (i.e. continuing an existing offer with recurrence is ok)
431
+
- if `offer_recurrence_optional` or `offer_recurrence_compulsory` are set:
423
432
- if `time_unit` is not one of 0, 1, 2 or 3:
424
433
- MUST NOT respond to the offer.
425
434
- if `offer_recurrence_limit` is set and `max_period` is 0:
426
435
- MUST NOT respond to the offer.
427
-
- otherwise: (no `offer_recurrence`):
436
+
- otherwise: (no recurrence):
428
437
- if it `offer_recurrence_paywindow`, `offer_recurrence_limit` or `offer_recurrence_base` are set:
429
438
- MUST NOT respond to the offer.
430
439
- if it chooses to send an invoice request, it sends an onion message:
@@ -531,7 +540,11 @@ while still allowing signature validation.
531
540
1. type: 22 (`offer_issuer_id`)
532
541
2. data:
533
542
*[`point`:`id`]
534
-
1. type: 24 (`offer_recurrence`)
543
+
1. type: 24 (`offer_recurrence_compulsory`)
544
+
2. data:
545
+
*[`byte`:`time_unit`]
546
+
*[`tu32`:`period`]
547
+
1. type: 25 (`offer_recurrence_optional`)
535
548
2. data:
536
549
*[`byte`:`time_unit`]
537
550
*[`tu32`:`period`]
@@ -607,7 +620,7 @@ The writer:
607
620
- MUST set `invreq_quantity` less than or equal to `offer_quantity_max`.
608
621
- otherwise:
609
622
- MUST NOT set `invreq_quantity`
610
-
- if `offer_recurrence` is present:
623
+
- if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
611
624
- for the initial request:
612
625
- MUST use a unique `invreq_payer_id`.
613
626
- MUST set `invreq_recurrence_counter``counter` to 0.
@@ -692,7 +705,7 @@ The reader:
692
705
- MAY reject the invoice request if `invreq_amount`.`msat` greatly exceeds the *expected amount*.
693
706
- otherwise (no `offer_amount`):
694
707
- MUST reject the invoice request if it does not contain `invreq_amount`.
695
-
- if `offer_recurrence` is present:
708
+
- if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
696
709
- MUST reject the invoice request if there is no `invreq_recurrence_counter` field.
697
710
- if `offer_recurrence_base` is present:
698
711
- MUST reject the invoice request if there is no `invreq_recurrence_start` field.
@@ -710,7 +723,7 @@ The reader:
710
723
- SHOULD reject the invoice request if the current time is equal to or after the start of the period plus `seconds_after`.
711
724
- otherwise:
712
725
- SHOULD reject the invoice request if the current time is prior to the start of the previous period.
713
-
- otherwise (no `offer_recurrence`):
726
+
- otherwise (no recurrence):
714
727
- MUST reject the invoice request if there is a `invreq_recurrence_counter` field.
715
728
- MUST reject the invoice request if there is a `invreq_recurrence_start` field.
716
729
- SHOULD send an invoice in response using the `onionmsg_tlv``reply_path`.
@@ -802,7 +815,11 @@ the `onion_message` `invoice` field.
802
815
1. type: 22 (`offer_issuer_id`)
803
816
2. data:
804
817
*[`point`:`id`]
805
-
1. type: 24 (`offer_recurrence`)
818
+
1. type: 24 (`offer_recurrence_compulsory`)
819
+
2. data:
820
+
*[`byte`:`time_unit`]
821
+
*[`tu32`:`period`]
822
+
1. type: 25 (`offer_recurrence_optional`)
806
823
2. data:
807
824
*[`byte`:`time_unit`]
808
825
*[`tu32`:`period`]
@@ -949,7 +966,7 @@ A writer of an invoice:
949
966
- for the bitcoin chain, it MUST set each `fallback_address` with
950
967
`version` as a valid witness version and `address` as a valid witness
951
968
program
952
-
- if `offer_recurrence` is present:
969
+
- if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
953
970
- MUST set `invoice_recurrence_basetime`.`basetime` to the start of period #0 as calculated by [Period Calculation](#offer-period-calculation).
954
971
- if it sets `invoice_relative_expiry`:
955
972
- MUST NOT set `invoice_relative_expiry`.`seconds_from_creation` more than the number of seconds after `invoice_created_at` that payment for this period will be accepted.
@@ -1007,7 +1024,7 @@ A reader of an invoice:
1007
1024
- MUST ignore any `fallback_address` for which `version` is greater than 16.
1008
1025
- MUST ignore any `fallback_address` for which `address` is less than 2 or greater than 40 bytes.
1009
1026
- MUST ignore any `fallback_address` for which `address` does not meet known requirements for the given `version`
1010
-
- if `offer_recurrence` is present:
1027
+
- if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
1011
1028
- MUST reject the invoice if `invoice_recurrence_basetime` is not present.
1012
1029
- if `invreq_recurrence_counter` is 0:
1013
1030
- if `offer_recurrence_base` is present:
@@ -1024,7 +1041,7 @@ A reader of an invoice:
1024
1041
- MUST reject the invoice if it did not arrive via invoice request `onionmsg_tlv``reply_path`.
1025
1042
- if it pays the invoice:
1026
1043
- MUST have authorization for the payment purpose, recipient and amount.
1027
-
- if `offer_recurrence` is present:
1044
+
- if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
1028
1045
- SHOULD obtain single authorization which covers all expected payments.
0 commit comments