| 2443 | AUTODATA(json_command, &waitblockheight_command); |
| 2444 | |
| 2445 | static struct command_result *param_channel_or_all(struct command *cmd, |
| 2446 | const char *name, |
| 2447 | const char *buffer, |
| 2448 | const jsmntok_t *tok, |
| 2449 | struct channel ***channels) |
| 2450 | { |
| 2451 | struct command_result *res; |
| 2452 | struct peer *peer; |
| 2453 | |
| 2454 | /* early return the easy case */ |
| 2455 | if (json_tok_streq(buffer, tok, "all")) { |
| 2456 | *channels = NULL; |
| 2457 | return NULL; |
| 2458 | } |
| 2459 | |
| 2460 | /* Find channels by peer_id */ |
| 2461 | peer = peer_from_json(cmd->ld, buffer, tok); |
| 2462 | if (peer) { |
| 2463 | struct channel *channel; |
| 2464 | *channels = tal_arr(cmd, struct channel *, 0); |
| 2465 | list_for_each(&peer->channels, channel, list) { |
| 2466 | if (channel->state != CHANNELD_NORMAL |
| 2467 | && channel->state != CHANNELD_AWAITING_LOCKIN |
| 2468 | && channel->state != DUALOPEND_AWAITING_LOCKIN) |
| 2469 | continue; |
| 2470 | |
| 2471 | tal_arr_expand(channels, channel); |
| 2472 | } |
| 2473 | if (tal_count(*channels) == 0) |
| 2474 | return command_fail(cmd, LIGHTNINGD, |
| 2475 | "Could not find any active channels of peer with that id"); |
| 2476 | return NULL; |
| 2477 | /* Find channel by id or scid */ |
| 2478 | } else { |
| 2479 | struct channel *channel; |
| 2480 | res = command_find_channel(cmd, buffer, tok, &channel); |
| 2481 | if (res) |
| 2482 | return res; |
| 2483 | /* check channel is found and in valid state */ |
| 2484 | if (!channel) |
| 2485 | return command_fail(cmd, LIGHTNINGD, |
| 2486 | "Could not find channel with that id"); |
| 2487 | *channels = tal_arr(cmd, struct channel *, 1); |
| 2488 | (*channels)[0] = channel; |
| 2489 | return NULL; |
| 2490 | } |
| 2491 | } |
| 2492 | |
| 2493 | /* Fee base is a u32, but it's convenient to let them specify it using |
| 2494 | * msat etc. suffix. */ |
nothing calls this directly
no test coverage detected