@@ -17,6 +17,16 @@ static bool scid_in_arr(const struct short_channel_id *scidarr,
1717 return false;
1818}
1919
20+ static bool is_fronting_node (const struct lightningd * ld ,
21+ const struct node_id * node )
22+ {
23+ for (size_t i = 0 ; i < tal_count (ld -> fronting_nodes ); i ++ ) {
24+ if (node_id_eq (& ld -> fronting_nodes [i ], node ))
25+ return true;
26+ }
27+ return false;
28+ }
29+
2030struct routehint_candidate *
2131routehint_candidates (const tal_t * ctx ,
2232 struct lightningd * ld ,
@@ -62,7 +72,7 @@ routehint_candidates(const tal_t *ctx,
6272 struct routehint_candidate candidate ;
6373 struct amount_msat fee_base , htlc_max ;
6474 struct route_info * r ;
65- bool is_public ;
75+ bool is_public , is_fronting ;
6676
6777 r = tal (tmpctx , struct route_info );
6878
@@ -92,6 +102,17 @@ routehint_candidates(const tal_t *ctx,
92102 json_tok_full (buf , toks ));
93103 }
94104
105+ /* If they specify fronting nodes, always use them. */
106+ if (tal_count (ld -> fronting_nodes )) {
107+ if (!is_fronting_node (ld , & r -> pubkey )) {
108+ log_debug (ld -> log , "%s: not a fronting node" ,
109+ fmt_node_id (tmpctx , & r -> pubkey ));
110+ continue ;
111+ }
112+ is_fronting = true;
113+ } else
114+ is_fronting = false;
115+
95116 /* Note: listincoming returns real scid or local alias if no real scid. */
96117 candidate .c = any_channel_by_scid (ld , r -> short_channel_id , true);
97118 if (!candidate .c ) {
@@ -133,6 +154,10 @@ routehint_candidates(const tal_t *ctx,
133154 if (expose_all_private != NULL && * expose_all_private )
134155 is_public = true;
135156
157+ /* Also, consider fronting nodes public */
158+ if (is_fronting )
159+ is_public = true;
160+
136161 r -> fee_base_msat = fee_base .millisatoshis ; /* Raw: route_info */
137162 /* Could wrap: if so ignore */
138163 if (!amount_msat_eq (amount_msat (r -> fee_base_msat ), fee_base )) {
@@ -156,7 +181,7 @@ routehint_candidates(const tal_t *ctx,
156181 continue ;
157182 }
158183 /* If they give us a hint, we use even if capacity 0 */
159- } else if (amount_msat_is_zero (capacity )) {
184+ } else if (! is_fronting && amount_msat_is_zero (capacity )) {
160185 log_debug (ld -> log , "%s: deadend" ,
161186 fmt_short_channel_id (tmpctx ,
162187 r -> short_channel_id ));
@@ -166,8 +191,8 @@ routehint_candidates(const tal_t *ctx,
166191 continue ;
167192 }
168193
169- /* Is it offline? */
170- if (candidate .c -> owner == NULL ) {
194+ /* Is it offline? Leave it if it's fronting. */
195+ if (! is_fronting && candidate .c -> owner == NULL ) {
171196 log_debug (ld -> log , "%s: offline" ,
172197 fmt_short_channel_id (tmpctx ,
173198 r -> short_channel_id ));
0 commit comments