mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
wallet: fix maturity off-by-one
based on Electron-Cash/Electron-Cash@c70957eb13
This commit is contained in:
parent
e3d5475f03
commit
abde8ff169
1 changed files with 5 additions and 4 deletions
|
@ -551,7 +551,7 @@ class AddressSynchronizer(Logger):
|
||||||
txs.add(tx_hash)
|
txs.add(tx_hash)
|
||||||
return txs
|
return txs
|
||||||
|
|
||||||
def get_local_height(self):
|
def get_local_height(self) -> int:
|
||||||
""" return last known height if we are offline """
|
""" return last known height if we are offline """
|
||||||
cached_local_height = getattr(self.threadlocal_cache, 'local_height', None)
|
cached_local_height = getattr(self.threadlocal_cache, 'local_height', None)
|
||||||
if cached_local_height is not 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)}"
|
assert isinstance(excluded_coins, set), f"excluded_coins should be set, not {type(excluded_coins)}"
|
||||||
received, sent = self.get_addr_io(address)
|
received, sent = self.get_addr_io(address)
|
||||||
c = u = x = 0
|
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():
|
for txo, (tx_height, v, is_cb) in received.items():
|
||||||
if txo in excluded_coins:
|
if txo in excluded_coins:
|
||||||
continue
|
continue
|
||||||
if is_cb and tx_height + COINBASE_MATURITY > local_height:
|
if is_cb and tx_height + COINBASE_MATURITY > mempool_height:
|
||||||
x += v
|
x += v
|
||||||
elif tx_height > 0:
|
elif tx_height > 0:
|
||||||
c += v
|
c += v
|
||||||
|
@ -774,6 +774,7 @@ class AddressSynchronizer(Logger):
|
||||||
domain = set(domain)
|
domain = set(domain)
|
||||||
if excluded_addresses:
|
if excluded_addresses:
|
||||||
domain = set(domain) - set(excluded_addresses)
|
domain = set(domain) - set(excluded_addresses)
|
||||||
|
mempool_height = self.get_local_height() + 1 # height of next block
|
||||||
for addr in domain:
|
for addr in domain:
|
||||||
utxos = self.get_addr_utxo(addr)
|
utxos = self.get_addr_utxo(addr)
|
||||||
for x in utxos.values():
|
for x in utxos.values():
|
||||||
|
@ -781,7 +782,7 @@ class AddressSynchronizer(Logger):
|
||||||
continue
|
continue
|
||||||
if nonlocal_only and x['height'] == TX_HEIGHT_LOCAL:
|
if nonlocal_only and x['height'] == TX_HEIGHT_LOCAL:
|
||||||
continue
|
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
|
continue
|
||||||
coins.append(x)
|
coins.append(x)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Reference in a new issue