Repository navigation
Description
When the app is run in -testnet mode, it creates a testnet QSettings using QAPP_APP_NAME_TESTNET.
This is by design, so mainnet and testnet can exist om same computer. Options such as strDataDirSyscoin can be specified to use different datadirs.
Expected behavior
When Qt client is run with the -testnet command line argument, use the settings from QAPP_APP_NAME_TESTNET.
Actual behavior
The settings from QAPP_APP_NAME_DEFAULT are used in stead.
As a workaround, devs append hardcoded testnet3 to the mainnet value read from strDataDirSyscoin setting. This is wrong, because it should use the {QAPP_APP_NAME_TESTNET}/strDataDirSyscoin value in stead. This value should have testnet3 or Syscoin-testnet3 as the default, rather than an append on the mainnet settings.
The problem probably starts here:
Lines 522 to 527 in 55ed9f2
| /// 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); |
Because QAPP_APP_NAME_DEFAULT is hardcoded while the actual settings key name is now tucked away in NetworkStyle:
syscoin/src/qt/networkstyle.cpp
Lines 14 to 24 in 55ed9f2
| 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}, | |
| }; |
To reproduce
Change testnet settings in the relevant location (on Windows it's the registry) and see how the setting is ignored.
System information
Windows 10 x64
v4.2.0rc5 tagged release

Activity
work on #417
sidhujag commentedon Feb 11, 2021
check this commit @beirut-boop
0b78005
This look ok? We can remove that hack now
beirut-boop commentedon Feb 11, 2021
@sidhujag commit is fine, but it doesn't seem to address the issue.
I believe the most concise summary is this:
syscoin-qt.exe -testnetfor the first time creates a QSettings (e.g. Windows Registry directory) with default settings specifically for testnet.I am not sure where exactly the QSettings appName is defined, but in essence right in the beginning (when writing the defaults) the app name is
QAPP_APP_NAME_TESTNET, yet later (when reading the settings) the app name changed toQAPP_APP_NAME_DEFAULT.I think this is because the AppName is stored in
NetworkStylewhich should be referenced, but in stead it is ignored and DEFAULT is used when looking for QSettings:syscoin/src/qt/syscoin.cpp
Lines 522 to 527 in 55ed9f2
Line 527 might need something like this:
sidhujag commentedon Feb 11, 2021
@beirut-boop it is consistent with Bitcoin, does the problem happen on Bitcoin?
I believe the logic you are describing happens here:
syscoin/src/qt/syscoin.cpp
Line 591 in 55ed9f2
It will use testnet there and set app name, if its happening in Bitcoin as well we can open a PR to fix upstream. If what you are saying is true then it locates wrong QSettings and later changes the name after QSettings are already loaded with default regardless of testnet settings. Perhaps its not desired but we can ask upstream as intended behavior in that case.
My guess is params isn't available at the time of the first call and thus its working as designed and we don't have enough information to load QSettings with testnet in line 527.
Note: comments do say it will use QSettings from the new configuration after QApplication::setApplicationName(networkStyle->getAppName()); is applied on L594
beirut-boop commentedon Feb 11, 2021
@sidhujag commented:
You are correct. I just tested this. The exact same behavior. Didn't know this. Never used Bitcoin Qt.
sidhujag commentedon Feb 11, 2021
Why don't you open one upstream and ask them the intended behaviour and perhaps if it is a real bug or not
beirut-boop commentedon Feb 11, 2021
I've written my observations upstream: bitcoin#21154
Let's wait and see which was the intended behavior.
sidhujag commentedon Feb 13, 2021
@beirut-boop please post your syscoin address for a tip
sidhujag commentedon Mar 3, 2021
@beirut-boop seems like not an issue according to upstream
beirut-boop commentedon Mar 4, 2021
@sidhujag at least not an issue with any kind of urgency.
But definitely an issue of sorts. Confirmed in 2016(!). You can see what went wrong when following the logic:
It works and anyone working with testnet for the first time will trash their mainnet data a maximum of 1 times and never again, so it's probably not worth fixing.
I will close this issue to keep the tracker clean.