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 bfacfd08b..7340dddf9 100644 --- a/ports/stm32/boards/Passport/modules/flows/verify_address_flow.py +++ b/ports/stm32/boards/Passport/modules/flows/verify_address_flow.py @@ -48,13 +48,17 @@ def __init__(self, sig_type=None, multisig_wallet=None): async def choose_sig_type(self): from pages import SinglesigMultisigChooserPage from multisig_wallet import MultisigWallet + from common import settings + + xfp = settings.get('xfp') + multisigs = MultisigWallet.get_by_xfp(xfp) - if MultisigWallet.get_count() == 0: + if len(multisigs) == 0: self.sig_type = 'single-sig' self.goto(self.scan_address, save_curr=False) # Don't save this since we're skipping this state else: result = await SinglesigMultisigChooserPage( - initial_value=self.sig_type).show() + initial_value=self.sig_type, multisigs=multisigs).show() if result is None: if not self.back(): self.set_result(False) diff --git a/ports/stm32/boards/Passport/modules/multisig_wallet.py b/ports/stm32/boards/Passport/modules/multisig_wallet.py index 46059e4d1..0dd325782 100644 --- a/ports/stm32/boards/Passport/modules/multisig_wallet.py +++ b/ports/stm32/boards/Passport/modules/multisig_wallet.py @@ -367,6 +367,19 @@ def get_by_id(cls, id): return None + @classmethod + def get_by_xfp(cls, xfp): + lst = cls.get_all() + lst_by_xfp = [] + + for ms in lst: + for xpub in ms.xpubs: + if xfp == xpub[0]: # XFP entry in the multisig's xpub tuple + lst_by_xfp.append(ms) + break + + return lst_by_xfp + @classmethod def delete_by_id(cls, id): from utils import to_str diff --git a/ports/stm32/boards/Passport/modules/pages/singlesig_multisig_chooser_page.py b/ports/stm32/boards/Passport/modules/pages/singlesig_multisig_chooser_page.py index aa06d33fd..9ed5c7c70 100644 --- a/ports/stm32/boards/Passport/modules/pages/singlesig_multisig_chooser_page.py +++ b/ports/stm32/boards/Passport/modules/pages/singlesig_multisig_chooser_page.py @@ -8,20 +8,12 @@ class SinglesigMultisigChooserPage(ChooserPage): - def __init__(self, card_header={'title': 'Single/Multisig'}, initial_value=None): - from multisig_wallet import MultisigWallet - from common import settings - + def __init__(self, multisigs, card_header={'title': 'Single/Multisig'}, initial_value=None): options = [{'label': 'Single-sig', 'value': ('single-sig', None)}] - xfp = settings.get('xfp') - - for ms in MultisigWallet.get_all(): - for xpub in ms.xpubs: - if xfp == xpub[0]: # XFP entry in the multisig's xpub tuple - label = '%d/%d: %s' % (ms.M, ms.N, ms.name) - options.append({'label': label, 'value': ('multisig', ms)}) - continue + for ms in multisigs: + label = '%d/%d: %s' % (ms.M, ms.N, ms.name) + options.append({'label': label, 'value': ('multisig', ms)}) super().__init__( card_header=card_header,