@@ -316,9 +316,20 @@ struct find_best_peer_data {
316316 const struct chaninfo * ,
317317 void * );
318318 int needed_feature ;
319+ const struct pubkey * fronting_only ;
319320 void * arg ;
320321};
321322
323+ static bool is_in_pubkeys (const struct pubkey * pubkeys ,
324+ const struct pubkey * k )
325+ {
326+ for (size_t i = 0 ; i < tal_count (pubkeys ); i ++ ) {
327+ if (pubkey_eq (& pubkeys [i ], k ))
328+ return true;
329+ }
330+ return false;
331+ }
332+
322333static struct command_result * listincoming_done (struct command * cmd ,
323334 const char * method ,
324335 const char * buf ,
@@ -363,6 +374,18 @@ static struct command_result *listincoming_done(struct command *cmd,
363374 }
364375 ci .feebase = feebase .millisatoshis ; /* Raw: feebase */
365376
377+ if (data -> fronting_only ) {
378+ if (!is_in_pubkeys (data -> fronting_only , & ci .id ))
379+ continue ;
380+
381+ /* If disconnected, don't eliminate, simply
382+ * consider it last. */
383+ if (!enabled ) {
384+ ci .capacity = AMOUNT_MSAT (0 );
385+ enabled = true;
386+ }
387+ }
388+
366389 /* Don't pick a peer which is disconnected */
367390 if (!enabled )
368391 continue ;
@@ -388,6 +411,7 @@ static struct command_result *listincoming_done(struct command *cmd,
388411
389412struct command_result * find_best_peer_ (struct command * cmd ,
390413 int needed_feature ,
414+ const struct pubkey * fronting_only ,
391415 struct command_result * (* cb )(struct command * ,
392416 const struct chaninfo * ,
393417 void * ),
@@ -398,6 +422,7 @@ struct command_result *find_best_peer_(struct command *cmd,
398422 data -> cb = cb ;
399423 data -> arg = arg ;
400424 data -> needed_feature = needed_feature ;
425+ data -> fronting_only = fronting_only ;
401426 req = jsonrpc_request_start (cmd , "listincoming" ,
402427 listincoming_done , forward_error , data );
403428 return send_outreq (req );
0 commit comments