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

Function json_disconnect

lightningd/peer_control.c:3509–3550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3507AUTODATA(json_command, &graceful_command);
3508
3509static struct command_result *json_disconnect(struct command *cmd,
3510 const char *buffer,
3511 const jsmntok_t *obj UNNEEDED,
3512 const jsmntok_t *params)
3513{
3514 struct disconnect_command *dc;
3515 struct peer *peer;
3516 struct channel *channel;
3517 bool *force;
3518
3519 if (!param_check(cmd, buffer, params,
3520 p_req("id", param_peer, &peer),
3521 p_opt_def("force", param_bool, &force, false),
3522 NULL))
3523 return command_param_failed();
3524
3525 if (peer->connected == PEER_DISCONNECTED) {
3526 return command_fail(cmd, LIGHTNINGD, "Peer not connected");
3527 }
3528
3529 channel = peer_any_channel_bystate(peer, channel_state_wants_peercomms,
3530 NULL);
3531 if (channel && !*force) {
3532 return command_fail(cmd, LIGHTNINGD,
3533 "Peer has (at least one) channel in state %s",
3534 channel_state_name(channel));
3535 }
3536
3537 if (command_check_only(cmd))
3538 return command_check_done(cmd);
3539
3540 force_peer_disconnect(cmd->ld, peer, "disconnect command");
3541
3542 /* Connectd tells us when it's finally disconnected */
3543 dc = tal(cmd, struct disconnect_command);
3544 dc->cmd = cmd;
3545 dc->id = peer->id;
3546 list_add_tail(&cmd->ld->disconnect_commands, &dc->list);
3547 tal_add_destructor(dc, destroy_disconnect_command);
3548
3549 return command_still_pending(cmd);
3550}
3551
3552static const struct json_command disconnect_command = {
3553 "disconnect",

Callers

nothing calls this directly

Calls 9

param_checkFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
peer_any_channel_bystateFunction · 0.70
channel_state_nameFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70
force_peer_disconnectFunction · 0.70
command_still_pendingFunction · 0.70

Tested by

no test coverage detected