fix
[electrum-server.git] / backends / bitcoind / blockchain_processor.py
index d4c56f4..6891c41 100644 (file)
@@ -686,14 +686,14 @@ class BlockchainProcessor(Processor):
         error = None
 
         if method == 'blockchain.numblocks.subscribe':
-            if session not in self.watch_headers:
-                with self.watch_lock:
+            with self.watch_lock:
+                if session not in self.watch_blocks:
                     self.watch_blocks.append(session)
             result = self.height
 
         elif method == 'blockchain.headers.subscribe':
-            if session not in self.watch_headers:
-                with self.watch_lock:
+            with self.watch_lock:
+                if session not in self.watch_headers:
                     self.watch_headers.append(session)
             result = self.header
 
@@ -967,7 +967,7 @@ class BlockchainProcessor(Processor):
                 break
 
             status = self.get_status(addr)
-            for session in self.watched_addresses[addr]:
+            for session in self.watched_addresses.get(addr,[]):
                 self.push_response(session, {
                         'id': None,
                         'method': 'blockchain.address.subscribe',