From c9c674fe976f4f9f9b73c464756a69048d5539f7 Mon Sep 17 00:00:00 2001 From: 21M4TW <21m4tw@proton.me> Date: Tue, 15 Apr 2025 08:49:34 -0400 Subject: [PATCH] -Fixing offers when offer_paths are present and offer_issuer_id is no longer needed. -There is a missing piece however in plugins/offers_invreq_hook.c, which causes an error in plugins/fetchinvoice.c when trying to fetch an invoice for an offer without offer_issuer _id. Comments were added to describe the remaining issue. --- plugins/fetchinvoice.c | 5 +++++ plugins/offers_invreq_hook.c | 5 +++++ plugins/offers_offer.c | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c index c40889763d95..e566101cc19c 100644 --- a/plugins/fetchinvoice.c +++ b/plugins/fetchinvoice.c @@ -240,6 +240,11 @@ static struct command_result *handle_invreq_response(struct command *cmd, badfield = "invoice_payment_hash"; goto badinv; } + /* Currently the following check fails for offers that do not contain + * offer_issuer_id and for which an invoice is fetched from a CLN node, + * because listoffers_done in offers_invrek_hook.c sets invoice_node_id + * to offer_issuer_id regardless. + */ if (!inv->invoice_node_id) { badfield = "invoice_node_id"; goto badinv; diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c index 5cefec997537..2a94214780b2 100644 --- a/plugins/offers_invreq_hook.c +++ b/plugins/offers_invreq_hook.c @@ -935,6 +935,11 @@ static struct command_result *listoffers_done(struct command *cmd, * - MUST set `invoice_node_id` to the `offer_issuer_id` */ /* FIXME: We always provide an offer_issuer_id! */ + /* The following line is wrong when offer_issuer_id is not used. + * According to fetchinvoice.c, it should be "equal to the final + * `blinded_node_id` it [the payer] sent the invoice request to", when + * offer_issuer_id is not set and offer_paths is set + */ ir->inv->invoice_node_id = ir->inv->offer_issuer_id; /* BOLT #12: diff --git a/plugins/offers_offer.c b/plugins/offers_offer.c index a50052cb13b1..ab9b42d206c6 100644 --- a/plugins/offers_offer.c +++ b/plugins/offers_offer.c @@ -296,6 +296,12 @@ static struct command_result *found_best_peer(struct command *cmd, struct secret blinding_path_secret; struct sha256 offer_id; + /* offer_issuer_id is not needed when offer_paths are used. + * The following line seems to produce a valid offer with + * offer_issuer_id removed. + */ + offinfo->offer->offer_issuer_id = NULL; + /* Note: "id" of offer minus paths */ offer_offer_id(offinfo->offer, &offer_id);