Exemple #1
0
 def start_new_window(self, path, uri):
     '''Raises the window for the wallet if it is open.  Otherwise
     opens the wallet and creates a new window for it.'''
     for w in self.windows:
         if w.wallet.storage.path == path:
             w.bring_to_top()
             break
     else:
         try:
             wallet = self.daemon.load_wallet(path, None)
         except BaseException as e:
             d = QMessageBox(QMessageBox.Warning, _('Error'),
                             'Cannot load wallet:\n' + str(e))
             d.exec_()
             return
         if not wallet:
             storage = WalletStorage(path)
             wizard = InstallWizard(self.config, self.app, self.plugins,
                                    storage)
             wallet = wizard.run_and_get_wallet()
             wizard.terminate()
             if not wallet:
                 return
             wallet.start_threads(self.daemon.network)
             self.daemon.add_wallet(wallet)
         w = self.create_window_for_wallet(wallet)
     if uri:
         w.pay_to_URI(uri)
     return w
Exemple #2
0
 def start_new_window(self, path, uri):
     '''Raises the window for the wallet if it is open.  Otherwise
     opens the wallet and creates a new window for it.'''
     for w in self.windows:
         if w.wallet.storage.path == path:
             w.bring_to_top()
             break
     else:
         try:
             wallet = self.daemon.load_wallet(path)
         except BaseException as e:
             QMessageBox.information(None, _('Error'), str(e), _('OK'))
             return
         if wallet is None:
             wizard = InstallWizard(self.config, self.app, self.plugins,
                                    path)
             wallet = wizard.run_and_get_wallet()
             if not wallet:
                 return
             wallet.start_threads(self.daemon.network)
             self.daemon.add_wallet(wallet)
         w = self.create_window_for_wallet(wallet)
     if uri:
         w.pay_to_URI(uri)
     return w
Exemple #3
0
    def load_wallet_file(self, filename):
        try:
            storage = WalletStorage(filename)
        except Exception as e:
            QMessageBox.information(None, _('Error'), str(e), _('OK'))
            return
        if not storage.file_exists:
            recent = self.config.get('recently_open', [])
            if filename in recent:
                recent.remove(filename)
                self.config.set_key('recently_open', recent)
            action = 'new'
        else:
            try:
                wallet = Wallet(storage)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                QMessageBox.warning(None, _('Warning'), str(e), _('OK'))
                return
            action = wallet.get_action()
        # run wizard
        if action is not None:
            wizard = InstallWizard(self.config, self.network, storage)
            wallet = wizard.run(action)
            # keep current wallet
            if not wallet:
                return
        else:
            wallet.start_threads(self.network)

        return wallet
Exemple #4
0
    def load_wallet_file(self, filename):
        try:
            storage = WalletStorage(filename)
        except Exception as e:
            QMessageBox.information(None, _('Error'), str(e), _('OK'))
            return
        if not storage.file_exists:
            recent = self.config.get('recently_open', [])
            if filename in recent:
                recent.remove(filename)
                self.config.set_key('recently_open', recent)
            action = 'new'
        else:
            try:
                wallet = Wallet(storage)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                QMessageBox.warning(None, _('Warning'), str(e), _('OK'))
                return
            action = wallet.get_action()
        # run wizard
        if action is not None:
            wizard = InstallWizard(self.app, self.config, self.network, storage)
            wallet = wizard.run(action)
            # keep current wallet
            if not wallet:
                return
        else:
            wallet.start_threads(self.network)

        return wallet
Exemple #5
0
 def init_network(self):
     # Show network dialog if config does not exist
     if self.daemon.network:
         if self.config.get('auto_connect') is None:
             wizard = InstallWizard(self.config, self.app, self.plugins, None)
             wizard.init_network(self.daemon.network)
             wizard.terminate()
Exemple #6
0
    def start_new_window(self, path, uri):
        '''Raises the window for the wallet if it is open.  Otherwise
        opens the wallet and creates a new window for it.'''
        for w in self.windows:
            if w.wallet.storage.path == path:
                w.bring_to_top()
                break
        else:
            wizard = InstallWizard(self.config, self.app, self.plugins)
            result = wizard.open_wallet(self.network, path)
            if not result:
                return
            w = self.create_window_for_wallet(*result)

        if uri:
            w.pay_to_URI(uri)

        return w
Exemple #7
0
 def start_new_window(self, path, uri):
     '''Raises the window for the wallet if it is open.  Otherwise
     opens the wallet and creates a new window for it.'''
     for w in self.windows:
         if w.wallet.storage.path == path:
             w.bring_to_top()
             break
     else:
         wallet = self.daemon.load_wallet(path)
         if not wallet:
             wizard = InstallWizard(self.config, self.app, self.plugins, path)
             wallet = wizard.run_and_get_wallet()
             if not wallet:
                 return
             wallet.start_threads(self.daemon.network)
             self.daemon.add_wallet(wallet)
         w = self.create_window_for_wallet(wallet)
     if uri:
         w.pay_to_URI(uri)
     return w
Exemple #8
0
 def start_new_window(self, path, uri):
     '''Raises the window for the wallet if it is open.  Otherwise
     opens the wallet and creates a new window for it.'''
     for w in self.windows:
         if w.wallet.storage.path == path:
             w.bring_to_top()
             break
     else:
         wallet = self.daemon.load_wallet(path, None)
         if not wallet:
             storage = WalletStorage(path)
             wizard = InstallWizard(self.config, self.app, self.plugins, storage)
             wallet = wizard.run_and_get_wallet()
             if not wallet:
                 return
             wallet.start_threads(self.daemon.network)
             self.daemon.add_wallet(wallet)
         w = self.create_window_for_wallet(wallet)
     if uri:
         w.pay_to_URI(uri)
     return w
Exemple #9
0
 def new_wallet(self):
     wallet_folder = self.get_wallet_folder()
     i = 1
     while True:
         filename = "wallet_%d"%i
         if filename in os.listdir(wallet_folder):
             i += 1
         else:
             break
     filename = line_dialog(None, _('New Wallet'), _('Enter file name') + ':', _('OK'), filename)
     if not filename:
         return
     full_path = os.path.join(wallet_folder, filename)
     storage = WalletStorage(full_path)
     if storage.file_exists:
         QMessageBox.critical(None, "Error", _("File exists"))
         return
     wizard = InstallWizard(self.app, self.config, self.network, storage)
     wallet = wizard.run('new')
     if wallet:
         self.new_window(full_path)
Exemple #10
0
 def new_wallet(self):
     wallet_folder = self.get_wallet_folder()
     i = 1
     while True:
         filename = "wallet_%d"%i
         if filename in os.listdir(wallet_folder):
             i += 1
         else:
             break
     filename = line_dialog(None, _('New Wallet'), _('Enter file name') + ':', _('OK'), filename)
     if not filename:
         return
     full_path = os.path.join(wallet_folder, filename)
     storage = WalletStorage(full_path)
     if storage.file_exists:
         QMessageBox.critical(None, "Error", _("File exists"))
         return
     wizard = InstallWizard(self.app, self.config, self.network, storage)
     wallet = wizard.run('new')
     if wallet:
         self.new_window(full_path)
Exemple #11
0
 def init_network(self):
     # Show network dialog if config does not exist
     if self.daemon.network:
         if self.config.get('auto_connect') is None:
             wizard = InstallWizard(self.config, self.app, self.plugins, None)
             wizard.init_network(self.daemon.network)
             wizard.terminate()
Exemple #12
0
 def get_wizard(self):
     return InstallWizard(self.config, self.app, self.plugins)