MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_openchannel_abort

Function json_openchannel_abort

lightningd/dual_open_control.c:2389–2444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2387}
2388
2389static struct command_result *
2390json_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
2446static char *restart_dualopend(const tal_t *ctx, const struct lightningd *ld,

Callers

nothing calls this directly

Calls 9

param_checkFunction · 0.85
command_param_failedFunction · 0.70
channel_by_cidFunction · 0.70
command_failFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70
subd_send_msgFunction · 0.70
command_still_pendingFunction · 0.70
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected