electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 076ecb26809f6eeac45726921e2557ff0bd25199
parent 63227142227e46c269fd5ffded4d9f0ecf5d4525
Author: ThomasV <thomasv@electrum.org>
Date:   Mon, 30 May 2016 16:11:49 +0200

move get_status to synchronizer

Diffstat:
Mlib/synchronizer.py | 13+++++++++++--
Mlib/wallet.py | 8--------
2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lib/synchronizer.py b/lib/synchronizer.py @@ -25,6 +25,7 @@ from threading import Lock +import hashlib from bitcoin import Hash, hash_encode from transaction import Transaction @@ -78,13 +79,21 @@ class Synchronizer(ThreadJob): addresses) self.network.send(msgs, self.addr_subscription_response) + def get_status(self, h): + if not h: + return None + status = '' + for tx_hash, height in h: + status += tx_hash + ':%d:' % height + return hashlib.sha256(status).digest().encode('hex') + def addr_subscription_response(self, response): params, result = self.parse_response(response) if not params: return addr = params[0] history = self.wallet.get_address_history(addr) - if self.wallet.get_status(history) != result: + if self.get_status(history) != result: if self.requested_histories.get(addr) is None: self.requested_histories[addr] = result self.network.send([('blockchain.address.get_history', [addr])], @@ -109,7 +118,7 @@ class Synchronizer(ThreadJob): if len(hashes) != len(result): self.print_error("error: server history has non-unique txids: %s"% addr) # Check that the status corresponds to what was announced - elif self.wallet.get_status(hist) != server_status: + elif self.get_status(hist) != server_status: self.print_error("error: status mismatch: %s" % addr) else: # Store received history diff --git a/lib/wallet.py b/lib/wallet.py @@ -713,14 +713,6 @@ class Abstract_Wallet(PrintError): with self.lock: return self.history.get(address, []) - def get_status(self, h): - if not h: - return None - status = '' - for tx_hash, height in h: - status += tx_hash + ':%d:' % height - return hashlib.sha256( status ).digest().encode('hex') - def find_pay_to_pubkey_address(self, prevout_hash, prevout_n): dd = self.txo.get(prevout_hash, {}) for addr, l in dd.items():