diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index b919cfc9..7517b22f 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -70,3 +70,24 @@ func sendMany(ctx *cli.Context) { printRespJson(txid) } + +var ConnectCommand = cli.Command{ + Name: "connect", + Usage: "connect to a remote lnd peer: @host", + Action: connectPeer, +} + +func connectPeer(ctx *cli.Context) { + ctxb := context.Background() + client := getClient(ctx) + + targetAddress := ctx.Args().Get(0) + req := &lnrpc.ConnectPeerRequest{targetAddress} + + lnid, err := client.ConnectPeer(ctxb, req) + if err != nil { + fatal(err) + } + + printRespJson(lnid) +} diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index 534aaf0d..32424063 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -55,11 +55,11 @@ func main() { app.Commands = []cli.Command{ NewAddressCommand, SendManyCommand, + ConnectCommand, ShellCommand, } + if err := app.Run(os.Args); err != nil { fatal(err) } - - // ctx := context.Background() }