diff --git a/ports/stm32/boards/Passport/modules/flows/verify_address_flow.py b/ports/stm32/boards/Passport/modules/flows/verify_address_flow.py index 7cc58d628..bfacfd08b 100644 --- a/ports/stm32/boards/Passport/modules/flows/verify_address_flow.py +++ b/ports/stm32/boards/Passport/modules/flows/verify_address_flow.py @@ -87,10 +87,10 @@ async def scan_address(self): self.address = result # Simple check on the data type first - chain_name = chains.current_chain().name + chain = chains.current_chain() self.address, is_valid_btc = is_valid_btc_address(self.address) if not is_valid_btc: - await ErrorPage("Not a valid {} address.".format(chain_name)).show() + await ErrorPage("Not a valid {} address.".format(chain.name)).show() return # Get the address type from the address @@ -105,10 +105,12 @@ async def scan_address(self): a = [get_next_addr(self.acct_num, self.addr_type, xfp, + chain.b44_cointype, False), get_next_addr(self.acct_num, self.addr_type, xfp, + chain.b44_cointype, True)] self.low_range = [(a[_RECEIVE_ADDR], a[_RECEIVE_ADDR]), (a[_CHANGE_ADDR], a[_CHANGE_ADDR])] self.high_range = [(a[_RECEIVE_ADDR], a[_RECEIVE_ADDR]), (a[_CHANGE_ADDR], a[_CHANGE_ADDR])] @@ -224,9 +226,15 @@ async def found(self): from utils import save_next_addr, format_btc_address import passport from common import settings + import chains # Remember where to start from next time - save_next_addr(self.acct_num, self.addr_type, self.found_addr_idx, settings.get('xfp'), self.found_is_change) + save_next_addr(self.acct_num, + self.addr_type, + self.found_addr_idx, + settings.get('xfp'), + chains.current_chain().b44_cointype, + self.found_is_change) address = format_btc_address(self.address, self.addr_type) msg = '''{} diff --git a/ports/stm32/boards/Passport/modules/utils.py b/ports/stm32/boards/Passport/modules/utils.py index 7436690a5..2ef21e602 100644 --- a/ports/stm32/boards/Passport/modules/utils.py +++ b/ports/stm32/boards/Passport/modules/utils.py @@ -949,23 +949,23 @@ def get_width_from_num_words(num_words): # return False -def make_next_addr_key(acct_num, addr_type, xfp, is_change): - return '{}.{}/{}{}'.format(xfp, acct_num, addr_type, '/1' if is_change else '') +def make_next_addr_key(acct_num, addr_type, xfp, chain_type, is_change): + return '{}.{}.{}/{}{}'.format(chain_type, xfp, acct_num, addr_type, '/1' if is_change else '') -def get_next_addr(acct_num, addr_type, xfp, is_change): +def get_next_addr(acct_num, addr_type, xfp, chain_type, is_change): from common import settings next_addrs = settings.get('next_addrs', {}) - key = make_next_addr_key(acct_num, addr_type, xfp, is_change) + key = make_next_addr_key(acct_num, addr_type, xfp, chain_type, is_change) return next_addrs.get(key, 0) # Save the next address to use for the specific account and address type -def save_next_addr(acct_num, addr_type, addr_idx, xfp, is_change, force_update=False): +def save_next_addr(acct_num, addr_type, addr_idx, xfp, chain_type, is_change, force_update=False): from common import settings next_addrs = settings.get('next_addrs', {}) - key = make_next_addr_key(acct_num, addr_type, xfp, is_change) + key = make_next_addr_key(acct_num, addr_type, xfp, chain_type, is_change) # Only save the found index if it's newer if next_addrs.get(key, -1) < addr_idx or force_update: