Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2011-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_QT_OPTIONSMODEL_H6#define BITCOIN_QT_OPTIONSMODEL_H8#include <cstdint>9#include <qt/bitcoinunits.h>10#include <qt/guiconstants.h>11#include <util/byte_units.h>13#include <QAbstractListModel>14#include <QFont>16#include <cassert>17#include <variant>19struct bilingual_str;20namespace interfaces {21class Node;22}24extern const char *DEFAULT_GUI_PROXY_HOST;25inline constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;27/**28* Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage.29*/30static inline int PruneMiBtoGB(int64_t mib) { return (mib * 1_MiB + GB_BYTES - 1) / GB_BYTES; }32/**33* Convert displayed prune target GB to configured MiB. Round down so roundtrip GB -> MiB -> GB conversion is stable.34*/35static inline int64_t PruneGBtoMiB(int gb) { return gb * GB_BYTES / 1_MiB; }37/** Interface from Qt to configuration data structure for Bitcoin client.38To Qt, the options are presented as a list with the different options39laid out vertically.40This can be changed to a tree once the settings become sufficiently41complex.42*/43class OptionsModel : public QAbstractListModel44{45Q_OBJECT47public:48explicit OptionsModel(interfaces::Node& node, QObject *parent = nullptr);50enum OptionID {51StartAtStartup, // bool52ShowTrayIcon, // bool53MinimizeToTray, // bool54MapPortNatpmp, // bool55MinimizeOnClose, // bool56ProxyUse, // bool57ProxyIP, // QString58ProxyPort, // int59ProxyUseTor, // bool60ProxyIPTor, // QString61ProxyPortTor, // int62DisplayUnit, // BitcoinUnit63ThirdPartyTxUrls, // QString64Language, // QString65FontForMoney, // FontChoice66CoinControlFeatures, // bool67SubFeeFromAmount, // bool68ThreadsScriptVerif, // int69Prune, // bool70PruneSize, // int71DatabaseCache, // int72ExternalSignerPath, // QString73SpendZeroConfChange, // bool74Listen, // bool75Server, // bool76EnablePSBTControls, // bool77MaskValues, // bool78OptionIDRowCount,79};81enum class FontChoiceAbstract {82EmbeddedFont,83BestSystemFont,84};85typedef std::variant<FontChoiceAbstract, QFont> FontChoice;86static inline const FontChoice UseBestSystemFont{FontChoiceAbstract::BestSystemFont};87static QFont getFontForChoice(const FontChoice& fc);89bool Init(bilingual_str& error);90void Reset();92int rowCount(const QModelIndex & parent = QModelIndex()) const override;93QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;94bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;95QVariant getOption(OptionID option, const std::string& suffix="") const;96bool setOption(OptionID option, const QVariant& value, const std::string& suffix="");97/** Updates current unit in memory, settings and emits displayUnitChanged(new_unit) signal */98void setDisplayUnit(const QVariant& new_unit);100/* Explicit getters */101bool getShowTrayIcon() const { return m_show_tray_icon; }102bool getMinimizeToTray() const { return fMinimizeToTray; }103bool getMinimizeOnClose() const { return fMinimizeOnClose; }104BitcoinUnit getDisplayUnit() const { return m_display_bitcoin_unit; }105QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }106QFont getFontForMoney() const;107bool getCoinControlFeatures() const { return fCoinControlFeatures; }108bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }109bool getEnablePSBTControls() const { return m_enable_psbt_controls; }110const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }112/** Whether -signer was set or not */113bool hasSigner();115/* Explicit setters */116void SetPruneTargetGB(int prune_target_gb);118/* Restart flag helper */119void setRestartRequired(bool fRequired);120bool isRestartRequired() const;122interfaces::Node& node() const { return m_node; }124private:125interfaces::Node& m_node;126/* Qt-only settings */127bool m_show_tray_icon;128bool fMinimizeToTray;129bool fMinimizeOnClose;130QString language;131BitcoinUnit m_display_bitcoin_unit;132QString strThirdPartyTxUrls;133FontChoice m_font_money{FontChoiceAbstract::EmbeddedFont};134bool fCoinControlFeatures;135bool m_sub_fee_from_amount;136bool m_enable_psbt_controls;137bool m_mask_values;139/* settings that were overridden by command-line */140QString strOverriddenByCommandLine;142static QString FontChoiceToString(const OptionsModel::FontChoice&);143static FontChoice FontChoiceFromString(const QString&);145// Add option to list of GUI options overridden through command line/config file146void addOverriddenOption(const std::string &option);148// Check settings version and upgrade default values if required149void checkAndMigrate();151Q_SIGNALS:152void displayUnitChanged(BitcoinUnit unit);153void coinControlFeaturesChanged(bool);154void showTrayIconChanged(bool);155void fontForMoneyChanged(const QFont&);156};158Q_DECLARE_METATYPE(OptionsModel::FontChoice)160#endif // BITCOIN_QT_OPTIONSMODEL_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.