We want to combine local knowledge to we know which are actually inactive! */
| 346 | |
| 347 | /* We want to combine local knowledge to we know which are actually inactive! */ |
| 348 | static struct command_result *listpeers_done(struct command *cmd, |
| 349 | const char *buf, |
| 350 | const jsmntok_t *result, |
| 351 | struct listchannels_opts *opts) |
| 352 | { |
| 353 | struct node_map *connected; |
| 354 | struct gossmap_chan *c; |
| 355 | struct json_stream *js; |
| 356 | struct gossmap *gossmap = get_gossmap(); |
| 357 | |
| 358 | connected = local_connected(opts, buf, result); |
| 359 | |
| 360 | js = jsonrpc_stream_success(cmd); |
| 361 | json_array_start(js, "channels"); |
| 362 | if (opts->scid) { |
| 363 | c = gossmap_find_chan(gossmap, opts->scid); |
| 364 | if (c) |
| 365 | json_add_halfchan(js, gossmap, connected, c, 3); |
| 366 | } else if (opts->source) { |
| 367 | struct gossmap_node *src; |
| 368 | |
| 369 | src = gossmap_find_node(gossmap, opts->source); |
| 370 | if (src) { |
| 371 | for (size_t i = 0; i < src->num_chans; i++) { |
| 372 | int dir; |
| 373 | c = gossmap_nth_chan(gossmap, src, i, &dir); |
| 374 | json_add_halfchan(js, gossmap, connected, |
| 375 | c, 1 << dir); |
| 376 | } |
| 377 | } |
| 378 | } else if (opts->destination) { |
| 379 | struct gossmap_node *dst; |
| 380 | |
| 381 | dst = gossmap_find_node(gossmap, opts->destination); |
| 382 | if (dst) { |
| 383 | for (size_t i = 0; i < dst->num_chans; i++) { |
| 384 | int dir; |
| 385 | c = gossmap_nth_chan(gossmap, dst, i, &dir); |
| 386 | json_add_halfchan(js, gossmap, connected, |
| 387 | c, 1 << !dir); |
| 388 | } |
| 389 | } |
| 390 | } else { |
| 391 | for (c = gossmap_first_chan(gossmap); |
| 392 | c; |
| 393 | c = gossmap_next_chan(gossmap, c)) { |
| 394 | json_add_halfchan(js, gossmap, connected, c, 3); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | json_array_end(js); |
| 399 | |
| 400 | return command_finished(cmd, js); |
| 401 | } |
| 402 | |
| 403 | static struct command_result *json_listchannels(struct command *cmd, |
| 404 | const char *buffer, |
nothing calls this directly
no test coverage detected