electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit abde8ff1692c50ca5c5fa12c71f9edb2cf6d0f72
parent e3d5475f037236b455b5ee26a38940719ea77488
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun,  8 Sep 2019 18:26:04 +0200

wallet: fix maturity off-by-one

based on Electron-Cash/Electron-Cash@c70957eb131ccb780726c8d01bcbb914df5b9644

Diffstat:
Melectrum/address_synchronizer.py | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py @@ -551,7 +551,7 @@ class AddressSynchronizer(Logger): txs.add(tx_hash) return txs - def get_local_height(self): + def get_local_height(self) -> int: """ return last known height if we are offline """ cached_local_height = getattr(self.threadlocal_cache, 'local_height', None) if cached_local_height is not None: @@ -742,11 +742,11 @@ class AddressSynchronizer(Logger): assert isinstance(excluded_coins, set), f"excluded_coins should be set, not {type(excluded_coins)}" received, sent = self.get_addr_io(address) c = u = x = 0 - local_height = self.get_local_height() + mempool_height = self.get_local_height() + 1 # height of next block for txo, (tx_height, v, is_cb) in received.items(): if txo in excluded_coins: continue - if is_cb and tx_height + COINBASE_MATURITY > local_height: + if is_cb and tx_height + COINBASE_MATURITY > mempool_height: x += v elif tx_height > 0: c += v @@ -774,6 +774,7 @@ class AddressSynchronizer(Logger): domain = set(domain) if excluded_addresses: domain = set(domain) - set(excluded_addresses) + mempool_height = self.get_local_height() + 1 # height of next block for addr in domain: utxos = self.get_addr_utxo(addr) for x in utxos.values(): @@ -781,7 +782,7 @@ class AddressSynchronizer(Logger): continue if nonlocal_only and x['height'] == TX_HEIGHT_LOCAL: continue - if mature_only and x['coinbase'] and x['height'] + COINBASE_MATURITY > self.get_local_height(): + if mature_only and x['coinbase'] and x['height'] + COINBASE_MATURITY > mempool_height: continue coins.append(x) continue