| 622 | } |
| 623 | |
| 624 | u64 invoice_expiry(const struct tlv_invoice *invoice) |
| 625 | { |
| 626 | u64 expiry; |
| 627 | |
| 628 | /* BOLT #12: |
| 629 | * - if `invoice_relative_expiry` is present: |
| 630 | * - MUST reject the invoice if the current time since 1970-01-01 UTC |
| 631 | * is greater than `invoice_created_at` plus `seconds_from_creation`. |
| 632 | * - otherwise: |
| 633 | * - MUST reject the invoice if the current time since 1970-01-01 UTC |
| 634 | * is greater than `invoice_created_at` plus 7200. |
| 635 | */ |
| 636 | if (invoice->invoice_relative_expiry) |
| 637 | expiry = *invoice->invoice_relative_expiry; |
| 638 | else |
| 639 | expiry = 7200; |
| 640 | |
| 641 | /* If it overflows, it's forever */ |
| 642 | if (add_overflows_u64(*invoice->invoice_created_at, expiry)) |
| 643 | return UINT64_MAX; |
| 644 | |
| 645 | return *invoice->invoice_created_at + expiry; |
| 646 | } |
| 647 | |
| 648 | static bool bolt12_has_invoice_prefix(const char *str) |
| 649 | { |
no test coverage detected