From 548eaeccdc3d06f73e12e47cb7f1e9b5928863ee Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Tue, 5 Sep 2023 11:47:00 +0200 Subject: [PATCH] multi: use "bitcoin" chain name constant Make use of the `bitcoinChainName` constant instead of re-writing the "bitcoin" string. --- cmd/lncli/main.go | 5 +++-- config.go | 4 ++-- lntest/node/config.go | 3 ++- lntest/node/harness_node.go | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index 63a7a4d6ca..8aeb904e81 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -15,6 +15,7 @@ import ( "syscall" "github.com/btcsuite/btcd/btcutil" + "github.com/lightningnetwork/lnd" "github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc" @@ -301,8 +302,8 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) { // lnddir/data/chain// in order to fetch the // macaroon that we need. macPath = filepath.Join( - lndDir, defaultDataDir, defaultChainSubDir, "bitcoin", - network, defaultMacaroonFilename, + lndDir, defaultDataDir, defaultChainSubDir, + lnd.BitcoinChainName, network, defaultMacaroonFilename, ) } diff --git a/config.go b/config.go index 9a604aa395..88e45e502c 100644 --- a/config.go +++ b/config.go @@ -259,7 +259,7 @@ var ( defaultBtcdDir = btcutil.AppDataDir(btcdBackendName, false) defaultBtcdRPCCertFile = filepath.Join(defaultBtcdDir, "rpc.cert") - defaultBitcoindDir = btcutil.AppDataDir("bitcoin", false) + defaultBitcoindDir = btcutil.AppDataDir(BitcoinChainName, false) defaultTorSOCKS = net.JoinHostPort("localhost", strconv.Itoa(defaultTorSOCKSPort)) defaultTorDNS = net.JoinHostPort(defaultTorDNSHost, strconv.Itoa(defaultTorDNSPort)) @@ -1808,7 +1808,7 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{}, daemonName = bitcoindBackendName confDir = conf.Dir confFile = conf.ConfigPath - confFileBase = "bitcoin" + confFileBase = BitcoinChainName // Check that cookie and credentials don't contradict each // other. diff --git a/lntest/node/config.go b/lntest/node/config.go index f044475e74..855325ebc9 100644 --- a/lntest/node/config.go +++ b/lntest/node/config.go @@ -11,6 +11,7 @@ import ( "sync/atomic" "github.com/btcsuite/btcd/chaincfg" + "github.com/lightningnetwork/lnd" "github.com/lightningnetwork/lnd/chanbackup" "github.com/lightningnetwork/lnd/kvdb/etcd" "github.com/lightningnetwork/lnd/lntest/wait" @@ -157,7 +158,7 @@ func (cfg BaseNodeConfig) DBPath() string { func (cfg BaseNodeConfig) ChanBackupPath() string { return filepath.Join( - cfg.DataDir, "chain", "bitcoin", + cfg.DataDir, "chain", lnd.BitcoinChainName, fmt.Sprintf( "%v/%v", cfg.NetParams.Name, chanbackup.DefaultBackupFileName, diff --git a/lntest/node/harness_node.go b/lntest/node/harness_node.go index d337f906f7..7502451162 100644 --- a/lntest/node/harness_node.go +++ b/lntest/node/harness_node.go @@ -18,6 +18,7 @@ import ( "time" "github.com/jackc/pgx/v4/pgxpool" + "github.com/lightningnetwork/lnd" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lntest/rpc" "github.com/lightningnetwork/lnd/lntest/wait" @@ -107,7 +108,7 @@ func NewHarnessNode(t *testing.T, cfg *BaseNodeConfig) (*HarnessNode, error) { cfg.TLSKeyPath = filepath.Join(cfg.BaseDir, "tls.key") networkDir := filepath.Join( - cfg.DataDir, "chain", "bitcoin", cfg.NetParams.Name, + cfg.DataDir, "chain", lnd.BitcoinChainName, cfg.NetParams.Name, ) cfg.AdminMacPath = filepath.Join(networkDir, "admin.macaroon") cfg.ReadMacPath = filepath.Join(networkDir, "readonly.macaroon")