MCPcopy Create free account
hub / github.com/ElementsProject/lightning / invoice_expiry

Function invoice_expiry

common/bolt12.c:624–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

622}
623
624u64 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
648static bool bolt12_has_invoice_prefix(const char *str)
649{

Callers 2

json_renepayFunction · 0.85
xpay_coreFunction · 0.85

Calls 1

add_overflows_u64Function · 0.85

Tested by

no test coverage detected