@@ -39,6 +39,9 @@ struct invreq {
3939
4040 /* Optional secret. */
4141 const struct secret * secret ;
42+
43+ /* Fronting nodes to use for invoice. */
44+ const struct pubkey * fronting_nodes ;
4245};
4346
4447static struct command_result * WARN_UNUSED_RESULT
@@ -278,9 +281,11 @@ static struct command_result *found_best_peer(struct command *cmd,
278281 */
279282 if (!best ) {
280283 /* Don't allow bare invoices if they explicitly told us to front */
281- if (od -> fronting_nodes ) {
284+ if (ir -> fronting_nodes ) {
282285 return fail_invreq (cmd , ir ,
283- "Could not find path from payment-fronting-node" );
286+ "Could not find path from %zu nodes (%s)" ,
287+ tal_count (ir -> fronting_nodes ),
288+ fmt_pubkey (tmpctx , ir -> fronting_nodes ));
284289 }
285290
286291 /* Note: since we don't make one, createinvoice adds a dummy. */
@@ -393,12 +398,10 @@ static struct command_result *found_best_peer(struct command *cmd,
393398static struct command_result * add_blindedpaths (struct command * cmd ,
394399 struct invreq * ir )
395400{
396- const struct offers_data * od = get_offers_data (cmd -> plugin );
397-
398- if (!we_want_blinded_path (cmd -> plugin , od -> fronting_nodes , true))
401+ if (!we_want_blinded_path (cmd -> plugin , ir -> fronting_nodes , true))
399402 return create_invoicereq (cmd , ir );
400403
401- return find_best_peer (cmd , OPT_ROUTE_BLINDING , od -> fronting_nodes ,
404+ return find_best_peer (cmd , OPT_ROUTE_BLINDING , ir -> fronting_nodes ,
402405 found_best_peer , ir );
403406}
404407
@@ -828,6 +831,7 @@ static struct command_result *listoffers_done(struct command *cmd,
828831 struct command_result * err ;
829832 struct amount_msat amt ;
830833 struct tlv_invoice_request_invreq_recurrence_cancel * cancel ;
834+ struct pubkey * offer_fronts ;
831835
832836 /* BOLT #12:
833837 *
@@ -913,6 +917,29 @@ static struct command_result *listoffers_done(struct command *cmd,
913917 return fail_invreq (cmd , ir , "Offer expired" );
914918 }
915919
920+ /* If offer used fronting nodes, we use them too. */
921+ offer_fronts = tal_arr (NULL , struct pubkey , 0 );
922+ for (size_t i = 0 ; i < tal_count (ir -> invreq -> offer_paths ); i ++ ) {
923+ const struct blinded_path * p = ir -> invreq -> offer_paths [i ];
924+ struct sciddir_or_pubkey first = p -> first_node_id ;
925+
926+ /* In dev mode we could set this. Fail if we can't map */
927+ if (!first .is_pubkey && !gossmap_scidd_pubkey (get_gossmap (cmd -> plugin ), & first ))
928+ return fail_invreq (cmd , ir , "Fronting failed" );
929+ assert (first .is_pubkey );
930+ /* Self-paths are not fronting nodes */
931+ if (!pubkey_eq (& od -> id , & first .pubkey ))
932+ tal_arr_expand (& offer_fronts , first .pubkey );
933+ }
934+
935+ if (tal_count (offer_fronts ) != 0 )
936+ ir -> fronting_nodes = tal_steal (ir , offer_fronts );
937+ else {
938+ /* Otherwise, use defaults */
939+ tal_free (offer_fronts );
940+ ir -> fronting_nodes = od -> fronting_nodes ;
941+ }
942+
916943 /* BOLT-recurrence #12:
917944 * - if `offer_quantity_max` is present:
918945 * - MUST reject the invoice request if `invreq_recurrence_cancel`
0 commit comments