| 313 | } |
| 314 | |
| 315 | static const char *decode_n(struct bolt11 *b11, |
| 316 | const struct feature_set *our_features, |
| 317 | struct hash_u5 *hu5, |
| 318 | const u5 **data, size_t *field_len, |
| 319 | bool *have_n) |
| 320 | { |
| 321 | const char *err; |
| 322 | |
| 323 | assert(!*have_n); |
| 324 | /* BOLT #11: |
| 325 | * |
| 326 | * A reader... |
| 327 | * - MUST fail the payment if any field with fixed `data_length` (`p`, `h`, `s`, `n`) |
| 328 | * does not have the correct length (52, 52, 52, 53). */ |
| 329 | err = pull_expected_length(b11, hu5, data, field_len, 53, 'n', have_n, |
| 330 | &b11->receiver_id.k); |
| 331 | |
| 332 | /* If that gave us a node ID, check it. */ |
| 333 | if (*have_n) { |
| 334 | struct pubkey k; |
| 335 | if (!pubkey_from_node_id(&k, &b11->receiver_id)) |
| 336 | return tal_fmt( |
| 337 | b11, "invalid public key %s", |
| 338 | fmt_node_id(tmpctx, &b11->receiver_id)); |
| 339 | } |
| 340 | |
| 341 | return err; |
| 342 | } |
| 343 | |
| 344 | /* BOLT #11: |
| 345 | * |
nothing calls this directly
no test coverage detected