mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 12:53:35 +02:00
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:
committed by
Olaoluwa Osuntokun
parent
1eaa522265
commit
5b7fe7de9e
@@ -250,6 +250,36 @@ func connectPeer(ctx *cli.Context) error {
|
|||||||
return nil
|
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
|
// TODO(roasbeef): change default number of confirmations
|
||||||
var openChannelCommand = cli.Command{
|
var openChannelCommand = cli.Command{
|
||||||
Name: "openchannel",
|
Name: "openchannel",
|
||||||
|
@@ -78,6 +78,7 @@ func main() {
|
|||||||
debugLevelCommand,
|
debugLevelCommand,
|
||||||
decodePayReqComamnd,
|
decodePayReqComamnd,
|
||||||
listChainTxnsCommand,
|
listChainTxnsCommand,
|
||||||
|
disconnectCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
Reference in New Issue
Block a user