Skip to content

Testnet configuration is ignored. #21154

Closed

Description

@beirut-boop

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:

image

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:

image

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:

bitcoin/src/qt/bitcoin.cpp

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:

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

  1. hebasto commented on Feb 17, 2021

    @hebasto
    Member
  2. beirut-boop commented on Feb 19, 2021

    @beirut-boop
    Author
  3. locked as resolved and limited conversation to collaborators on Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions