| 2869 | } |
| 2870 | |
| 2871 | static struct command_result *json_dev_reenable_commit(struct command *cmd, |
| 2872 | const char *buffer, |
| 2873 | const jsmntok_t *obj UNNEEDED, |
| 2874 | const jsmntok_t *params) |
| 2875 | { |
| 2876 | struct node_id *peerid; |
| 2877 | struct peer *peer; |
| 2878 | u8 *msg; |
| 2879 | struct channel *channel; |
| 2880 | bool more_than_one; |
| 2881 | |
| 2882 | if (!param(cmd, buffer, params, |
| 2883 | p_req("id", param_node_id, &peerid), |
| 2884 | NULL)) |
| 2885 | return command_param_failed(); |
| 2886 | |
| 2887 | peer = peer_by_id(cmd->ld, peerid); |
| 2888 | if (!peer) { |
| 2889 | return command_fail(cmd, LIGHTNINGD, |
| 2890 | "Could not find peer with that id"); |
| 2891 | } |
| 2892 | |
| 2893 | channel = peer_any_active_channel(peer, &more_than_one); |
| 2894 | if (!channel || more_than_one) { |
| 2895 | return command_fail(cmd, LIGHTNINGD, |
| 2896 | "Peer has no active channel"); |
| 2897 | } |
| 2898 | if (!channel->owner) { |
| 2899 | return command_fail(cmd, LIGHTNINGD, |
| 2900 | "Peer has no owner"); |
| 2901 | } |
| 2902 | |
| 2903 | if (!streq(channel->owner->name, "channeld")) { |
| 2904 | return command_fail(cmd, LIGHTNINGD, |
| 2905 | "Peer owned by %s", channel->owner->name); |
| 2906 | } |
| 2907 | |
| 2908 | msg = towire_channeld_dev_reenable_commit(channel); |
| 2909 | subd_req(peer, channel->owner, take(msg), -1, 0, |
| 2910 | dev_reenable_commit_finished, cmd); |
| 2911 | return command_still_pending(cmd); |
| 2912 | } |
| 2913 | |
| 2914 | static const struct json_command dev_reenable_commit = { |
| 2915 | "dev-reenable-commit", |
nothing calls this directly
no test coverage detected