@@ -320,9 +320,20 @@ struct find_best_peer_data {
320
320
const struct chaninfo * ,
321
321
void * );
322
322
int needed_feature ;
323
+ const struct pubkey * fronting_only ;
323
324
void * arg ;
324
325
};
325
326
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
+
326
337
static struct command_result * listincoming_done (struct command * cmd ,
327
338
const char * method ,
328
339
const char * buf ,
@@ -367,6 +378,18 @@ static struct command_result *listincoming_done(struct command *cmd,
367
378
}
368
379
ci .feebase = feebase .millisatoshis ; /* Raw: feebase */
369
380
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
+
370
393
/* Don't pick a peer which is disconnected */
371
394
if (!enabled )
372
395
continue ;
@@ -392,6 +415,7 @@ static struct command_result *listincoming_done(struct command *cmd,
392
415
393
416
struct command_result * find_best_peer_ (struct command * cmd ,
394
417
int needed_feature ,
418
+ const struct pubkey * fronting_only ,
395
419
struct command_result * (* cb )(struct command * ,
396
420
const struct chaninfo * ,
397
421
void * ),
@@ -402,6 +426,7 @@ struct command_result *find_best_peer_(struct command *cmd,
402
426
data -> cb = cb ;
403
427
data -> arg = arg ;
404
428
data -> needed_feature = needed_feature ;
429
+ data -> fronting_only = fronting_only ;
405
430
req = jsonrpc_request_start (cmd , "listincoming" ,
406
431
listincoming_done , forward_error , data );
407
432
return send_outreq (req );
0 commit comments