2015-12-30 03:31:03 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2016-01-16 19:45:54 +01:00
|
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
2016-07-26 19:42:35 +02:00
|
|
|
"github.com/urfave/cli"
|
2015-12-30 03:31:03 +01: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 07:28:22 +01: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 03:31:03 +01: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 02:47:10 +01:00
|
|
|
Value: "localhost:10009",
|
2016-01-16 19:45:54 +01:00
|
|
|
Usage: "host:port of ln daemon",
|
2015-12-30 03:31:03 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
NewAddressCommand,
|
|
|
|
SendManyCommand,
|
2016-06-29 20:29:21 +02:00
|
|
|
SendCoinsCommand,
|
2016-01-17 04:10:29 +01:00
|
|
|
ConnectCommand,
|
2016-06-21 21:35:07 +02:00
|
|
|
OpenChannelCommand,
|
|
|
|
CloseChannelCommand,
|
|
|
|
ListPeersCommand,
|
|
|
|
WalletBalanceCommand,
|
2016-09-15 20:59:51 +02:00
|
|
|
ChannelBalanceCommand,
|
2015-12-30 21:19:09 +01:00
|
|
|
ShellCommand,
|
2016-07-06 03:58:41 +02:00
|
|
|
GetInfoCommand,
|
2016-07-08 00:35:58 +02:00
|
|
|
PendingChannelsCommand,
|
2016-07-13 02:47:24 +02:00
|
|
|
SendPaymentCommand,
|
2016-09-19 21:05:54 +02:00
|
|
|
AddInvoiceCommand,
|
|
|
|
LookupInvoiceCommand,
|
|
|
|
ListInvoicesCommand,
|
2016-07-15 13:02:59 +02:00
|
|
|
ShowRoutingTableCommand,
|
2015-12-30 03:31:03 +01:00
|
|
|
}
|
2016-01-17 04:10:29 +01:00
|
|
|
|
2015-12-30 03:31:03 +01:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
fatal(err)
|
|
|
|
}
|
|
|
|
}
|