| 394 | } |
| 395 | |
| 396 | struct tlv_invoice *invoice_decode_minimal(const tal_t *ctx, |
| 397 | const char *b12, size_t b12len, |
| 398 | const struct feature_set *our_features, |
| 399 | const struct chainparams *must_be_chain, |
| 400 | const char **fail) |
| 401 | { |
| 402 | struct tlv_invoice *invoice; |
| 403 | const u8 *data; |
| 404 | size_t dlen; |
| 405 | |
| 406 | data = b12_string_to_data(tmpctx, b12, b12len, "lni", &dlen, fail); |
| 407 | if (!data) { |
| 408 | tal_steal(ctx, *fail); |
| 409 | return NULL; |
| 410 | } |
| 411 | |
| 412 | invoice = fromwire_tlv_invoice(ctx, &data, &dlen); |
| 413 | if (!invoice) { |
| 414 | *fail = tal_fmt(ctx, "invalid invoice data"); |
| 415 | return NULL; |
| 416 | } |
| 417 | |
| 418 | /* BOLT #12: |
| 419 | * - if `invreq_chain` is not present: |
| 420 | * - MUST reject the invoice if bitcoin is not a supported chain. |
| 421 | * - otherwise: |
| 422 | * - MUST reject the invoice if `invreq_chain`.`chain` is not a supported chain. |
| 423 | * - if `invoice_features` contains unknown _odd_ bits that are non-zero: |
| 424 | * - MUST ignore the bit. |
| 425 | * - if `invoice_features` contains unknown _even_ bits that are non-zero: |
| 426 | * - MUST reject the invoice. |
| 427 | */ |
| 428 | *fail = check_features_and_chain(ctx, |
| 429 | our_features, must_be_chain, |
| 430 | invoice->invoice_features, |
| 431 | BOLT12_INVOICE_FEATURE, |
| 432 | invoice->invreq_chain, 1); |
| 433 | if (*fail) |
| 434 | return tal_free(invoice); |
| 435 | |
| 436 | return invoice; |
| 437 | } |
| 438 | |
| 439 | static void add_days(struct tm *tm, u32 number) |
| 440 | { |
no test coverage detected