twallet: fix balance_at_timestamp - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 46ae86f6002489c501416b82146a25fc80397943 DIR parent aab067372c72e056886ffc35de208f23882b8bf0 HTML Author: SomberNight <somber.night@protonmail.com> Date: Fri, 10 May 2019 19:22:13 +0200 wallet: fix balance_at_timestamp closes #5326 Diffstat: M electrum/wallet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- DIR diff --git a/electrum/wallet.py b/electrum/wallet.py t@@ -438,10 +438,12 @@ class Abstract_Wallet(AddressSynchronizer): return c1-c2, u1-u2, x1-x2 def balance_at_timestamp(self, domain, target_timestamp): + # we assume that get_history returns items ordered by block height + # we also assume that block timestamps are monotonic (which is false...!) h = self.get_history(domain) balance = 0 for tx_hash, tx_mined_status, value, balance in h: - if tx_mined_status.timestamp > target_timestamp: + if tx_mined_status.timestamp is None or tx_mined_status.timestamp > target_timestamp: return balance - value # return last balance return balance