Issue Details

Number
27246
Title
Bitcoin ignores datadir and blocksdir parameter in .conf
Description
### 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](https://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
URL
https://github.com/bitcoin/bitcoin/issue/27246
Closed by
Back to List