We failed to find a flow at all. Why? */
| 216 | |
| 217 | /* We failed to find a flow at all. Why? */ |
| 218 | const char *explain_failure(const tal_t *ctx, |
| 219 | const struct route_query *rq, |
| 220 | const struct gossmap_node *srcnode, |
| 221 | const struct gossmap_node *dstnode, |
| 222 | struct amount_msat amount) |
| 223 | { |
| 224 | const struct route_hop *hops; |
| 225 | const struct dijkstra *dij; |
| 226 | char *path; |
| 227 | const char *cap_check; |
| 228 | const char *explanation; |
| 229 | struct short_channel_id_dir scidd; |
| 230 | struct gossmap_chan *c; |
| 231 | struct amount_msat rolling_amount; |
| 232 | struct amount_msat *path_amount; |
| 233 | |
| 234 | /* Do we have enough funds? */ |
| 235 | cap_check = check_capacity(ctx, rq, srcnode, OUT_OF_NODE, |
| 236 | amount, "source"); |
| 237 | if (cap_check) |
| 238 | return cap_check; |
| 239 | |
| 240 | /* Does destination have enough capacity? */ |
| 241 | cap_check = check_capacity(ctx, rq, dstnode, INTO_NODE, |
| 242 | amount, "destination"); |
| 243 | if (cap_check) |
| 244 | return cap_check; |
| 245 | |
| 246 | /* OK, fall back to telling them why didn't shortest path |
| 247 | * work. This covers the "but I have a direct channel!" |
| 248 | * case. */ |
| 249 | dij = dijkstra(tmpctx, rq->gossmap, dstnode, AMOUNT_MSAT(0), 0, |
| 250 | always_true, route_score_one, NULL); |
| 251 | hops = route_from_dijkstra(tmpctx, rq->gossmap, dij, srcnode, |
| 252 | AMOUNT_MSAT(0), 0); |
| 253 | if (!hops) |
| 254 | return child_log(ctx, LOG_INFORM, |
| 255 | "There is no connection between source and destination at all"); |
| 256 | |
| 257 | /* Description of shortest path */ |
| 258 | path = tal_strdup(tmpctx, ""); |
| 259 | for (size_t i = 0; i < tal_count(hops); i++) { |
| 260 | tal_append_fmt(&path, "%s%s", |
| 261 | i > 0 ? "->" : "", |
| 262 | fmt_short_channel_id(tmpctx, hops[i].scid)); |
| 263 | } |
| 264 | |
| 265 | path_amount = tal_arr(tmpctx, struct amount_msat, tal_count(hops)); |
| 266 | rolling_amount = amount; |
| 267 | for (size_t i = tal_count(hops) - 1; i < tal_count(hops); i--) { |
| 268 | scidd.scid = hops[i].scid; |
| 269 | scidd.dir = hops[i].direction; |
| 270 | c = gossmap_find_chan(rq->gossmap, &scidd.scid); |
| 271 | |
| 272 | path_amount[i] = rolling_amount; |
| 273 | if (!amount_msat_add_fee(&rolling_amount, |
| 274 | c->half[scidd.dir].base_fee, |
| 275 | c->half[scidd.dir].proportional_fee)) { |
no test coverage detected