Skip to content

Commit 559e3fc

Browse files
committed
common: fix bolt12 quotes to bring them up-to-date.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 92a6961 commit 559e3fc

File tree

5 files changed

+61
-52
lines changed

5 files changed

+61
-52
lines changed

common/bolt12.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ u64 offer_period_start(u64 basetime, size_t n,
407407
const struct recurrence *recur)
408408
{
409409
/* BOLT-recurrence #12:
410-
* 1. A `time_unit` defining 0 (seconds), 1 (days), or 2 (months).
410+
* 1. A `time_unit` defining 0 (seconds), 1 (days), 2 (months).
411411
*/
412412
switch (recur->time_unit) {
413413
case 0:
@@ -429,17 +429,17 @@ void offer_period_paywindow(const struct recurrence *recurrence,
429429
u64 *start, u64 *end)
430430
{
431431
/* BOLT-recurrence #12:
432-
* - if the offer contains `recurrence_paywindow`:
432+
* - if `offer_recurrence_paywindow` is present:
433433
*/
434434
if (recurrence_paywindow) {
435435
u64 pstart = offer_period_start(basetime, period_idx,
436436
recurrence);
437437
/* BOLT-recurrence #12:
438-
* - if the offer has a `recurrence_basetime` or the
438+
* - if `recurrence_basetime` is present or
439439
* `recurrence_counter` is non-zero:
440-
* - SHOULD NOT send an `invreq` for a period prior to
440+
* - SHOULD NOT send an `invoice_request` for a period prior to
441441
* `seconds_before` seconds before that period start.
442-
* - SHOULD NOT send an `invreq` for a period later
442+
* - SHOULD NOT send an `invoice_request` for a period later
443443
* than `seconds_after` seconds past that period start.
444444
*/
445445
*start = pstart - recurrence_paywindow->seconds_before;
@@ -454,9 +454,9 @@ void offer_period_paywindow(const struct recurrence *recurrence,
454454
} else {
455455
/* BOLT-recurrence #12:
456456
* - otherwise:
457-
* - SHOULD NOT send an `invreq` with
458-
* `recurrence_counter` is non-zero for a period whose
459-
* immediate predecessor has not yet begun.
457+
* - SHOULD NOT send an `invoice_request` with
458+
* non-zero `recurrence_counter` for a period
459+
* whose immediate predecessor has not yet begun.
460460
*/
461461
if (period_idx == 0)
462462
*start = 0;
@@ -465,7 +465,7 @@ void offer_period_paywindow(const struct recurrence *recurrence,
465465
recurrence);
466466

467467
/* BOLT-recurrence #12:
468-
* - SHOULD NOT send an `invreq` for a period which
468+
* - SHOULD NOT send an `invoice_request` for a period which
469469
* has already passed.
470470
*/
471471
*end = offer_period_start(basetime, period_idx+1,

devtools/bolt12-cli.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,22 @@ static bool print_recurrence(const char *fieldname,
186186

187187
/* BOLT-recurrence #12:
188188
* Thus, each offer containing a recurring payment has:
189-
* 1. A `time_unit` defining 0 (seconds), 1 (days), or 2 (months).
189+
* 1. A `time_unit` defining 0 (seconds), 1 (days), 2 (months).
190190
* 2. A `period`, defining how often (in `time_unit`) it has to be paid.
191-
* 3. An optional `recurrence_limit` of total payments to be paid.
192-
* 4. An optional `recurrence_base`:
191+
* 3. An optional `offer_recurrence_limit` of total payments to be paid.
192+
* 4. An optional `offer_recurrence_base`:
193193
* * `basetime`, defining when the first period starts
194194
* in seconds since 1970-01-01 UTC.
195-
* 5. An optional `recurrence_paywindow`:
195+
* * The payer uses `invreq_recurrence_start` to indicate what period
196+
* they are starting at. If you don't want them to start at arbitrary
197+
* periods, use `offer_absolute_expiry`.
198+
* * A `proportional_amount` flag: if set indicating that a payment made
199+
* during the period itself will be charged proportionally to the
200+
* remaining time in the period (e.g. 150 seconds into a 1500 second
201+
* period gives a 10% discount).
202+
* 5. An optional `offer_recurrence_paywindow`:
196203
* * `seconds_before`, defining how many seconds prior to the start of
197204
* the period a payment will be accepted.
198-
* * `proportional_amount`, if set indicating that a payment made
199-
* during the period itself will be charged proportionally to the
200-
* remaining time in the period (e.g. 150 seconds into a 1500
201-
* second period gives a 10% discount).
202205
* * `seconds_after`, defining how many seconds after the start of the
203206
* period a payment will be accepted.
204207
* If this field is missing, payment will be accepted during the prior

plugins/fetchinvoice.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,14 @@ static struct command_result *handle_invreq_response(struct command *cmd,
291291
} else
292292
expected_amount = NULL;
293293

294+
recurrence = invoice_recurrence(inv);
295+
294296
/* BOLT-recurrence #12:
295-
* - if the offer contained `recurrence`:
296-
* - MUST reject the invoice if `recurrence_basetime` is not set.
297+
* - if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
298+
* - MUST reject the invoice if `invoice_recurrence_basetime` is not present.
297299
*/
298-
if (inv->invreq_recurrence_counter && !inv->invoice_recurrence_basetime) {
299-
badfield = "recurrence_basetime";
300+
if (recurrence && !inv->invoice_recurrence_basetime) {
301+
badfield = "invoice_recurrence_basetime";
300302
goto badinv;
301303
}
302304

@@ -316,7 +318,6 @@ static struct command_result *handle_invreq_response(struct command *cmd,
316318
json_object_end(out);
317319

318320
/* We tell them about next period at this point, if any. */
319-
recurrence = invoice_recurrence(inv);
320321
if (recurrence) {
321322
u64 next_counter, next_period_idx;
322323
u64 paywindow_start, paywindow_end;
@@ -704,9 +705,9 @@ static struct command_result *invreq_done(struct command *cmd,
704705
period_idx += *sent->invreq->invreq_recurrence_start;
705706

706707
/* BOLT-recurrence #12:
707-
* - if the offer contained `recurrence_limit`:
708-
* - MUST NOT send an `invoice_request` for a period greater
709-
* than `max_period`
708+
* - if `offer_recurrence_limit` is present:
709+
* - MUST NOT send an `invoice_request` for a period greater than
710+
* `max_period`
710711
*/
711712
if (sent->invreq->offer_recurrence_limit
712713
&& period_idx > *sent->invreq->offer_recurrence_limit)
@@ -926,7 +927,7 @@ struct command_result *json_fetchinvoice(struct command *cmd,
926927
}
927928

928929
/* BOLT-recurrence #12:
929-
* - if the offer contained `recurrence`:
930+
* - if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
930931
*/
931932
if (invreq_recurrence(invreq)) {
932933
struct sha256 offer_id, tweak;
@@ -935,12 +936,12 @@ struct command_result *json_fetchinvoice(struct command *cmd,
935936
/* BOLT-recurrence #12:
936937
* - for the initial request:
937938
*...
938-
* - MUST set `recurrence_counter` `counter` to 0.
939+
* - MUST set `invreq_recurrence_counter` `counter` to 0.
939940
*/
940941
/* BOLT-recurrence #12:
941942
* - for any successive requests:
942943
*...
943-
* - MUST set `recurrence_counter` `counter` to one greater
944+
* - MUST set `invreq_recurrence_counter` `counter` to one greater
944945
* than the highest-paid invoice.
945946
*/
946947
if (!invreq->invreq_recurrence_counter)
@@ -998,15 +999,19 @@ struct command_result *json_fetchinvoice(struct command *cmd,
998999
} else {
9991000
/* BOLT-recurrence #12:
10001001
* - otherwise:
1001-
* - MUST NOT set `recurrence_counter`.
1002-
* - MUST NOT set `recurrence_start`
1002+
* - MUST NOT set `invreq_recurrence_counter`.
1003+
* - MUST NOT set `invreq_recurrence_start`
1004+
* - MUST NOT set `invreq_recurrence_cancel`
10031005
*/
10041006
if (invreq->invreq_recurrence_counter)
10051007
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1006-
"unnecessary recurrence_counter");
1008+
"unnecessary invreq_recurrence_counter");
10071009
if (invreq->invreq_recurrence_start)
10081010
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1009-
"unnecessary recurrence_start");
1011+
"unnecessary invreq_recurrence_start");
1012+
if (invreq->invreq_recurrence_cancel)
1013+
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1014+
"unnecessary invreq_recurrence_cancel");
10101015

10111016
/* if the payer force to use the payer_metadata */
10121017
if (payer_metadata) {

plugins/offers.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ static bool json_add_blinded_paths(struct command *cmd,
668668
static const char *recurrence_time_unit_name(u8 time_unit)
669669
{
670670
/* BOLT-recurrence #12:
671-
* `time_unit` defining 0 (seconds), 1 (days), or 2 (months).
671+
* `time_unit` defining 0 (seconds), 1 (days), 2 (months).
672672
*/
673673
switch (time_unit) {
674674
case 0:
@@ -1242,9 +1242,8 @@ static void json_add_b12_invoice(struct command *cmd,
12421242
}
12431243

12441244
/* BOLT-recurrence #12:
1245-
* - if the offer contained `recurrence`:
1246-
* - MUST reject the invoice if `recurrence_basetime` is not
1247-
* set.
1245+
* - if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
1246+
* - MUST reject the invoice if `invoice_recurrence_basetime` is not present.
12481247
*/
12491248
if (invoice_recurrence(invoice)) {
12501249
if (invoice->invoice_recurrence_basetime)

plugins/offers_invreq_hook.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ test_field(struct command *cmd,
122122
}
123123

124124
/* BOLT-recurrence #12:
125-
* - if the invoice corresponds to an offer with `recurrence`:
126-
* ...
127-
* - if it sets `relative_expiry`:
128-
* - MUST NOT set `relative_expiry` `seconds_from_creation` more than the
129-
* number of seconds after `created_at` that payment for this period will
130-
* be accepted.
125+
* - if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
126+
*...
127+
* - if it sets `invoice_relative_expiry`:
128+
* - MUST NOT set `invoice_relative_expiry`.`seconds_from_creation` more than the
129+
* number of seconds after `invoice_created_at` that payment for this period
130+
* will be accepted.
131131
*/
132132
static void set_recurring_inv_expiry(struct tlv_invoice *inv, u64 last_pay)
133133
{
@@ -385,17 +385,19 @@ static struct command_result *check_period(struct command *cmd,
385385
basetime = ir->invreq->offer_recurrence_base->basetime;
386386

387387
/* BOLT-recurrence #12:
388-
* - if the invoice corresponds to an offer with `recurrence`:
389-
* - MUST set `recurrence_basetime` to the start of period #0 as
390-
* calculated by [Period Calculation](#offer-period-calculation).
388+
* - if `offer_recurrence_optional` or `offer_recurrence_compulsory`
389+
* are present:
390+
* - MUST set `invoice_recurrence_basetime`.`basetime` to the
391+
* start of period #0 as calculated by
392+
* [Period Calculation](#offer-period-calculation).
391393
*/
392394
ir->inv->invoice_recurrence_basetime = tal_dup(ir->inv, u64, &basetime);
393395

394396
period_idx = *ir->invreq->invreq_recurrence_counter;
395397

396398
/* BOLT-recurrence #12:
397399
* - if `offer_recurrence_base` is present:
398-
* - MUST fail the request if there is no `invreq_recurrence_start`
400+
* - MUST reject the invoice request if there is no `invreq_recurrence_start`
399401
* field.
400402
* - MUST consider the period index for this request to be the
401403
* `invreq_recurrence_start` field plus the `invreq_recurrence_counter`
@@ -423,8 +425,8 @@ static struct command_result *check_period(struct command *cmd,
423425
}
424426

425427
/* BOLT-recurrence #12:
426-
* - if the offer has a `recurrence_limit`:
427-
* - MUST fail the request if the period index is greater than
428+
* - if `offer_recurrence_limit` is present:
429+
* - MUST reject the invoice request if the period index is greater than
428430
* `max_period`.
429431
*/
430432
if (ir->invreq->offer_recurrence_limit
@@ -901,18 +903,18 @@ static struct command_result *listoffers_done(struct command *cmd,
901903
/* BOLT-recurrence #12:
902904
*
903905
* - if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
904-
* - MUST reject the invoice request if there is no `recurrence_counter`
906+
* - MUST reject the invoice request if there is no `invreq_recurrence_counter`
905907
* field.
906908
*/
907909
err = invreq_must_have(cmd, ir, invreq_recurrence_counter);
908910
if (err)
909911
return err;
910912
} else {
911913
/* BOLT-recurrence #12:
912-
* - otherwise (the offer had no `recurrence`):
913-
* - MUST reject the invoice request if there is a `recurrence_counter`
914+
* - otherwise (no recurrence):
915+
* - MUST reject the invoice request if there is a `invreq_recurrence_counter`
914916
* field.
915-
* - MUST reject the invoice request if there is a `recurrence_start`
917+
* - MUST reject the invoice request if there is a `invreq_recurrence_start`
916918
* field.
917919
*/
918920
err = invreq_must_not_have(cmd, ir, invreq_recurrence_counter);

0 commit comments

Comments
 (0)