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 authored and Olaoluwa Osuntokun committed 2017-05-05 14:24:25 -07:00
1 parent 1eaa522265
commit 5b7fe7de9e
2 files changed
+31

No files matched your search

+30
View File
@@ -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",
+1
View File
@@ -78,6 +78,7 @@ func main() {
debugLevelCommand,
decodePayReqComamnd,
listChainTxnsCommand,
disconnectCommand,
}
if err := app.Run(os.Args); err != nil {