get_history: minor simplification
This commit is contained in:
@@ -522,23 +522,22 @@ class AddressSynchronizer(Logger):
|
|||||||
tx_mined_status = self.get_tx_height(tx_hash)
|
tx_mined_status = self.get_tx_height(tx_hash)
|
||||||
fee = self.get_tx_fee(tx_hash)
|
fee = self.get_tx_fee(tx_hash)
|
||||||
history.append((tx_hash, tx_mined_status, delta, fee))
|
history.append((tx_hash, tx_mined_status, delta, fee))
|
||||||
history.sort(key = lambda x: self.get_txpos(x[0]), reverse=True)
|
history.sort(key = lambda x: self.get_txpos(x[0]))
|
||||||
# 3. add balance
|
# 3. add balance
|
||||||
c, u, x = self.get_balance(domain)
|
|
||||||
balance = c + u + x
|
|
||||||
h2 = []
|
h2 = []
|
||||||
|
balance = 0
|
||||||
for tx_hash, tx_mined_status, delta, fee in history:
|
for tx_hash, tx_mined_status, delta, fee in history:
|
||||||
h2.append(HistoryItem(txid=tx_hash,
|
balance += delta
|
||||||
tx_mined_status=tx_mined_status,
|
h2.append(HistoryItem(
|
||||||
delta=delta,
|
txid=tx_hash,
|
||||||
fee=fee,
|
tx_mined_status=tx_mined_status,
|
||||||
balance=balance))
|
delta=delta,
|
||||||
balance -= delta
|
fee=fee,
|
||||||
h2.reverse()
|
balance=balance))
|
||||||
|
# sanity check
|
||||||
if balance != 0:
|
c, u, x = self.get_balance(domain=domain)
|
||||||
|
if balance != c + u + x:
|
||||||
raise Exception("wallet.get_history() failed balance sanity-check")
|
raise Exception("wallet.get_history() failed balance sanity-check")
|
||||||
|
|
||||||
return h2
|
return h2
|
||||||
|
|
||||||
def _add_tx_to_local_history(self, txid):
|
def _add_tx_to_local_history(self, txid):
|
||||||
|
|||||||
Reference in New Issue
Block a user