Commit Graph

19 Commits

Author SHA1 Message Date
ThomasV
9f5f802cd1 config: save ports instead of net addresses (follow-up 012ce1c1bb) 2023-08-11 08:12:54 +02:00
ThomasV
012ce1c1bb Remove SSL options from config.
This is out of scope for Electrum; HTTP services that require SSL
should be exposed to the world through a reverse proxy.
2023-08-10 17:24:29 +02:00
SomberNight
d51f00e2a3 asyncio.wait_for() is too buggy. use util.wait_for2() instead
wasted some time because asyncio.wait_for() was suppressing cancellations. [0][1][2]
deja vu... [3]

Looks like this is finally getting fixed in cpython 3.12 [4]
So far away...
In attempt to avoid encountering this again, let's try using
asyncio.timeout in 3.11, which is how upstream reimplemented wait_for in 3.12 [4], and
aiorpcx.timeout_after in 3.8-3.10.

[0] https://github.com/python/cpython/issues/86296
[1] https://bugs.python.org/issue42130
[2] https://bugs.python.org/issue45098
[3] https://github.com/kyuupichan/aiorpcX/issues/44
[4] https://github.com/python/cpython/pull/98518
2023-08-04 18:18:21 +00:00
Sander van Grieken
2a4d2ac009 payserver: fix import 2023-06-02 13:35:51 +02: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
ThomasV
2e70776a72 fix missing import 2023-04-12 12:21:08 +02:00
ThomasV
2203bba4ea fix flake8 test 2023-04-12 11:59:52 +02:00
ThomasV
0544c4b651 payserver: fix #8299 2023-04-12 11:28:16 +02:00
SomberNight
b20933de6d payserver: better handle running with --offline
```
 19.70 | E | plugin | Plugin error. plugin: payserver, hook: wallet_export_request
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/plugin.py", line 227, in run_hook
    r = f(*args)
  File "/home/user/wspace/electrum/electrum/plugins/payserver/payserver.py", line 69, in wallet_export_request
    d['view_url'] = self.view_url(key)
  File "/home/user/wspace/electrum/electrum/plugins/payserver/payserver.py", line 55, in view_url
    return self.server.base_url + self.server.root + '/pay?id=' + key
AttributeError: 'NoneType' object has no attribute 'base_url'
```
```
 23.22 | E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/plugins/payserver/qt.py", line 48, in settings_dialog
    url = self.server.base_url + self.server.root + '/create_invoice.html'
AttributeError: 'NoneType' object has no attribute 'base_url'
```
2023-02-08 01:51:43 +00:00
ThomasV
dec397af95 update payserver submodule 2023-01-26 15:52:01 +01:00
ThomasV
396fa4a97a payserver: add 'view in payserver' menu item 2023-01-18 11:28:37 +01:00
ThomasV
d13c74eb0d payserver plugin improvements 2023-01-17 12:26:03 +01:00
ThomasV
f680607683 update payserver submodule 2023-01-17 07:35:52 +01:00
ThomasV
9f8b91da50 update payserver submodule 2023-01-16 13:57:08 +01:00
ThomasV
2c0dd0deb0 update payserver www submodule 2023-01-15 10:43:45 +01:00
SomberNight
d5c3c7ca66 payserver: daemon._run should only be called once 2023-01-13 01:02:47 +00:00
SomberNight
9039ec1dc4 payserver: make daemon_wallet_loaded hook reliable
daemon.load_wallet() often early-returns,
e.g. in Qt case, for storage-encrypted wallets.

closes https://github.com/spesmilo/electrum/issues/8118
2023-01-13 00:58:02 +00:00
ThomasV
3bb453aaba PayServer: add settings dialog and hook for view_url 2022-10-28 13:52:24 +02:00
ThomasV
724edd223c make PayServer a plugin 2022-10-28 12:07:30 +02:00