Skip to content

Commit 946107a

Browse files
committed
Only log "Using PATH_TO_bitcoin.conf" message on startup if conf file exists.
Currently we log a message indicating that a bitcoin.conf file is being used even if one does not exists. This commit changes the logic to only display this message if a config file exists and logs a separate message if no config file exists. Additionally, a warning is now logged if the file path passed in the -conf flag does not exist.
1 parent 07033a8 commit 946107a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/init.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,19 @@ bool AppInitMain()
12431243
LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
12441244
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
12451245
LogPrintf("Using data directory %s\n", GetDataDir().string());
1246-
LogPrintf("Using config file %s\n", GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string());
1246+
1247+
// Only log conf file usage message if conf file actually exists.
1248+
fs::path config_file_path = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
1249+
if (fs::exists(config_file_path)) {
1250+
LogPrintf("Config file: %s\n", config_file_path.string());
1251+
} else if (gArgs.IsArgSet("-conf")) {
1252+
// Warn if no conf file exists at path provided by user
1253+
InitWarning(strprintf(_("The specified config file %s does not exist\n"), config_file_path.string()));
1254+
} else {
1255+
// Not categorizing as "Warning" because it's the default behavior
1256+
LogPrintf("Config file: %s (not found, skipping)\n", config_file_path.string());
1257+
}
1258+
12471259
LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
12481260

12491261
// Warn about relative -datadir path.

0 commit comments

Comments
 (0)