Commit graph

47 commits

Author SHA1 Message Date
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
SomberNight
4159322db0
synchronizer.py: rename tx_response to on_tx_response 2018-05-30 17:35:29 +02:00
SomberNight
e4dad0a425
fix #4198 2018-04-05 12:52:21 +02:00
SomberNight
de4fe9db69
fix a race condition in synchronizer
wallet.synchronizer gets assigned a newly constructed Synchronizer instance.
Synchronizer in tx_response refers to the value of wallet.synchronizer.
If the wallet has a missing txn, there could be a race condition that synchronizer asks for a txn and we get the callback from the network WHILE the constructor is still running, in which case wallet.synchronizer would still be None and we would consider the callback "orphan", and the wallet would get "stuck" synchronizing.
2018-04-05 08:32:02 +02:00
SomberNight
81666bf9ac fix #4026 2018-03-05 11:44:03 +01:00
ThomasV
e6dd3e6ad8 allow to save unbroadcasted transactions in wallet 2018-01-18 11:56:21 +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
f1666f208b remove height parameter from blockchain.transaction.get 2017-09-13 11:33:28 +02:00
ThomasV
216e9403be cleanup six (no python2 support) 2017-09-04 14:43:31 +02:00
ThomasV
5f1d9cbcf5 separate network layer from synchronizer 2017-08-31 09:59:29 +02:00
Dmitry Sorokin
d304ccdf17 py3 in qtgui 2017-08-26 08:27:47 +02:00
Dmitry Sorokin
5be78950ca py3 2017-08-26 08:27:47 +02:00
ThomasV
3a64ec0f2e Initial segwit support (testnet only) 2017-01-25 21:42:15 +01:00
ThomasV
1159f85e05 Major refactoring
- separation between Wallet and key management (Keystore)
 - simplification of wallet classes
 - remove support for multiple accounts in the same wallet
 - add support for OP_RETURN to Trezor plugin
 - split multi-accounts wallets for backward compatibility
2016-08-12 11:02:28 +02:00
ThomasV
599906eef6 show warning icon if unconfirmed tx has low fee. fixes 1798 2016-05-30 18:26:58 +02:00
ThomasV
076ecb2680 move get_status to synchronizer 2016-05-30 16:11:49 +02:00
ThomasV
305843999e Relicensing 2016-02-24 10:20:30 +01:00
Neil Booth
a58c19d7c0 Clean up and fix account adding
As per BIP44, 20 addresses are checked for transactions, not just the
first one.
Show the last account only if used or named.
If all accounts are used, prompt for password to create new one.

Fixes #1128
2015-12-25 23:34:04 +09:00
Neil Booth
e1c0298fc2 Write the wallet less often
This should speed up synchronization / restoration of large wallets.
Wallets are written only when they switch to up_to_date state, or
when stop_threads() is called when closing the daemon, or when
a command line command finishes.
2015-12-20 15:47:46 +09:00
Neil Booth
206e38fb7c Make use of trigger_callback easier to understand 2015-11-12 16:08:37 +09:00
Neil Booth
8cc3b58364 Allow syncronizer to be GC-ed
Proper fix for #1525.
Using python's GC module, I've verified that the daemon, when running,
now releases all verifiers, synchronizers and wallets - all the resources
we care about releasing.
2015-11-12 08:40:58 +09:00
ThomasV
d82896dadf fix #1525 (part 2) 2015-11-06 18:00:19 +01:00
ThomasV
b3529147d5 fix #1525 2015-11-06 17:32:54 +01:00
Neil Booth
f5a43b8738 Warn if server is serving bad address histories 2015-09-06 19:49:35 +09:00
Neil Booth
01491dd1d0 Have network_proxy use ThreadJob framework
Rename WalletSynchronizer to Synchronizer so that diagnostic messages,
which are based on class name, still refer to Synchronizer.
2015-08-26 16:50:40 +09:00
Neil Booth
a056f9804b Notify when a chunk of headers is validated
And a couple of cosmetic changes.
This should fix #1379.
2015-08-25 14:27:53 +09:00
ThomasV
bfae04e6f0 Improved in network callbacks:
* Pass arguments
 * Don't redraw history when a tx is verified.
 * Fix new tx notifications.
2015-08-16 11:36:23 +02:00
ThomasV
fa2de58c90 redo fixes for 1324 2015-07-02 09:22:59 +02:00
Neil Booth
e8db8983ec Make the synchronizer not a thread.
The synchronizer's work is done from the network proxy's main loop.

A minor problem with the old synchronizer was that it considered itself
out of date if the network was out of date.  This was too generic: the
network can have pending requests unrelated to the synchronizer.  This
resulted in the synchronizer often unnecessarily flipping the wallet
between up-to-date and not-up-to-date, and causing unnecessary calls
to wallet.save_transactions().  This was observable when opening the
network dialog box: frequently just opening it would cause a wallet
status change and transaction flush, simply because the network dialog
sends a get_parameters() request.  This rework of the synchronizer does
not have that issue.
2015-06-09 08:41:31 +09:00
ThomasV
a99c2bc9fa less verbose debug message 2015-05-05 21:00:35 +02:00
ThomasV
e3de121be9 store deserialized tx in/out in wallet file for fast computation 2015-03-30 14:10:46 +02:00
ThomasV
4ebefc6e4c standardize error messages in synchronizer 2015-03-14 09:29:44 +01:00
ThomasV
8e7ce452f6 move misplaced debug message 2015-03-14 09:27:18 +01:00
ThomasV
a4cb70649d fix synchronizer hanging when not connected. 2015-03-14 08:43:43 +01:00
ThomasV
72688a5cfa clean implementation of daemon threads 2015-03-13 23:04:29 +01:00
Tafelpoot
d9c5250a6f removed trailing whitespace and fixed indentation in history widget 2014-10-21 19:05:51 +02:00
ThomasV
71d97eeecc shorter timeouts in synchronizer, so that it terminates properly 2014-07-29 12:23:42 +02:00
ThomasV
fb0574c5a0 fix callbacks 2014-07-28 07:53:02 +02:00
ThomasV
28df27fba2 update interface.py 2014-07-28 00:13:40 +02:00
ThomasV
035ecbc7cd redo inter-thread communication using pipes 2014-07-27 17:13:46 +02:00
ThomasV
8196bc5779 adapt network dialog to daemon 2014-07-25 09:11:56 +02:00
ThomasV
09e4efc439 daemon notifications (network.status) 2014-07-24 23:17:06 +02:00
ThomasV
9ee0614edb make daemon usable with the GUI 2014-07-24 16:12:18 +02:00
ThomasV
a89abee969 Rewrite accounts and transactions: store pubkeys instead of addresses in order to avoid unnecessary derivations. 2014-07-06 21:10:41 +02:00
ThomasV
38f5deee86 use an input queue in synchronizer, so that new addresses can be created from other threads 2014-06-26 17:41:09 +02:00
ThomasV
7e0711f6ec move synchronizer class in its own file. abstract wallet class. 2014-04-30 10:32:40 +02:00