Running bitcoin-qt.exe -testnet
creates a separate testnet QSettings called Bitcoin-Qt-testnet
. I assume this was done on purpose, so you can easily run testnet settings in parallel to mainnet.
Expected behavior
Changing settings in the Bitcoin-Qt-testnet
QSettings should be reflected in the Qt wallet when running with -testnet
.
For example, on Windows the QSettings are stored in the registry. The testnet key is here:
Actual behavior
The Bitcoin-Qt-testnet
settings are ignored, and Bitcoin-Qt
mainnet settings are used in stead.
To reproduce
On a clean system, start the wallet for the first time in -testnet
mode. In the start wizard, change any option (e.g. the path). Observe how all defaults are written to Bitcoin-Qt-testnet
, but the updated settings are written to the (previously empty) Bitcoin-Qt
QSettings:
What is happening
It appears as if during the initialization of the app (while writing default settings), the appName (and QSettings based on appName) is still QAPP_APP_NAME_TESTNET
. Yet later (when reading the settings) the app name changed to QAPP_APP_NAME_DEFAULT
.
What causes this
Perhaps because here the appName is set to QAPP_APP_NAME_DEFAULT
:
https://github.com/bitcoin/bitcoin/blob/8e1913ae025ad8912457abe24ae5c61da02fc17a/src/qt/bitcoin.cpp#L496-L501
Rather than the one from the test NetworkStyle: https://github.com/bitcoin/bitcoin/blob/8e1913ae025ad8912457abe24ae5c61da02fc17a/src/qt/networkstyle.cpp#L14-L24
Perhaps it would work as intended if we would use the NetworkStyle app name. E.g.:
0 /// 3. Application identification
1 // must be set before OptionsModel is initialized or translations are loaded,
2 // as it is used to locate QSettings
3 QApplication::setOrganizationName(QAPP_ORG_NAME);
4 QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN);
5- QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT);
6+ QApplication::setApplicationName(networkStyle->getAppName());
System information
Windows 10 Bitcoin 0.21 precompiled
Extra info
It is possible that the intended behavior was never finished and forgotten, or it was never intended to work the way I am assuming.
Originally found on Syscoin here: https://github.com/syscoin/syscoin/issues/417