@@ -39,6 +39,9 @@ struct invreq {
39
39
40
40
/* Optional secret. */
41
41
const struct secret * secret ;
42
+
43
+ /* Fronting nodes to use for invoice. */
44
+ const struct pubkey * fronting_nodes ;
42
45
};
43
46
44
47
static struct command_result * WARN_UNUSED_RESULT
@@ -278,9 +281,11 @@ static struct command_result *found_best_peer(struct command *cmd,
278
281
*/
279
282
if (!best ) {
280
283
/* Don't allow bare invoices if they explicitly told us to front */
281
- if (od -> fronting_nodes ) {
284
+ if (ir -> fronting_nodes ) {
282
285
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 ));
284
289
}
285
290
286
291
/* 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,
393
398
static struct command_result * add_blindedpaths (struct command * cmd ,
394
399
struct invreq * ir )
395
400
{
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))
399
402
return create_invoicereq (cmd , ir );
400
403
401
- return find_best_peer (cmd , OPT_ROUTE_BLINDING , od -> fronting_nodes ,
404
+ return find_best_peer (cmd , OPT_ROUTE_BLINDING , ir -> fronting_nodes ,
402
405
found_best_peer , ir );
403
406
}
404
407
@@ -828,6 +831,7 @@ static struct command_result *listoffers_done(struct command *cmd,
828
831
struct command_result * err ;
829
832
struct amount_msat amt ;
830
833
struct tlv_invoice_request_invreq_recurrence_cancel * cancel ;
834
+ struct pubkey * offer_fronts ;
831
835
832
836
/* BOLT #12:
833
837
*
@@ -913,6 +917,29 @@ static struct command_result *listoffers_done(struct command *cmd,
913
917
return fail_invreq (cmd , ir , "Offer expired" );
914
918
}
915
919
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
+
916
943
/* BOLT-recurrence #12:
917
944
* - if `offer_quantity_max` is present:
918
945
* - MUST reject the invoice request if `invreq_recurrence_cancel`
0 commit comments