Skip to content

Commit 06545b1

Browse files
committed
BOLT12: remove -offers from bolt12 quotes, update them.
Typo fixes and wording changes. Signed-off-by: Rusty Russell <[email protected]>
1 parent f68f893 commit 06545b1

20 files changed

+242
-234
lines changed

common/bolt12.c

+31-32
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ bool bolt12_chains_match(const struct bitcoin_blkid *chains,
1818
size_t max_num_chains,
1919
const struct chainparams *must_be_chain)
2020
{
21-
/* BOLT-offers #12:
21+
/* BOLT #12:
2222
* - if the chain for the invoice is not solely bitcoin:
2323
* - MUST specify `offer_chains` the offer is valid for.
2424
* - otherwise:
25-
* - MAY omit `offer_chains`, implying that bitcoin is only chain.
25+
* - SHOULD omit `offer_chains`, implying that bitcoin is only chain.
2626
*/
27-
/* BOLT-offers #12:
27+
/* BOLT #12:
2828
* A reader of an offer:
2929
*...
3030
* - if `offer_chains` is not set:
@@ -194,7 +194,7 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
194194
if (*fail)
195195
return tal_free(offer);
196196

197-
/* BOLT-offers #12:
197+
/* BOLT #12:
198198
* A reader of an offer:
199199
* - if the offer contains any TLV fields outside the inclusive ranges: 1 to 79 and 1000000000 to 1999999999:
200200
* - MUST NOT respond to the offer.
@@ -214,7 +214,7 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
214214
return tal_free(offer);
215215
}
216216

217-
/* BOLT-offers #12:
217+
/* BOLT #12:
218218
*
219219
* - if `offer_amount` is set and `offer_description` is not set:
220220
* - MUST NOT respond to the offer.
@@ -224,7 +224,7 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
224224
return tal_free(offer);
225225
}
226226

227-
/* BOLT-offers #12:
227+
/* BOLT #12:
228228
*
229229
* - if neither `offer_issuer_id` nor `offer_paths` are set:
230230
* - MUST NOT respond to the offer.
@@ -234,7 +234,7 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
234234
return tal_free(offer);
235235
}
236236

237-
/* BOLT-offers #12:
237+
/* BOLT #12:
238238
* - if `num_hops` is 0 in any `blinded_path` in `offer_paths`:
239239
* - MUST NOT respond to the offer.
240240
*/
@@ -287,10 +287,10 @@ struct tlv_invoice_request *invrequest_decode(const tal_t *ctx,
287287
if (*fail)
288288
return tal_free(invrequest);
289289

290-
/* BOLT-offers #12:
290+
/* BOLT #12:
291291
* The reader:
292292
*...
293-
* - MUST fail the request if any non-signature TLV fields are outside the inclusive ranges: 0 to 159 and 1000000000 to 2999999999
293+
* - MUST reject the invoice request if any non-signature TLV fields are outside the inclusive ranges: 0 to 159 and 1000000000 to 2999999999
294294
*/
295295
badf = any_field_outside_range(invrequest->fields, true,
296296
0, 159,
@@ -302,9 +302,9 @@ struct tlv_invoice_request *invrequest_decode(const tal_t *ctx,
302302
return tal_free(invrequest);
303303
}
304304

305-
/* BOLT-offers #12:
305+
/* BOLT #12:
306306
* - if `num_hops` is 0 in any `blinded_path` in `invreq_paths`:
307-
* - MUST fail the request.
307+
* - MUST reject the invoice request.
308308
*/
309309
for (size_t i = 0; i < tal_count(invrequest->invreq_paths); i++) {
310310
if (tal_count(invrequest->invreq_paths[i]->path) == 0) {
@@ -346,12 +346,11 @@ struct tlv_invoice *invoice_decode_minimal(const tal_t *ctx,
346346
return NULL;
347347
}
348348

349-
/* BOLT-offers #12:
349+
/* BOLT #12:
350350
* - if `invreq_chain` is not present:
351-
* - MUST fail the request if bitcoin is not a supported chain.
352-
* - otherwise:
353-
* - MUST fail the request if `invreq_chain`.`chain` is not a
354-
* supported chain.
351+
* - MUST reject the invoice if bitcoin is not a supported chain.
352+
* - otherwise:
353+
* - MUST reject the invoice if `invreq_chain`.`chain` is not a supported chain.
355354
* - if `invoice_features` contains unknown _odd_ bits that are non-zero:
356355
* - MUST ignore the bit.
357356
* - if `invoice_features` contains unknown _even_ bits that are non-zero:
@@ -412,7 +411,7 @@ static u64 time_change(u64 prevstart, u32 number,
412411
u64 offer_period_start(u64 basetime, size_t n,
413412
const struct recurrence *recur)
414413
{
415-
/* BOLT-offers-recurrence #12:
414+
/* BOLT-recurrence #12:
416415
* 1. A `time_unit` defining 0 (seconds), 1 (days), 2 (months),
417416
* 3 (years).
418417
*/
@@ -437,13 +436,13 @@ void offer_period_paywindow(const struct recurrence *recurrence,
437436
u64 basetime, u64 period_idx,
438437
u64 *start, u64 *end)
439438
{
440-
/* BOLT-offers-recurrence #12:
439+
/* BOLT-recurrence #12:
441440
* - if the offer contains `recurrence_paywindow`:
442441
*/
443442
if (recurrence_paywindow) {
444443
u64 pstart = offer_period_start(basetime, period_idx,
445444
recurrence);
446-
/* BOLT-offers-recurrence #12:
445+
/* BOLT-recurrence #12:
447446
* - if the offer has a `recurrence_basetime` or the
448447
* `recurrence_counter` is non-zero:
449448
* - SHOULD NOT send an `invreq` for a period prior to
@@ -461,7 +460,7 @@ void offer_period_paywindow(const struct recurrence *recurrence,
461460
&& recurrence_paywindow->seconds_after < 60)
462461
*end = pstart + 60;
463462
} else {
464-
/* BOLT-offers-recurrence #12:
463+
/* BOLT-recurrence #12:
465464
* - otherwise:
466465
* - SHOULD NOT send an `invreq` with
467466
* `recurrence_counter` is non-zero for a period whose
@@ -473,7 +472,7 @@ void offer_period_paywindow(const struct recurrence *recurrence,
473472
*start = offer_period_start(basetime, period_idx-1,
474473
recurrence);
475474

476-
/* BOLT-offers-recurrence #12:
475+
/* BOLT-recurrence #12:
477476
* - SHOULD NOT send an `invreq` for a period which
478477
* has already passed.
479478
*/
@@ -502,7 +501,7 @@ struct tlv_invoice *invoice_decode(const tal_t *ctx,
502501
if (*fail)
503502
return tal_free(invoice);
504503

505-
/* BOLT-offers #12:
504+
/* BOLT #12:
506505
* A reader of an invoice:
507506
* - MUST reject the invoice if `invoice_amount` is not present.
508507
* - MUST reject the invoice if `invoice_created_at` is not present.
@@ -526,15 +525,15 @@ struct tlv_invoice *invoice_decode(const tal_t *ctx,
526525
return tal_free(invoice);
527526
}
528527

529-
/* BOLT-offers #12:
528+
/* BOLT #12:
530529
* - MUST reject the invoice if `invoice_paths` is not present or is
531530
* empty. */
532531
if (tal_count(invoice->invoice_paths) == 0) {
533532
*fail = tal_strdup(ctx, "missing/empty invoice_paths");
534533
return tal_free(invoice);
535534
}
536535

537-
/* BOLT-offers #12:
536+
/* BOLT #12:
538537
* - MUST reject the invoice if `num_hops` is 0 in any
539538
* `blinded_path` in `invoice_paths`.
540539
*/
@@ -546,7 +545,7 @@ struct tlv_invoice *invoice_decode(const tal_t *ctx,
546545
return tal_free(invoice);
547546
}
548547

549-
/* BOLT-offers #12:
548+
/* BOLT #12:
550549
* - MUST reject the invoice if `invoice_blindedpay` is not present.
551550
* - MUST reject the invoice if `invoice_blindedpay` does not contain exactly one `blinded_payinfo` per `invoice_paths`.`blinded_path`.
552551
*/
@@ -565,7 +564,7 @@ u64 invoice_expiry(const struct tlv_invoice *invoice)
565564
{
566565
u64 expiry;
567566

568-
/* BOLT-offers #12:
567+
/* BOLT #12:
569568
* - if `invoice_relative_expiry` is present:
570569
* - MUST reject the invoice if the current time since 1970-01-01 UTC
571570
* is greater than `invoice_created_at` plus `seconds_from_creation`.
@@ -639,7 +638,7 @@ static void calc_offer(const u8 *tlvstream, struct sha256 *id)
639638
size_t start1, len1, start2, len2;
640639
struct sha256_ctx ctx;
641640

642-
/* BOLT-offers #12:
641+
/* BOLT #12:
643642
* A writer of an offer:
644643
* - MUST NOT set any TLV fields outside the inclusive ranges: 1 to 79 and 1000000000 to 1999999999.
645644
*/
@@ -681,7 +680,7 @@ static void calc_invreq(const u8 *tlvstream, struct sha256 *id)
681680
size_t start1, len1, start2, len2;
682681
struct sha256_ctx ctx;
683682

684-
/* BOLT-offers #12:
683+
/* BOLT #12:
685684
* The writer:
686685
*...
687686
* - MUST NOT set any non-signature TLV fields outside the inclusive ranges: 0 to 159 and 1000000000 to 2999999999
@@ -712,7 +711,7 @@ void invoice_invreq_id(const struct tlv_invoice *invoice, struct sha256 *id)
712711
}
713712

714713

715-
/* BOLT-offers #12:
714+
/* BOLT #12:
716715
* ## Requirements for Invoice Requests
717716
*
718717
* The writer:
@@ -744,11 +743,11 @@ struct tlv_invoice *invoice_for_invreq(const tal_t *ctx,
744743

745744
towire_tlv_invoice_request(&wire, invreq);
746745

747-
/* BOLT-offers #12:
746+
/* BOLT #12:
748747
* A writer of an invoice:
749748
*...
750749
* - if the invoice is in response to an `invoice_request`:
751-
* - MUST copy all non-signature fields from the `invoice_request` (including
750+
* - MUST copy all non-signature fields from the invoice request (including
752751
* unknown fields).
753752
*/
754753
len1 = tlv_span(wire, 0, 159, &start1);
@@ -765,7 +764,7 @@ struct tlv_invoice *invoice_for_invreq(const tal_t *ctx,
765764

766765
bool is_bolt12_signature_field(u64 typenum)
767766
{
768-
/* BOLT-offers #12:
767+
/* BOLT #12:
769768
* Each form is signed using one or more *signature TLV elements*: TLV
770769
* types 240 through 1000 (inclusive). */
771770
return typenum >= 240 && typenum <= 1000;

common/bolt12.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
struct feature_set;
77

8-
/* BOLT-offers #12:
8+
/* BOLT #12:
99
* - if `invoice_relative_expiry` is present:
1010
* - MUST reject the invoice if the current time since 1970-01-01 UTC
1111
* is greater than `invoice_created_at` plus `seconds_from_creation`.
@@ -161,7 +161,7 @@ struct tlv_invoice_request *invoice_request_for_offer(const tal_t *ctx,
161161
struct tlv_invoice *invoice_for_invreq(const tal_t *ctx,
162162
const struct tlv_invoice_request *invreq);
163163

164-
/* BOLT-offers #12:
164+
/* BOLT #12:
165165
* Each form is signed using one or more *signature TLV elements*: TLV
166166
* types 240 through 1000 (inclusive). */
167167
bool is_bolt12_signature_field(u64 typenum);

common/bolt12_merkle.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define SUPERVERBOSE(...)
1111
#endif
1212

13-
/* BOLT-offers #12:
13+
/* BOLT #12:
1414
* Each form is signed using one or more *signature TLV elements*: TLV
1515
* types 240 through 1000 (inclusive).
1616
*/
@@ -39,7 +39,7 @@ static void sha256_update_tlvfield(struct sha256_ctx *ctx,
3939
sha256_update(ctx, field->value, field->length);
4040
}
4141

42-
/* BOLT-offers #12:
42+
/* BOLT #12:
4343
* Thus we define H(`tag`,`msg`) as SHA256(SHA256(`tag`) || SHA256(`tag`) || `msg`)*/
4444
/* Create a sha256_ctx which has the tag part done. */
4545
static void h_simpletag_ctx(struct sha256_ctx *sctx, const char *tag)
@@ -55,7 +55,7 @@ static void h_simpletag_ctx(struct sha256_ctx *sctx, const char *tag)
5555
}
5656

5757

58-
/* BOLT-offers #12:
58+
/* BOLT #12:
5959
* The Merkle tree's leaves are, in TLV-ascending order for each tlv:
6060
* 1. The H("LnLeaf",tlv).
6161
* 2. The H("LnNonce"||first-tlv,tlv-type) where first-tlv is the numerically-first TLV entry in the stream, and tlv-type is the "type" field (1-9 bytes) of the current tlv.
@@ -108,7 +108,7 @@ static void calc_lnleaf(const struct tlv_field *field, struct sha256 *hash)
108108
SUPERVERBOSE(") -> %s\n", fmt_sha256(tmpctx, hash));
109109
}
110110

111-
/* BOLT-offers #12:
111+
/* BOLT #12:
112112
* The Merkle tree inner nodes are H("LnBranch", lesser-SHA256||greater-SHA256)
113113
*/
114114
static struct sha256 *merkle_pair(const tal_t *ctx,
@@ -193,7 +193,7 @@ void merkle_tlv(const struct tlv_field *fields, struct sha256 *merkle)
193193
tal_free(arr);
194194
}
195195

196-
/* BOLT-offers #12:
196+
/* BOLT #12:
197197
* All signatures are created as per
198198
* [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki)
199199
* and tagged as recommended there. Thus we define H(`tag`,`msg`) as

common/iso4217.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#include "config.h"
44
#include <wire/wire.h>
55

6-
/* BOLT-offers #12:
6+
/* BOLT #12:
77
*
8-
* - MUST specify `offer_currency` `iso4217` as an ISO 4712 three-letter code.
9-
* - MUST specify `offer_amount` in the currency unit adjusted by the ISO 4712
8+
* - MUST specify `offer_currency` `iso4217` as an ISO 4217 three-letter code.
9+
* - MUST specify `offer_amount` in the currency unit adjusted by the ISO 4217
1010
* exponent (e.g. USD cents).
1111
*/
1212
struct iso4217_name_and_divisor {

common/onion_message_parse.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static bool decrypt_forwarding_onionmsg(const struct pubkey *path_key,
5757
if (encmsg->path_id)
5858
return false;
5959

60-
/* BOLT-offers #4:
60+
/* BOLT #4:
6161
* - if it is not the final node according to the onion encryption:
6262
*...
6363
* - if `next_node_id` is present:

common/test/run-bolt12-encode-test.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,8 @@ int main(int argc, char *argv[])
245245
print_valid_offer(offer, "with blinded path via Bob (0x424242...), path_key 020202...",
246246
"path is [id=02020202..., enc=0x00*16], [id=02020202..., enc=0x11*8]", NULL);
247247

248-
/* BOLT-offers #12:
248+
/* BOLT #12:
249249
* - if it includes `offer_paths`:
250-
* - SHOULD ignore any invoice_request which does not use the path.
251250
* - MAY set `offer_issuer_id`.
252251
* - otherwise:
253252
* - MUST set `offer_issuer_id` to the node's public key to request the invoice from.
@@ -386,7 +385,7 @@ int main(int argc, char *argv[])
386385
"Malformed: invalid offer_issuer_id");
387386

388387
/* Now these are simply invalid, not bad encodings */
389-
/* BOLT-offers #12:
388+
/* BOLT #12:
390389
* A reader of an offer:
391390
* - if the offer contains any TLV fields outside the inclusive ranges: 1 to 79 and 1000000000 to 1999999999:
392391
* - MUST NOT respond to the offer.
@@ -416,24 +415,30 @@ int main(int argc, char *argv[])
416415

417416
offer->offer_features = tal_arr(offer, u8, 0);
418417
set_feature_bit(&offer->offer_features, 22);
419-
/* BOLT-offers #12:
418+
/* BOLT #12:
420419
* - if `offer_features` contains unknown _even_ bits that are non-zero:
421420
* - MUST NOT respond to the offer.
422421
* - SHOULD indicate the unknown bit to the user.
423422
*/
424423
print_invalid_offer(offer, "Contains unknown feature 22");
425424
offer->offer_features = NULL;
426425

427-
/* BOLT-offers #12:
426+
/* BOLT #12:
428427
* - if `offer_amount` is set and `offer_description` is not set:
429428
* - MUST NOT respond to the offer.
429+
* - if `offer_currency` is set and `offer_amount` is not set:
430+
* - MUST NOT respond to the offer.
430431
* - if neither `offer_issuer_id` nor `offer_paths` are set:
431432
* - MUST NOT respond to the offer.
432433
*/
433434
offer->offer_description = NULL;
434435
print_invalid_offer(offer, "Missing offer_description and offer_amount");
435436
offer->offer_description = tal_utf8(tmpctx, "Test vectors");
436437

438+
offer->offer_currency = tal_utf8(offer, "USD");
439+
print_invalid_offer(offer, "Missing offer_amount with offer_currency");
440+
offer->offer_currency = NULL;
441+
437442
offer->offer_issuer_id = NULL;
438443
print_invalid_offer(offer, "Missing offer_issuer_id and no offer_path");
439444

0 commit comments

Comments
 (0)