2017-11-28 01:12:09 +01:00
|
|
|
// Copyright (c) 2013-2017 The btcsuite developers
|
|
|
|
// Copyright (c) 2015-2016 The Decred developers
|
|
|
|
// Copyright (C) 2015-2017 The Lightning Network Developers
|
|
|
|
|
2015-12-30 03:31:03 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-01-07 18:48:02 +01:00
|
|
|
"crypto/tls"
|
2015-12-30 03:31:03 +01:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2017-07-26 01:22:06 +02:00
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
2020-09-04 16:06:12 +02:00
|
|
|
"syscall"
|
2015-12-30 03:31:03 +01:00
|
|
|
|
2018-07-31 09:17:17 +02:00
|
|
|
"github.com/btcsuite/btcutil"
|
2018-09-20 12:26:38 +02:00
|
|
|
"github.com/lightningnetwork/lnd/build"
|
2018-05-23 15:41:36 +02:00
|
|
|
"github.com/lightningnetwork/lnd/lncfg"
|
2016-01-16 19:45:54 +01:00
|
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
2017-08-18 03:51:33 +02:00
|
|
|
"github.com/lightningnetwork/lnd/macaroons"
|
2016-07-26 19:42:35 +02:00
|
|
|
"github.com/urfave/cli"
|
2015-12-30 03:31:03 +01:00
|
|
|
|
2021-09-24 09:21:32 +02:00
|
|
|
"golang.org/x/term"
|
2015-12-30 03:31:03 +01:00
|
|
|
"google.golang.org/grpc"
|
2017-07-26 01:22:06 +02:00
|
|
|
"google.golang.org/grpc/credentials"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-08-22 21:31:47 +02:00
|
|
|
defaultDataDir = "data"
|
|
|
|
defaultChainSubDir = "chain"
|
2017-08-18 03:51:33 +02:00
|
|
|
defaultTLSCertFilename = "tls.cert"
|
|
|
|
defaultMacaroonFilename = "admin.macaroon"
|
2018-07-31 10:29:12 +02:00
|
|
|
defaultRPCPort = "10009"
|
|
|
|
defaultRPCHostPort = "localhost:" + defaultRPCPort
|
2017-07-26 01:22:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-08-22 21:31:47 +02:00
|
|
|
defaultLndDir = btcutil.AppDataDir("lnd", false)
|
|
|
|
defaultTLSCertPath = filepath.Join(defaultLndDir, defaultTLSCertFilename)
|
2018-12-25 20:09:34 +01:00
|
|
|
|
|
|
|
// maxMsgRecvSize is the largest message our client will receive. We
|
2019-11-15 16:21:20 +01:00
|
|
|
// set this to 200MiB atm.
|
2022-01-10 23:11:42 +01:00
|
|
|
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize)
|
2015-12-30 03:31:03 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func fatal(err error) {
|
|
|
|
fmt.Fprintf(os.Stderr, "[lncli] %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2017-10-12 11:42:06 +02:00
|
|
|
func getWalletUnlockerClient(ctx *cli.Context) (lnrpc.WalletUnlockerClient, func()) {
|
2018-02-01 01:04:56 +01:00
|
|
|
conn := getClientConn(ctx, true)
|
2017-10-12 11:42:06 +02:00
|
|
|
|
|
|
|
cleanUp := func() {
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return lnrpc.NewWalletUnlockerClient(conn), cleanUp
|
|
|
|
}
|
|
|
|
|
2021-02-09 15:20:18 +01:00
|
|
|
func getStateServiceClient(ctx *cli.Context) (lnrpc.StateClient, func()) {
|
|
|
|
conn := getClientConn(ctx, true)
|
|
|
|
|
|
|
|
cleanUp := func() {
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return lnrpc.NewStateClient(conn), cleanUp
|
|
|
|
}
|
|
|
|
|
2017-01-29 23:51:30 +01:00
|
|
|
func getClient(ctx *cli.Context) (lnrpc.LightningClient, func()) {
|
2018-02-01 01:04:56 +01:00
|
|
|
conn := getClientConn(ctx, false)
|
2017-01-29 23:51:30 +01:00
|
|
|
|
|
|
|
cleanUp := func() {
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return lnrpc.NewLightningClient(conn), cleanUp
|
2015-12-30 03:31:03 +01:00
|
|
|
}
|
|
|
|
|
2018-02-01 01:04:56 +01:00
|
|
|
func getClientConn(ctx *cli.Context, skipMacaroons bool) *grpc.ClientConn {
|
2020-09-04 16:06:12 +02:00
|
|
|
// First, we'll get the selected stored profile or an ephemeral one
|
|
|
|
// created from the global options in the CLI context.
|
2020-09-25 15:38:40 +02:00
|
|
|
profile, err := getGlobalOptions(ctx, skipMacaroons)
|
2018-08-24 02:48:41 +02:00
|
|
|
if err != nil {
|
2020-09-04 16:06:12 +02:00
|
|
|
fatal(fmt.Errorf("could not load global options: %v", err))
|
2018-08-24 02:48:41 +02:00
|
|
|
}
|
2018-02-24 21:59:22 +01:00
|
|
|
|
2019-01-07 18:48:02 +01:00
|
|
|
// Load the specified TLS certificate.
|
2020-09-04 16:06:12 +02:00
|
|
|
certPool, err := profile.cert()
|
2017-08-18 03:51:33 +02:00
|
|
|
if err != nil {
|
2020-09-04 16:06:12 +02:00
|
|
|
fatal(fmt.Errorf("could not create cert pool: %v", err))
|
2017-07-26 01:22:06 +02:00
|
|
|
}
|
2019-01-07 18:48:02 +01:00
|
|
|
|
|
|
|
// Build transport credentials from the certificate pool. If there is no
|
|
|
|
// certificate pool, we expect the server to use a non-self-signed
|
|
|
|
// certificate such as a certificate obtained from Let's Encrypt.
|
|
|
|
var creds credentials.TransportCredentials
|
|
|
|
if certPool != nil {
|
|
|
|
creds = credentials.NewClientTLSFromCert(certPool, "")
|
|
|
|
} else {
|
|
|
|
// Fallback to the system pool. Using an empty tls config is an
|
|
|
|
// alternative to x509.SystemCertPool(). That call is not
|
|
|
|
// supported on Windows.
|
|
|
|
creds = credentials.NewTLS(&tls.Config{})
|
|
|
|
}
|
2017-08-18 03:51:33 +02:00
|
|
|
|
|
|
|
// Create a dial options array.
|
|
|
|
opts := []grpc.DialOption{
|
|
|
|
grpc.WithTransportCredentials(creds),
|
2017-07-26 01:22:06 +02:00
|
|
|
}
|
2017-08-18 03:51:33 +02:00
|
|
|
|
2018-02-01 01:04:56 +01:00
|
|
|
// Only process macaroon credentials if --no-macaroons isn't set and
|
|
|
|
// if we're not skipping macaroon processing.
|
2020-09-04 16:06:12 +02:00
|
|
|
if !profile.NoMacaroons && !skipMacaroons {
|
|
|
|
// Find out which macaroon to load.
|
|
|
|
macName := profile.Macaroons.Default
|
|
|
|
if ctx.GlobalIsSet("macfromjar") {
|
|
|
|
macName = ctx.GlobalString("macfromjar")
|
|
|
|
}
|
|
|
|
var macEntry *macaroonEntry
|
|
|
|
for _, entry := range profile.Macaroons.Jar {
|
|
|
|
if entry.Name == macName {
|
|
|
|
macEntry = entry
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if macEntry == nil {
|
|
|
|
fatal(fmt.Errorf("macaroon with name '%s' not found "+
|
|
|
|
"in profile", macName))
|
2017-08-18 03:51:33 +02:00
|
|
|
}
|
2018-08-24 02:48:41 +02:00
|
|
|
|
2020-09-04 16:06:12 +02:00
|
|
|
// Get and possibly decrypt the specified macaroon.
|
|
|
|
//
|
|
|
|
// TODO(guggero): Make it possible to cache the password so we
|
|
|
|
// don't need to ask for it every time.
|
|
|
|
mac, err := macEntry.loadMacaroon(readPassword)
|
|
|
|
if err != nil {
|
|
|
|
fatal(fmt.Errorf("could not load macaroon: %v", err))
|
2017-08-18 03:51:33 +02:00
|
|
|
}
|
|
|
|
|
2017-09-02 02:45:14 +02:00
|
|
|
macConstraints := []macaroons.Constraint{
|
|
|
|
// We add a time-based constraint to prevent replay of the
|
|
|
|
// macaroon. It's good for 60 seconds by default to make up for
|
|
|
|
// any discrepancy between client and server clocks, but leaking
|
|
|
|
// the macaroon before it becomes invalid makes it possible for
|
|
|
|
// an attacker to reuse the macaroon. In addition, the validity
|
|
|
|
// time of the macaroon is extended by the time the server clock
|
|
|
|
// is behind the client clock, or shortened by the time the
|
|
|
|
// server clock is ahead of the client clock (or invalid
|
|
|
|
// altogether if, in the latter case, this time is more than 60
|
|
|
|
// seconds).
|
|
|
|
// TODO(aakselrod): add better anti-replay protection.
|
2020-09-04 16:06:12 +02:00
|
|
|
macaroons.TimeoutConstraint(profile.Macaroons.Timeout),
|
2017-09-02 02:45:14 +02:00
|
|
|
|
2017-09-02 02:46:27 +02:00
|
|
|
// Lock macaroon down to a specific IP address.
|
2020-09-04 16:06:12 +02:00
|
|
|
macaroons.IPLockConstraint(profile.Macaroons.IP),
|
2017-09-02 02:46:27 +02:00
|
|
|
|
2017-09-02 02:45:14 +02:00
|
|
|
// ... Add more constraints if needed.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply constraints to the macaroon.
|
2020-09-04 16:06:12 +02:00
|
|
|
constrainedMac, err := macaroons.AddConstraints(
|
|
|
|
mac, macConstraints...,
|
|
|
|
)
|
2017-09-13 22:44:05 +02:00
|
|
|
if err != nil {
|
|
|
|
fatal(err)
|
|
|
|
}
|
2017-08-18 03:51:33 +02:00
|
|
|
|
|
|
|
// Now we append the macaroon credentials to the dial options.
|
2021-08-12 16:07:18 +02:00
|
|
|
cred, err := macaroons.NewMacaroonCredential(constrainedMac)
|
|
|
|
if err != nil {
|
|
|
|
fatal(fmt.Errorf("error cloning mac: %v", err))
|
|
|
|
}
|
2017-09-02 02:45:14 +02:00
|
|
|
opts = append(opts, grpc.WithPerRPCCredentials(cred))
|
2017-07-26 01:22:06 +02:00
|
|
|
}
|
2015-12-30 03:31:03 +01:00
|
|
|
|
2018-05-23 15:41:36 +02:00
|
|
|
// We need to use a custom dialer so we can also connect to unix sockets
|
|
|
|
// and not just TCP addresses.
|
2018-12-25 20:09:34 +01:00
|
|
|
genericDialer := lncfg.ClientAddressDialer(defaultRPCPort)
|
2019-12-17 13:37:25 +01:00
|
|
|
opts = append(opts, grpc.WithContextDialer(genericDialer))
|
2018-12-25 20:09:34 +01:00
|
|
|
opts = append(opts, grpc.WithDefaultCallOptions(maxMsgRecvSize))
|
|
|
|
|
2020-09-04 16:06:12 +02:00
|
|
|
conn, err := grpc.Dial(profile.RPCServer, opts...)
|
2015-12-30 03:31:03 +01:00
|
|
|
if err != nil {
|
2018-08-24 02:48:41 +02:00
|
|
|
fatal(fmt.Errorf("unable to connect to RPC server: %v", err))
|
2015-12-30 03:31:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return conn
|
|
|
|
}
|
|
|
|
|
2018-08-24 02:48:41 +02:00
|
|
|
// extractPathArgs parses the TLS certificate and macaroon paths from the
|
|
|
|
// command.
|
|
|
|
func extractPathArgs(ctx *cli.Context) (string, string, error) {
|
2018-08-22 21:31:47 +02:00
|
|
|
// We'll start off by parsing the active chain and network. These are
|
|
|
|
// needed to determine the correct path to the macaroon when not
|
|
|
|
// specified.
|
|
|
|
chain := strings.ToLower(ctx.GlobalString("chain"))
|
|
|
|
switch chain {
|
|
|
|
case "bitcoin", "litecoin":
|
|
|
|
default:
|
2018-08-24 02:48:41 +02:00
|
|
|
return "", "", fmt.Errorf("unknown chain: %v", chain)
|
2018-08-22 21:31:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
network := strings.ToLower(ctx.GlobalString("network"))
|
|
|
|
switch network {
|
2020-12-24 16:46:13 +01:00
|
|
|
case "mainnet", "testnet", "regtest", "simnet", "signet":
|
2018-08-22 21:31:47 +02:00
|
|
|
default:
|
2018-08-24 02:48:41 +02:00
|
|
|
return "", "", fmt.Errorf("unknown network: %v", network)
|
2018-08-22 21:31:47 +02:00
|
|
|
}
|
|
|
|
|
2018-08-24 02:48:00 +02:00
|
|
|
// We'll now fetch the lnddir so we can make a decision on how to
|
|
|
|
// properly read the macaroons (if needed) and also the cert. This will
|
|
|
|
// either be the default, or will have been overwritten by the end
|
|
|
|
// user.
|
2020-09-04 16:06:11 +02:00
|
|
|
lndDir := lncfg.CleanAndExpandPath(ctx.GlobalString("lnddir"))
|
2018-08-22 21:31:47 +02:00
|
|
|
|
2018-08-24 02:48:00 +02:00
|
|
|
// If the macaroon path as been manually provided, then we'll only
|
|
|
|
// target the specified file.
|
|
|
|
var macPath string
|
|
|
|
if ctx.GlobalString("macaroonpath") != "" {
|
2020-09-04 16:06:11 +02:00
|
|
|
macPath = lncfg.CleanAndExpandPath(ctx.GlobalString("macaroonpath"))
|
2018-08-24 02:48:00 +02:00
|
|
|
} else {
|
|
|
|
// Otherwise, we'll go into the path:
|
|
|
|
// lnddir/data/chain/<chain>/<network> in order to fetch the
|
|
|
|
// macaroon that we need.
|
|
|
|
macPath = filepath.Join(
|
|
|
|
lndDir, defaultDataDir, defaultChainSubDir, chain,
|
|
|
|
network, defaultMacaroonFilename,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-09-04 16:06:11 +02:00
|
|
|
tlsCertPath := lncfg.CleanAndExpandPath(ctx.GlobalString("tlscertpath"))
|
2018-08-24 02:48:00 +02:00
|
|
|
|
|
|
|
// If a custom lnd directory was set, we'll also check if custom paths
|
|
|
|
// for the TLS cert and macaroon file were set as well. If not, we'll
|
|
|
|
// override their paths so they can be found within the custom lnd
|
|
|
|
// directory set. This allows us to set a custom lnd directory, along
|
|
|
|
// with custom paths to the TLS cert and macaroon file.
|
|
|
|
if lndDir != defaultLndDir {
|
|
|
|
tlsCertPath = filepath.Join(lndDir, defaultTLSCertFilename)
|
2018-08-22 21:31:47 +02:00
|
|
|
}
|
|
|
|
|
2018-08-24 02:48:41 +02:00
|
|
|
return tlsCertPath, macPath, nil
|
2018-08-22 21:31:47 +02:00
|
|
|
}
|
|
|
|
|
2021-03-11 01:29:50 +01:00
|
|
|
// checkNotBothSet accepts two flag names, a and b, and checks that only flag a
|
|
|
|
// or flag b can be set, but not both. It returns the name of the flag or an
|
|
|
|
// error.
|
|
|
|
func checkNotBothSet(ctx *cli.Context, a, b string) (string, error) {
|
|
|
|
if ctx.IsSet(a) && ctx.IsSet(b) {
|
|
|
|
return "", fmt.Errorf(
|
|
|
|
"either %s or %s should be set, but not both", a, b,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if ctx.IsSet(a) {
|
|
|
|
return a, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return b, nil
|
|
|
|
}
|
|
|
|
|
2015-12-30 03:31:03 +01:00
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "lncli"
|
2020-04-14 11:13:11 +02:00
|
|
|
app.Version = build.Version() + " commit=" + build.Commit
|
2016-12-28 00:45:10 +01:00
|
|
|
app.Usage = "control plane for your Lightning Network Daemon (lnd)"
|
2015-12-30 03:31:03 +01:00
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "rpcserver",
|
2018-07-31 10:29:12 +02:00
|
|
|
Value: defaultRPCHostPort,
|
2020-09-04 16:06:12 +02:00
|
|
|
Usage: "The host:port of LN daemon.",
|
2015-12-30 03:31:03 +01:00
|
|
|
},
|
2018-02-24 21:59:22 +01:00
|
|
|
cli.StringFlag{
|
2020-04-26 17:12:16 +02:00
|
|
|
Name: "lnddir",
|
|
|
|
Value: defaultLndDir,
|
|
|
|
Usage: "The path to lnd's base directory.",
|
|
|
|
TakesFile: true,
|
2018-02-24 21:59:22 +01:00
|
|
|
},
|
2017-07-26 01:22:06 +02:00
|
|
|
cli.StringFlag{
|
2020-04-26 17:12:16 +02:00
|
|
|
Name: "tlscertpath",
|
|
|
|
Value: defaultTLSCertPath,
|
|
|
|
Usage: "The path to lnd's TLS certificate.",
|
|
|
|
TakesFile: true,
|
2017-07-26 01:22:06 +02:00
|
|
|
},
|
2018-08-22 21:31:14 +02:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "chain, c",
|
2020-09-04 16:06:12 +02:00
|
|
|
Usage: "The chain lnd is running on, e.g. bitcoin.",
|
2018-08-22 21:31:14 +02:00
|
|
|
Value: "bitcoin",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "network, n",
|
2020-09-04 16:06:12 +02:00
|
|
|
Usage: "The network lnd is running on, e.g. mainnet, " +
|
2018-08-22 21:31:14 +02:00
|
|
|
"testnet, etc.",
|
|
|
|
Value: "mainnet",
|
|
|
|
},
|
2017-08-18 03:51:33 +02:00
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "no-macaroons",
|
2020-09-04 16:06:12 +02:00
|
|
|
Usage: "Disable macaroon authentication.",
|
2017-08-18 03:51:33 +02:00
|
|
|
},
|
|
|
|
cli.StringFlag{
|
2020-04-26 17:12:16 +02:00
|
|
|
Name: "macaroonpath",
|
|
|
|
Usage: "The path to macaroon file.",
|
|
|
|
TakesFile: true,
|
2017-08-18 03:51:33 +02:00
|
|
|
},
|
|
|
|
cli.Int64Flag{
|
|
|
|
Name: "macaroontimeout",
|
|
|
|
Value: 60,
|
2020-09-04 16:06:12 +02:00
|
|
|
Usage: "Anti-replay macaroon validity time in seconds.",
|
2017-08-18 03:51:33 +02:00
|
|
|
},
|
2017-09-02 02:46:27 +02:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "macaroonip",
|
2020-09-04 16:06:12 +02:00
|
|
|
Usage: "If set, lock macaroon to specific IP address.",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "profile, p",
|
|
|
|
Usage: "Instead of reading settings from command " +
|
|
|
|
"line parameters or using the default " +
|
|
|
|
"profile, use a specific profile. If " +
|
|
|
|
"a default profile is set, this flag can be " +
|
|
|
|
"set to an empty string to disable reading " +
|
|
|
|
"values from the profiles file.",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "macfromjar",
|
|
|
|
Usage: "Use this macaroon from the profile's " +
|
|
|
|
"macaroon jar instead of the default one. " +
|
|
|
|
"Can only be used if profiles are defined.",
|
2017-09-02 02:46:27 +02:00
|
|
|
},
|
2015-12-30 03:31:03 +01:00
|
|
|
}
|
|
|
|
app.Commands = []cli.Command{
|
2017-10-12 11:42:06 +02:00
|
|
|
createCommand,
|
2021-10-14 15:42:58 +02:00
|
|
|
createWatchOnlyCommand,
|
2017-10-12 11:42:06 +02:00
|
|
|
unlockCommand,
|
2018-04-20 09:14:51 +02:00
|
|
|
changePasswordCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
newAddressCommand,
|
2019-03-05 14:22:30 +01:00
|
|
|
estimateFeeCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
sendManyCommand,
|
|
|
|
sendCoinsCommand,
|
2018-09-27 15:49:44 +02:00
|
|
|
listUnspentCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
connectCommand,
|
2017-05-06 00:54:25 +02:00
|
|
|
disconnectCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
openChannelCommand,
|
2021-08-24 11:21:57 +02:00
|
|
|
batchOpenChannelCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
closeChannelCommand,
|
2018-01-24 03:34:29 +01:00
|
|
|
closeAllChannelsCommand,
|
2018-05-29 11:26:47 +02:00
|
|
|
abandonChannelCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
listPeersCommand,
|
|
|
|
walletBalanceCommand,
|
|
|
|
channelBalanceCommand,
|
|
|
|
getInfoCommand,
|
2020-06-09 08:47:17 +02:00
|
|
|
getRecoveryInfoCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
pendingChannelsCommand,
|
|
|
|
sendPaymentCommand,
|
2017-10-28 00:39:54 +02:00
|
|
|
payInvoiceCommand,
|
2018-01-25 05:19:40 +01:00
|
|
|
sendToRouteCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
addInvoiceCommand,
|
|
|
|
lookupInvoiceCommand,
|
|
|
|
listInvoicesCommand,
|
|
|
|
listChannelsCommand,
|
2018-05-24 11:35:53 +02:00
|
|
|
closedChannelsCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
listPaymentsCommand,
|
|
|
|
describeGraphCommand,
|
2020-03-19 11:14:28 +01:00
|
|
|
getNodeMetricsCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
getChanInfoCommand,
|
|
|
|
getNodeInfoCommand,
|
2017-03-21 03:01:57 +01:00
|
|
|
queryRoutesCommand,
|
2017-02-24 14:32:33 +01:00
|
|
|
getNetworkInfoCommand,
|
|
|
|
debugLevelCommand,
|
2018-02-07 04:11:11 +01:00
|
|
|
decodePayReqCommand,
|
2017-03-09 05:44:32 +01:00
|
|
|
listChainTxnsCommand,
|
2017-05-11 23:55:56 +02:00
|
|
|
stopCommand,
|
2017-04-20 04:33:09 +02:00
|
|
|
signMessageCommand,
|
|
|
|
verifyMessageCommand,
|
2017-08-22 09:29:08 +02:00
|
|
|
feeReportCommand,
|
2017-12-16 23:13:17 +01:00
|
|
|
updateChannelPolicyCommand,
|
2018-02-28 07:24:37 +01:00
|
|
|
forwardingHistoryCommand,
|
2018-12-10 05:16:11 +01:00
|
|
|
exportChanBackupCommand,
|
2019-03-11 01:55:12 +01:00
|
|
|
verifyChanBackupCommand,
|
2018-12-10 05:16:11 +01:00
|
|
|
restoreChanBackupCommand,
|
2018-05-26 10:00:49 +02:00
|
|
|
bakeMacaroonCommand,
|
2020-07-23 18:37:13 +02:00
|
|
|
listMacaroonIDsCommand,
|
|
|
|
deleteMacaroonIDCommand,
|
2020-09-04 09:22:49 +02:00
|
|
|
listPermissionsCommand,
|
2020-09-04 09:22:50 +02:00
|
|
|
printMacaroonCommand,
|
2020-03-30 12:55:10 +02:00
|
|
|
trackPaymentCommand,
|
2020-04-10 02:07:05 +02:00
|
|
|
versionCommand,
|
2020-09-04 16:06:09 +02:00
|
|
|
profileSubCommand,
|
2021-02-09 15:20:18 +01:00
|
|
|
getStateCommand,
|
2021-09-07 13:41:51 +02:00
|
|
|
deletePaymentsCommand,
|
2021-05-31 10:03:47 +02:00
|
|
|
sendCustomCommand,
|
2021-05-31 12:06:48 +02:00
|
|
|
subscribeCustomCommand,
|
2020-04-26 17:13:06 +02:00
|
|
|
fishCompletionCommand,
|
2015-12-30 03:31:03 +01:00
|
|
|
}
|
2016-01-17 04:10:29 +01:00
|
|
|
|
2019-06-21 01:56:11 +02:00
|
|
|
// Add any extra commands determined by build flags.
|
2018-12-13 12:26:30 +01:00
|
|
|
app.Commands = append(app.Commands, autopilotCommands()...)
|
2018-11-26 14:19:43 +01:00
|
|
|
app.Commands = append(app.Commands, invoicesCommands()...)
|
2019-05-10 10:39:16 +02:00
|
|
|
app.Commands = append(app.Commands, routerCommands()...)
|
2019-05-17 04:53:42 +02:00
|
|
|
app.Commands = append(app.Commands, walletCommands()...)
|
2019-06-21 01:56:11 +02:00
|
|
|
app.Commands = append(app.Commands, watchtowerCommands()...)
|
2019-06-08 02:46:43 +02:00
|
|
|
app.Commands = append(app.Commands, wtclientCommands()...)
|
2022-01-19 21:33:15 +01:00
|
|
|
app.Commands = append(app.Commands, devCommands()...)
|
2018-12-13 12:26:30 +01:00
|
|
|
|
2015-12-30 03:31:03 +01:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2020-09-04 16:06:12 +02:00
|
|
|
|
|
|
|
// readPassword reads a password from the terminal. This requires there to be an
|
|
|
|
// actual TTY so passing in a password from stdin won't work.
|
|
|
|
func readPassword(text string) ([]byte, error) {
|
|
|
|
fmt.Print(text)
|
|
|
|
|
|
|
|
// The variable syscall.Stdin is of a different type in the Windows API
|
|
|
|
// that's why we need the explicit cast. And of course the linter
|
|
|
|
// doesn't like it either.
|
2021-09-24 09:21:32 +02:00
|
|
|
pw, err := term.ReadPassword(int(syscall.Stdin)) // nolint:unconvert
|
2020-09-04 16:06:12 +02:00
|
|
|
fmt.Println()
|
|
|
|
return pw, err
|
|
|
|
}
|