Skip to content

Commit 25d5f7f

Browse files
committed
listoffers_done: Fix invoice_node_id so it is set to the final
blinded_node_id when offer_issuer_id is not present and offers_path is present.
1 parent aa5807d commit 25d5f7f

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

plugins/fetchinvoice.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,6 @@ static struct command_result *handle_invreq_response(struct command *cmd,
231231
badfield = "invoice_payment_hash";
232232
goto badinv;
233233
}
234-
/* Currently the following check fails for offers that do not contain
235-
* offer_issuer_id and for which an invoice is fetched from a CLN node,
236-
* because listoffers_done in offers_invrek_hook.c sets invoice_node_id
237-
* to offer_issuer_id regardless.
238-
*/
239234
if (!inv->invoice_node_id) {
240235
badfield = "invoice_node_id";
241236
goto badinv;

plugins/offers_invreq_hook.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -989,16 +989,15 @@ static struct command_result *listoffers_done(struct command *cmd,
989989
ir->invreq->invreq_recurrence_cancel = cancel;
990990

991991
/* BOLT #12:
992-
* - if `offer_issuer_id` is present:
992+
* - if `offer_issuer_id` is present or if `offer_paths` is not present:
993993
* - MUST set `invoice_node_id` to the `offer_issuer_id`
994+
* - else:
995+
* - MUST set `invoice_node_id` to the final `blinded_node_id`
994996
*/
995-
/* FIXME: We always provide an offer_issuer_id! */
996-
/* The following line is wrong when offer_issuer_id is not used.
997-
* According to fetchinvoice.c, it should be "equal to the final
998-
* `blinded_node_id` it [the payer] sent the invoice request to", when
999-
* offer_issuer_id is not set and offer_paths is set
1000-
*/
1001-
ir->inv->invoice_node_id = ir->inv->offer_issuer_id;
997+
if(!ir->inv->offer_issuer_id && ir->invreq->offer_paths) {
998+
ir->inv->invoice_node_id = &(*ir->invreq->offer_paths)->path[tal_count((*ir->invreq->offer_paths)->path)-1]->blinded_node_id;
999+
1000+
} else ir->inv->invoice_node_id = ir->inv->offer_issuer_id;
10021001

10031002
/* BOLT #12:
10041003
* - MUST set `invoice_created_at` to the number of seconds since

0 commit comments

Comments
 (0)