Commit Graph

67 Commits

Author SHA1 Message Date
SomberNight 5b9b616146 simple_config: allow deepcopy-ing ConfigVars
Was getting error:
```
>>> import copy
>>> from electrum.simple_config import SimpleConfig
>>> copy.deepcopy(SimpleConfig.EXPERIMENTAL_LN_FORWARD_PAYMENTS)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "...\Python\Python310\lib\copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'ConfigVar' object
```

This is useful in tests/test_lnpeer.py, to deepcopy the GRAPH_DEFINITIONS dict.
2023-07-11 14:50:09 +00:00
ThomasV cc57648a0c follow-up previous commit 2023-06-19 14:49:25 +02:00
ThomasV 39f8664402 make submarine swap server url configurable 2023-06-19 14:46:56 +02:00
SomberNight 23f2412da7 qt: follow-up "rm thousand sep when copying numbers to clipboard"
follow-up https://github.com/spesmilo/electrum/pull/8479
2023-06-13 15:59:18 +00:00
Thomas cdab59f620 remove thousand separator when copying numbers to clipboard
from contextual menus
2023-06-11 23:55:10 +02:00
SomberNight 328a2bb3f2 config: migrate qt gui optional tabs to config vars 2023-05-30 14:04:20 +00:00
SomberNight dfa2b71bc3 config: trivial rename for better readability 2023-05-30 14:04:17 +00:00
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 03ab33f4b2 SimpleConfig: change API of set_key(): "save" is now kwarg-only 2023-05-25 17:37:16 +00:00
SomberNight 312f2641e7 don't use bare except
use "except Exception", or if really needed explicitly "except BaseException"
2023-04-24 12:58:01 +00:00
SomberNight fc6cbb39ea qml: QEConfig.formatMilliSats to use config.format_amount 2023-03-31 22:17:53 +00:00
x fffbccff3b make it easier to troubleshoot config parse errors
Change the logging message displayed when the config file can't be
parsed: include the underlying exception text, so that a user who is
attepting to edit the config manually can find and fix any errors.
2022-10-24 17:51:57 +02:00
avirgovi b5d2b3c512 create chmod aware of XDG_RUNTIME_DIR
closes https://github.com/spesmilo/electrum/pull/7681
related https://github.com/spesmilo/electrum/issues/6334

Co-authored-by: avirgovi <avirgovi@cisco.com>
Co-authored-by: SomberNight <somber.night@protonmail.com>
2022-08-09 19:04:17 +02:00
SomberNight 7268fa55f2 config: abstract away mempool depth format str "%.1f MB from tip"
related: https://github.com/spesmilo/electrum/commit/4dd94172a6dc87a32bd6b0542c7c985f23afab1f
(as that commit introduced depth targets that need more precision to display)
2022-03-31 22:50:31 +02:00
SomberNight 4dd94172a6 config: fee slider: add more steps in mempool mode
closes https://github.com/spesmilo/electrum/issues/6474
2022-03-29 20:22:09 +02:00
ThomasV a15dac2b8c channel_establishment_flow: do not save wallet file backup in the background.
Instead, display a popup everytime, if the channel is not recoverable.
2022-03-24 14:55:45 +01:00
SomberNight 05649861c8 qt gui: more resilient startup: catch more exceptions, better fallback
fixes https://github.com/spesmilo/electrum/issues/7447

Consider this trace for 4.2.0:
```
Traceback (most recent call last):
  File "electrum/gui/qt/__init__.py", line 332, in start_new_window
  File "electrum/gui/qt/__init__.py", line 363, in _start_wizard_to_select_or_create_wallet
  File "electrum/gui/qt/installwizard.py", line 302, in select_storage
  File "electrum/util.py", line 504, in get_new_wallet_name
PermissionError: [Errno 1] Operation not permitted: '/Users/admin/Documents/Peach/MS'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "electrum/gui/qt/__init__.py", line 426, in main
  File "electrum/gui/qt/__init__.py", line 307, in wrapper
  File "electrum/gui/qt/__init__.py", line 349, in start_new_window
  File "electrum/util.py", line 504, in get_new_wallet_name
PermissionError: [Errno 1] Operation not permitted: '/Users/admin/Documents/Peach/MS'
```

Note that `get_new_wallet_name` (os.listdir) can raise OSError,
and we were calling that on the main entrypoint codepath without exception-handling.
We were also calling it in the fallback codepath without exception-handling.
i.e. the GUI errored out on every startup for affected users, and without CLI usage
it was not possible to recover.
2022-03-23 03:58:33 +01:00
SomberNight 1ff9f9910f ln update_fee: enforce that feerate is over default min relay fee
(this was always already the case when we are the funder, but we were
not checking it when remote is responsible for update_fee)
2021-09-28 19:48:31 +02:00
SomberNight e7ccf1584e config: make adding thousand separators to amounts optional 2021-07-28 15:29:16 +02:00
djboi 6a431aab8c Fixed issue with thousands separator for better readability (#7427)
util.format_satoshis: introduce new option to add thousands separators
2021-07-28 13:26:30 +00:00
SomberNight 5891e039b1 config: add option to display amounts with msat precision 2021-07-20 20:35:44 +02:00
wakiyamap 639cd94dcb add signet support 2021-05-06 19:47:22 +09:00
SomberNight 7ffb2c3cb0 config: (trivial) add some type hints and rm unused variable 2021-04-15 19:00:46 +02:00
SomberNight f53f177203 kivy swaps: handle no dynamic fee estimates
fixes #7215
2021-04-15 18:50:54 +02:00
ThomasV 18d7db12da Change warning shown on first channel creation
Qt: if created channel is not recoverable, show channel backup after creation
2021-03-24 10:24:14 +01:00
ThomasV 90d66953cf kivy: add confirm_tx_dialog, similar to qt 2021-01-19 14:15:07 +01:00
bitromortac 08ec368baf fee-slider: fix dialog crashes for float pos values 2021-01-18 10:38:15 +01:00
SomberNight fc97181aa5 config: fix get_fee_text for static fees
mismatching units
2020-11-04 01:49:57 +01:00
SomberNight ea22d0073e config: distinguish knowing mempool is empty vs not having mempool_fees
config.mempool_fees is now [] if server claims mempool is ~empty,
and None if no valid histogram has been received from server.
(previously it used to be [] in both cases)
2020-10-27 18:55:39 +01:00
SomberNight c5da22a9dd network: tighten checks of server responses for type/sanity 2020-10-16 19:30:42 +02:00
SomberNight 547b231b80 config: make sure fee_per_kb() returns Optional[int]
electrs sends fee histogram with float feerates
2020-10-15 19:50:59 +02:00
SomberNight caa68e2fe8 (trivial) config.get_netaddress: use NetAddress.from_string 2020-09-16 17:38:20 +02:00
SomberNight b6db201570 util: small clean-up for format_satoshis 2020-06-22 02:46:16 +02:00
ThomasV 959af0065b follow-up previous commit: cleanup imports 2020-05-26 16:06:15 +02:00
ThomasV 7490787d38 follow-up previous commit 2020-05-26 15:55:47 +02:00
ThomasV 1c436bbc22 move units and amount formatting to simple_config 2020-05-26 15:49:28 +02:00
SomberNight 7da8c2dfe5 qt/kivy: show warning when sending tx with high fee/amount ratio
related: #6162
2020-05-15 20:00:59 +02:00
ThomasV 11aaa0b66f Simplify services (watchtower, payserver):
- Do not expose services settings in GUI
 - Use a single netaddress configuration variable.
2020-05-10 14:52:50 +02:00
ThomasV b891d3dc85 new command: get_ssl_domain 2020-05-09 10:33:18 +02:00
SomberNight 69de3b94db config: "serverfingerprint" key requires "server" key
follow-up prev
2020-04-24 17:17:12 +02:00
ThomasV 89fa9b5090 Merge pull request #5898 from leo-lb/plausible-deniability-config
Add command line option to forget config on exit.
2020-03-03 11:50:04 +01:00
ThomasV 4ec86d36a8 faster and improved regtests
- print the test name before each test
 - start only needed agents (alice, bob, carol)
 - set settle_delay using setconfig instead of restarting daemon
 - test the watchtower ctn in test_watchtower
2020-02-02 15:07:28 +01:00
Leo Le Bouter f81db9cd1d Add command line option to forget config on exit.
By default, Electrum saves the last opened wallet's path as well as
recently opened wallets.

This can be damaging to plausible deniability.

Now it's possible to run Electrum with `--forgetconfig` to not
write to the config at all, which includes the wallet paths.
2020-01-21 13:32:02 +01:00
SomberNight 04edad9984 config: no longer singleton. it is passed to Wallet.__init__
The few other cases that used SimpleConfig.get_instance() now
either get passed a config instance, or they try to get a reference
to something else that has a reference to a config.
(see lnsweep, qt/qrcodewidget, qt/qrtextedit)
2019-09-22 20:46:01 +02:00
SomberNight e9a1c05d23 bitcoin.relayfee: minor clean-up 2019-09-18 22:08:19 +02:00
ThomasV 1ecbafb920 add SSL context to watchtower server 2019-09-13 12:26:27 +02:00
ThomasV 7370910fee fix simple_config.estimate_fee 2019-09-11 11:49:32 +02:00
SomberNight b2920db8b8 config: enforce that SimpleConfig is singleton
related: #5629
2019-09-10 18:01:10 +02:00
SomberNight 1a08063928 config: remove 'open_last_wallet' side-effecting
related: #5629
2019-09-10 17:10:52 +02:00
ThomasV 54257cbcca Rewrite JsonRPC requests using asyncio.
- commands are async
 - the asyncio loop is started and stopped from the main script
 - the daemon's main loop runs in the main thread
 - use jsonrpcserver and jsonrpcclient instead of jsonrpclib
2019-08-20 09:03:12 +02:00