1
0

config: move tooltips from Qt gui into configvars

This commit is contained in:
SomberNight
2023-09-18 11:00:52 +00:00
parent f58387eaa8
commit 357ae985cc
12 changed files with 246 additions and 149 deletions

View File

@@ -63,10 +63,18 @@ class ConfigVar(property):
*,
default: Union[Any, Callable[['SimpleConfig'], Any]], # typically a literal, but can also be a callable
type_=None,
short_desc: Callable[[], str] = None,
long_desc: Callable[[], str] = None,
):
self._key = key
self._default = default
self._type = type_
# note: the descriptions are callables instead of str literals, to delay evaluating the _() translations
# until after the language is set.
assert short_desc is None or callable(short_desc)
assert long_desc is None or callable(long_desc)
self._short_desc = short_desc
self._long_desc = long_desc
property.__init__(self, self._get_config_value, self._set_config_value)
assert key not in _config_var_from_key, f"duplicate config key str: {key!r}"
_config_var_from_key[key] = self
@@ -102,6 +110,14 @@ class ConfigVar(property):
def get_default_value(self) -> Any:
return self._default
def get_short_desc(self) -> Optional[str]:
desc = self._short_desc
return desc() if desc else None
def get_long_desc(self) -> Optional[str]:
desc = self._long_desc
return desc() if desc else None
def __repr__(self):
return f"<ConfigVar key={self._key!r}>"
@@ -128,6 +144,12 @@ class ConfigVarWithConfig:
def get_default_value(self) -> Any:
return self._config_var.get_default_value()
def get_short_desc(self) -> Optional[str]:
return self._config_var.get_short_desc()
def get_long_desc(self) -> Optional[str]:
return self._config_var.get_long_desc()
def is_modifiable(self) -> bool:
return self._config.is_modifiable(self._config_var)
@@ -867,33 +889,96 @@ class SimpleConfig(Logger):
NETWORK_MAX_INCOMING_MSG_SIZE = ConfigVar('network_max_incoming_msg_size', default=1_000_000, type_=int) # in bytes
NETWORK_TIMEOUT = ConfigVar('network_timeout', default=None, type_=int)
WALLET_BATCH_RBF = ConfigVar('batch_rbf', default=False, type_=bool)
WALLET_SPEND_CONFIRMED_ONLY = ConfigVar('confirmed_only', default=False, type_=bool)
WALLET_BATCH_RBF = ConfigVar(
'batch_rbf', default=False, type_=bool,
short_desc=lambda: _('Batch unconfirmed transactions'),
long_desc=lambda: (
_('If you check this box, your unconfirmed transactions will be consolidated into a single transaction.') + '\n' +
_('This will save fees, but might have unwanted effects in terms of privacy')),
)
WALLET_SPEND_CONFIRMED_ONLY = ConfigVar(
'confirmed_only', default=False, type_=bool,
short_desc=lambda: _('Spend only confirmed coins'),
long_desc=lambda: _('Spend only confirmed inputs.'),
)
WALLET_COIN_CHOOSER_POLICY = ConfigVar('coin_chooser', default='Privacy', type_=str)
WALLET_COIN_CHOOSER_OUTPUT_ROUNDING = ConfigVar('coin_chooser_output_rounding', default=True, type_=bool)
WALLET_COIN_CHOOSER_OUTPUT_ROUNDING = ConfigVar(
'coin_chooser_output_rounding', default=True, type_=bool,
short_desc=lambda: _('Enable output value rounding'),
long_desc=lambda: (
_('Set the value of the change output so that it has similar precision to the other outputs.') + '\n' +
_('This might improve your privacy somewhat.') + '\n' +
_('If enabled, at most 100 satoshis might be lost due to this, per transaction.')),
)
WALLET_UNCONF_UTXO_FREEZE_THRESHOLD_SAT = ConfigVar('unconf_utxo_freeze_threshold', default=5_000, type_=int)
WALLET_BIP21_LIGHTNING = ConfigVar('bip21_lightning', default=False, type_=bool)
WALLET_BOLT11_FALLBACK = ConfigVar('bolt11_fallback', default=True, type_=bool)
WALLET_BIP21_LIGHTNING = ConfigVar(
'bip21_lightning', default=False, type_=bool,
short_desc=lambda: _('Add lightning requests to bitcoin URIs'),
long_desc=lambda: _('This may result in large QR codes'),
)
WALLET_BOLT11_FALLBACK = ConfigVar(
'bolt11_fallback', default=True, type_=bool,
short_desc=lambda: _('Add on-chain fallback to lightning requests'),
)
WALLET_PAYREQ_EXPIRY_SECONDS = ConfigVar('request_expiry', default=invoices.PR_DEFAULT_EXPIRATION_WHEN_CREATING, type_=int)
WALLET_USE_SINGLE_PASSWORD = ConfigVar('single_password', default=False, type_=bool)
# note: 'use_change' and 'multiple_change' are per-wallet settings
WALLET_SEND_CHANGE_TO_LIGHTNING = ConfigVar('send_change_to_lightning', default=False, type_=bool)
WALLET_SEND_CHANGE_TO_LIGHTNING = ConfigVar(
'send_change_to_lightning', default=False, type_=bool,
short_desc=lambda: _('Send change to Lightning'),
long_desc=lambda: _('If possible, send the change of this transaction to your channels, with a submarine swap'),
)
FX_USE_EXCHANGE_RATE = ConfigVar('use_exchange_rate', default=False, type_=bool)
FX_CURRENCY = ConfigVar('currency', default='EUR', type_=str)
FX_EXCHANGE = ConfigVar('use_exchange', default='CoinGecko', type_=str) # default exchange should ideally provide historical rates
FX_HISTORY_RATES = ConfigVar('history_rates', default=False, type_=bool)
FX_HISTORY_RATES_CAPITAL_GAINS = ConfigVar('history_rates_capital_gains', default=False, type_=bool)
FX_SHOW_FIAT_BALANCE_FOR_ADDRESSES = ConfigVar('fiat_address', default=False, type_=bool)
FX_HISTORY_RATES = ConfigVar(
'history_rates', default=False, type_=bool,
short_desc=lambda: _('Download historical rates'),
)
FX_HISTORY_RATES_CAPITAL_GAINS = ConfigVar(
'history_rates_capital_gains', default=False, type_=bool,
short_desc=lambda: _('Show Capital Gains'),
)
FX_SHOW_FIAT_BALANCE_FOR_ADDRESSES = ConfigVar(
'fiat_address', default=False, type_=bool,
short_desc=lambda: _('Show Fiat balances'),
)
LIGHTNING_LISTEN = ConfigVar('lightning_listen', default=None, type_=str)
LIGHTNING_PEERS = ConfigVar('lightning_peers', default=None)
LIGHTNING_USE_GOSSIP = ConfigVar('use_gossip', default=False, type_=bool)
LIGHTNING_USE_RECOVERABLE_CHANNELS = ConfigVar('use_recoverable_channels', default=True, type_=bool)
LIGHTNING_ALLOW_INSTANT_SWAPS = ConfigVar('allow_instant_swaps', default=False, type_=bool)
LIGHTNING_USE_GOSSIP = ConfigVar(
'use_gossip', default=False, type_=bool,
short_desc=lambda: _("Use trampoline routing"),
long_desc=lambda: _("""Lightning payments require finding a path through the Lightning Network. You may use trampoline routing, or local routing (gossip).
Downloading the network gossip uses quite some bandwidth and storage, and is not recommended on mobile devices. If you use trampoline, you can only open channels with trampoline nodes."""),
)
LIGHTNING_USE_RECOVERABLE_CHANNELS = ConfigVar(
'use_recoverable_channels', default=True, type_=bool,
short_desc=lambda: _("Create recoverable channels"),
long_desc=lambda: _("""Add extra data to your channel funding transactions, so that a static backup can be recovered from your seed.
Note that static backups only allow you to request a force-close with the remote node. This assumes that the remote node is still online, did not lose its data, and accepts to force close the channel.
If this is enabled, other nodes cannot open a channel to you. Channel recovery data is encrypted, so that only your wallet can decrypt it. However, blockchain analysis will be able to tell that the transaction was probably created by Electrum."""),
)
LIGHTNING_ALLOW_INSTANT_SWAPS = ConfigVar(
'allow_instant_swaps', default=False, type_=bool,
short_desc=lambda: _("Allow instant swaps"),
long_desc=lambda: _("""If this option is checked, your client will complete reverse swaps before the funding transaction is confirmed.
Note you are at risk of losing the funds in the swap, if the funding transaction never confirms."""),
)
LIGHTNING_TO_SELF_DELAY_CSV = ConfigVar('lightning_to_self_delay', default=7 * 144, type_=int)
LIGHTNING_MAX_FUNDING_SAT = ConfigVar('lightning_max_funding_sat', default=LN_MAX_FUNDING_SAT_LEGACY, type_=int)
LIGHTNING_LEGACY_ADD_TRAMPOLINE = ConfigVar('lightning_legacy_add_trampoline', default=False, type_=bool)
LIGHTNING_LEGACY_ADD_TRAMPOLINE = ConfigVar(
'lightning_legacy_add_trampoline', default=False, type_=bool,
short_desc=lambda: _("Add extra trampoline to legacy payments"),
long_desc=lambda: _("""When paying a non-trampoline invoice, add an extra trampoline to the route, in order to improve your privacy.
This will result in longer routes; it might increase your fees and decrease the success rate of your payments."""),
)
EXPERIMENTAL_LN_FORWARD_PAYMENTS = ConfigVar('lightning_forward_payments', default=False, type_=bool)
EXPERIMENTAL_LN_FORWARD_TRAMPOLINE_PAYMENTS = ConfigVar('lightning_forward_trampoline_payments', default=False, type_=bool)
@@ -921,18 +1006,36 @@ class SimpleConfig(Logger):
GUI_NAME = ConfigVar('gui', default='qt', type_=str)
GUI_LAST_WALLET = ConfigVar('gui_last_wallet', default=None, type_=str)
GUI_QT_COLOR_THEME = ConfigVar('qt_gui_color_theme', default='default', type_=str)
GUI_QT_COLOR_THEME = ConfigVar(
'qt_gui_color_theme', default='default', type_=str,
short_desc=lambda: _('Color theme'),
)
GUI_QT_DARK_TRAY_ICON = ConfigVar('dark_icon', default=False, type_=bool)
GUI_QT_WINDOW_IS_MAXIMIZED = ConfigVar('is_maximized', default=False, type_=bool)
GUI_QT_HIDE_ON_STARTUP = ConfigVar('hide_gui', default=False, type_=bool)
GUI_QT_HISTORY_TAB_SHOW_TOOLBAR = ConfigVar('show_toolbar_history', default=False, type_=bool)
GUI_QT_ADDRESSES_TAB_SHOW_TOOLBAR = ConfigVar('show_toolbar_addresses', default=False, type_=bool)
GUI_QT_TX_DIALOG_FETCH_TXIN_DATA = ConfigVar('tx_dialog_fetch_txin_data', default=False, type_=bool)
GUI_QT_TX_DIALOG_FETCH_TXIN_DATA = ConfigVar(
'tx_dialog_fetch_txin_data', default=False, type_=bool,
short_desc=lambda: _('Download missing data'),
long_desc=lambda: _(
'Download parent transactions from the network.\n'
'Allows filling in missing fee and input details.'),
)
GUI_QT_RECEIVE_TABS_INDEX = ConfigVar('receive_tabs_index', default=0, type_=int)
GUI_QT_RECEIVE_TAB_QR_VISIBLE = ConfigVar('receive_qr_visible', default=False, type_=bool)
GUI_QT_TX_EDITOR_SHOW_IO = ConfigVar('show_tx_io', default=False, type_=bool)
GUI_QT_TX_EDITOR_SHOW_FEE_DETAILS = ConfigVar('show_tx_fee_details', default=False, type_=bool)
GUI_QT_TX_EDITOR_SHOW_LOCKTIME = ConfigVar('show_tx_locktime', default=False, type_=bool)
GUI_QT_TX_EDITOR_SHOW_IO = ConfigVar(
'show_tx_io', default=False, type_=bool,
short_desc=lambda: _('Show inputs and outputs'),
)
GUI_QT_TX_EDITOR_SHOW_FEE_DETAILS = ConfigVar(
'show_tx_fee_details', default=False, type_=bool,
short_desc=lambda: _('Edit fees manually'),
)
GUI_QT_TX_EDITOR_SHOW_LOCKTIME = ConfigVar(
'show_tx_locktime', default=False, type_=bool,
short_desc=lambda: _('Edit Locktime'),
)
GUI_QT_SHOW_TAB_ADDRESSES = ConfigVar('show_addresses_tab', default=False, type_=bool)
GUI_QT_SHOW_TAB_CHANNELS = ConfigVar('show_channels_tab', default=False, type_=bool)
GUI_QT_SHOW_TAB_UTXO = ConfigVar('show_utxo_tab', default=False, type_=bool)
@@ -943,21 +1046,59 @@ class SimpleConfig(Logger):
GUI_QML_USER_KNOWS_PRESS_AND_HOLD = ConfigVar('user_knows_press_and_hold', default=False, type_=bool)
BTC_AMOUNTS_DECIMAL_POINT = ConfigVar('decimal_point', default=DECIMAL_POINT_DEFAULT, type_=int)
BTC_AMOUNTS_FORCE_NZEROS_AFTER_DECIMAL_POINT = ConfigVar('num_zeros', default=0, type_=int)
BTC_AMOUNTS_PREC_POST_SAT = ConfigVar('amt_precision_post_satoshi', default=0, type_=int)
BTC_AMOUNTS_ADD_THOUSANDS_SEP = ConfigVar('amt_add_thousands_sep', default=False, type_=bool)
BTC_AMOUNTS_FORCE_NZEROS_AFTER_DECIMAL_POINT = ConfigVar(
'num_zeros', default=0, type_=int,
short_desc=lambda: _('Zeros after decimal point'),
long_desc=lambda: _('Number of zeros displayed after the decimal point. For example, if this is set to 2, "1." will be displayed as "1.00"'),
)
BTC_AMOUNTS_PREC_POST_SAT = ConfigVar(
'amt_precision_post_satoshi', default=0, type_=int,
short_desc=lambda: _("Show Lightning amounts with msat precision"),
)
BTC_AMOUNTS_ADD_THOUSANDS_SEP = ConfigVar(
'amt_add_thousands_sep', default=False, type_=bool,
short_desc=lambda: _("Add thousand separators to bitcoin amounts"),
)
BLOCK_EXPLORER = ConfigVar('block_explorer', default='Blockstream.info', type_=str)
BLOCK_EXPLORER = ConfigVar(
'block_explorer', default='Blockstream.info', type_=str,
short_desc=lambda: _('Online Block Explorer'),
long_desc=lambda: _('Choose which online block explorer to use for functions that open a web browser'),
)
BLOCK_EXPLORER_CUSTOM = ConfigVar('block_explorer_custom', default=None)
VIDEO_DEVICE_PATH = ConfigVar('video_device', default='default', type_=str)
OPENALIAS_ID = ConfigVar('alias', default="", type_=str)
VIDEO_DEVICE_PATH = ConfigVar(
'video_device', default='default', type_=str,
short_desc=lambda: _('Video Device'),
long_desc=lambda: (_("For scanning QR codes.") + "\n" +
_("Install the zbar package to enable this.")),
)
OPENALIAS_ID = ConfigVar(
'alias', default="", type_=str,
short_desc=lambda: 'OpenAlias',
long_desc=lambda: (
_('OpenAlias record, used to receive coins and to sign payment requests.') + '\n\n' +
_('The following alias providers are available:') + '\n' +
'\n'.join(['https://cryptoname.co/', 'http://xmr.link']) + '\n\n' +
'For more information, see https://openalias.org'),
)
HWD_SESSION_TIMEOUT = ConfigVar('session_timeout', default=300, type_=int)
CLI_TIMEOUT = ConfigVar('timeout', default=60, type_=float)
AUTOMATIC_CENTRALIZED_UPDATE_CHECKS = ConfigVar('check_updates', default=False, type_=bool)
WRITE_LOGS_TO_DISK = ConfigVar('log_to_file', default=False, type_=bool)
AUTOMATIC_CENTRALIZED_UPDATE_CHECKS = ConfigVar(
'check_updates', default=False, type_=bool,
short_desc=lambda: _("Automatically check for software updates"),
)
WRITE_LOGS_TO_DISK = ConfigVar(
'log_to_file', default=False, type_=bool,
short_desc=lambda: _("Write logs to file"),
long_desc=lambda: _('Debug logs can be persisted to disk. These are useful for troubleshooting.'),
)
LOGS_NUM_FILES_KEEP = ConfigVar('logs_num_files_keep', default=10, type_=int)
GUI_ENABLE_DEBUG_LOGS = ConfigVar('gui_enable_debug_logs', default=False, type_=bool)
LOCALIZATION_LANGUAGE = ConfigVar('language', default="", type_=str)
LOCALIZATION_LANGUAGE = ConfigVar(
'language', default="", type_=str,
short_desc=lambda: _("Language"),
long_desc=lambda: _("Select which language is used in the GUI (after restart)."),
)
BLOCKCHAIN_PREFERRED_BLOCK = ConfigVar('blockchain_preferred_block', default=None)
SHOW_CRASH_REPORTER = ConfigVar('show_crash_reporter', default=True, type_=bool)
DONT_SHOW_TESTNET_WARNING = ConfigVar('dont_show_testnet_warning', default=False, type_=bool)
@@ -975,7 +1116,15 @@ class SimpleConfig(Logger):
TEST_SWAPSERVER_REFUND = ConfigVar('test_swapserver_refund', default=False, type_=bool)
# connect to remote WT
WATCHTOWER_CLIENT_ENABLED = ConfigVar('use_watchtower', default=False, type_=bool)
WATCHTOWER_CLIENT_ENABLED = ConfigVar(
'use_watchtower', default=False, type_=bool,
short_desc=lambda: _("Use a remote watchtower"),
long_desc=lambda: ' '.join([
_("A watchtower is a daemon that watches your channels and prevents the other party from stealing funds by broadcasting an old state."),
_("If you have private a watchtower, enter its URL here."),
_("Check our online documentation if you want to configure Electrum as a watchtower."),
]),
)
WATCHTOWER_CLIENT_URL = ConfigVar('watchtower_url', default=None, type_=str)
# run WT locally