1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 01:43:29 +01:00

Fix contrib/xpub.py

Following https://github.com/romanz/electrs/issues/549
This commit is contained in:
Roman Zeyde 2021-10-14 08:56:40 +03:00
parent e76b9df1d7
commit f927e237f7

View File

@ -28,23 +28,22 @@ def main():
for change in (0, 1):
empty = 0
for n in range(100):
for n in range(1000):
address = xpub.subkey(change).subkey(n).address()
script = network.parse.address(address).script()
script_hash = hashlib.sha256(script).digest()[::-1].hex()
log.debug('{}', conn.call('blockchain.scripthash.get_history',
script_hash))
reply = conn.call('blockchain.scripthash.get_balance', script_hash)
result = reply['result']
result, = conn.call([client.request('blockchain.scripthash.get_history', script_hash)])
ntx = len(result)
result, = conn.call([client.request('blockchain.scripthash.get_balance', script_hash)])
log.info('{}/{}: {} -> {} BTC confirmed, {} BTC unconfirmed, {} txs', change, n, address, result["confirmed"], result["unconfirmed"], ntx)
confirmed = result['confirmed'] / 1e8
total += confirmed
if confirmed:
log.info('{}/{} => {} has {:11.8f} BTC',
change, n, address, confirmed)
if confirmed or ntx:
empty = 0
else:
empty += 1
if empty >= 10:
if empty >= 20:
break
log.info('total balance: {} BTC', total)