aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2019-04-29 15:29:00 -0400
committerRyan Ofsky <ryan@ofsky.org>2022-05-26 11:05:10 -0400
commit1dc4fc29c1086420b7dc51b20c0b7a18fecb4462 (patch)
tree90f47ab26f9a6d079277cbfb593083a8b23dc7e5 /src
parenta7ef6d5975a5f40b90b2709b32a00647bd2bd5a3 (diff)
downloadbitcoin-1dc4fc29c1086420b7dc51b20c0b7a18fecb4462.tar.xz
Migrate -spendzeroconfchange and -signer settings from QSettings to settings.json
Diffstat (limited to 'src')
-rw-r--r--src/qt/optionsmodel.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index b42dbf40df..ba5c5e03e9 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -19,6 +19,7 @@
#include <txdb.h> // for -dbcache defaults
#include <util/string.h>
#include <validation.h> // For DEFAULT_SCRIPTCHECK_THREADS
+#include <wallet/wallet.h> // For DEFAULT_SPEND_ZEROCONF_CHANGE
#include <QDebug>
#include <QLatin1Char>
@@ -38,6 +39,8 @@ static const char* SettingName(OptionsModel::OptionID option)
switch (option) {
case OptionsModel::DatabaseCache: return "dbcache";
case OptionsModel::ThreadsScriptVerif: return "par";
+ case OptionsModel::SpendZeroConfChange: return "spendzeroconfchange";
+ case OptionsModel::ExternalSignerPath: return "signer";
default: throw std::logic_error(strprintf("GUI option %i has no corresponding node setting.", option));
}
}
@@ -125,7 +128,7 @@ bool OptionsModel::Init(bilingual_str& error)
// These are shared with the core or have a command-line parameter
// and we want command-line parameters to overwrite the GUI settings.
- for (OptionID option : {DatabaseCache, ThreadsScriptVerif}) {
+ for (OptionID option : {DatabaseCache, ThreadsScriptVerif, SpendZeroConfChange, ExternalSignerPath}) {
std::string setting = SettingName(option);
if (node().isSettingIgnored(setting)) addOverriddenOption("-" + setting);
try {
@@ -155,18 +158,6 @@ bool OptionsModel::Init(bilingual_str& error)
// Wallet
#ifdef ENABLE_WALLET
- if (!settings.contains("bSpendZeroConfChange"))
- settings.setValue("bSpendZeroConfChange", true);
- if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
- addOverriddenOption("-spendzeroconfchange");
-
- if (!settings.contains("external_signer_path"))
- settings.setValue("external_signer_path", "");
-
- if (!gArgs.SoftSetArg("-signer", settings.value("external_signer_path").toString().toStdString())) {
- addOverriddenOption("-signer");
- }
-
if (!settings.contains("SubFeeFromAmount")) {
settings.setValue("SubFeeFromAmount", false);
}
@@ -430,9 +421,9 @@ QVariant OptionsModel::getOption(OptionID option) const
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
- return settings.value("bSpendZeroConfChange");
+ return SettingToBool(setting(), wallet::DEFAULT_SPEND_ZEROCONF_CHANGE);
case ExternalSignerPath:
- return settings.value("external_signer_path");
+ return QString::fromStdString(SettingToString(setting(), ""));
case SubFeeFromAmount:
return m_sub_fee_from_amount;
#endif
@@ -551,14 +542,14 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value)
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
- if (settings.value("bSpendZeroConfChange") != value) {
- settings.setValue("bSpendZeroConfChange", value);
+ if (changed()) {
+ update(value.toBool());
setRestartRequired(true);
}
break;
case ExternalSignerPath:
- if (settings.value("external_signer_path") != value.toString()) {
- settings.setValue("external_signer_path", value.toString());
+ if (changed()) {
+ update(value.toString().toStdString());
setRestartRequired(true);
}
break;
@@ -703,4 +694,8 @@ void OptionsModel::checkAndMigrate()
migrate_setting(DatabaseCache, "nDatabaseCache");
migrate_setting(ThreadsScriptVerif, "nThreadsScriptVerif");
+#ifdef ENABLE_WALLET
+ migrate_setting(SpendZeroConfChange, "bSpendZeroConfChange");
+ migrate_setting(ExternalSignerPath, "external_signer_path");
+#endif
}