5 #if defined(HAVE_CONFIG_H)
21 #include <validation.h>
25 #include <QLatin1Char>
27 #include <QStringList>
57 default:
throw std::logic_error(
strprintf(
"GUI option %i has no corresponding node setting.", option));
85 assert(!prune_enabled || prune_size_gb >= 1);
109 return std::max(1, prune_size.toInt());
118 static std::string
ProxyString(
bool is_set, QString
ip, QString port);
153 if (!settings.contains(
"fHideTrayIcon")) {
154 settings.setValue(
"fHideTrayIcon",
false);
159 if (!settings.contains(
"fMinimizeToTray"))
160 settings.setValue(
"fMinimizeToTray",
false);
163 if (!settings.contains(
"fMinimizeOnClose"))
164 settings.setValue(
"fMinimizeOnClose",
false);
168 if (!settings.contains(
"DisplayBitcoinUnit")) {
169 settings.setValue(
"DisplayBitcoinUnit", QVariant::fromValue(
BitcoinUnit::BTC));
171 QVariant unit = settings.value(
"DisplayBitcoinUnit");
179 if (!settings.contains(
"strThirdPartyTxUrls"))
180 settings.setValue(
"strThirdPartyTxUrls",
"");
183 if (!settings.contains(
"fCoinControlFeatures"))
184 settings.setValue(
"fCoinControlFeatures",
false);
187 if (!settings.contains(
"enable_psbt_controls")) {
188 settings.setValue(
"enable_psbt_controls",
false);
200 }
catch (
const std::exception& e) {
203 error.original =
strprintf(
"Could not read setting \"%s\", %s.", setting, e.what());
204 error.translated = tr(
"Could not read setting \"%1\", %2.").arg(QString::fromStdString(setting), e.what()).toStdString();
212 if (!settings.contains(
"strDataDir"))
217 if (!settings.contains(
"SubFeeFromAmount")) {
218 settings.setValue(
"SubFeeFromAmount",
false);
224 if (!settings.contains(
"UseEmbeddedMonospacedFont")) {
225 settings.setValue(
"UseEmbeddedMonospacedFont",
"true");
238 for (
const QString& key : src.allKeys()) {
239 dst.setValue(key, src.value(key));
264 dataDir = settings.value(
"strDataDir", dataDir).toString();
270 settings.setValue(
"strDataDir", dataDir);
273 settings.setValue(
"fReset",
true);
289 if (proxy.isEmpty()) {
294 if (ip_port.size() == 2) {
295 return {
true, ip_port.at(0), ip_port.at(1)};
308 return is_set ? QString(
ip +
":" + port).toStdString() :
"";
342 if(role == Qt::EditRole)
352 bool successful =
true;
353 if(role == Qt::EditRole)
358 Q_EMIT dataChanged(index, index);
425 return settings.value(
"enable_psbt_controls");
445 auto changed = [&] {
return value.isValid() && value !=
getOption(option); };
448 bool successful =
true;
466 update(value.toBool());
472 update(value.toBool());
536 update(value.toBool());
542 update(value.toString().toStdString());
563 update(value.toString().toStdString());
598 update(
static_cast<int64_t
>(value.toLongLong()));
604 update(
static_cast<int64_t
>(value.toLongLong()));
611 update(value.toBool());
634 return settings.setValue(
"fRestartRequired", fRequired);
640 return settings.value(
"fRestartRequired",
false).toBool();
648 static const char strSettingsVersionKey[] =
"nSettingsVersion";
649 int settingsVersion = settings.contains(strSettingsVersionKey) ? settings.value(strSettingsVersionKey).toInt() : 0;
655 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") && settings.value(
"nDatabaseCache").toLongLong() == 100)
663 if (settings.contains(
"addrProxy") && settings.value(
"addrProxy").toString().endsWith(
"%2")) {
669 if (settings.contains(
"addrSeparateProxyTor") && settings.value(
"addrSeparateProxyTor").toString().endsWith(
"%2")) {
674 auto migrate_setting = [&](
OptionID option,
const QString& qt_name) {
675 if (!settings.contains(qt_name))
return;
676 QVariant value = settings.value(qt_name);
690 settings.remove(qt_name);
701 migrate_setting(
Listen,
"fListen");
702 migrate_setting(
Server,
"server");
703 migrate_setting(
PruneSize,
"nPruneSize");
704 migrate_setting(
Prune,
"bPrune");
705 migrate_setting(
ProxyIP,
"addrProxy");
706 migrate_setting(
ProxyUse,
"fUseProxy");
707 migrate_setting(
ProxyIPTor,
"addrSeparateProxyTor");
708 migrate_setting(
ProxyUseTor,
"fUseSeparateProxyTor");
709 migrate_setting(
Language,
"language");
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
BitcoinUnit m_display_bitcoin_unit
QString strOverriddenByCommandLine
bool m_use_embedded_monospaced_font
bool isRestartRequired() const
bool fCoinControlFeatures
int m_prune_size_gb
In-memory settings for display.
void coinControlFeaturesChanged(bool)
QString strThirdPartyTxUrls
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool m_sub_fee_from_amount
@ UseEmbeddedMonospacedFont
void displayUnitChanged(BitcoinUnit unit)
void SetPruneTargetGB(int prune_target_gb)
bool Init(bilingual_str &error)
QVariant getOption(OptionID option) const
void showTrayIconChanged(bool)
OptionsModel(interfaces::Node &node, QObject *parent=nullptr)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
bool setOption(OptionID option, const QVariant &value)
bool m_enable_psbt_controls
void setDisplayUnit(const QVariant &new_unit)
Updates current unit in memory, settings and emits displayUnitChanged(new_unit) signal.
interfaces::Node & node() const
void addOverriddenOption(const std::string &option)
void useEmbeddedMonospacedFontChanged(bool)
void setRestartRequired(bool fRequired)
const std::string & getValStr() const
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Top-level interface for a bitcoin node (bitcoind process).
virtual void resetSettings()=0
Clear all settings in <datadir>/settings.json and store a backup of previous settings in <datadir>/se...
virtual void initParameterInteraction()=0
Init parameter interaction.
virtual void forceSetting(const std::string &name, const util::SettingsValue &value)=0
Force a setting value to be applied, overriding any other configuration source, but not being persist...
virtual void mapPort(bool use_upnp, bool use_natpmp)=0
Map port.
virtual util::SettingsValue getPersistentSetting(const std::string &name)=0
Return setting value from <datadir>/settings.json or bitcoin.conf.
static const int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
static CService ip(uint32_t i)
static constexpr int DEFAULT_PRUNE_TARGET_GB
static constexpr bool DEFAULT_NATPMP
static constexpr bool DEFAULT_UPNP
QString getDefaultDataDirectory()
Determine default data directory for operating system.
bool SetStartOnSystemStartup(bool fAutoStart)
QString PathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
bool GetStartOnSystemStartup()
QStringList SplitSkipEmptyParts(const QString &string, const SeparatorType &separator)
Splits the string into substrings wherever separator occurs, and returns the list of those strings.
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
static const bool DEFAULT_LISTEN
-listen default
static void CopySettings(QSettings &dst, const QSettings &src)
Helper function to copy contents from one QSettings to another.
static int ParsePruneSizeGB(const QVariant &prune_size)
Parse pruning size value provided by user in GUI or loaded from QSettings (windows registry key or qt...
static const char * SettingName(OptionsModel::OptionID option)
Map GUI option ID to node setting name.
static util::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb)
Convert enabled/size values to bitcoin -prune setting.
static ProxySetting ParseProxyString(const std::string &proxy)
static QString GetDefaultProxyAddress()
static int PruneSizeGB(const util::SettingsValue &prune_setting)
Get pruning size value to show in GUI from bitcoin -prune setting.
static std::string ProxyString(bool is_set, QString ip, QString port)
static void UpdateRwSetting(interfaces::Node &node, OptionsModel::OptionID option, const util::SettingsValue &value)
Call node.updateRwSetting() with Bitcoin 22.x workaround.
static void BackupSettings(const fs::path &filename, const QSettings &src)
Back up a QSettings to an ini-formatted file.
const char * DEFAULT_GUI_PROXY_HOST
static bool PruneEnabled(const util::SettingsValue &prune_setting)
Get pruning enabled value to show in GUI from bitcoin -prune setting.
static int PruneMiBtoGB(int64_t mib)
Convert configured prune target MiB to displayed GB.
static int64_t PruneGBtoMiB(int gb)
Convert displayed prune target GB to configured MiB.
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
bool error(const char *fmt, const Args &... args)
static const int64_t nDefaultDbCache
-dbcache default (MiB)
std::optional< std::string > SettingToString(const util::SettingsValue &value)
std::optional< int64_t > SettingToInt(const util::SettingsValue &value)
std::optional< bool > SettingToBool(const util::SettingsValue &value)
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)