| 1304 | } |
| 1305 | |
| 1306 | static bool check_htlc_max_limits(struct route_query *rq, struct flow **flows) |
| 1307 | { |
| 1308 | |
| 1309 | for (size_t k = 0; k < tal_count(flows); k++) { |
| 1310 | struct flow *flow = flows[k]; |
| 1311 | size_t pathlen = tal_count(flow->path); |
| 1312 | struct amount_msat hop_amt = flow->delivers; |
| 1313 | for (size_t i = pathlen - 1; i < pathlen; i--) { |
| 1314 | const struct half_chan *h = flow_edge(flow, i); |
| 1315 | struct short_channel_id_dir scidd; |
| 1316 | |
| 1317 | get_scidd(rq->gossmap, flow, i, &scidd); |
| 1318 | struct amount_msat htlc_max = |
| 1319 | get_chan_htlc_max(rq, flow->path[i], &scidd); |
| 1320 | if (amount_msat_greater(hop_amt, htlc_max)) |
| 1321 | return false; |
| 1322 | |
| 1323 | if (!amount_msat_add_fee(&hop_amt, h->base_fee, |
| 1324 | h->proportional_fee)) |
| 1325 | abort(); |
| 1326 | } |
| 1327 | } |
| 1328 | return true; |
| 1329 | } |
| 1330 | |
| 1331 | /* FIXME: add extra constraint maximum route length, use an activation |
| 1332 | * probability cost for each channel. Recall that every activation cost, eg. |
no test coverage detected