X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=backends%2Fbitcoind%2Fblockchain_processor.py;h=5e7901ae705c022fb9ecaa2b810ab54ba4cd35ce;hb=c7b49738a0a7eb7bd67e7e08c2fb265556ce5d20;hp=7891f68262726c0b7a0af151be15bbca4a2a9d73;hpb=fdc576873627546b8677b7acb560918fac9cafd0;p=electrum-server.git diff --git a/backends/bitcoind/blockchain_processor.py b/backends/bitcoind/blockchain_processor.py index 7891f68..5e7901a 100644 --- a/backends/bitcoind/blockchain_processor.py +++ b/backends/bitcoind/blockchain_processor.py @@ -16,6 +16,7 @@ class BlockchainProcessor(Processor): Processor.__init__(self) self.shared = shared + self.config = config self.up_to_date = False self.watched_addresses = [] self.history_cache = {} @@ -498,9 +499,11 @@ class BlockchainProcessor(Processor): "read:%0.2f "%(t1 - t00), "proc:%.2f "%(t2-t1), "write:%.2f "%(t3-t2), - "max:", max_len, max_addr) + "max:", max_len, hash_160_to_bc_address(max_addr)) - for addr in self.batch_list.keys(): self.invalidate_cache(addr) + for h160 in self.batch_list.keys(): + addr = hash_160_to_bc_address(h160) + self.invalidate_cache(addr) @@ -535,16 +538,22 @@ class BlockchainProcessor(Processor): error = str(e) + ': ' + address print_log( "error:", error ) - elif method == 'blockchain.address.subscribe2': + elif method == 'blockchain.address.unsubscribe': try: - address = params[0] - result = self.get_status(address, cache_only) - self.watch_address(address) + password = params[0] + address = params[1] + if password == self.config.get('server','password'): + self.watched_addresses.remove(address) + print_log('unsubscribed', address) + result = "ok" + else: + print_log('incorrect password') + result = "authentication error" except BaseException, e: error = str(e) + ': ' + address print_log( "error:", error ) - elif method == 'blockchain.address.get_history2': + elif method == 'blockchain.address.get_history': try: address = params[0] result = self.get_history( address, cache_only ) @@ -686,7 +695,8 @@ class BlockchainProcessor(Processor): for x in tx.get('inputs'): txi = (x.get('prevout_hash') + int_to_hex(x.get('prevout_n'), 4)).decode('hex') try: - addr = self.db.Get(txi) + h160 = self.db.Get(txi) + addr = hash_160_to_bc_address(h160) except: continue l = self.mempool_addresses.get(tx_hash, []) @@ -776,8 +786,6 @@ class BlockchainProcessor(Processor): if addr in self.watched_addresses: status = self.get_status( addr ) self.push_response({ 'id': None, 'method':'blockchain.address.subscribe', 'params':[addr, status] }) - self.push_response({ 'id': None, 'method':'blockchain.address.subscribe2', 'params':[addr, status] }) - if not self.shared.stopped(): threading.Timer(10, self.main_iteration).start()