| 868 | } |
| 869 | |
| 870 | void channel_cleanup_commands(struct channel *channel, const char *why) |
| 871 | { |
| 872 | if (channel->open_attempt) { |
| 873 | struct open_attempt *oa = channel->open_attempt; |
| 874 | if (oa->cmd) { |
| 875 | /* If we requested this be aborted, it's a success */ |
| 876 | if (oa->aborted) { |
| 877 | struct json_stream *response; |
| 878 | response = json_stream_success(oa->cmd); |
| 879 | json_add_channel_id(response, |
| 880 | "channel_id", |
| 881 | &channel->cid); |
| 882 | json_add_bool(response, "channel_canceled", |
| 883 | list_empty(&channel->inflights)); |
| 884 | json_add_string(response, "reason", why); |
| 885 | was_pending(command_success(oa->cmd, response)); |
| 886 | } else |
| 887 | was_pending(command_fail(oa->cmd, LIGHTNINGD, |
| 888 | "%s", why)); |
| 889 | } |
| 890 | notify_channel_open_failed(channel->peer->ld, &channel->cid); |
| 891 | channel->open_attempt = tal_free(channel->open_attempt); |
| 892 | } |
| 893 | |
| 894 | if (channel->openchannel_signed_cmd) { |
| 895 | was_pending(command_fail(channel->openchannel_signed_cmd, |
| 896 | LIGHTNINGD, "%s", why)); |
| 897 | channel->openchannel_signed_cmd = NULL; |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | void channel_internal_error(struct channel *channel, const char *fmt, ...) |
| 902 | { |
no test coverage detected