@@ -12,6 +12,7 @@ struct channel_data {
12
12
struct amount_msat htlc_min , htlc_max , liquidity_max ;
13
13
u32 fee_base_msat , fee_proportional_millionths ;
14
14
struct short_channel_id_dir scidd ;
15
+ u32 idx ;
15
16
};
16
17
17
18
@@ -148,31 +149,36 @@ enum why_capped {
148
149
CAPPED_CAPACITY ,
149
150
};
150
151
151
- static void remove_htlc_min_violations (const tal_t * ctx , struct route_query * rq ,
152
- const struct flow * flow ,
153
- const struct channel_data * channels )
152
+ static const char *
153
+ remove_htlc_min_violations (const tal_t * ctx , struct route_query * rq ,
154
+ const struct flow * flow ,
155
+ const struct channel_data * channels )
154
156
{
155
-
157
+ const char * error_message = NULL ;
156
158
struct amount_msat msat = flow -> delivers ;
157
159
for (size_t i = tal_count (flow -> path ) - 1 ; i < tal_count (flow -> path );
158
160
i -- ) {
159
161
if (amount_msat_less (msat , channels [i ].htlc_min )) {
160
162
rq_log (
161
- ctx , rq , LOG_UNUSUAL ,
162
- "Sending %s across %s would violate htlc_min (~%s)" ,
163
+ ctx , rq , LOG_DBG ,
164
+ "Sending %s across %s would violate htlc_min "
165
+ "(~%s), disabling this channel" ,
163
166
fmt_amount_msat (ctx , msat ),
164
167
fmt_short_channel_id_dir (ctx , & channels [i ].scidd ),
165
168
fmt_amount_msat (ctx , channels [i ].htlc_min ));
169
+ bitmap_set_bit (rq -> disabled_chans , channels [i ].idx );
166
170
break ;
167
171
}
168
172
if (!amount_msat_add_fee (
169
173
& msat , channels [i ].fee_base_msat ,
170
174
channels [i ].fee_proportional_millionths )) {
171
- plugin_err (rq -> plugin , "%s: Adding fee to amount" ,
172
- __func__ );
173
- // TODO: fail this function and report to caller
175
+ error_message =
176
+ rq_log (ctx , rq , LOG_BROKEN ,
177
+ "%s: Adding fee to amount" , __func__ );
178
+ break ;
174
179
}
175
180
}
181
+ return error_message ;
176
182
}
177
183
178
184
/* Cache channel data along the path used by this flow. */
@@ -199,6 +205,8 @@ static struct channel_data *new_channel_path_cache(const tal_t *ctx,
199
205
path [i ].fee_proportional_millionths = h -> proportional_fee ;
200
206
path [i ].liquidity_max = known_max ;
201
207
path [i ].scidd = scidd ;
208
+ path [i ].idx = scidd .dir +
209
+ 2 * gossmap_chan_idx (rq -> gossmap , flow -> path [i ]);
202
210
}
203
211
return path ;
204
212
}
@@ -380,7 +388,8 @@ const char *refine_with_fees_and_limits(const tal_t *ctx,
380
388
struct flow * * * flows )
381
389
{
382
390
const tal_t * working_ctx = tal (ctx , tal_t );
383
- struct amount_msat * max_deliverable ;
391
+ const char * error_message = NULL ;
392
+ struct amount_msat * max_deliverable ;
384
393
struct amount_msat * min_deliverable ;
385
394
struct channel_data * * channel_mpp_cache ;
386
395
size_t * flows_index ;
@@ -423,8 +432,10 @@ const char *refine_with_fees_and_limits(const tal_t *ctx,
423
432
}
424
433
/* htlc_min is not met for this flow */
425
434
tal_arr_remove (& flows_index , i );
426
- remove_htlc_min_violations (working_ctx , rq , (* flows )[k ],
427
- channel_mpp_cache [k ]);
435
+ error_message = remove_htlc_min_violations (
436
+ working_ctx , rq , (* flows )[k ], channel_mpp_cache [k ]);
437
+ if (error_message )
438
+ goto fail ;
428
439
}
429
440
430
441
/* remove 0 amount flows if any */
@@ -451,4 +462,8 @@ const char *refine_with_fees_and_limits(const tal_t *ctx,
451
462
452
463
tal_free (working_ctx );
453
464
return NULL ;
465
+
466
+ fail :
467
+ tal_free (working_ctx );
468
+ return error_message ;
454
469
}
0 commit comments