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

Function listoffers_done

plugins/offers_invreq_hook.c:826–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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