Commit graph

96 commits

Author SHA1 Message Date
ghost43
61a9deaa61
Check SPV proof inner nodes not to be valid transactions. (#4436) 2018-06-20 18:09:38 +02:00
Francisco J. Hernandez Heras
469565c188 Improving imports (#4448) 2018-06-19 18:36:01 +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
SomberNight
060404e17c
wallet/verifier: persist wallet.verified_tx when verifier finishes
Previously verified_tx was only persisted in wallet.stop_threads(), hence only on clean shutdowns.
2018-05-30 18:21:29 +02:00
SomberNight
81666bf9ac fix #4026 2018-03-05 11:44:03 +01:00
ThomasV
aaf89d2325 fix #3858 2018-02-23 11:30:59 +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
c8e67e2bd0 fix #3635 2018-01-13 17:09:25 +01:00
ThomasV
d1b8a6fae6 Replace initial headers download with hardcoded checkpoints 2017-12-12 10:20:44 +01:00
Dmitry Sorokin
f02d18226b misc ui and lib fixes for py3 2017-08-26 08:27:47 +02:00
Dmitry Sorokin
5be78950ca py3 2017-08-26 08:27:47 +02:00
ThomasV
0c6de8ff56 fix undo_verification 2017-07-20 06:38:49 +02:00
ThomasV
ca220d8dbb Detect blockchain splits and validate multiple chains 2017-06-21 09:48:31 +02:00
ThomasV
1a46a795a5 detect non-final transactions, and transactions with unconfirmed inputs 2016-05-29 19:53:04 +02:00
ThomasV
305843999e Relicensing 2016-02-24 10:20:30 +01:00
Neil Booth
f30090a321 Use network to get local height 2015-09-11 14:03:44 +09:00
Neil Booth
f11e46e479 Remove unused import 2015-08-31 18:14:07 +09:00
Neil Booth
be7cb011a3 Simply verifier now network is in-process 2015-08-31 18:12:02 +09:00
Neil Booth
2d05e7d891 Merge the network and network_proxy 2015-08-31 12:00:38 +09:00
Neil Booth
351272f0b6 Small optimization for large wallets
Previously the verifier job would scan all transactions in
unverified_tx each time it ran.
Nothing was ever removed from this map; it would essentially
be the full set of transactions.
As the job runs about 10 times a second, for a wallet with 500 txs
this would be 5,000 useless loops a second.
This patch makes unverified_tx be simply the set of confirmed
transactions that haven't yet been verified.  txs are added once
confirmed, and removed once verified.  Hence it will almost always be
empty.
2015-08-28 12:39:19 +09:00
Neil Booth
9455815ad0 Merge requested_merkle and merkle_roots. 2015-08-26 17:12:40 +09:00
Neil Booth
b64c42b1eb Make the verifier a thread job instead of a thread
The verifier, like the synchronizer, now runs as part of the
network proxy thread.
2015-08-26 17:07:36 +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
Roman Zeyde
cb4d3a78b4 verifier: fix typo 2015-06-13 16:58:08 +03:00
Neil Booth
37c3cce329 Remove wallet.get_transactions()
Because references are returned, it's not threadsafe as ThomasV
pointed out.
2015-05-08 09:31:45 +09:00
Neil Booth
a47881d72b Move the verified and unverified txs to the wallet. 2015-05-07 23:54:39 +09:00
Neil Booth
79de458101 Preparation for moving the set of verified and unverified txs to the wallet.
The verifier will retain responsibility for verification, but will no longer
hold the transaction sets itself.

Change requires_fee to take a wallet.
Add new function add_unverified_tx()
Move get_confirmations() to the wallet from the verifier.
2015-05-07 09:21:08 +09:00
ThomasV
b2a13dbd9c remove unused imports 2015-03-14 09:37:56 +01:00
ThomasV
5b8588ee90 rename spv class, use own print_error 2015-03-14 09:20:27 +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
ThomasV
e389745491 remove appdata_dir and data_dir 2015-02-18 18:48:32 +01:00
ThomasV
247f4944a6 do not store merkle root before verification succeeded. keep it in requested_merkle for the session 2014-08-15 23:30:55 +02:00
ThomasV
4f56cda0c3 do not stop thread if a tx is not verified 2014-08-15 08:35:00 +02:00
ThomasV
47b71eebfb shorter timeout: verifier too 2014-07-29 12:26:16 +02:00
ThomasV
fb0574c5a0 fix callbacks 2014-07-28 07:53:02 +02:00
ThomasV
37127e563b fix #750 2014-07-05 03:57:05 +02:00
ThomasV
b4bed1ccaa remove blockchain object from verifier 2014-03-10 20:53:05 +01:00
ThomasV
2321cb9bb3 print less debug messages 2013-11-11 16:23:17 +01:00
ThomasV
1f13b2f4f3 network.send method 2013-11-11 16:18:40 +01:00
thomasv
b75f8d795a new command: getrawtransaction 2013-09-15 11:19:48 +02:00
ThomasV
907dca6eb9 simplify interface: use callbacks 2013-09-12 08:41:27 +02:00
thomasv
74735bd64e minor fixes 2013-09-10 16:13:30 +02:00
thomasv
047e4b3478 move callbacks to the network class 2013-09-09 13:33:25 +02:00
thomasv
2a6e8927dd select the longest blockchain from several servers 2013-09-02 17:49:12 +02:00
ThomasV
e9b103b283 fix regressions in tx verifier 2013-09-02 08:50:39 +02:00
ThomasV
d47892b690 separate blockchain verifier from transaction verifier 2013-09-01 18:16:15 +02:00
ecdsa
c95c80163d distinction between unconfirmed and unverified transactions 2013-04-27 17:48:27 +02:00
ecdsa
5cc05b0685 fix: verified tx contains pos 2013-04-01 12:12:16 +02:00