Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/release-notes-8029.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Configuration
-------------

- `dashd` no longer creates an empty `dash.conf` when none exists, matching Bitcoin Core. `dash-qt`'s "Open Configuration File" still creates it on demand. (#8029)
4 changes: 4 additions & 0 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@ void openConfigfile()
{
fs::path pathConfig = gArgs.GetConfigFilePath();

/* Create the file */
std::ofstream configFile{pathConfig, std::ios_base::app};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
configFile.close();

/* Open dash.conf with the associated application */
if (fs::exists(pathConfig)) {
// Workaround for macOS-specific behavior; see #15409.
Expand Down
7 changes: 0 additions & 7 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,13 +990,6 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
tfm::format(std::cerr, "warning: -includeconf cannot be used from included files; ignoring -includeconf=%s\n", conf_file_name);
}
}
} else {
// Create an empty dash.conf if it does not exist
std::ofstream configFile{conf_path, std::ios_base::app};
if (!configFile.good())
return false;
configFile.close();
return true; // Nothing to read, so just return
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

// If datadir is changed in .conf file:
Expand Down
22 changes: 22 additions & 0 deletions test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,27 @@ def test_ignored_conf(self):
self.start_node(0, [f'-conf={node.datadir}/dash.conf'])
self.stop_node(0)

def test_missing_default_datadir(self):
# Overriding the default datadir through the environment does not work on Windows
if sys.platform == "win32":
return

self.log.info('Test -version, -help and a first start without a default data directory')
node = self.nodes[0]
node_args = node.args
node.args = [arg for arg in node.args if not arg.startswith("-datadir=")]
for name, extra_args in [("version", ["-version"]), ("help", ["-help"]), ("start", ["-regtest", "-listen=0", "-server=0"])]:
env, default_datadir = util.get_temp_default_datadir(pathlib.Path(self.options.tmpdir, "no_datadir", name))
default_datadir.parent.mkdir(parents=True)
node.start(extra_args, env=env)
if name == "start":
debug_log = default_datadir / "regtest" / "debug.log"
self.wait_until(lambda: node.process.poll() is not None or (debug_log.exists() and "Done loading" in debug_log.read_text(encoding="utf-8")))
assert node.process.poll() is None
node.process.terminate()
node.wait_until_stopped()
node.args = node_args

def test_ignored_default_conf(self):
# Disable this test for windows currently because trying to override
# the default datadir through the environment does not seem to work.
Expand Down Expand Up @@ -394,6 +415,7 @@ def run_test(self):
self.test_config_file_log()
self.test_invalid_command_line_options()
self.test_ignored_conf()
self.test_missing_default_datadir()
self.test_ignored_default_conf()
self.test_acceptstalefeeestimates_arg_support()

Expand Down
Loading