2015-12-30 05:31:03 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/codegangsta/cli"
|
2016-01-16 21:45:54 +03:00
|
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
2015-12-30 05:31:03 +03:00
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
func fatal(err error) {
|
|
|
|
fmt.Fprintf(os.Stderr, "[lncli] %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getClient(ctx *cli.Context) lnrpc.LightningClient {
|
|
|
|
conn := getClientConn(ctx)
|
|
|
|
return lnrpc.NewLightningClient(conn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getClientConn(ctx *cli.Context) *grpc.ClientConn {
|
|
|
|
// TODO(roasbeef): macaroon based auth
|
2015-12-31 09:28:22 +03:00
|
|
|
// * http://www.grpc.io/docs/guides/auth.html
|
|
|
|
// * http://research.google.com/pubs/pub41892.html
|
|
|
|
// * https://github.com/go-macaroon/macaroon
|
2015-12-30 05:31:03 +03:00
|
|
|
opts := []grpc.DialOption{grpc.WithInsecure()}
|
|
|
|
|
|
|
|
conn, err := grpc.Dial(ctx.GlobalString("rpcserver"), opts...)
|
|
|
|
if err != nil {
|
|
|
|
fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return conn
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "lncli"
|
|
|
|
app.Version = "0.1"
|
|
|
|
app.Usage = "control plane for your LN daemon"
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "rpcserver",
|
2016-03-23 04:47:10 +03:00
|
|
|
Value: "localhost:10009",
|
2016-01-16 21:45:54 +03:00
|
|
|
Usage: "host:port of ln daemon",
|
2015-12-30 05:31:03 +03:00
|
|
|
},
|
|
|
|
}
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
NewAddressCommand,
|
|
|
|
SendManyCommand,
|
2016-06-29 21:29:21 +03:00
|
|
|
SendCoinsCommand,
|
2016-01-17 06:10:29 +03:00
|
|
|
ConnectCommand,
|
2016-06-21 22:35:07 +03:00
|
|
|
OpenChannelCommand,
|
|
|
|
CloseChannelCommand,
|
|
|
|
ListPeersCommand,
|
|
|
|
WalletBalanceCommand,
|
2015-12-30 23:19:09 +03:00
|
|
|
ShellCommand,
|
2016-07-06 04:58:41 +03:00
|
|
|
GetInfoCommand,
|
2015-12-30 05:31:03 +03:00
|
|
|
}
|
2016-01-17 06:10:29 +03:00
|
|
|
|
2015-12-30 05:31:03 +03:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
fatal(err)
|
|
|
|
}
|
|
|
|
}
|