| 2198 | } |
| 2199 | |
| 2200 | static struct command_result * |
| 2201 | json_openchannel_abort(struct command *cmd, |
| 2202 | const char *buffer, |
| 2203 | const jsmntok_t *obj UNNEEDED, |
| 2204 | const jsmntok_t *params) |
| 2205 | { |
| 2206 | struct channel_id *cid; |
| 2207 | struct channel *channel; |
| 2208 | u8 *msg; |
| 2209 | |
| 2210 | if (!param(cmd, buffer, params, |
| 2211 | p_req("channel_id", param_channel_id, &cid), |
| 2212 | NULL)) |
| 2213 | return command_param_failed(); |
| 2214 | |
| 2215 | channel = channel_by_cid(cmd->ld, cid); |
| 2216 | if (!channel) |
| 2217 | return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL, |
| 2218 | "Unknown channel %s", |
| 2219 | type_to_string(tmpctx, struct channel_id, |
| 2220 | cid)); |
| 2221 | |
| 2222 | if (!channel->owner) |
| 2223 | return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED, |
| 2224 | "Peer not connected"); |
| 2225 | |
| 2226 | if (!channel->open_attempt) { |
| 2227 | if (list_empty(&channel->inflights)) |
| 2228 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2229 | "Channel open not in progress"); |
| 2230 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2231 | "Sigs already exchanged, can't cancel"); |
| 2232 | } |
| 2233 | |
| 2234 | if (channel->open_attempt->cmd) |
| 2235 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2236 | "Another openchannel command" |
| 2237 | " is in progress"); |
| 2238 | |
| 2239 | if (channel->openchannel_signed_cmd) |
| 2240 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2241 | "Already sent sigs, waiting for peer's"); |
| 2242 | |
| 2243 | /* Mark it as aborted so when we clean-up, we send the |
| 2244 | * correct response */ |
| 2245 | channel->open_attempt->aborted = true; |
| 2246 | channel->open_attempt->cmd = cmd; |
| 2247 | |
| 2248 | /* Tell dualopend to fail this channel */ |
| 2249 | msg = towire_dualopend_fail(NULL, "Abort requested"); |
| 2250 | subd_send_msg(channel->owner, take(msg)); |
| 2251 | |
| 2252 | return command_still_pending(cmd); |
| 2253 | } |
| 2254 | |
| 2255 | static struct command_result * |
| 2256 | json_openchannel_bump(struct command *cmd, |
nothing calls this directly
no test coverage detected