@@ -137,17 +137,7 @@ func Run(rpcCfg RPCConfig) error {
137137
138138 // Parse ini file.
139139 loopDir := lncfg .CleanAndExpandPath (config .LoopDir )
140- configFile := lncfg .CleanAndExpandPath (config .ConfigFile )
141-
142- // If our loop directory is set and the config file parameter is not
143- // set, we assume that they want to point to a config file in their
144- // loop dir. However, if the config file has a non-default value, then
145- // we leave the config parameter as its custom value.
146- if loopDir != loopDirBase && configFile == defaultConfigFile {
147- configFile = filepath .Join (
148- loopDir , defaultConfigFilename ,
149- )
150- }
140+ configFile := getConfigPath (config , loopDir )
151141
152142 if err := flags .IniParse (configFile , & config ); err != nil {
153143 // If it's a parsing related error, then we'll return
@@ -237,3 +227,25 @@ func Run(rpcCfg RPCConfig) error {
237227
238228 return fmt .Errorf ("unimplemented command %v" , parser .Active .Name )
239229}
230+
231+ // getConfigPath gets our config path based on the values that are set in our
232+ // config.
233+ func getConfigPath (cfg Config , loopDir string ) string {
234+ // If the config file path provided by the user is set, then we just
235+ // use this value.
236+ if cfg .ConfigFile != defaultConfigFile {
237+ return lncfg .CleanAndExpandPath (cfg .ConfigFile )
238+ }
239+
240+ // If the user has set a loop directory that is different to the default
241+ // we will use this loop directory as the location of our config file.
242+ // We do not namespace by network, because this is a custom loop dir.
243+ if loopDir != loopDirBase {
244+ return filepath .Join (loopDir , defaultConfigFilename )
245+ }
246+
247+ // Otherwise, we are using our default loop directory, and the user did
248+ // not set a config file path. We use our default loop dir, namespaced
249+ // by network.
250+ return filepath .Join (loopDir , cfg .Network , defaultConfigFilename )
251+ }
0 commit comments