lncli: add disconnect peer command

Issue: 139

This commit contains lncli command  which disconnects remote peers from
console by passing one string argument: pubKey.
This commit is contained in:
afederigo 2017-05-05 15:05:30 +03:00 committed by Olaoluwa Osuntokun
parent 1eaa522265
commit 5b7fe7de9e
2 changed files with 31 additions and 0 deletions

@ -250,6 +250,36 @@ func connectPeer(ctx *cli.Context) error {
return nil
}
var disconnectCommand = cli.Command{
Name: "disconnect",
Usage: "disconnect a remote lnd peer identified by public key",
ArgsUsage: "<pubkey>",
Action: disconnectPeer,
}
func disconnectPeer(ctx *cli.Context) error {
ctxb := context.Background()
client, cleanUp := getClient(ctx)
defer cleanUp()
pubKey := ctx.Args().First()
if pubKey == "" {
return fmt.Errorf("target address expected in format: <pubkey>")
}
req := &lnrpc.DisconnectPeerRequest{
PubKey: pubKey,
}
lnid, err := client.DisconnectPeer(ctxb, req)
if err != nil {
return err
}
printRespJSON(lnid)
return nil
}
// TODO(roasbeef): change default number of confirmations
var openChannelCommand = cli.Command{
Name: "openchannel",

@ -78,6 +78,7 @@ func main() {
debugLevelCommand,
decodePayReqComamnd,
listChainTxnsCommand,
disconnectCommand,
}
if err := app.Run(os.Args); err != nil {