@@ -179,16 +179,15 @@ static const char *decode_p(struct bolt11 *b11,
179179{
180180 /* BOLT #11:
181181 *
182- * A payer... SHOULD use the first `p` field that it did NOT
183- * skip as the payment hash.
182+ * A payer... SHOULD use the first `p` field as the payment hash.
184183 */
185184 assert (!* have_p );
186185
187186 /* BOLT #11:
188187 *
189- * A reader... MUST skip over unknown fields, OR an `f` field
190- * with unknown `version`, OR `p`, `h`, `s` or `n` fields that do
191- * NOT have `data_length`s of 52, 52, 52 or 53, respectively .
188+ * A reader...
189+ * - MUST fail the payment if any mandatory field ( `p`, `h`, `s`, `n`)
190+ * does not have the correct length ( 52, 52, 52, 53) .
192191 */
193192 return pull_expected_length (b11 , hu5 , data , field_len , 52 , 'p' ,
194193 have_p , & b11 -> payment_hash );
@@ -240,9 +239,9 @@ static const char *decode_h(struct bolt11 *b11,
240239 assert (!* have_h );
241240 /* BOLT #11:
242241 *
243- * A reader... MUST skip over unknown fields, OR an `f` field
244- * with unknown `version`, OR `p`, `h`, `s` or `n` fields that do
245- * NOT have `data_length`s of 52, 52, 52 or 53, respectively . */
242+ * A reader...
243+ * - MUST fail the payment if any mandatory field ( `p`, `h`, `s`, `n`)
244+ * does not have the correct length ( 52, 52, 52, 53) . */
246245 err = pull_expected_length (b11 , hu5 , data , field_len , 52 , 'h' ,
247246 have_h , & hash );
248247
@@ -325,9 +324,9 @@ static const char *decode_n(struct bolt11 *b11,
325324 assert (!* have_n );
326325 /* BOLT #11:
327326 *
328- * A reader... MUST skip over unknown fields, OR an `f` field
329- * with unknown `version`, OR `p`, `h`, `s` or `n` fields that do
330- * NOT have `data_length`s of 52, 52, 52 or 53, respectively . */
327+ * A reader...
328+ * - MUST fail the payment if any mandatory field ( `p`, `h`, `s`, `n`)
329+ * does not have the correct length ( 52, 52, 52, 53) . */
331330 err = pull_expected_length (b11 , hu5 , data , field_len , 53 , 'n' , have_n ,
332331 & b11 -> receiver_id .k );
333332
@@ -361,9 +360,9 @@ static const char *decode_s(struct bolt11 *b11,
361360
362361 /* BOLT #11:
363362 *
364- * A reader... MUST skip over unknown fields, OR an `f` field
365- * with unknown `version`, OR `p`, `h`, `s` or `n` fields that do
366- * NOT have `data_length`s of 52, 52, 52 or 53, respectively . */
363+ * A reader...
364+ * - MUST fail the payment if any mandatory field ( `p`, `h`, `s`, `n`)
365+ * does not have the correct length ( 52, 52, 52, 53) . */
367366 err = pull_expected_length (b11 , hu5 , data , field_len , 52 , 's' ,
368367 have_s , & secret );
369368 if (* have_s )
@@ -443,6 +442,9 @@ static const char *decode_f(struct bolt11 *b11,
443442 fallback = scriptpubkey_witness_raw (b11 , version ,
444443 f , tal_count (f ));
445444 } else {
445+ /* BOLT #11:
446+ * - MUST skip over `f` fields that use an unknown `version`.
447+ */
446448 /* Restore version for unknown field! */
447449 * data = orig_data ;
448450 * field_len = orig_len ;
@@ -664,8 +666,7 @@ struct decoder {
664666static const struct decoder decoders [] = {
665667 /* BOLT #11:
666668 *
667- * A payer... SHOULD use the first `p` field that it did NOT
668- * skip as the payment hash.
669+ * A payer... SHOULD use the first `p` field as the payment hash.
669670 */
670671 { 'p' , false, decode_p },
671672 { 'd' , false, decode_d },
0 commit comments