Commit Graph

46 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
31fde2484f qt network dialog: use icon for selected server, instead of "*"
Previously we added a " *" suffix to distinguish the selected/main server
in the list. However in case of an .onion address, anything we put as a
suffix inline is elided/truncated - as the address itself does not fit.
Hence we could instead use a prefix - and then why not use an icon.
2023-03-30 14:56:33 +00:00
SomberNight
101958e022 qt network_dialog: fix right-click "Use as server" for raw IPv6 servers
`server.net_addr_str()` cuts off the trailing protocol marker, while `str(server)` has it.
`parent.set_server` then called `ServerAddr.from_str_with_inference` trying to guess the just cut off protocol,
but fails if given an IPv6 address.
2023-03-30 00:59:10 +00:00
ThomasV
fcbd25c1fd qml: display network status and history server status separately. Also, show network fees on full screen width 2023-03-17 10:15:07 +01:00
SomberNight
253150cb36 qt network dialog: don't poll Tor socks proxy, but scan on interaction
Polling is introduces spam in Tor logs.
Also, Tor Browser 12.0 apparently has a bug where our polling renders
the socks proxy unusuable after some time.
see https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/41549

Instead of trying to detect a Tor socks proxy every 10 seconds, we now
run detection when the Qt network dialog gets opened, and also when
the user switches to the "Proxy" tab in the dialog.

fixes https://github.com/spesmilo/electrum/issues/7317
2023-01-02 11:58:16 +00:00
ThomasV
dbf055de9a EventListener class to handle callbacks
and QtEventListener for Qt
2022-06-22 02:07:46 +02:00
SomberNight
981381346f qt: even more clean-up before exiting
related: https://github.com/spesmilo/electrum/issues/6889#issuecomment-812776695
2021-04-03 19:17:32 +02:00
SomberNight
34e64ef152 qt gui: some more clean-up when exiting
related: https://github.com/spesmilo/electrum/issues/6889

This fixes the case where the user quits by pressing Ctrl+C,
and some other minor things.

There is still another issue that sometimes causes a segfault during shutdown...
2021-04-03 01:44:42 +02:00
Benoit Verret
f731c38293 Minor style changes 2021-03-21 00:36:23 -04:00
SomberNight
1d9311aeef qt network dialog: show protocol (if ":t") for servers in NodesList 2021-01-27 20:46:56 +01:00
bitromortac
292016d283 network dialog: include protocol in server address field (#6624)
* network-dialog: include protocol in server field

In this way it is now possible again to use plain server connections
without reverting it automatically to tls connections.

* qt network dialog: hide trailing protocol ":s" in TextEdit

This hides some complexity from casual users, while still allowing
advanced users to set the protocol.

Co-authored-by: SomberNight <somber.night@protonmail.com>
2020-10-14 16:28:31 +00:00
SomberNight
52f4189176 qt TorDetector: close socket
ResourceWarning below is shown when running python3 with "-X dev":

...\electrum\electrum\gui\qt\network_dialog.py:457: ResourceWarning: unclosed <socket.socket fd=3276, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 55693), raddr=('127.0.0.1', 9050)>
  if TorDetector.is_tor_port(net_addr):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
2020-10-06 19:15:20 +02:00
ThomasV
b7c2820951 Qt: add Key_Enter wherever Key_Return is used 2020-08-26 19:37:52 +02:00
Richard
973d1875c4 Update network_dialog.py 2020-06-21 16:38:10 -04:00
SomberNight
58dee38ed2 qt network dialog: merge "Overview" and "Servers" tabs 2020-04-25 06:54:31 +02:00
SomberNight
bf223470ce network: handle unparseable server-str
follow-up 9e57ae630b

fixes #6113
2020-04-25 06:53:25 +02:00
SomberNight
69de3b94db config: "serverfingerprint" key requires "server" key
follow-up prev
2020-04-24 17:17:12 +02:00
SomberNight
9e57ae630b network/gui: unify host/port input fields to single server str
This allows optionally specifying the protocol for the main server.

fixes #6095
fixes #5278
2020-04-16 21:19:48 +02:00
SomberNight
b2cfaddff2 network.NetworkParameters: merge host+port+protocol into "server" field 2020-04-16 21:19:45 +02:00
SomberNight
adc3784bc2 network: allow mixed protocols among interfaces
Previously all the interfaces used either "t" or "s".
Now the network only tries to use "s" for all interfaces, except for
the main interface, which the user can manually specify to use "t".
(so e.g. if you run with "--server localhost:50002:t", the main server will use "t",
but all the rest will use "s")
2020-04-16 21:19:42 +02:00
SomberNight
cf1f2ba4dc network: replace "server" strings with ServerAddr objects 2020-04-15 17:23:47 +02:00
ThomasV
9224404108 Move callback manager out of Network class 2020-04-14 18:29:51 +02:00
SomberNight
c798e5d9a1 qt: introduce PasswordLineEdit(QLineEdit) 2020-04-07 18:58:37 +02:00
SomberNight
c9006032d9 qt network dialog: let user edit server host/port in peace
incoming network updates could keep changing the text fields while
user is editing them
2019-07-04 21:46:11 +02:00
SomberNight
37809bed74 qt high dpi: fix some text fields
There are probably other DPI related issues though.

closes #5471
closes #4597
closes #1927
2019-06-29 05:27:28 +02:00
SomberNight
e7304ce23e TorDetector: minor clean-up 2019-06-29 04:03:29 +02:00
SomberNight
3385a94753 logging: basics 2019-05-02 15:19:03 +02:00
SomberNight
15dda65c52 qt network dialog: "use Tor proxy" cb would get auto-checked incorrectly 2019-05-02 01:20:14 +02:00
SomberNight
790c889483 qt network dialog: increase min size 2019-03-07 16:33:30 +01:00
SomberNight
026448837f no more "import *"
fixes #5101
fixes #5105
2019-02-11 20:21:24 +01:00
SomberNight
43487910c7 qt network dialog: use intenum for columns 2019-02-03 20:04:33 +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
fd5ad9ac70 qt network dialog: detect Tor proxy dynamically
keep thread running to detect changes
2019-01-04 10:58:59 +01:00
SomberNight
5b9b6a931d qt network dialog: fix NodesListWidget if there is fork
undo part of 5473320ce4
2018-12-10 08:04:54 +01:00
Janus
5473320ce4 qt: use QStandardItemModel 2018-12-03 15:35:54 +01:00
SomberNight
141ff99580 blockchain.py: generalise fork ids to get rid of conflicts 2018-11-22 16:57:22 +01:00
SomberNight
37206ec08e network: auto-switch servers to preferred fork (or longest chain)
If auto_connect is enabled, allow jumping between forks too.
(Previously auto_connect was only switching servers on a given fork,
not across forks)
If there is a preferred fork set, jump to that (and stay);
if there isn't, always jump to the longest fork.
2018-10-11 20:07:19 +02:00
SomberNight
952e9b87e1 network: clean-up. make external API clear. rm interface_lock (mostly). 2018-09-25 16:44:39 +02:00
SomberNight
af63913189 network triggers: rm 'updated'; more fine-grained instead
rm 'interfaces'
add 'wallet_updated', add 'network_updated'
2018-09-18 16:49:48 +02:00
SomberNight
24ec7ce6b8 qt network dialog: maybe fix refresh bug 2018-09-17 22:31:31 +02:00
SomberNight
3d424077fd introduce NetworkParameters namedtuple 2018-09-10 00:59:53 +02:00
SomberNight
ecf4ea9ba7 move (de)serialize_server to interface; and use it 2018-09-09 23:08:44 +02:00
Janus
8f36c9167d aiorpcx: remove callback based code, add session to Interface 2018-09-06 14:17:29 +02:00
Janus
f733cb8947 aiorpcx: socks support 2018-09-06 14:11:36 +02:00
SomberNight
531cdeffa9 blockchain.py: rename 'checkpoint' to 'forkpoint' 2018-08-03 18:25:53 +02:00
Janus
097ac144d9 file reorganization with top-level module 2018-07-13 14:01:37 +02:00