From 409d2c9a90de520fa6a7decf40e5fadd14e77306 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 30 Apr 2020 09:34:10 +0200 Subject: [PATCH] lnd+config: export config struct and LoadConfig As a preparation to be moved to the lncfg package, the main struct and functions related to configuration are exported. --- chainregistry.go | 2 +- config.go | 12 ++++++------ fundingmanager_test.go | 2 +- lnd.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/chainregistry.go b/chainregistry.go index 4f5320fa7..5e8e0e308 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -160,7 +160,7 @@ type chainControl struct { // full-node, another backed by a running bitcoind full-node, and the other // backed by a running neutrino light client instance. When running with a // neutrino light client instance, `neutrinoCS` must be non-nil. -func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB, +func newChainControlFromConfig(cfg *Config, chanDB *channeldb.DB, privateWalletPw, publicWalletPw []byte, birthday time.Time, recoveryWindow uint32, wallet *wallet.Wallet, neutrinoCS *neutrino.ChainService) (*chainControl, error) { diff --git a/config.go b/config.go index bc599a160..005d7e267 100644 --- a/config.go +++ b/config.go @@ -238,11 +238,11 @@ type torConfig struct { WatchtowerKeyPath string `long:"watchtowerkeypath" description:"The path to the private key of the watchtower onion service being created"` } -// config defines the configuration options for lnd. +// Config defines the configuration options for lnd. // -// See loadConfig for further details regarding the configuration +// See LoadConfig for further details regarding the configuration // loading+parsing process. -type config struct { +type Config struct { ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"` LndDir string `long:"lnddir" description:"The base directory that contains lnd's data, logs, configuration file, etc."` @@ -365,7 +365,7 @@ type config struct { AllowCircularRoute bool `long:"allow-circular-route" description:"If true, our node will allow htlc forwards that arrive and depart on the same channel."` } -// loadConfig initializes and parses the config using a config file and command +// LoadConfig initializes and parses the config using a config file and command // line options. // // The configuration proceeds as follows: @@ -373,8 +373,8 @@ type config struct { // 2) Pre-parse the command line to check for an alternative config file // 3) Load configuration file overwriting defaults with any specified options // 4) Parse CLI options and overwrite/add any specified options -func loadConfig() (*config, error) { - defaultCfg := config{ +func LoadConfig() (*Config, error) { + defaultCfg := Config{ LndDir: defaultLndDir, ConfigFile: defaultConfigFile, DataDir: defaultDataDir, diff --git a/fundingmanager_test.go b/fundingmanager_test.go index 408c1052f..45a9bdeef 100644 --- a/fundingmanager_test.go +++ b/fundingmanager_test.go @@ -3084,7 +3084,7 @@ func TestGetUpfrontShutdownScript(t *testing.T) { } // Set the command line option in config as needed. - cfg = &config{EnableUpfrontShutdown: test.localEnabled} + cfg = &Config{EnableUpfrontShutdown: test.localEnabled} addr, err := getUpfrontShutdownScript( &mockPeer, test.upfrontScript, test.getScript, diff --git a/lnd.go b/lnd.go index 291a33cff..7f3404ba0 100644 --- a/lnd.go +++ b/lnd.go @@ -52,7 +52,7 @@ import ( ) var ( - cfg *config + cfg *Config registeredChains = newChainRegistry() // networkDir is the path to the directory of the currently active @@ -156,7 +156,7 @@ func Main(lisCfg ListenerCfg) error { // Load the configuration, and parse any command line options. This // function will also set up logging properly. - loadedConfig, err := loadConfig() + loadedConfig, err := LoadConfig() if err != nil { return err }