| 2841 | AUTODATA(json_command, &dev_feerate_command); |
| 2842 | |
| 2843 | static struct command_result *json_dev_peer_shachain(struct command *cmd, |
| 2844 | const char *buffer, |
| 2845 | const jsmntok_t *obj UNNEEDED, |
| 2846 | const jsmntok_t *params) |
| 2847 | { |
| 2848 | struct sha256 *shachain_seed; |
| 2849 | struct node_id *id; |
| 2850 | struct peer *peer; |
| 2851 | struct channel *channel; |
| 2852 | const u8 *msg; |
| 2853 | bool more_than_one; |
| 2854 | |
| 2855 | if (!param_check(cmd, buffer, params, |
| 2856 | p_req("id", param_node_id, &id), |
| 2857 | p_req("seed", param_sha256, &shachain_seed), |
| 2858 | NULL)) |
| 2859 | return command_param_failed(); |
| 2860 | |
| 2861 | peer = peer_by_id(cmd->ld, id); |
| 2862 | if (!peer) |
| 2863 | return command_fail(cmd, LIGHTNINGD, "Peer not connected"); |
| 2864 | |
| 2865 | channel = peer_any_channel_bystate(peer, channel_state_can_add_htlc, &more_than_one); |
| 2866 | if (!channel || !channel->owner) |
| 2867 | return command_fail(cmd, LIGHTNINGD, "Peer bad state"); |
| 2868 | /* This is a dev command: fix the api if you need this! */ |
| 2869 | if (more_than_one) |
| 2870 | return command_fail(cmd, LIGHTNINGD, "More than one channel"); |
| 2871 | |
| 2872 | if (command_check_only(cmd)) |
| 2873 | return command_check_done(cmd); |
| 2874 | |
| 2875 | msg = towire_channeld_dev_peer_shachain(NULL, shachain_seed); |
| 2876 | subd_send_msg(channel->owner, take(msg)); |
| 2877 | |
| 2878 | return command_success(cmd, json_stream_success(cmd)); |
| 2879 | } |
| 2880 | |
| 2881 | static const struct json_command dev_peer_shachain_command = { |
| 2882 | "dev-peer-shachain", |
nothing calls this directly
no test coverage detected