Exemple #1
0
    def create_or_restore(self, storage):
        '''After querying the user what they wish to do, create or restore
        a wallet and return it.'''
        self.remove_from_recently_open(storage.path)

        # Filter out any unregistered wallet kinds
        registered_kinds = Wallet.categories()
        kinds, descriptions = zip(*[pair for pair in WizardBase.wallet_kinds
                                    if pair[0] in registered_kinds])
        action, kind_index = self.query_create_or_restore(descriptions)

        assert action in WizardBase.user_actions

        kind = kinds[kind_index]
        if kind == 'multisig':
            wallet_type = self.query_multisig(action)
        elif kind == 'hardware':
            # The create/restore distinction is not obvious for hardware
            # wallets; so we ask for the action again and default based
            # on the prior choice :)
            hw_wallet_types, choices = self.plugins.hardware_wallets(action)
            msg = _('Select the type of hardware wallet: ')
            action, choice = self.query_hw_wallet_choice(msg, action, choices)
            wallet_type = hw_wallet_types[choice]
        elif kind == 'twofactor':
            wallet_type = '2fa'
        else:
            wallet_type = 'standard'

        if action == 'create':
            wallet = self.create_wallet(storage, wallet_type, kind)
        else:
            wallet = self.restore_wallet(storage, wallet_type, kind)

        return action, wallet
    def create_or_restore(self, storage):
        '''After querying the user what they wish to do, create or restore
        a wallet and return it.'''
        self.remove_from_recently_open(storage.path)

        # Filter out any unregistered wallet kinds
        registered_kinds = Wallet.categories()
        kinds, descriptions = zip(*[pair for pair in WizardBase.wallet_kinds
                                    if pair[0] in registered_kinds])
        action, kind_index = self.query_create_or_restore(descriptions)

        assert action in WizardBase.user_actions

        kind = kinds[kind_index]
        if kind == 'multisig':
            wallet_type = self.query_multisig(action)
        elif kind == 'hardware':
            # The create/restore distinction is not obvious for hardware
            # wallets; so we ask for the action again and default based
            # on the prior choice :)
            hw_wallet_types, choices = self.plugins.hardware_wallets(action)
            msg = _('Select the type of hardware wallet: ')
            action, choice = self.query_hw_wallet_choice(msg, action, choices)
            wallet_type = hw_wallet_types[choice]
        elif kind == 'twofactor':
            wallet_type = '2fa'
        else:
            wallet_type = 'standard'

        if action == 'create':
            wallet = self.create_wallet(storage, wallet_type, kind)
        else:
            wallet = self.restore_wallet(storage, wallet_type, kind)

        return action, wallet
Exemple #3
0
 def new(self):
     name = os.path.basename(self.storage.path)
     title = _("Welcome to the Electrum installation wizard.")
     message = '\n'.join([
         _("The wallet '%s' does not exist.") % name,
         _("What kind of wallet do you want to create?")
     ])
     wallet_kinds = [
         ('standard',  _("Standard wallet")),
         ('twofactor', _("Wallet with two-factor authentication")),
         ('multisig',  _("Multi-signature wallet")),
     ]
     registered_kinds = Wallet.categories()
     choices = wallet_kinds#[pair for pair in wallet_kinds if pair[0] in registered_kinds]
     self.choice_dialog(title=title, message=message, choices=choices, run_next=self.on_wallet_type)
Exemple #4
0
 def new(self):
     name = os.path.basename(self.storage.path)
     title = _("Welcome to the Electrum installation wizard.")
     message = '\n'.join([
         _("The wallet '%s' does not exist.") % name,
         _("What kind of wallet do you want to create?")
     ])
     wallet_kinds = [
         ('standard', _("Standard wallet")),
         ('twofactor', _("Wallet with two-factor authentication")),
         ('multisig', _("Multi-signature wallet")),
     ]
     registered_kinds = Wallet.categories()
     choices = wallet_kinds  #[pair for pair in wallet_kinds if pair[0] in registered_kinds]
     self.choice_dialog(title=title,
                        message=message,
                        choices=choices,
                        run_next=self.on_wallet_type)
Exemple #5
0
    def create_or_restore(self, storage):
        '''After querying the user what they wish to do, create or restore
        a wallet and return it.'''
        self.remove_from_recently_open(storage.path)

        # Filter out any unregistered wallet kinds
        registered_kinds = Wallet.categories()
        kinds, descriptions = zip(*[
            pair for pair in WizardBase.wallet_kinds
            if pair[0] in registered_kinds
        ])
        action, kind_index = self.query_create_or_restore(descriptions)
        assert action in WizardBase.user_actions
        kind = kinds[kind_index]
        if kind == 'multisig':
            wallet_type = self.query_multisig(action)
        elif kind == 'hardware':
            hw_wallet_types, choices = self.plugins.hardware_wallets(action)
            if choices:
                msg = _('Select the type of hardware wallet: ')
            else:
                msg = ' '.join([
                    _('No hardware wallet support found on your system.'),
                    _('Please install the relevant libraries (eg python-trezor for Trezor).'
                      ),
                ])
            choice = self.query_hw_wallet_choice(msg, choices)
            wallet_type = hw_wallet_types[choice]
        elif kind == 'twofactor':
            wallet_type = '2fa'
        else:
            wallet_type = 'standard'

        if action == 'create':
            wallet = self.create_wallet(storage, wallet_type, kind)
        else:
            wallet = self.restore_wallet(storage, wallet_type, kind)

        return action, wallet
Exemple #6
0
    def create_or_restore(self, storage):
        '''After querying the user what they wish to do, create or restore
        a wallet and return it.'''
        self.remove_from_recently_open(storage.path)

        # Filter out any unregistered wallet kinds
        registered_kinds = Wallet.categories()
        kinds, descriptions = zip(*[pair for pair in WizardBase.wallet_kinds
                                    if pair[0] in registered_kinds])
        action, kind_index = self.query_create_or_restore(descriptions)
        assert action in WizardBase.user_actions
        kind = kinds[kind_index]
        if kind == 'multisig':
            wallet_type = self.query_multisig(action)
        elif kind == 'hardware':
            hw_wallet_types, choices = self.plugins.hardware_wallets(action)
            if choices:
                msg = _('Select the type of hardware wallet: ')
            else:
                msg = ' '.join([
                    _('No hardware wallet support found on your system.'),
                    _('Please install the relevant libraries (eg python-trezor for Trezor).'),
                ])
            choice = self.query_hw_wallet_choice(msg, choices)
            wallet_type = hw_wallet_types[choice]
        elif kind == 'twofactor':
            wallet_type = '2fa'
        else:
            wallet_type = 'standard'

        if action == 'create':
            wallet = self.create_wallet(storage, wallet_type, kind)
        else:
            wallet = self.restore_wallet(storage, wallet_type, kind)

        return action, wallet