@@ -320,9 +320,20 @@ struct find_best_peer_data {
320320 const struct chaninfo * ,
321321 void * );
322322 int needed_feature ;
323+ const struct pubkey * fronting_only ;
323324 void * arg ;
324325};
325326
327+ static bool is_in_pubkeys (const struct pubkey * pubkeys ,
328+ const struct pubkey * k )
329+ {
330+ for (size_t i = 0 ; i < tal_count (pubkeys ); i ++ ) {
331+ if (pubkey_eq (& pubkeys [i ], k ))
332+ return true;
333+ }
334+ return false;
335+ }
336+
326337static struct command_result * listincoming_done (struct command * cmd ,
327338 const char * method ,
328339 const char * buf ,
@@ -367,6 +378,18 @@ static struct command_result *listincoming_done(struct command *cmd,
367378 }
368379 ci .feebase = feebase .millisatoshis ; /* Raw: feebase */
369380
381+ if (data -> fronting_only ) {
382+ if (!is_in_pubkeys (data -> fronting_only , & ci .id ))
383+ continue ;
384+
385+ /* If disconnected, don't eliminate, simply
386+ * consider it last. */
387+ if (!enabled ) {
388+ ci .capacity = AMOUNT_MSAT (0 );
389+ enabled = true;
390+ }
391+ }
392+
370393 /* Don't pick a peer which is disconnected */
371394 if (!enabled )
372395 continue ;
@@ -392,6 +415,7 @@ static struct command_result *listincoming_done(struct command *cmd,
392415
393416struct command_result * find_best_peer_ (struct command * cmd ,
394417 int needed_feature ,
418+ const struct pubkey * fronting_only ,
395419 struct command_result * (* cb )(struct command * ,
396420 const struct chaninfo * ,
397421 void * ),
@@ -402,6 +426,7 @@ struct command_result *find_best_peer_(struct command *cmd,
402426 data -> cb = cb ;
403427 data -> arg = arg ;
404428 data -> needed_feature = needed_feature ;
429+ data -> fronting_only = fronting_only ;
405430 req = jsonrpc_request_start (cmd , "listincoming" ,
406431 listincoming_done , forward_error , data );
407432 return send_outreq (req );
0 commit comments