diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 776dd36e8..0e10fdb80 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -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: "", + 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: ") + } + + 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", diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index 83275260d..16177e329 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -78,6 +78,7 @@ func main() { debugLevelCommand, decodePayReqComamnd, listChainTxnsCommand, + disconnectCommand, } if err := app.Run(os.Args); err != nil {