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.
This commit is contained in:
Oliver Gugger 2020-04-30 09:34:10 +02:00
parent 2f84d1a819
commit 409d2c9a90
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
4 changed files with 10 additions and 10 deletions

@ -160,7 +160,7 @@ type chainControl struct {
// full-node, another backed by a running bitcoind full-node, and the other // 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 // backed by a running neutrino light client instance. When running with a
// neutrino light client instance, `neutrinoCS` must be non-nil. // 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, privateWalletPw, publicWalletPw []byte, birthday time.Time,
recoveryWindow uint32, wallet *wallet.Wallet, recoveryWindow uint32, wallet *wallet.Wallet,
neutrinoCS *neutrino.ChainService) (*chainControl, error) { neutrinoCS *neutrino.ChainService) (*chainControl, error) {

@ -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"` 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. // loading+parsing process.
type config struct { type Config struct {
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"` 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."` 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."` 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. // line options.
// //
// The configuration proceeds as follows: // 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 // 2) Pre-parse the command line to check for an alternative config file
// 3) Load configuration file overwriting defaults with any specified options // 3) Load configuration file overwriting defaults with any specified options
// 4) Parse CLI options and overwrite/add any specified options // 4) Parse CLI options and overwrite/add any specified options
func loadConfig() (*config, error) { func LoadConfig() (*Config, error) {
defaultCfg := config{ defaultCfg := Config{
LndDir: defaultLndDir, LndDir: defaultLndDir,
ConfigFile: defaultConfigFile, ConfigFile: defaultConfigFile,
DataDir: defaultDataDir, DataDir: defaultDataDir,

@ -3084,7 +3084,7 @@ func TestGetUpfrontShutdownScript(t *testing.T) {
} }
// Set the command line option in config as needed. // Set the command line option in config as needed.
cfg = &config{EnableUpfrontShutdown: test.localEnabled} cfg = &Config{EnableUpfrontShutdown: test.localEnabled}
addr, err := getUpfrontShutdownScript( addr, err := getUpfrontShutdownScript(
&mockPeer, test.upfrontScript, test.getScript, &mockPeer, test.upfrontScript, test.getScript,

4
lnd.go

@ -52,7 +52,7 @@ import (
) )
var ( var (
cfg *config cfg *Config
registeredChains = newChainRegistry() registeredChains = newChainRegistry()
// networkDir is the path to the directory of the currently active // 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 // Load the configuration, and parse any command line options. This
// function will also set up logging properly. // function will also set up logging properly.
loadedConfig, err := loadConfig() loadedConfig, err := LoadConfig()
if err != nil { if err != nil {
return err return err
} }