bitcoin: Bitcoin ignores datadir and blocksdir parameter in .conf

Is there an existing issue for this?

  • Similar questions was raised in #15745 but it is marked as “solved” and closed.

Current behaviour

Registry has a REG_SZ key HKEY_CURRENT_USER\SOFTWARE\Bitcoin\Bitcoin-Qt\strDataDir (and there can be Bitcoin-Qt-regtest\strDataDir, Bitcoin-Qt-testnet\strDataDir for test chains). It is created by default when bitcoin-qt starts first time and after editing/accepting first start wizard. Change database directory to non-default path, put there bitcoin.conf with datadir=databasepath and run bitcoin-qt (-cli/etc) and bitcoin ignores datadir path if no -datadir argument passed to a program exclusively. The same problem with the blocksdir parameter.

Expected behaviour

In all situations behavior must be identical - if we start without arguments or pass “-conf” then use .conf “datadir=path” (according to sections [main], [regtest], [test] or global if there are no sections) if .conf exists and datadir are there. Now it is ignored. If we start with “-datadir=path” argument it’s works.


Steps to reproduce

  1. For example, change HKEY_CURRENT_USER\SOFTWARE\Bitcoin\Bitcoin-Qt\strDataDir to W:\BitcoinCore\strDataDir (assuming our disk is W: and all paths in this example exists).
  2. Create W:\BitcoinCore\strDataDir\bitcoin.conf with three lines: datadir=W:/BitcoinCore/DataDir/main1 [main] datadir=W:/BitcoinCore/DataDir/main2
  3. Start bitcoin-qt.exe -debuglogfile=W:/BitcoinCore/debug.no_params.log
  4. After a few seconds close opened wallet (bitcoin-qt) [Alt-F4].
  5. Start bitcoin-qt.exe -datadir=W:\BitcoinCore\DataDir\main -debuglogfile=W:\BitcoinCore\debug.w_datadir_param.log
  6. After a few seconds close opened wallet (bitcoin-qt) [Alt-F4].
  7. Start bitcoin-qt.exe -conf=W:\BitcoinCore\strDataDir\bitcoin.conf -debuglogfile=W:\BitcoinCore\debug.w_conf_param.log
  8. After a few seconds close opened wallet (bitcoin-qt) [Alt-F4].
  9. Check filesystem and logs (attached).

I’ve used Sysinternals Process Monitor to dig what’s happening.


Relevant log output

debug.no_params.log:

Default data directory C:\Users\USERNAME\AppData\Roaming\Bitcoin Using data directory W:\BitcoinCore\strDataDir Config file: W:\BitcoinCore\strDataDir\bitcoin.conf Config file arg: datadir=“W:/BitcoinCore/DataDir/main1” Config file arg: [main] datadir=“W:/BitcoinCore/DataDir/main2” Creating peers.dat because the file was not found (“W:\BitcoinCore\strDataDir\peers.dat”) Opening LevelDB in W:\BitcoinCore\strDataDir\blocks\index Opening LevelDB in W:\BitcoinCore\strDataDir\chainstate

debug.w_datadir_param.log:

Default data directory C:\Users\USERNAME\AppData\Roaming\Bitcoin Using data directory W:\BitcoinCore\DataDir\main Config file: W:\BitcoinCore\DataDir\main\bitcoin.conf (not found, skipping) Command-line arg: datadir=“W:\\BitcoinCore\\DataDir\\main” Opening LevelDB in W:\BitcoinCore\\DataDir\main\blocks\index Opening LevelDB in W:\BitcoinCore\DataDir\main\chainstate

debug.w_conf_param.log output is identical to debug.no_params.log.


How did you obtain Bitcoin Core

  1. Downloaded from bitcoincore.org/bin
  2. Compiled from source

What version of Bitcoin Core are you using?

24.0.1

Operating system and version

Win 10 x64

Machine specifications

Non relevant

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 26 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I did not address anything directly related to bitcoin-cli, I wasn’t able to reproduce any issues and I’m not exactly sure what your cli issue was. Can you provide steps and unexpected behavior for that?

The issue with bitcoind described https://github.com/bitcoin/bitcoin/issues/27246#issuecomment-1470006043 is that a config file specifying a datadir which contains a second config file will ignore the second config file with no warning. I outlined three solutions for this issue here: https://github.com/bitcoin/bitcoin/issues/27246#issuecomment-1470284856 and implemented the third solution in a branch here: https://github.com/bitcoin/bitcoin/compare/master...ryanofsky:bitcoin:pr/ignoredconf

I haven’t posted a PR yet because I’m working on a python test which is a little tricky to implement.

EDIT: This is now posted as #27302