Skip to content

Commit 37633d2

Browse files
committed
Merge #602: Unify bitcoin-qt and bitcoind persistent 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
2 parents 9ef180a + e47c6c7 commit 37633d2

13 files changed

+407
-245
lines changed

doc/release-notes-15936.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
GUI changes
2+
-----------
3+
4+
Configuration changes made in the bitcoin GUI (such as the pruning setting,
5+
proxy settings, UPNP preferences) are now saved to `<datadir>/settings.json`
6+
file rather than to the Qt settings backend (windows registry or unix desktop
7+
config files), so these settings will now apply to bitcoind, instead of being
8+
ignored.
9+
10+
Also, the interaction between GUI settings and `bitcoin.conf` settings is
11+
simplified. Settings from `bitcoin.conf` are now displayed normally in the GUI
12+
settings dialog, instead of in a separate warning message ("Options set in this
13+
dialog are overridden by the configuration file: -setting=value"). And these
14+
settings can now be edited because `settings.json` values take precedence over
15+
`bitcoin.conf` values.

src/qt/bitcoin.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,26 @@ void BitcoinApplication::createPaymentServer()
259259
}
260260
#endif
261261

262-
void BitcoinApplication::createOptionsModel(bool resetSettings)
262+
bool BitcoinApplication::createOptionsModel(bool resetSettings)
263263
{
264-
optionsModel = new OptionsModel(node(), this, resetSettings);
264+
optionsModel = new OptionsModel(node(), this);
265+
if (resetSettings) {
266+
optionsModel->Reset();
267+
}
268+
bilingual_str error;
269+
if (!optionsModel->Init(error)) {
270+
fs::path settings_path;
271+
if (gArgs.GetSettingsPath(&settings_path)) {
272+
error += Untranslated("\n");
273+
std::string quoted_path = strprintf("%s", fs::quoted(fs::PathToString(settings_path)));
274+
error.original += strprintf("Settings file %s might be corrupt or invalid.", quoted_path);
275+
error.translated += tr("Settings file %1 might be corrupt or invalid.").arg(QString::fromStdString(quoted_path)).toStdString();
276+
}
277+
InitError(error);
278+
QMessageBox::critical(nullptr, PACKAGE_NAME, QString::fromStdString(error.translated));
279+
return false;
280+
}
281+
return true;
265282
}
266283

267284
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
@@ -327,7 +344,7 @@ void BitcoinApplication::parameterSetup()
327344

328345
void BitcoinApplication::InitPruneSetting(int64_t prune_MiB)
329346
{
330-
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB), true);
347+
optionsModel->SetPruneTargetGB(PruneMiBtoGB(prune_MiB));
331348
}
332349

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

643660
// Load GUI settings from QSettings
644-
app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false));
661+
if (!app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false))) {
662+
return EXIT_FAILURE;
663+
}
645664

646665
if (did_show_intro) {
647666
// Store intro dialog settings other than datadir (network specific)

src/qt/bitcoin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BitcoinApplication: public QApplication
4747
/// parameter interaction/setup based on rules
4848
void parameterSetup();
4949
/// Create options model
50-
void createOptionsModel(bool resetSettings);
50+
[[nodiscard]] bool createOptionsModel(bool resetSettings);
5151
/// Initialize prune setting
5252
void InitPruneSetting(int64_t prune_MiB);
5353
/// Create main window

src/qt/forms/optionsdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@
896896
<item>
897897
<widget class="QLabel" name="overriddenByCommandLineInfoLabel">
898898
<property name="text">
899-
<string>Options set in this dialog are overridden by the command line or in the configuration file:</string>
899+
<string>Options set in this dialog are overridden by the command line:</string>
900900
</property>
901901
<property name="textFormat">
902902
<enum>Qt::PlainText</enum>

src/qt/optionsdialog.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <QIntValidator>
2727
#include <QLocale>
2828
#include <QMessageBox>
29-
#include <QSettings>
3029
#include <QSystemTrayIcon>
3130
#include <QTimer>
3231

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

6459
ui->proxyIp->setEnabled(false);
6560
ui->proxyPort->setEnabled(false);

0 commit comments

Comments
 (0)