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

View File

@ -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) {

View File

@ -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,

View File

@ -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,

4
lnd.go
View File

@ -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
}