| 2387 | } |
| 2388 | |
| 2389 | static struct command_result * |
| 2390 | json_openchannel_abort(struct command *cmd, |
| 2391 | const char *buffer, |
| 2392 | const jsmntok_t *obj UNNEEDED, |
| 2393 | const jsmntok_t *params) |
| 2394 | { |
| 2395 | struct channel_id *cid; |
| 2396 | struct channel *channel; |
| 2397 | u8 *msg; |
| 2398 | |
| 2399 | if (!param_check(cmd, buffer, params, |
| 2400 | p_req("channel_id", param_channel_id, &cid), |
| 2401 | NULL)) |
| 2402 | return command_param_failed(); |
| 2403 | |
| 2404 | channel = channel_by_cid(cmd->ld, cid); |
| 2405 | if (!channel) |
| 2406 | return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL, |
| 2407 | "Unknown channel %s", |
| 2408 | fmt_channel_id(tmpctx, cid)); |
| 2409 | |
| 2410 | if (!channel->owner) |
| 2411 | return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED, |
| 2412 | "Peer not connected"); |
| 2413 | |
| 2414 | if (!channel->open_attempt) { |
| 2415 | if (list_empty(&channel->inflights)) |
| 2416 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2417 | "Channel open not in progress"); |
| 2418 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2419 | "Sigs already exchanged, can't cancel"); |
| 2420 | } |
| 2421 | |
| 2422 | if (channel->open_attempt->cmd) |
| 2423 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2424 | "Another openchannel command" |
| 2425 | " is in progress"); |
| 2426 | |
| 2427 | if (channel->openchannel_signed_cmd) |
| 2428 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 2429 | "Already sent sigs, waiting for peer's"); |
| 2430 | |
| 2431 | if (command_check_only(cmd)) |
| 2432 | return command_check_done(cmd); |
| 2433 | |
| 2434 | /* Mark it as aborted so when we clean-up, we send the |
| 2435 | * correct response */ |
| 2436 | channel->open_attempt->aborted = true; |
| 2437 | channel->open_attempt->cmd = cmd; |
| 2438 | |
| 2439 | /* Tell dualopend to fail this channel */ |
| 2440 | msg = towire_dualopend_fail(NULL, "Abort requested"); |
| 2441 | subd_send_msg(channel->owner, take(msg)); |
| 2442 | |
| 2443 | return command_still_pending(cmd); |
| 2444 | } |
| 2445 | |
| 2446 | static char *restart_dualopend(const tal_t *ctx, const struct lightningd *ld, |
nothing calls this directly
no test coverage detected