Browse Source

disconnect: add force option to disconnect even with a live channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
plugin-6
Rusty Russell 6 years ago
parent
commit
19ecf8c6fb
  1. 5
      contrib/pylightning/lightning/lightning.py
  2. 10
      lightningd/peer_control.c

5
contrib/pylightning/lightning/lightning.py

@ -480,12 +480,13 @@ class LightningRpc(UnixDomainSocketRpc):
payload={"id": peerid, "force": force}
)
def disconnect(self, peer_id):
def disconnect(self, peer_id, force=False):
"""
Disconnect from peer with {peer_id}
Disconnect from peer with {peer_id}, optional {force} even if has active channel
"""
payload = {
"id": peer_id,
"force": force,
}
return self.call("disconnect", payload)

10
lightningd/peer_control.c

@ -1044,9 +1044,11 @@ static void json_disconnect(struct command *cmd,
struct pubkey *id;
struct peer *peer;
struct channel *channel;
bool *force;
if (!param(cmd, buffer, params,
p_req("id", json_tok_pubkey, &id),
p_opt_def("force", json_tok_bool, &force, false),
NULL))
return;
@ -1057,6 +1059,12 @@ static void json_disconnect(struct command *cmd,
}
channel = peer_active_channel(peer);
if (channel) {
if (*force) {
channel_fail_transient(channel,
"disconnect command force=true");
command_success(cmd, null_response(cmd));
return;
}
command_fail(cmd, LIGHTNINGD, "Peer is in state %s",
channel_state_name(channel));
return;
@ -1073,7 +1081,7 @@ static void json_disconnect(struct command *cmd,
static const struct json_command disconnect_command = {
"disconnect",
json_disconnect,
"Disconnect from {id} that has previously been connected to using connect"
"Disconnect from {id} that has previously been connected to using connect; with {force} set, even if it has a current channel"
};
AUTODATA(json_command, &disconnect_command);

Loading…
Cancel
Save