Browse Source

get_history: return empty history if balance check fails

283
ThomasV 10 years ago
parent
commit
065145e557
  1. 16
      lib/wallet.py

16
lib/wallet.py

@ -737,8 +737,7 @@ class Abstract_Wallet(object):
delta = self.get_tx_delta(tx_hash, addr) delta = self.get_tx_delta(tx_hash, addr)
hh.append([addr, tx_hash, height, delta]) hh.append([addr, tx_hash, height, delta])
# 2. merge # 2. merge: the delta of a tx on the domain is the sum of its deltas on addresses
# the delta of a tx on the domain is the sum of its deltas on addresses
merged = {} merged = {}
for addr, tx_hash, height, delta in hh: for addr, tx_hash, height, delta in hh:
if tx_hash not in merged: if tx_hash not in merged:
@ -749,15 +748,13 @@ class Abstract_Wallet(object):
# 3. create sorted list # 3. create sorted list
history = [] history = []
#balance = 0
for tx_hash, v in merged.items(): for tx_hash, v in merged.items():
height, value = v height, value = v
#balance += value
conf, timestamp = self.verifier.get_confirmations(tx_hash) if self.verifier else (None, None) conf, timestamp = self.verifier.get_confirmations(tx_hash) if self.verifier else (None, None)
history.append((tx_hash, conf, value, timestamp)) history.append((tx_hash, conf, value, timestamp))
if self.verifier:
history.sort(key = lambda x: self.verifier.get_txpos(x[0])) history.sort(key = lambda x: self.verifier.get_txpos(x[0]))
# 4. add balance
c, u = self.get_balance(domain) c, u = self.get_balance(domain)
balance = c + u balance = c + u
h2 = [] h2 = []
@ -769,11 +766,10 @@ class Abstract_Wallet(object):
else: else:
balance = None balance = None
assert balance in [None, 0] # fixme: this may happen if history is incomplete
#if balance not in [None, 0]: if balance not in [None, 0]:
# print_error("history error") print_error("Error: history not synchronized")
# self.clear_history() return []
# self.update()
return h2 return h2

Loading…
Cancel
Save