BOLT #11: * * `9` (5): `data_length` variable. One or more 5-bit values containing features * supported or required for receiving this payment. * See [Feature Bits](#feature-bits). */
| 557 | * See [Feature Bits](#feature-bits). |
| 558 | */ |
| 559 | static const char *decode_9(struct bolt11 *b11, |
| 560 | const struct feature_set *our_features, |
| 561 | struct hash_u5 *hu5, |
| 562 | const u5 **data, size_t *field_len, |
| 563 | bool *have_9) |
| 564 | { |
| 565 | size_t flen = (*field_len * 5 + 7) / 8; |
| 566 | int badf; |
| 567 | size_t databits = *field_len * 5; |
| 568 | const char *err; |
| 569 | |
| 570 | assert(!*have_9); |
| 571 | |
| 572 | b11->features = pull_all(b11, hu5, data, field_len, true, &err); |
| 573 | if (!b11->features) |
| 574 | return err; |
| 575 | |
| 576 | /* BOLT #11: |
| 577 | * - if a `c`, `x`, or `9` field is provided which has a non-minimal `data_length` |
| 578 | * (i.e. begins with 0 field elements): |
| 579 | * - SHOULD treat the invoice as invalid. |
| 580 | */ |
| 581 | if (tal_count(b11->features) > 0 && b11->features[0] == 0) |
| 582 | return tal_fmt(b11, "9: non-minimal length (begins with 0)"); |
| 583 | |
| 584 | /* pull_bits pads with zero bits: we need to remove them. */ |
| 585 | shift_bitmap_down(b11->features, |
| 586 | flen * 8 - databits); |
| 587 | |
| 588 | /* BOLT #11: |
| 589 | * |
| 590 | * - if the `9` field contains unknown _odd_ bits that are non-zero: |
| 591 | * - MUST ignore the bit. |
| 592 | * - if the `9` field contains unknown _even_ bits that are non-zero: |
| 593 | * - MUST fail the payment. |
| 594 | */ |
| 595 | /* We skip this check for the cli tool, which sets our_features to NULL */ |
| 596 | if (our_features) { |
| 597 | badf = features_unsupported(our_features, |
| 598 | b11->features, BOLT11_FEATURE); |
| 599 | if (badf != -1) |
| 600 | return tal_fmt(b11, "9: unknown feature bit %i", badf); |
| 601 | } |
| 602 | |
| 603 | *have_9 = true; |
| 604 | return NULL; |
| 605 | } |
| 606 | |
| 607 | /* BOLT #11: |
| 608 | * |
nothing calls this directly
no test coverage detected