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

Function invreq_done

plugins/fetchinvoice.c:677–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675}
676
677static struct command_result *invreq_done(struct command *cmd,
678 const char *method,
679 const char *buf,
680 const jsmntok_t *result,
681 struct sent *sent)
682{
683 struct tlv_onionmsg_tlv *payload;
684 const jsmntok_t *t;
685 const char *fail;
686 const struct recurrence *recurrence;
687
688 /* Get invoice request */
689 t = json_get_member(buf, result, "bolt12");
690 if (!t)
691 return command_fail(cmd, LIGHTNINGD,
692 "Missing bolt12 %.*s",
693 json_tok_full_len(result),
694 json_tok_full(buf, result));
695
696 plugin_log(cmd->plugin, LOG_DBG,
697 "invoice_request: %.*s",
698 json_tok_full_len(t),
699 json_tok_full(buf, t));
700
701 sent->inv = NULL;
702 sent->invreq = invrequest_decode(sent,
703 buf + t->start,
704 t->end - t->start,
705 plugin_feature_set(cmd->plugin),
706 chainparams,
707 &fail);
708 if (!sent->invreq)
709 return command_fail(cmd, LIGHTNINGD,
710 "Invalid invoice_request %.*s: %s",
711 json_tok_full_len(t),
712 json_tok_full(buf, t),
713 fail);
714
715 recurrence = invreq_recurrence(sent->invreq);
716 /* Now that's given us the previous base, check this is an OK time
717 * to request an invoice. */
718 if (sent->invreq->invreq_recurrence_counter) {
719 u64 *base;
720 const jsmntok_t *pbtok;
721 u64 period_idx = *sent->invreq->invreq_recurrence_counter;
722
723 if (sent->invreq->invreq_recurrence_start)
724 period_idx += *sent->invreq->invreq_recurrence_start;
725
726 /* BOLT-recurrence #12:
727 * - if `offer_recurrence_limit` is present:
728 * - MUST NOT send an `invoice_request` for a period index greater than
729 * `max_period_index`
730 */
731 if (sent->invreq->offer_recurrence_limit
732 && period_idx > *sent->invreq->offer_recurrence_limit)
733 return command_fail(cmd, LIGHTNINGD,
734 "Can't send invreq for period %"

Callers

nothing calls this directly

Calls 13

json_get_memberFunction · 0.85
invrequest_decodeFunction · 0.85
invreq_recurrenceFunction · 0.85
clock_timeFunction · 0.85
offer_period_paywindowFunction · 0.85
send_messageFunction · 0.85
command_failFunction · 0.70
plugin_logFunction · 0.70
plugin_feature_setFunction · 0.70
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_to_u64Function · 0.50

Tested by

no test coverage detected