Commit Graph

25 Commits

Author SHA1 Message Date
SomberNight
24980feab7 config: introduce ConfigVars
A new config API is introduced, and ~all of the codebase is adapted to it.
The old API is kept but mainly only for dynamic usage where its extra flexibility is needed.

Using examples, the old config API looked this:
```
>>> config.get("request_expiry", 86400)
604800
>>> config.set_key("request_expiry", 86400)
>>>
```

The new config API instead:
```
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS
604800
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS = 86400
>>>
```

The old API operated on arbitrary string keys, the new one uses
a static ~enum-like list of variables.

With the new API:
- there is a single centralised list of config variables, as opposed to
  these being scattered all over
- no more duplication of default values (in the getters)
- there is now some (minimal for now) type-validation/conversion for
  the config values

closes https://github.com/spesmilo/electrum/pull/5640
closes https://github.com/spesmilo/electrum/pull/5649

Note: there is yet a third API added here, for certain niche/abstract use-cases,
where we need a reference to the config variable itself.
It should only be used when needed:
```
>>> var = config.cv.WALLET_PAYREQ_EXPIRY_SECONDS
>>> var
<ConfigVarWithConfig key='request_expiry'>
>>> var.get()
604800
>>> var.set(3600)
>>> var.get_default_value()
86400
>>> var.is_set()
True
>>> var.is_modifiable()
True
```
2023-05-25 17:39:48 +00:00
SomberNight
ff2da7ceb9 crash reporter: hardcode gui text. do not trust the server with it
paranoia.
2023-03-16 19:48:35 +00:00
SomberNight
388811296e qt: replace some hardcoded pixel sizes for better high-dpi support 2022-08-10 20:23:56 +02:00
SomberNight
3771553a2c crash reporter: if disabled via config, make sure EEQueue is flushed
If the user had `config.get("show_crash_reporter")==False`, they would
never get to see excs collected via `send_exception_to_crash_reporter(exc)`.

E.g.:
```
E | gui.qt.ElectrumGui | error loading wallet (or creating window for it)
Traceback (most recent call last):
  File "/opt/electrum/electrum/gui/qt/__init__.py", line 433, in main
    if not self.start_new_window(path, self.config.get('url'), app_is_starting=True):
  File "/opt/electrum/electrum/gui/qt/__init__.py", line 307, in wrapper
    return func(self, *args, **kwargs)
  File "/opt/electrum/electrum/gui/qt/__init__.py", line 332, in start_new_window
    wallet = self._start_wizard_to_select_or_create_wallet(path)
  File "/opt/electrum/electrum/gui/qt/__init__.py", line 377, in _start_wizard_to_select_or_create_wallet
    db = WalletDB(storage.read(), manual_upgrades=False)
  File "/opt/electrum/electrum/wallet_db.py", line 73, in __init__
    self.load_data(raw)
  File "/opt/electrum/electrum/wallet_db.py", line 104, in load_data
    self._after_upgrade_tasks()
  File "/opt/electrum/electrum/wallet_db.py", line 202, in _after_upgrade_tasks
    self._load_transactions()
  File "/opt/electrum/electrum/util.py", line 439, in <lambda>
    return lambda *args, **kw_args: do_profile(args, kw_args)
  File "/opt/electrum/electrum/util.py", line 435, in do_profile
    o = func(*args, **kw_args)
  File "/opt/electrum/electrum/wallet_db.py", line 1310, in _load_transactions
    self.data = StoredDict(self.data, self, [])
  File "/opt/electrum/electrum/json_db.py", line 79, in __init__
    self.__setitem__(k, v)
  File "/opt/electrum/electrum/json_db.py", line 44, in wrapper
    return func(self, *args, **kwargs)
  File "/opt/electrum/electrum/json_db.py", line 97, in __setitem__
    v = self.db._convert_dict(self.path, key, v)
  File "/opt/electrum/electrum/wallet_db.py", line 1361, in _convert_dict
    v = dict((k, SwapData(**x)) for k, x in v.items())
```
2022-03-15 13:39:33 +01:00
SomberNight
c331c311db crash reporter: add EarlyExceptionsQueue
`util.send_exception_to_crash_reporter` is now useful and can be transparently
used even before the exception hook is set up.
2021-11-05 20:01:43 +01:00
SomberNight
d0f0669e8f crash reporter: send traceback for full chain of exceptions
Previously if there was a chain of exceptions, we were only
sending the traceback for the final exception.

E.g.
try:
    raise ExcOne("asdasd")
except ExcOne() as e:
    raise ExcTwo("qweqwe") from e

^ we would lose all info about ExcOne, including potentially many lines of trace
2021-07-12 19:24:58 +02:00
SomberNight
8945dcda7a qt init: on exc, let crash reporter appear instead of silently dying
related: https://github.com/spesmilo/electrum/issues/7390

```
20210706T091826.513398Z |    ERROR | __main__ | daemon.run_gui errored
Traceback (most recent call last):
  File "run_electrum", line 407, in handle_cmd
  File "electrum\daemon.py", line 584, in run_gui
  File "electrum\gui\qt\__init__.py", line 414, in main
  File "electrum\gui\qt\__init__.py", line 291, in wrapper
  File "electrum\gui\qt\__init__.py", line 316, in start_new_window
  File "electrum\gui\qt\__init__.py", line 361, in _start_wizard_to_select_or_create_wallet
  File "electrum\wallet_db.py", line 73, in __init__
  File "electrum\wallet_db.py", line 106, in load_data
  File "electrum\util.py", line 412, in <lambda>
  File "electrum\util.py", line 408, in do_profile
  File "electrum\wallet_db.py", line 175, in upgrade
  File "electrum\wallet_db.py", line 540, in _convert_version_24
ValueError: too many values to unpack (expected 2)
```
2021-07-07 19:19:43 +02:00
SomberNight
82bfe1ba9c kivy crash reporter: warn users not to share sensitive info
Previously only Qt had the warning.
2021-07-05 18:59:02 +02:00
SomberNight
240c823e8b crash reporter: propagate HTTP error as exception
which will then get displayed as an error, and not as if we succeeded sending...
2020-06-14 03:41:45 +02:00
SomberNight
2105c6c4e6 qt exception window: turn Exception_Hook into singleton
related #4905
related Electron-Cash/Electron-Cash@6a3d76b0ab

conceptually did not really make sense that the Exception_Hook kept a reference
to an ~arbitrary main window (preventing gc)
2020-05-01 06:33:38 +02:00
SomberNight
8f4c384aad qt crash reporter: html.escape traceback to avoid formatting issues
fixes #6099
2020-04-18 05:48:11 +02:00
SomberNight
b50c47c5ce qt exc reporter: add FIXME re HTML tags in traceback 2020-02-17 19:44:12 +01:00
SomberNight
aa3d817ef2 qt: clean-up imports 2019-11-18 20:56:49 +01:00
SomberNight
650225e238 crash reporter UX
see #5483
2019-07-04 19:13:12 +02:00
SomberNight
53893be4c9 crash reporter: in Qt subclass, do network request using WaitingDialog
so it does not block the GUI
2019-07-02 19:27:36 +02:00
SomberNight
5f71163449 qt crash reporter: add warning that report contents are public 2019-06-20 17:32:21 +02:00
SomberNight
7a99fdc275 kivy: fix crash in logging.py; platform.platform() not available 2019-05-06 19:10:29 +02:00
SomberNight
163a814dc4 logging: log exceptions caught by crash reporter 2019-05-02 15:19:11 +02:00
SomberNight
3385a94753 logging: basics 2019-05-02 15:19:03 +02:00
SomberNight
026448837f no more "import *"
fixes #5101
fixes #5105
2019-02-11 20:21:24 +01:00
SomberNight
16bac5fd73 rm qt icons file
so we don't need pyrcc5, which is not deterministic,
and so we don't need the submodule for the icons

based on electrumsv/electrumsv@bf8802c2ea
2019-02-01 20:15:28 +01:00
SomberNight
0bce96d2de qt crash report: fix formatting
follow-up 5dc240d4ed
2018-12-24 18:52:03 +01:00
Janus
52b877ac3d network: add singleton accessor classmethod, port trustedcoin to aiohttp 2018-09-07 11:35:16 +02:00
Janus
6e80ba7b4f asyncio: labels, crash_reporter, fx: migrate requests use to aiohttp 2018-09-06 16:18:45 +02:00
Janus
097ac144d9 file reorganization with top-level module 2018-07-13 14:01:37 +02:00