Commit Graph

160 Commits

Author SHA1 Message Date
SomberNight
3c019c2f9c daemon/wallet/network: make stop() methods async 2021-03-09 17:52:36 +01:00
SomberNight
34413a9c30 python 3.6 compat: asyncio.Task.set_name was added in 3.8 2021-03-05 20:11:54 +01:00
SomberNight
064670bd75 network: close interfaces more aggressively (abort after 2 seconds)
fixes #7083
2021-03-04 17:47:49 +01:00
SomberNight
ff485cee62 use functools.wraps() for some wrappers
to help debugging
2021-03-04 16:44:13 +01:00
SomberNight
228c4b4597 synchronizer: better handle history-status mismatch
When receiving the history of an address, the client behaved unexpectedly
if either of two checks failed.
The client checked that the txids in the history are unique, and that the
history matches the previously announced status. If either failed, it
would just log a line and do nothing. Importantly, the synchronizer could
even consider itself is_up_to_date, i.e. the GUI could show the wallet is
synced.

This is now changed such that:
- if the txid uniqueness test fails, we simply disconnect
- if the history is not consistent with previously announced status,
  we wait a bit, make sure is_up_to_date is False in the meantime,
  and then potentially disconnect
See rationale for these in the comments.

related: https://github.com/spesmilo/electrum/issues/7058#issuecomment-783613084
2021-02-24 12:32:54 +01:00
SomberNight
26d73cba0e interface.get_history: enforce sorted order of heights
related: #7058
2021-02-23 02:13:16 +01:00
SomberNight
1ee99cf9c4 interface: "block.headers": nicer error if server uses too low 'max'
related 4ff6a9c4f0
2021-02-18 20:40:38 +01:00
SomberNight
338adf05ba interface.get_transaction: stricter sanitisation
in particular, Transaction.__init__ allows leading/trailing whitespaces
2021-01-27 20:46:49 +01:00
SomberNight
60792dc808 network: fix not retrying main interface in some cases
This was a regression from e83f0dd3fc,
introduced by the change in connection_down() there.
(if the initial connection to the main interface is not successful, the
network status will not be set to 'disconnected' - but it should be)
That change is now reverted here.
That change was somewhat independent of the rest of that commit,
except the rest highlighted that something of the sort was needed:
as it might sometimes take many seconds for an interface to close
and we might launch another interface for the same server while the
first one is still closing, the "server == self.default_server" test
is highly problematic.
To fix this second - original - issue, we now introduce a "closing" state
for interfaces (in the form of network._closing_ifaces).
2021-01-21 04:02:11 +01:00
SomberNight
b1449a0a39 interface.got_disconnected: change from Future to Event
Events are far easier to reason about.
2021-01-21 03:11:15 +01:00
ln2max
42366ba57d network: increase MOST_RELAXED default timeout to 10 minutes
related: https://github.com/spesmilo/electrum/pull/6741
2020-12-16 11:02:09 +01:00
SomberNight
e83f0dd3fc network: when switching servers, don't wait for old interface to close
The GUI blocks until network.set_parameters returns when switching servers,
which waits for switch_to_interface, which used to wait until interface.close()
returns. interface.close() tries to flush buffered writes to the wire, with a
30 sec timeout.

If the server or the network connection is slow, flushing the buffer can take
several seconds. In particular, servers running Fulcrum always seem to
timeout in this case, freezing the GUI for 30 seconds (when switching away).
2020-12-13 18:08:36 +01:00
SomberNight
de80f68e4d interface: validate protocol-version negotiation on client-side too
related: https://github.com/romanz/electrs/issues/314
2020-11-03 20:45:31 +01:00
SomberNight
5481fd8af6 interface: validate field order in "mempool.get_fee_histogram" response 2020-10-26 02:07:30 +01:00
SomberNight
c5da22a9dd network: tighten checks of server responses for type/sanity 2020-10-16 19:30:42 +02: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
aae06116f9 follow-up prev 2020-09-25 11:23:23 +02:00
SomberNight
5a7c3dc4d0 network: make MAX_INCOMING_MSG_SIZE configurable from config
requested in https://github.com/spesmilo/electrum/issues/4315#issuecomment-698730778
2020-09-25 11:15:04 +02:00
SomberNight
d19ff43266 interface: check server response for some methods
some basic sanity checks

Previously if the server sent back a malformed response, it could partially corrupt a wallet file.
(as sometimes the response would get persisted, and issues would only arise later when the values were used)
2020-07-02 15:41:39 +02:00
SomberNight
3766420a0b network: clarify local_height/server_height 2020-06-21 08:20:56 +02:00
SomberNight
56a9ccca6d interface: make localhost exempt from ip-range bucketing 2020-04-25 06:38:26 +02:00
SomberNight
38980a4f5c interface: (trivial) make some methods private 2020-04-24 17:18:05 +02:00
Luke Childs
ca1046bce2 Add --serverfingerprint option (#6094)
* Add --fingerprint option

* Simplify conditional checks

* Improve warning wording

* Throw error instead of logging and returning

* --fingerprint => --serverfingerprint

* Only run fingerprint checks against main server

* Throw error if --serverfingerprint is set for a non SSL main server

* Fix linting errors

* Don't check certificate fingerprint in a seperate connection

* Disallow CA signed certs when a fingerprint is provided

* Show clear error and then exit for Qt GUI users

* Remove leading newlines from error dialog

* Always check is_main_server() when getting fingerprint

* Document how to generate SSL cert fingerprint
2020-04-24 14:11:40 +00: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
ea64b2af64 interface.get_certificate: use public asyncio APIs 2020-04-16 17:31:58 +02:00
SomberNight
223b62554e lntransport: use network proxy if available
fixes #4824
2020-04-15 21:44:09 +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
ThomasV
133d74adfb fee estimates: use median if auto-connect 2020-03-12 15:39:50 +01:00
SomberNight
ed234d3444 rename all TaskGroup() fields to "taskgroup"
for consistency
2020-02-27 19:13:56 +01:00
SomberNight
e65ce96f9d interface: better error msg for main server re SSL cert issues
(logger.warning is shown even without -v, if there is a terminal)

closes #5884
2020-01-12 04:29:39 +01:00
SomberNight
0b0139c676 network.get_transaction: move some response validation logic from Synchronizer 2020-01-09 19:23:28 +01:00
SomberNight
787ac5fe99 interface: make changing max incoming msg size (1 MB) easier 2019-12-27 17:43:12 +01:00
SomberNight
24ebc77d76 ln chan verifier: fix code rot 2019-12-10 01:14:38 +01:00
SomberNight
68dad21fb4 network: make best_effort_reliable smarter and a bit more lenient
related: #5815
2019-12-01 23:24:43 +01:00
SomberNight
a13344938f interface: fix connecting to raw IPv6 (as hostname) on Windows
Changed cert pinning filename as on Windows paths cannot contain a colon ':'.
2019-11-27 13:08:22 +01:00
SomberNight
d430ec4bfc interface.deserialize_server: better ipv6 handling 2019-11-26 00:17:00 +01:00
SomberNight
a10dc04b28 wallet: fix offline hw wallet signing when not specifying --offline
closes #5532
2019-07-29 13:27:37 +02:00
SomberNight
935ab9a12f interface: check if future already done in handle_disconnect
future could get cancelled in network.py in which case set_result raised
2019-06-28 21:13:33 +02:00
SomberNight
4fc43da344 interface.debug will now also print errors 2019-06-26 01:16:34 +02:00
SomberNight
ab81a09de2 interface: hide some server-induced errors from log 2019-05-28 21:23:06 +02:00
SomberNight
d17e6a1b87 interface: fix for aiorpcx 0.18 2019-05-28 06:14:53 +02:00
SomberNight
41f160dd74 update to aiorpcx 0.18 2019-05-27 19:35:30 +02:00
SomberNight
eaf203dbb5 interface: fix connecting to new servers using self-signed certs
got broken in 6ec1578a90
2019-05-27 19:09:54 +02:00
SomberNight
e1c1a9d6a2 interface: add comment 2019-05-25 05:20:21 +02:00
SomberNight
a591ccf9b1 interface: follow-up 6ec1578a90 2019-05-22 17:43:33 +02:00
SomberNight
6ec1578a90 follow-up prev 2019-05-21 18:43:16 +02:00
SomberNight
fecef91ee0 interface was suppressing storage r/w exceptions 2019-05-21 18:11:49 +02:00
SomberNight
e8bc5bbec4 interface: follow-up 6cc70bc7a2 2019-05-15 19:56:16 +02:00
SomberNight
6cc70bc7a2 interface: when disconnecting due to RPCError, don't dump traceback 2019-05-14 15:58:02 +02:00