commit b0f7411a0a1f4fbe634fb28760c3eeba1542e444
parent 383f8924d711f97e8c94570a2eb19af3263d54bc
Author: ThomasV <thomasv@gitorious>
Date: Sun, 5 Jul 2015 17:29:41 +0200
check and fix history on startup
Diffstat:
1 file changed, 25 insertions(+), 0 deletions(-)
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -183,6 +183,8 @@ class Abstract_Wallet(object):
self.transaction_lock = threading.Lock()
self.tx_event = threading.Event()
+ self.check_history()
+
# save wallet type the first time
if self.storage.get('wallet_type') is None:
self.storage.put('wallet_type', self.wallet_type, True)
@@ -233,6 +235,25 @@ class Abstract_Wallet(object):
s.add(addr)
self.tx_addr_hist[tx_hash] = s
+ @profiler
+ def check_history(self):
+ save = False
+ for addr, hist in self.history.items():
+ if not self.is_mine(addr):
+ self.history.pop(addr)
+ save = True
+ continue
+
+ for tx_hash, tx_height in hist:
+ if tx_hash in self.pruned_txo.values() or self.txi.get(tx_hash) or self.txo.get(tx_hash):
+ continue
+ tx = self.transactions.get(tx_hash)
+ if tx is not None:
+ tx.deserialize()
+ self.add_transaction(tx_hash, tx, tx_height)
+ if save:
+ self.storage.put('addr_history', self.history, True)
+
# wizard action
def get_action(self):
pass
@@ -314,6 +335,10 @@ class Abstract_Wallet(object):
self.accounts[IMPORTED_ACCOUNT].add(address, pubkey, sec, password)
self.save_accounts()
+ # force resynchronization, because we need to re-run add_transaction
+ if addr in self.history:
+ self.history.pop(addr)
+
if self.synchronizer:
self.synchronizer.add(address)
return address