tprevent errors when history is empty - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 4bdc1ca60f7b89ac0d1c36ccec3bdf29f9b65191 DIR parent eaec64c3ef26c1c854fc4be808f2681365c2985d HTML Author: ThomasV <thomasv@gitorious> Date: Sun, 4 Dec 2011 12:50:32 +0100 prevent errors when history is empty Diffstat: M client/electrum.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- DIR diff --git a/client/electrum.py b/client/electrum.py t@@ -404,6 +404,7 @@ class Wallet: def get_addr_balance(self, addr): h = self.history.get(addr) + if not h: return 0,0 c = u = 0 for item in h: v = item['value'] t@@ -474,7 +475,7 @@ class Wallet: if blocks == -1: raise BaseException("session not found") self.blocks = int(blocks) for addr, blk_hash in changed_addresses.items(): - if self.status[addr] != blk_hash: + if self.status.get(addr) != blk_hash: print "updating history for", addr self.history[addr] = self.retrieve_history(addr) self.status[addr] = blk_hash t@@ -568,7 +569,9 @@ class Wallet: def update_tx_history(self): self.tx_history= {} for addr in self.addresses: - for tx in self.history[addr]: + h = self.history.get(addr) + if h is None: continue + for tx in h: tx_hash = tx['tx_hash'] line = self.tx_history.get(tx_hash) if not line: