2015-12-30 05:31:03 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2016-01-16 21:45:54 +03:00
|
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
2016-07-26 20:42:35 +03:00
|
|
|
"github.com/urfave/cli"
|
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"
|
2016-12-28 02:45:10 +03:00
|
|
|
app.Usage = "control plane for your Lightning Network Daemon (lnd)"
|
2015-12-30 05:31:03 +03:00
|
|
|
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,
|
2016-09-15 21:59:51 +03:00
|
|
|
ChannelBalanceCommand,
|
2016-07-06 04:58:41 +03:00
|
|
|
GetInfoCommand,
|
2016-07-08 01:35:58 +03:00
|
|
|
PendingChannelsCommand,
|
2016-07-13 03:47:24 +03:00
|
|
|
SendPaymentCommand,
|
2016-09-19 22:05:54 +03:00
|
|
|
AddInvoiceCommand,
|
|
|
|
LookupInvoiceCommand,
|
|
|
|
ListInvoicesCommand,
|
2016-09-26 06:04:58 +03:00
|
|
|
ListChannelsCommand,
|
2016-12-05 14:59:36 +03:00
|
|
|
ListPaymentsCommand,
|
2016-12-28 02:45:10 +03:00
|
|
|
DescribeGraphCommand,
|
|
|
|
GetChanInfoCommand,
|
|
|
|
GetNodeInfoCommand,
|
|
|
|
QueryRouteCommand,
|
|
|
|
GetNetworkInfoCommand,
|
2017-01-15 05:19:02 +03:00
|
|
|
DebugLevel,
|
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)
|
|
|
|
}
|
|
|
|
}
|