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

Function invreq_done

plugins/fetchinvoice.c:718–837  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

716}
717
718static struct command_result *invreq_done(struct command *cmd,
719 const char *method,
720 const char *buf,
721 const jsmntok_t *result,
722 struct sent *sent)
723{
724 struct tlv_onionmsg_tlv *payload;
725 const jsmntok_t *t;
726 const char *fail;
727 const struct recurrence *recurrence;
728
729 /* Get invoice request */
730 t = json_get_member(buf, result, "bolt12");
731 if (!t)
732 return command_fail(cmd, LIGHTNINGD,
733 "Missing bolt12 %.*s",
734 json_tok_full_len(result),
735 json_tok_full(buf, result));
736
737 plugin_log(cmd->plugin, LOG_DBG,
738 "invoice_request: %.*s",
739 json_tok_full_len(t),
740 json_tok_full(buf, t));
741
742 sent->inv = NULL;
743 sent->invreq = invrequest_decode(sent,
744 buf + t->start,
745 t->end - t->start,
746 plugin_feature_set(cmd->plugin),
747 chainparams,
748 &fail);
749 if (!sent->invreq)
750 return command_fail(cmd, LIGHTNINGD,
751 "Invalid invoice_request %.*s: %s",
752 json_tok_full_len(t),
753 json_tok_full(buf, t),
754 fail);
755
756 recurrence = invreq_recurrence(sent->invreq);
757 /* Now that's given us the previous base, check this is an OK time
758 * to request an invoice. */
759 if (sent->invreq->invreq_recurrence_counter) {
760 u64 *base;
761 const jsmntok_t *pbtok;
762 u64 period_idx = *sent->invreq->invreq_recurrence_counter;
763
764 if (sent->invreq->invreq_recurrence_start)
765 period_idx += *sent->invreq->invreq_recurrence_start;
766
767 /* BOLT-recurrence #12:
768 * - if `offer_recurrence_limit` is present:
769 * - MUST NOT send an `invoice_request` for a period index greater than
770 * `max_period_index`
771 */
772 if (sent->invreq->offer_recurrence_limit
773 && period_idx > *sent->invreq->offer_recurrence_limit)
774 return command_fail(cmd, LIGHTNINGD,
775 "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