SomberNight
3 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
8 additions and
3 deletions
-
electrum/bip39_recovery.py
|
|
@ -3,6 +3,7 @@ |
|
|
|
# file LICENCE or http://www.opensource.org/licenses/mit-license.php |
|
|
|
|
|
|
|
from typing import TYPE_CHECKING |
|
|
|
import itertools |
|
|
|
|
|
|
|
from . import bitcoin |
|
|
|
from .constants import BIP39_WALLET_FORMATS |
|
|
@ -44,11 +45,15 @@ async def scan_for_active_accounts(network: 'Network', get_account_xpub, wallet_ |
|
|
|
|
|
|
|
|
|
|
|
async def account_has_history(network: 'Network', account_node: BIP32Node, script_type: str) -> bool: |
|
|
|
gap_limit = 20 |
|
|
|
# note: scan both receiving and change addresses. some wallets send change across accounts. |
|
|
|
path_suffixes = itertools.chain( |
|
|
|
itertools.product((0,), range(20)), # ad-hoc gap limits |
|
|
|
itertools.product((1,), range(10)), |
|
|
|
) |
|
|
|
async with OldTaskGroup() as group: |
|
|
|
get_history_tasks = [] |
|
|
|
for address_index in range(gap_limit): |
|
|
|
address_node = account_node.subkey_at_public_derivation("0/" + str(address_index)) |
|
|
|
for path_suffix in path_suffixes: |
|
|
|
address_node = account_node.subkey_at_public_derivation(path_suffix) |
|
|
|
pubkey = address_node.eckey.get_public_key_hex() |
|
|
|
address = bitcoin.pubkey_to_address(script_type, pubkey) |
|
|
|
script = bitcoin.address_to_script(address) |
|
|
|