bip39_recovery: also scan change addresses
fixes https://github.com/spesmilo/electrum/issues/7804
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
# file LICENCE or http://www.opensource.org/licenses/mit-license.php
|
# file LICENCE or http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
import itertools
|
||||||
|
|
||||||
from . import bitcoin
|
from . import bitcoin
|
||||||
from .constants import BIP39_WALLET_FORMATS
|
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:
|
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:
|
async with OldTaskGroup() as group:
|
||||||
get_history_tasks = []
|
get_history_tasks = []
|
||||||
for address_index in range(gap_limit):
|
for path_suffix in path_suffixes:
|
||||||
address_node = account_node.subkey_at_public_derivation("0/" + str(address_index))
|
address_node = account_node.subkey_at_public_derivation(path_suffix)
|
||||||
pubkey = address_node.eckey.get_public_key_hex()
|
pubkey = address_node.eckey.get_public_key_hex()
|
||||||
address = bitcoin.pubkey_to_address(script_type, pubkey)
|
address = bitcoin.pubkey_to_address(script_type, pubkey)
|
||||||
script = bitcoin.address_to_script(address)
|
script = bitcoin.address_to_script(address)
|
||||||
|
|||||||
Reference in New Issue
Block a user