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

Function listoffers_done

plugins/offers_invreq_hook.c:852–1124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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