Skip to content

Commit 5c53729

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 7c4804c commit 5c53729

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
@@ -240,11 +240,6 @@ static struct command_result *handle_invreq_response(struct command *cmd,
240240
badfield = "invoice_payment_hash";
241241
goto badinv;
242242
}
243-
/* Currently the following check fails for offers that do not contain
244-
* offer_issuer_id and for which an invoice is fetched from a CLN node,
245-
* because listoffers_done in offers_invrek_hook.c sets invoice_node_id
246-
* to offer_issuer_id regardless.
247-
*/
248243
if (!inv->invoice_node_id) {
249244
badfield = "invoice_node_id";
250245
goto badinv;

plugins/offers_invreq_hook.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -931,16 +931,15 @@ static struct command_result *listoffers_done(struct command *cmd,
931931
assert(ir->inv->invreq_payer_id);
932932

933933
/* BOLT #12:
934-
* - if `offer_issuer_id` is present:
934+
* - if `offer_issuer_id` is present or if `offer_paths` is not present:
935935
* - MUST set `invoice_node_id` to the `offer_issuer_id`
936+
* - else:
937+
* - MUST set `invoice_node_id` to the final `blinded_node_id`
936938
*/
937-
/* FIXME: We always provide an offer_issuer_id! */
938-
/* The following line is wrong when offer_issuer_id is not used.
939-
* According to fetchinvoice.c, it should be "equal to the final
940-
* `blinded_node_id` it [the payer] sent the invoice request to", when
941-
* offer_issuer_id is not set and offer_paths is set
942-
*/
943-
ir->inv->invoice_node_id = ir->inv->offer_issuer_id;
939+
if(!ir->inv->offer_issuer_id && ir->invreq->offer_paths) {
940+
ir->inv->invoice_node_id = &(*ir->invreq->offer_paths)->path[tal_count((*ir->invreq->offer_paths)->path)-1]->blinded_node_id;
941+
942+
} else ir->inv->invoice_node_id = ir->inv->offer_issuer_id;
944943

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

0 commit comments

Comments
 (0)