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

Function offer_period_paywindow

common/bolt12.c:351–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351void offer_period_paywindow(const struct tlv_offer_recurrence *recurrence,
352 const struct tlv_offer_recurrence_paywindow *recurrence_paywindow,
353 const struct tlv_offer_recurrence_base *recurrence_base,
354 u64 basetime, u64 period_idx,
355 u64 *start, u64 *end)
356{
357 /* BOLT-offers-recurrence #12:
358 * - if the offer contains `recurrence_paywindow`:
359 */
360 if (recurrence_paywindow) {
361 u64 pstart = offer_period_start(basetime, period_idx,
362 recurrence);
363 /* BOLT-offers-recurrence #12:
364 * - if the offer has a `recurrence_basetime` or the
365 * `recurrence_counter` is non-zero:
366 * - SHOULD NOT send an `invoice_request` for a period prior to
367 * `seconds_before` seconds before that period start.
368 * - SHOULD NOT send an `invoice_request` for a period later
369 * than `seconds_after` seconds past that period start.
370 */
371 *start = pstart - recurrence_paywindow->seconds_before;
372 *end = pstart + recurrence_paywindow->seconds_after;
373
374 /* First payment without recurrence_base, we give
375 * ourselves 60 seconds, since period will start
376 * now */
377 if (!recurrence_base && period_idx == 0
378 && recurrence_paywindow->seconds_after < 60)
379 *end = pstart + 60;
380 } else {
381 /* BOLT-offers-recurrence #12:
382 * - otherwise:
383 * - SHOULD NOT send an `invoice_request` with
384 * `recurrence_counter` is non-zero for a period whose
385 * immediate predecessor has not yet begun.
386 */
387 if (period_idx == 0)
388 *start = 0;
389 else
390 *start = offer_period_start(basetime, period_idx-1,
391 recurrence);
392
393 /* BOLT-offers-recurrence #12:
394 * - SHOULD NOT send an `invoice_request` for a period which
395 * has already passed.
396 */
397 *end = offer_period_start(basetime, period_idx+1,
398 recurrence) - 1;
399 }
400}
401
402struct tlv_invoice *invoice_decode(const tal_t *ctx,
403 const char *b12, size_t b12len,

Callers 3

check_periodFunction · 0.85
handle_invreq_responseFunction · 0.85
invreq_doneFunction · 0.85

Calls 1

offer_period_startFunction · 0.85

Tested by

no test coverage detected