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

Function tal_flow_amounts

plugins/renepay/flow.c:17–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#endif
16
17struct amount_msat *tal_flow_amounts(const tal_t *ctx, const struct flow *flow,
18 bool compute_fees)
19{
20 const size_t pathlen = tal_count(flow->path);
21 struct amount_msat *amounts = tal_arr(ctx, struct amount_msat, pathlen);
22 amounts[pathlen - 1] = flow->amount;
23
24 for (int i = (int)pathlen - 2; i >= 0; i--) {
25 const struct half_chan *h = flow_edge(flow, i + 1);
26 amounts[i] = amounts[i + 1];
27 if (compute_fees &&
28 !amount_msat_add_fee(&amounts[i], h->base_fee,
29 h->proportional_fee))
30 goto function_fail;
31 }
32
33 return amounts;
34
35function_fail:
36 return tal_free(amounts);
37}
38
39const char *fmt_flows(const tal_t *ctx, const struct gossmap *gossmap,
40 struct chan_extra_map *chan_extra_map,

Callers 2

flowset_probabilityFunction · 0.85
mainFunction · 0.85

Calls 3

amount_msat_add_feeFunction · 0.85
tal_freeFunction · 0.85
flow_edgeFunction · 0.70

Tested by 1

mainFunction · 0.68