2017-11-28 03:12:09 +03: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 05:31:03 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-01-07 20:48:02 +03:00
|
|
|
"crypto/tls"
|
2015-12-30 05:31:03 +03:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2017-07-26 02:22:06 +03:00
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
2020-09-04 17:06:12 +03:00
|
|
|
"syscall"
|
2015-12-30 05:31:03 +03:00
|
|
|
|
2018-07-31 10:17:17 +03:00
|
|
|
"github.com/btcsuite/btcutil"
|
2018-09-20 13:26:38 +03:00
|
|
|
"github.com/lightningnetwork/lnd/build"
|
2018-05-23 16:41:36 +03:00
|
|
|
"github.com/lightningnetwork/lnd/lncfg"
|
2016-01-16 21:45:54 +03:00
|
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
2017-08-18 04:51:33 +03:00
|
|
|
"github.com/lightningnetwork/lnd/macaroons"
|
2016-07-26 20:42:35 +03:00
|
|
|
"github.com/urfave/cli"
|
2015-12-30 05:31:03 +03:00
|
|
|
|
2020-09-04 17:06:12 +03:00
|
|
|
"golang.org/x/crypto/ssh/terminal"
|
2015-12-30 05:31:03 +03:00
|
|
|
"google.golang.org/grpc"
|
2017-07-26 02:22:06 +03:00
|
|
|
"google.golang.org/grpc/credentials"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-08-22 22:31:47 +03:00
|
|
|
defaultDataDir = "data"
|
|
|
|
defaultChainSubDir = "chain"
|
2017-08-18 04:51:33 +03:00
|
|
|
defaultTLSCertFilename = "tls.cert"
|
|
|
|
defaultMacaroonFilename = "admin.macaroon"
|
2018-07-31 11:29:12 +03:00
|
|
|
defaultRPCPort = "10009"
|
|
|
|
defaultRPCHostPort = "localhost:" + defaultRPCPort
|
2017-07-26 02:22:06 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-08-22 22:31:47 +03:00
|
|
|
defaultLndDir = btcutil.AppDataDir("lnd", false)
|
|
|
|
defaultTLSCertPath = filepath.Join(defaultLndDir, defaultTLSCertFilename)
|
2018-12-25 22:09:34 +03:00
|
|
|
|
|
|
|
// maxMsgRecvSize is the largest message our client will receive. We
|
2019-11-15 18:21:20 +03:00
|
|
|
// set this to 200MiB atm.
|
|
|
|
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
|
2015-12-30 05:31:03 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func fatal(err error) {
|
|
|
|
fmt.Fprintf(os.Stderr, "[lncli] %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2017-10-12 12:42:06 +03:00
|
|
|
func getWalletUnlockerClient(ctx *cli.Context) (lnrpc.WalletUnlockerClient, func()) {
|
2018-02-01 03:04:56 +03:00
|
|
|
conn := getClientConn(ctx, true)
|
2017-10-12 12:42:06 +03:00
|
|
|
|
|
|
|
cleanUp := func() {
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return lnrpc.NewWalletUnlockerClient(conn), cleanUp
|
|
|
|
}
|
|
|
|
|
2021-02-09 17:20:18 +03:00
|
|
|
func getStateServiceClient(ctx *cli.Context) (lnrpc.StateClient, func()) {
|
|
|
|
conn := getClientConn(ctx, true)
|
|
|
|
|
|
|
|
cleanUp := func() {
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return lnrpc.NewStateClient(conn), cleanUp
|
|
|
|
}
|
|
|
|
|
2017-01-30 01:51:30 +03:00
|
|
|
func getClient(ctx *cli.Context) (lnrpc.LightningClient, func()) {
|
2018-02-01 03:04:56 +03:00
|
|
|
conn := getClientConn(ctx, false)
|
2017-01-30 01:51:30 +03:00
|
|
|
|
|
|
|
cleanUp := func() {
|
|
|
|
conn.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
return lnrpc.NewLightningClient(conn), cleanUp
|
2015-12-30 05:31:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-01 03:04:56 +03:00
|
|
|
func getClientConn(ctx *cli.Context, skipMacaroons bool) *grpc.ClientConn {
|
2020-09-04 17:06:12 +03: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 16:38:40 +03:00
|
|
|
profile, err := getGlobalOptions(ctx, skipMacaroons)
|
2018-08-24 03:48:41 +03:00
|
|
|
if err != nil {
|
2020-09-04 17:06:12 +03:00
|
|
|
fatal(fmt.Errorf("could not load global options: %v", err))
|
2018-08-24 03:48:41 +03:00
|
|
|
}
|
2018-02-24 23:59:22 +03:00
|
|
|
|
2019-01-07 20:48:02 +03:00
|
|
|
// Load the specified TLS certificate.
|
2020-09-04 17:06:12 +03:00
|
|
|
certPool, err := profile.cert()
|
2017-08-18 04:51:33 +03:00
|
|
|
if err != nil {
|
2020-09-04 17:06:12 +03:00
|
|
|
fatal(fmt.Errorf("could not create cert pool: %v", err))
|
2017-07-26 02:22:06 +03:00
|
|
|
}
|
2019-01-07 20:48:02 +03: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 04:51:33 +03:00
|
|
|
|
|
|
|
// Create a dial options array.
|
|
|
|
opts := []grpc.DialOption{
|
|
|
|
grpc.WithTransportCredentials(creds),
|
2017-07-26 02:22:06 +03:00
|
|
|
}
|
2017-08-18 04:51:33 +03:00
|
|
|
|
2018-02-01 03:04:56 +03:00
|
|
|
// Only process macaroon credentials if --no-macaroons isn't set and
|
|
|
|
// if we're not skipping macaroon processing.
|
2020-09-04 17:06:12 +03: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 04:51:33 +03:00
|
|
|
}
|
2018-08-24 03:48:41 +03:00
|
|
|
|
2020-09-04 17:06:12 +03: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 04:51:33 +03:00
|
|
|
}
|
|
|
|
|
2017-09-02 03:45:14 +03: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 17:06:12 +03:00
|
|
|
macaroons.TimeoutConstraint(profile.Macaroons.Timeout),
|
2017-09-02 03:45:14 +03:00
|
|
|
|
2017-09-02 03:46:27 +03:00
|
|
|
// Lock macaroon down to a specific IP address.
|
2020-09-04 17:06:12 +03:00
|
|
|
macaroons.IPLockConstraint(profile.Macaroons.IP),
|
2017-09-02 03:46:27 +03:00
|
|
|
|
2017-09-02 03:45:14 +03:00
|
|
|
// ... Add more constraints if needed.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply constraints to the macaroon.
|
2020-09-04 17:06:12 +03:00
|
|
|
constrainedMac, err := macaroons.AddConstraints(
|
|
|
|
mac, macConstraints...,
|
|
|
|
)
|
2017-09-13 23:44:05 +03:00
|
|
|
if err != nil {
|
|
|
|
fatal(err)
|
|
|
|
}
|
2017-08-18 04:51:33 +03:00
|
|
|
|
|
|
|
// Now we append the macaroon credentials to the dial options.
|
2017-09-02 03:45:14 +03:00
|
|
|
cred := macaroons.NewMacaroonCredential(constrainedMac)
|
|
|
|
opts = append(opts, grpc.WithPerRPCCredentials(cred))
|
2017-07-26 02:22:06 +03:00
|
|
|
}
|
2015-12-30 05:31:03 +03:00
|
|
|
|
2018-05-23 16:41:36 +03:00
|
|
|
// We need to use a custom dialer so we can also connect to unix sockets
|
|
|
|
// and not just TCP addresses.
|
2018-12-25 22:09:34 +03:00
|
|
|
genericDialer := lncfg.ClientAddressDialer(defaultRPCPort)
|
2019-12-17 15:37:25 +03:00
|
|
|
opts = append(opts, grpc.WithContextDialer(genericDialer))
|
2018-12-25 22:09:34 +03:00
|
|
|
opts = append(opts, grpc.WithDefaultCallOptions(maxMsgRecvSize))
|
|
|
|
|
2020-09-04 17:06:12 +03:00
|
|
|
conn, err := grpc.Dial(profile.RPCServer, opts...)
|
2015-12-30 05:31:03 +03:00
|
|
|
if err != nil {
|
2018-08-24 03:48:41 +03:00
|
|
|
fatal(fmt.Errorf("unable to connect to RPC server: %v", err))
|
2015-12-30 05:31:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return conn
|
|
|
|
}
|
|
|
|
|
2018-08-24 03:48:41 +03:00
|
|
|
// extractPathArgs parses the TLS certificate and macaroon paths from the
|
|
|
|
// command.
|
|
|
|
func extractPathArgs(ctx *cli.Context) (string, string, error) {
|
2018-08-22 22:31:47 +03: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 03:48:41 +03:00
|
|
|
return "", "", fmt.Errorf("unknown chain: %v", chain)
|
2018-08-22 22:31:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
network := strings.ToLower(ctx.GlobalString("network"))
|
|
|
|
switch network {
|
2020-12-24 18:46:13 +03:00
|
|
|
case "mainnet", "testnet", "regtest", "simnet", "signet":
|
2018-08-22 22:31:47 +03:00
|
|
|
default:
|
2018-08-24 03:48:41 +03:00
|
|
|
return "", "", fmt.Errorf("unknown network: %v", network)
|
2018-08-22 22:31:47 +03:00
|
|
|
}
|
|
|
|
|
2018-08-24 03:48:00 +03: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 17:06:11 +03:00
|
|
|
lndDir := lncfg.CleanAndExpandPath(ctx.GlobalString("lnddir"))
|
2018-08-22 22:31:47 +03:00
|
|
|
|
2018-08-24 03:48:00 +03: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 17:06:11 +03:00
|
|
|
macPath = lncfg.CleanAndExpandPath(ctx.GlobalString("macaroonpath"))
|
2018-08-24 03:48:00 +03: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 17:06:11 +03:00
|
|
|
tlsCertPath := lncfg.CleanAndExpandPath(ctx.GlobalString("tlscertpath"))
|
2018-08-24 03:48:00 +03: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 22:31:47 +03:00
|
|
|
}
|
|
|
|
|
2018-08-24 03:48:41 +03:00
|
|
|
return tlsCertPath, macPath, nil
|
2018-08-22 22:31:47 +03:00
|
|
|
}
|
|
|
|
|
2021-03-11 03:29:50 +03: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 05:31:03 +03:00
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "lncli"
|
2020-04-14 12:13:11 +03:00
|
|
|
app.Version = build.Version() + " commit=" + build.Commit
|
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",
|
2018-07-31 11:29:12 +03:00
|
|
|
Value: defaultRPCHostPort,
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "The host:port of LN daemon.",
|
2015-12-30 05:31:03 +03:00
|
|
|
},
|
2018-02-24 23:59:22 +03:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "lnddir",
|
|
|
|
Value: defaultLndDir,
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "The path to lnd's base directory.",
|
2018-02-24 23:59:22 +03:00
|
|
|
},
|
2017-07-26 02:22:06 +03:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "tlscertpath",
|
|
|
|
Value: defaultTLSCertPath,
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "The path to lnd's TLS certificate.",
|
2017-07-26 02:22:06 +03:00
|
|
|
},
|
2018-08-22 22:31:14 +03:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "chain, c",
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "The chain lnd is running on, e.g. bitcoin.",
|
2018-08-22 22:31:14 +03:00
|
|
|
Value: "bitcoin",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "network, n",
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "The network lnd is running on, e.g. mainnet, " +
|
2018-08-22 22:31:14 +03:00
|
|
|
"testnet, etc.",
|
|
|
|
Value: "mainnet",
|
|
|
|
},
|
2017-08-18 04:51:33 +03:00
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "no-macaroons",
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "Disable macaroon authentication.",
|
2017-08-18 04:51:33 +03:00
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "macaroonpath",
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "The path to macaroon file.",
|
2017-08-18 04:51:33 +03:00
|
|
|
},
|
|
|
|
cli.Int64Flag{
|
|
|
|
Name: "macaroontimeout",
|
|
|
|
Value: 60,
|
2020-09-04 17:06:12 +03:00
|
|
|
Usage: "Anti-replay macaroon validity time in seconds.",
|
2017-08-18 04:51:33 +03:00
|
|
|
},
|
2017-09-02 03:46:27 +03:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "macaroonip",
|
2020-09-04 17:06:12 +03: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 03:46:27 +03:00
|
|
|
},
|
2015-12-30 05:31:03 +03:00
|
|
|
}
|
|
|
|
app.Commands = []cli.Command{
|
2017-10-12 12:42:06 +03:00
|
|
|
createCommand,
|
|
|
|
unlockCommand,
|
2018-04-20 10:14:51 +03:00
|
|
|
changePasswordCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
newAddressCommand,
|
2019-03-05 16:22:30 +03:00
|
|
|
estimateFeeCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
sendManyCommand,
|
|
|
|
sendCoinsCommand,
|
2018-09-27 16:49:44 +03:00
|
|
|
listUnspentCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
connectCommand,
|
2017-05-06 01:54:25 +03:00
|
|
|
disconnectCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
openChannelCommand,
|
|
|
|
closeChannelCommand,
|
2018-01-24 05:34:29 +03:00
|
|
|
closeAllChannelsCommand,
|
2018-05-29 12:26:47 +03:00
|
|
|
abandonChannelCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
listPeersCommand,
|
|
|
|
walletBalanceCommand,
|
|
|
|
channelBalanceCommand,
|
|
|
|
getInfoCommand,
|
2020-06-09 09:47:17 +03:00
|
|
|
getRecoveryInfoCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
pendingChannelsCommand,
|
|
|
|
sendPaymentCommand,
|
2017-10-28 01:39:54 +03:00
|
|
|
payInvoiceCommand,
|
2018-01-25 07:19:40 +03:00
|
|
|
sendToRouteCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
addInvoiceCommand,
|
|
|
|
lookupInvoiceCommand,
|
|
|
|
listInvoicesCommand,
|
|
|
|
listChannelsCommand,
|
2018-05-24 12:35:53 +03:00
|
|
|
closedChannelsCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
listPaymentsCommand,
|
|
|
|
describeGraphCommand,
|
2020-03-19 13:14:28 +03:00
|
|
|
getNodeMetricsCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
getChanInfoCommand,
|
|
|
|
getNodeInfoCommand,
|
2017-03-21 05:01:57 +03:00
|
|
|
queryRoutesCommand,
|
2017-02-24 16:32:33 +03:00
|
|
|
getNetworkInfoCommand,
|
|
|
|
debugLevelCommand,
|
2018-02-07 06:11:11 +03:00
|
|
|
decodePayReqCommand,
|
2017-03-09 07:44:32 +03:00
|
|
|
listChainTxnsCommand,
|
2017-05-12 00:55:56 +03:00
|
|
|
stopCommand,
|
2017-04-20 05:33:09 +03:00
|
|
|
signMessageCommand,
|
|
|
|
verifyMessageCommand,
|
2017-08-22 10:29:08 +03:00
|
|
|
feeReportCommand,
|
2017-12-17 01:13:17 +03:00
|
|
|
updateChannelPolicyCommand,
|
2018-02-28 09:24:37 +03:00
|
|
|
forwardingHistoryCommand,
|
2018-12-10 07:16:11 +03:00
|
|
|
exportChanBackupCommand,
|
2019-03-11 03:55:12 +03:00
|
|
|
verifyChanBackupCommand,
|
2018-12-10 07:16:11 +03:00
|
|
|
restoreChanBackupCommand,
|
2018-05-26 11:00:49 +03:00
|
|
|
bakeMacaroonCommand,
|
2020-07-23 19:37:13 +03:00
|
|
|
listMacaroonIDsCommand,
|
|
|
|
deleteMacaroonIDCommand,
|
2020-09-04 10:22:49 +03:00
|
|
|
listPermissionsCommand,
|
2020-09-04 10:22:50 +03:00
|
|
|
printMacaroonCommand,
|
2020-03-30 13:55:10 +03:00
|
|
|
trackPaymentCommand,
|
2020-04-10 03:07:05 +03:00
|
|
|
versionCommand,
|
2020-09-04 17:06:09 +03:00
|
|
|
profileSubCommand,
|
2021-02-09 17:20:18 +03:00
|
|
|
getStateCommand,
|
2015-12-30 05:31:03 +03:00
|
|
|
}
|
2016-01-17 06:10:29 +03:00
|
|
|
|
2019-06-21 02:56:11 +03:00
|
|
|
// Add any extra commands determined by build flags.
|
2018-12-13 14:26:30 +03:00
|
|
|
app.Commands = append(app.Commands, autopilotCommands()...)
|
2018-11-26 16:19:43 +03:00
|
|
|
app.Commands = append(app.Commands, invoicesCommands()...)
|
2019-05-10 11:39:16 +03:00
|
|
|
app.Commands = append(app.Commands, routerCommands()...)
|
2019-05-17 05:53:42 +03:00
|
|
|
app.Commands = append(app.Commands, walletCommands()...)
|
2019-06-21 02:56:11 +03:00
|
|
|
app.Commands = append(app.Commands, watchtowerCommands()...)
|
2019-06-08 03:46:43 +03:00
|
|
|
app.Commands = append(app.Commands, wtclientCommands()...)
|
2018-12-13 14:26:30 +03:00
|
|
|
|
2015-12-30 05:31:03 +03:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2020-09-04 17:06:12 +03: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.
|
|
|
|
pw, err := terminal.ReadPassword(int(syscall.Stdin)) // nolint:unconvert
|
|
|
|
fmt.Println()
|
|
|
|
return pw, err
|
|
|
|
}
|