Commit graph

359 commits

Author SHA1 Message Date
SomberNight
8e55fe5f91
network: disconnect from server if headers sub encounters error
we need at least e-x 1.3 since 1900e58e88
for older e-x, we get stuck in infinite "synchronizing"...
2018-07-01 04:52:01 +02:00
SomberNight
4dcefa7d3b
network: fix fork detection in certain backward search cases
if there are no checkpoints and the split is very old, the exponential backward search might undershoot so that it asks for the genesis block but 0 and None are not distinguished hence the fork detection logic fails
2018-06-26 16:56:30 +02:00
SomberNight
9a8183f348
network: avoid infinite loop if server headers conflict with checkpoints and server height is above max checkpoint 2018-06-25 11:53:31 +02:00
SomberNight
f8dab46a4b
kivy: fix fork detection gui 2018-06-25 01:02:21 +02:00
SomberNight
cd41a451f6
locks in network.py 2018-06-21 21:55:32 +02:00
Francisco J. Hernandez Heras
469565c188 Improving imports (#4448) 2018-06-19 18:36:01 +02:00
SomberNight
fc6cb70c80
socket.getaddrinfo on win32: do our own dns resolution outside the lock 2018-06-09 19:15:00 +02:00
Harm Aarts
e57e55aad8 Remove explicit send calls, part deux (#4408)
* Rename synchronous_get to synchronous_send

This makes it more inline with the method 'send' of which
synchronous_send is the, well, synchronous version.

* Move protocol strings from scripts to network

This is again a small step in the right direction. The network module is
going to accumulate more and more of these simple methods. Once
everything is moved into that module, that module is going to be split.

Note that I've left the scripts which use scripts/util.py alone. I
suspect the same functionality can be reached when using just
lib/network.py and that scripts/util.py is obsolete.

* Remove protocol string from verifier and websocket

Websocket still has some references, that'll take more work to remove. Once the
network module has been split this should be easy.
I took the liberty to rename a variable to better show what it is.

* Remove protocol strings from remainder

The naming scheme I'm following for the newly introduced methods in the network
module is: 'blockchain.<subject>.<action>' -> def <action>_(for|to)_<subject>

* Move explicit protocol calls closer to each other

This makes it easier to keep track of the methods which are due to be
extracted.

* Remove `send` when using `get_transaction`

This is the final step to formalize (the informal) interface of the network
module.
A chance of note is changed interface for async/sync calls. It is no longer
required to use the `synchronous_send` call. Merely NOT passing a callback
makes the call synchronous. I feel this makes the API more intuitive to work
with and easier to replace with a different network module.

* Remove send from get_merkle_for_transaction

The pattern which emerged for calling the lambda yielded an slight refactor.
I'm not happy with the name for the `__invoke` method.

* Remove explict send from websockets

* Remove explicit send from scripts

* Remove explicit send from wallet

* Remove explicit sync_send from commands, scripts

* Remove optional timeout parameter

This parameter doesn't seem to be used a lot and removing it makes the
remaining calls easier. Potentionally a contentious choice!

* Rename `broadcast` to `broadcast_transaction`

Doing so makes the method name consistent with the other ElectrumX protocol
method names.

* Remove synchronous_send

Now every method is intuitive in what it does, no special handling required.
The `broadcast_transaction` method is weird. I've opted not to change the
return type b/c I found it hard to know what the exact consequences are. But
ideally this method should just works as all the other ElectrumX related
messages. On the other hand this shows nicely how you _can_ do something
differnt quite easy.

* Rename the awkwardly name `__invoke` method

The new name reflects what it does.

* Process the result of linter feedback

I've used flake8-diff (and ignored a couple of line length warnings).

* Rename tx_response to on_tx_response

This fell through the cracks when this branch was rebased.

* subscript_to_scripthash should be get_balance

An oversight while refactoring.

* Add missing return statement

Without this statement the transaction would have been broadcasted twice.

* Pass list of tuples to send not single tuple

* Add @staticmethod decorator

* Fix argument to be an array
2018-06-06 15:06:04 +02:00
Neil Booth
bc83fa8d68 Stop using deprecated RPC blockchain.block.get_chunk
Use blockchain.block.headers instead.  It's more flexible but
that flexibility is not used here.

Port of 09798d6b20
2018-06-06 10:58:57 +09:00
Neil
e0a6b082d2 First message on an interface is server.version (#4407)
- Use server.ping to ping (valid as of protocol version 1.2) rather
  than server.version (deprecated as a ping)
- Ping every 5 mins rather than every 1 minute.  By default servers
  don't consider a connection stale until 10 minutes of inactivity.
- Remove unused last_request member of interface

Port of c3f26e59db
2018-06-05 12:41:41 +02:00
Neil Booth
1900e58e88 Subscribe to raw headers
The old interface is deprecated

Port of fe303c97c3
2018-06-04 16:19:11 +09:00
ghost43
9b7a449057
util.make_dir: 0o700 permissions on folders (#4357) 2018-05-28 14:22:54 +02:00
SomberNight
51d047a35e
fix #4375 2018-05-22 12:55:50 +02:00
Harm Aarts
812d570ee2 Rename method to reflect its goal
Answer the question *what* problem the method solves. Not *how* it is
solving it.
2018-05-17 15:17:06 +02:00
Harm Aarts
d0d39e534e Make side effect explicit
The removed method didn't allude to the fact it was adding the generated
hash to a dictionary. This was problematic since the code base now
seemingly had two methods for converting an address to a scripthash. One
in the network module and one in the (logical) bitcoin module.
2018-05-17 12:04:54 +02:00
SomberNight
7b50790584
do not raise BaseException 2018-04-07 17:10:30 +02:00
SomberNight
76e67daadd
changed some asserts to raise-exceptions in lib 2018-04-07 17:01:38 +02:00
ThomasV
95780a39a3
Merge pull request #4169 from SomberNight/open_utf8
use explicit utf-8 encoding when opening files in text mode
2018-03-25 10:35:37 +02:00
SomberNight
fa91cbf762 network - send_subscriptions: copy subscribed_addresses before iterating
see #4146
(this should at least avoid the RuntimeError)
2018-03-24 18:34:51 +01:00
SomberNight
9b7536e75c use explicit utf-8 encoding when opening files in text mode 2018-03-23 21:47:51 +01:00
SomberNight
c79de3ab3c fix #4139 2018-03-16 22:06:38 +01:00
SomberNight
08aee6a857 logging - use self.print_error instead of util.print_error 2018-03-09 14:58:13 +01:00
SomberNight
81b6d65764 refactor network constants 2018-03-04 22:10:59 +01:00
SomberNight
0df6d1ec97 trezor: segwit offline signing 2018-03-03 02:39:49 +01:00
ThomasV
d38a50b119 fix #3922: wrong parameter passed to connection_down 2018-02-23 09:35:07 +01:00
SomberNight
02c7524d75 logging: some extra network-related lines 2018-02-22 16:44:22 +01:00
ThomasV
0928ac961a fix #3955: fix interference between verifier and catch_up 2018-02-22 16:33:39 +01:00
ThomasV
c3f3843cc3 Add memory pool based fee estimates
- fee estimates can use ETA or mempool
 - require protocol version 1.2
 - remove fee_unit preference
2018-02-05 12:23:32 +01:00
ThomasV
35878b437a network: send version first 2018-01-19 15:48:20 +01:00
SomberNight
1c10d5dce1 remove --nossl option (follow-up dc388d4c7c) 2018-01-16 12:36:39 +01:00
ThomasV
c8e67e2bd0 fix #3635 2018-01-13 17:09:25 +01:00
SomberNight
fc574ee514 fix #3578 2017-12-21 23:31:59 +01:00
ThomasV
4bab8b63e1 fix too short headers file 2017-12-20 12:37:45 +01:00
ThomasV
dc388d4c7c replace SSL checkbox in GUI with command line option 2017-12-18 14:15:10 +01:00
ThomasV
83da45a7d2 Add checkpoints file for testnet. Check that received headers are after max_checkpoint 2017-12-13 14:22:46 +01:00
ThomasV
44a83c2401 read checkpoints file in NetworkConstants, add it to setup.py 2017-12-12 11:10:50 +01:00
ThomasV
40e13224f7 follow-up d1b8a6fae6 2017-12-12 10:48:05 +01:00
ThomasV
d1b8a6fae6 Replace initial headers download with hardcoded checkpoints 2017-12-12 10:20:44 +01:00
Justin Turner Arthur
857eb4ac1d Remove unused imports. Explicitly import a few deep imports. 2017-11-13 02:28:00 -06:00
Justin Turner Arthur
9a0aa9b478 Remove Python 2 support imports. 2017-11-13 02:26:48 -06:00
SomberNight
0db5ea67a0 bitcoin.NetworkConstants: easier changing between testnet and mainnet 2017-11-09 17:47:57 +01:00
ThomasV
d4b1c66168
Merge pull request #2906 from SomberNight/polling_fees
Periodically poll fee estimates from server
2017-11-01 20:53:01 +01:00
ThomasV
319a31e64c Merge branch 'master' of github.com:spesmilo/electrum 2017-10-13 13:47:41 +02:00
ThomasV
3b8c8c712d fix #3038 2017-10-13 13:47:32 +02:00
SomberNight
8025d81ec0 fix #3035 2017-10-13 12:38:19 +02:00
SomberNight
0510bdb85b fix: missing import 'stat' in network.py and simple_config.py 2017-10-12 08:04:55 +02:00
ThomasV
e0635f5d08 Merge pull request #2320 from da2x/bugfixes
Tighten directory permissions
2017-10-10 20:11:26 +02:00
ThomasV
031b911dce fix cache with h2addr 2017-09-30 13:01:33 +02:00
SomberNight
f80d8b02ca Periodically poll fee estimates from server. 2017-09-21 01:19:05 +02:00
SomberNight
0e89745c2b send server.version before subscriptions 2017-09-20 15:21:41 +02:00