Skip to content

Commit

Permalink
Merge bitcoin-core/gui#602: Unify bitcoin-qt and bitcoind persistent …
Browse files Browse the repository at this point in the history
…settings

e47c6c7 Reset settings.json when GUI options are reset (Ryan Ofsky)
99ccc02 Add release notes about unified bitcoin-qt and bitcoind persistent settings (Ryan Ofsky)
504b06b Migrate -lang setting from QSettings to settings.json (Ryan Ofsky)
9a016a3 Migrate -prune setting from QSettings to settings.json (Ryan Ofsky)
f067e19 Migrate -proxy and -onion settings from QSettings to settings.json (Ryan Ofsky)
a09e3b7 Migrate -listen and -server settings from QSettings to settings.json (Ryan Ofsky)
d2ada6e Migrate -upnp and -natpmp settings from QSettings to settings.json (Ryan Ofsky)
1dc4fc2 Migrate -spendzeroconfchange and -signer settings from QSettings to settings.json (Ryan Ofsky)
a7ef6d5 Migrate -par setting from QSettings to settings.json (Ryan Ofsky)
284f339 Migrate -dbcache setting from QSettings to settings.json (Ryan Ofsky)

Pull request description:

  If a setting like pruning, port mapping, or a network proxy is enabled in the GUI, it will now be stored in the bitcoin persistent setting file in the datadir and shared with bitcoind, instead of being stored as Qt settings which end up in the the windows registry or platform specific config files and are ignored by bitcoind.

  This PR has been split off from bitcoin/bitcoin#15936 so some review of these commits previously took place in that PR.

ACKs for top commit:
  furszy:
    Code review ACK e47c6c7
  hebasto:
    ACK e47c6c7

Tree-SHA512: 076ea7c7efe67805b4a357113bfe1643dce364d0032774106de59566a0ed5771d57a5923920085e03d686beb34b98114bd278555dfdf8bb7af0b778b0f35b7d2
  • Loading branch information
hebasto committed Jun 12, 2022
2 parents 9ef180a + e47c6c7 commit 37633d2
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 245 deletions.
15 changes: 15 additions & 0 deletions doc/release-notes-15936.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
GUI changes
-----------

Configuration changes made in the bitcoin GUI (such as the pruning setting,
proxy settings, UPNP preferences) are now saved to `<datadir>/settings.json`
file rather than to the Qt settings backend (windows registry or unix desktop
config files), so these settings will now apply to bitcoind, instead of being
ignored.

Also, the interaction between GUI settings and `bitcoin.conf` settings is
simplified. Settings from `bitcoin.conf` are now displayed normally in the GUI
settings dialog, instead of in a separate warning message ("Options set in this
dialog are overridden by the configuration file: -setting=value"). And these
settings can now be edited because `settings.json` values take precedence over
`bitcoin.conf` values.
27 changes: 23 additions & 4 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,26 @@ void BitcoinApplication::createPaymentServer()
}
#endif

void BitcoinApplication::createOptionsModel(bool resetSettings)
bool BitcoinApplication::createOptionsModel(bool resetSettings)
{
optionsModel = new OptionsModel(node(), this, resetSettings);
optionsModel = new OptionsModel(node(), this);
if (resetSettings) {
optionsModel->Reset();
}
bilingual_str error;
if (!optionsModel->Init(error)) {
fs::path settings_path;
if (gArgs.GetSettingsPath(&settings_path)) {
error += Untranslated("\n");
std::string quoted_path = strprintf("%s", fs::quoted(fs::PathToString(settings_path)));
error.original += strprintf("Settings file %s might be corrupt or invalid.", quoted_path);
error.translated += tr("Settings file %1 might be corrupt or invalid.").arg(QString::fromStdString(quoted_path)).toStdString();
}
InitError(error);
QMessageBox::critical(nullptr, PACKAGE_NAME, QString::fromStdString(error.translated));
return false;
}
return true;
}

void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
Expand Down Expand Up @@ -327,7 +344,7 @@ void BitcoinApplication::parameterSetup()

void BitcoinApplication::InitPruneSetting(int64_t prune_MiB)
{
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB), true);
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB));
}

void BitcoinApplication::requestInitialize()
Expand Down Expand Up @@ -641,7 +658,9 @@ int GuiMain(int argc, char* argv[])
app.createNode(*init);

// Load GUI settings from QSettings
app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false));
if (!app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false))) {
return EXIT_FAILURE;
}

if (did_show_intro) {
// Store intro dialog settings other than datadir (network specific)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BitcoinApplication: public QApplication
/// parameter interaction/setup based on rules
void parameterSetup();
/// Create options model
void createOptionsModel(bool resetSettings);
[[nodiscard]] bool createOptionsModel(bool resetSettings);
/// Initialize prune setting
void InitPruneSetting(int64_t prune_MiB);
/// Create main window
Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@
<item>
<widget class="QLabel" name="overriddenByCommandLineInfoLabel">
<property name="text">
<string>Options set in this dialog are overridden by the command line or in the configuration file:</string>
<string>Options set in this dialog are overridden by the command line:</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
Expand Down
5 changes: 0 additions & 5 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <QIntValidator>
#include <QLocale>
#include <QMessageBox>
#include <QSettings>
#include <QSystemTrayIcon>
#include <QTimer>

Expand Down Expand Up @@ -56,10 +55,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
#ifndef USE_NATPMP
ui->mapPortNatpmp->setEnabled(false);
#endif
connect(this, &QDialog::accepted, [this](){
QSettings settings;
model->node().mapPort(settings.value("fUseUPnP").toBool(), settings.value("fUseNatpmp").toBool());
});

ui->proxyIp->setEnabled(false);
ui->proxyPort->setEnabled(false);
Expand Down
Loading

0 comments on commit 37633d2

Please sign in to comment.