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

Function listoffers_done

plugins/offers_invreq_hook.c:839–1111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839static struct command_result *listoffers_done(struct command *cmd,
840 const char *method,
841 const char *buf,
842 const jsmntok_t *result,
843 struct invreq *ir)
844{
845 const struct offers_data *od = get_offers_data(cmd->plugin);
846 const jsmntok_t *arr = json_get_member(buf, result, "offers");
847 const jsmntok_t *offertok, *activetok, *b12tok, *forcetok;
848 bool active, force_paths;
849 struct command_result *err;
850 struct amount_msat amt;
851 struct tlv_invoice_request_invreq_recurrence_cancel *cancel;
852
853 /* BOLT #12:
854 *
855 * - MUST reject the invoice request if the offer fields do not exactly match a
856 * valid, unexpired offer.
857 */
858 if (arr->size == 0)
859 return fail_invreq(cmd, ir, "Unknown offer");
860
861 /* Now, since we looked up by hash, we know that the entire offer
862 * is faithfully mirrored in this invreq. */
863
864 /* BOLT #4:
865 *
866 * If it is the final recipient:
867 * - MUST ignore the message if the `path_id` does not match
868 * the blinded route it created for this purpose
869 */
870 offertok = arr + 1;
871 if (ir->secret) {
872 struct sha256 offer_id;
873 struct secret blinding_path_secret;
874 struct blinded_path **offer_paths;
875
876 if (!ir->invreq->offer_paths) {
877 /* You should not have used a blinded path for invreq */
878 if (command_dev_apis(cmd))
879 return fail_invreq(cmd, ir, "Unexpected blinded path");
880 return fail_invreq(cmd, ir, "Unknown offer");
881 }
882 /* We generated this without the paths, so temporarily remove them */
883 offer_paths = ir->invreq->offer_paths;
884 ir->invreq->offer_paths = NULL;
885 invreq_offer_id(ir->invreq, &offer_id);
886 ir->invreq->offer_paths = offer_paths;
887 bolt12_path_secret(&od->offerblinding_base, &offer_id,
888 &blinding_path_secret);
889 if (!secret_eq_consttime(ir->secret, &blinding_path_secret)) {
890 /* You used the wrong blinded path for invreq */
891 if (command_dev_apis(cmd))
892 return fail_invreq(cmd, ir, "Wrong blinded path");
893 return fail_invreq(cmd, ir, "Unknown offer");
894 }
895 } else {
896 if (ir->invreq->offer_paths) {

Callers

nothing calls this directly

Calls 15

get_offers_dataFunction · 0.85
json_get_memberFunction · 0.85
invreq_offer_idFunction · 0.85
bolt12_path_secretFunction · 0.85
secret_eq_consttimeFunction · 0.85
clock_timeFunction · 0.85
gossmap_scidd_pubkeyFunction · 0.85
fmt_sciddir_or_pubkeyFunction · 0.85
invrequest_encodeFunction · 0.85
check_payer_sigFunction · 0.85
invreq_recurrenceFunction · 0.85
invoice_for_invreqFunction · 0.85

Tested by

no test coverage detected