Address version for Litecoin is 48
[electrum-server.git] / backends / abe / __init__.py
index 7584fd5..48c01de 100644 (file)
@@ -13,6 +13,8 @@ import time, threading
 
 class AbeStore(Datastore_class):
 
+    addrtype = 48
+
     def __init__(self, config):
         conf = DataStore.CONFIG_DEFAULTS
         args, argv = readconf.parse_argv( [], conf)
@@ -68,7 +70,7 @@ class AbeStore(Datastore_class):
                 #print "WARNING: missing tx_in for tx", txid
                 continue
 
-            address = hash_to_address(chr(0), _hash)
+            address = hash_to_address(chr(addrtype), _hash)
             if self.tx_cache.has_key(address):
                 print "cache: invalidating", address
                 self.tx_cache.pop(address)
@@ -81,7 +83,7 @@ class AbeStore(Datastore_class):
                 #print "WARNING: missing tx_out for tx", txid
                 continue
 
-            address = hash_to_address(chr(0), _hash)
+            address = hash_to_address(chr(addrtype), _hash)
             if self.tx_cache.has_key(address):
                 print "cache: invalidating", address
                 self.tx_cache.pop(address)
@@ -282,14 +284,13 @@ class AbeStore(Datastore_class):
             if tx_hash in known_tx:
                 continue
 
-            # this means that pending transactions were added to the db, even if they are not returned by getmemorypool
-            address_has_mempool = True
-
             # discard transactions that are too old
-            if self.last_tx_id - tx_id > 10000:
+            if self.last_tx_id - tx_id > 50000:
                 print "discarding tx id", tx_id
                 continue
 
+            # this means that pending transactions were added to the db, even if they are not returned by getmemorypool
+            address_has_mempool = True
 
             #print "mempool", tx_hash
             txpoint = {
@@ -315,7 +316,7 @@ class AbeStore(Datastore_class):
                 if not _hash:
                     #print "WARNING: missing tx_in for tx", tx_id, addr
                     continue
-                address = hash_to_address(chr(0), _hash)
+                address = hash_to_address(chr(addrtype), _hash)
                 txinputs.append(address)
             txpoint['inputs'] = txinputs
             txoutputs = []
@@ -325,7 +326,7 @@ class AbeStore(Datastore_class):
                 if not _hash:
                     #print "WARNING: missing tx_out for tx", tx_id, addr
                     continue
-                address = hash_to_address(chr(0), _hash)
+                address = hash_to_address(chr(addrtype), _hash)
                 txoutputs.append(address)
             txpoint['outputs'] = txoutputs
 
@@ -439,6 +440,11 @@ class BlockchainProcessor(Processor):
         self.store = AbeStore(config)
         self.block_number = -1
         self.watched_addresses = []
+
+        # catch_up first
+        n = self.store.main_iteration()
+        print "blockchain: %d blocks"%n
+
         threading.Timer(10, self.run_store_iteration).start()
 
     def process(self, request):