lncli: add "connect" command

usage: lncli connect <lnid>@host:port

Currently one must specify port since we haven’t yet chosen an
“official” p2p port
This commit is contained in:
Olaoluwa Osuntokun 2016-01-16 19:10:29 -08:00
parent 3cb1ce050c
commit 701de388a0
2 changed files with 23 additions and 2 deletions

@ -70,3 +70,24 @@ func sendMany(ctx *cli.Context) {
printRespJson(txid)
}
var ConnectCommand = cli.Command{
Name: "connect",
Usage: "connect to a remote lnd peer: <lnid>@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)
}

@ -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()
}