MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_htlc_max_limits

Function check_htlc_max_limits

plugins/askrene/child/mcf.c:1306–1329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304}
1305
1306static 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.

Callers 1

linear_routesFunction · 0.85

Calls 6

amount_msat_greaterFunction · 0.85
amount_msat_add_feeFunction · 0.85
abortFunction · 0.85
flow_edgeFunction · 0.70
get_sciddFunction · 0.70
get_chan_htlc_maxFunction · 0.70

Tested by

no test coverage detected