Commit graph

21 commits

Author SHA1 Message Date
SomberNight
8591587f9e
fix websockets 2018-07-01 15:59:32 +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
Harm Aarts
ab2f59590c Push network calls into network module
Eventually all network calls should go through the network module
without resorting to using raw protocol strings. This, then, makes
adding an other backend easier.
Please note that the behaviour slightly changed. Initially the caller
received an unmodified response from the ElectrumX server. In it the
scripthash is present. This change replaces that scripthash with the
original address.
2018-05-17 15:20:22 +02:00
SomberNight
9b7536e75c use explicit utf-8 encoding when opening files in text mode 2018-03-23 21:47:51 +01:00
SomberNight
5ec3d2888f websocket: migrate to scripthashes 2018-01-16 16:02:58 +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
ThomasV
d96561bc9d fix #3175 2017-11-02 09:40:11 +01:00
ThomasV
216e9403be cleanup six (no python2 support) 2017-09-04 14:43:31 +02:00
ThomasV
15642ec8de python3: remove calls to unicode function 2017-08-26 08:28:24 +02:00
Dmitry Sorokin
5be78950ca py3 2017-08-26 08:27:47 +02:00
Serge Victor
55d392c274 Spread payment requests to subdirs
Currently Electrum stores all payment requests in main requests
directory. It's not going to be efficient when we have thousands of
thousands of payment requests. This patch spreads that files across
two level of subdirectories.
2016-10-01 05:40:40 +00:00
ThomasV
305843999e Relicensing 2016-02-24 10:20:30 +01:00
ThomasV
ed2ab5e3c1 websockets: minor fix 2015-11-25 11:37:10 +01:00
ThomasV
1207ad3ba4 fix: websocket uses network object 2015-11-25 10:48:34 +01:00
ThomasV
2a29d1e5e7 fix syntax error 2015-11-25 10:35:14 +01:00
ThomasV
2934fd17be fix websockets 2015-11-25 10:32:46 +01:00
Chris Beaven
876a2c8ed0 Missing sys import
Also put the error message in sys.exit rather than printing. This will output it to stderr and make the exit code non-zero
like it should be.
2015-10-19 10:51:05 +13:00
ThomasV
f3bd1662f7 fix web request server. fixes #1455 2015-09-30 11:06:27 +02:00
ThomasV
0c5bfb8c26 print -> util.print_error 2015-07-24 14:23:03 +02:00
ThomasV
18d145cced add websocket to webpages 2015-07-24 11:39:12 +02:00