| 15 | #endif |
| 16 | |
| 17 | struct 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 | |
| 35 | function_fail: |
| 36 | return tal_free(amounts); |
| 37 | } |
| 38 | |
| 39 | const char *fmt_flows(const tal_t *ctx, const struct gossmap *gossmap, |
| 40 | struct chan_extra_map *chan_extra_map, |