Repository navigation
Description
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:
Lines 496 to 501 in 8e1913a
| /// 3. Application identification | |
| // must be set before OptionsModel is initialized or translations are loaded, | |
| // as it is used to locate QSettings | |
| QApplication::setOrganizationName(QAPP_ORG_NAME); | |
| QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN); | |
| QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT); |
Rather than the one from the test NetworkStyle:
bitcoin/src/qt/networkstyle.cpp
Lines 14 to 24 in 8e1913a
| static const struct { | |
| const char *networkId; | |
| const char *appName; | |
| const int iconColorHueShift; | |
| const int iconColorSaturationReduction; | |
| } network_styles[] = { | |
| {"main", QAPP_APP_NAME_DEFAULT, 0, 0}, | |
| {"test", QAPP_APP_NAME_TESTNET, 70, 30}, | |
| {"signet", QAPP_APP_NAME_SIGNET, 35, 15}, | |
| {"regtest", QAPP_APP_NAME_REGTEST, 160, 30}, | |
| }; |
Perhaps it would work as intended if we would use the NetworkStyle app name. E.g.:
/// 3. Application identification
// must be set before OptionsModel is initialized or translations are loaded,
// as it is used to locate QSettings
QApplication::setOrganizationName(QAPP_ORG_NAME);
QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN);
- QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT);
+ 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: syscoin#417


Activity
hebasto commentedon Feb 17, 2021
@beirut-boop
Do you mind opening this issue in the dedicated https://github.com/bitcoin-core/gui/issues repo, and closing it here?
beirut-boop commentedon Feb 19, 2021
@hebasto moved to bitcoin-core/gui#212