Ejemplo n.º 1
0
 def on_filename(filename):
     path = os.path.join(wallet_folder, filename)
     try:
         self.storage = WalletStorage(path, manual_upgrades=True)
         self.next_button.setEnabled(True)
     except IOError:
         self.storage = None
         self.next_button.setEnabled(False)
     if self.storage:
         if not self.storage.file_exists():
             msg =_("This file does not exist.") + '\n' \
                   + _("Press 'Next' to create this wallet, or choose another file.")
             pw = False
         elif self.storage.file_exists() and self.storage.is_encrypted(
         ):
             msg = _("This file is encrypted.") + '\n' + _(
                 'Enter your password or choose another file.')
             pw = True
         else:
             msg = _("Press 'Next' to open this wallet.")
             pw = False
     else:
         msg = _('Cannot read file')
         pw = False
     self.msg_label.setText(msg)
     if pw:
         self.pw_label.show()
         self.pw_e.show()
         self.pw_e.setFocus()
     else:
         self.pw_label.hide()
         self.pw_e.hide()
Ejemplo n.º 2
0
    def __init__(self, config, daemon, plugins):

        self.config = config
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists():
            print("Wallet not found. try 'electron-cash create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:'******'')
        self.encoding = locale.getpreferredencoding()

        self.stdscr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        curses.use_default_colors()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN)
        curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE)
        self.stdscr.keypad(1)
        self.stdscr.border(0)
        self.maxy, self.maxx = self.stdscr.getmaxyx()
        self.set_cursor(0)
        self.w = curses.newwin(10, 50, 5, 5)

        set_verbosity(False)
        self.tab = 0
        self.pos = 0
        self.popup_pos = 0

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""
        self.history = None

        if self.network:
            self.network.register_callback(
                self.update, ['wallet_updated', 'blockchain_updated'])

        self.tab_names = [
            _("History"),
            _("Send"),
            _("Receive"),
            _("Addresses"),
            _("Contacts"),
            _("Banner")
        ]
        self.num_tabs = len(self.tab_names)
Ejemplo n.º 3
0
    def start_new_window(self, path, uri, daemon):
        '''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[daemon.currency]:
            if w.wallet.storage.path == path:
                w.bring_to_top()
                break
        else:
            try:

                wallet = daemon.load_wallet(path, None)
                if not wallet:
                    storage = WalletStorage(path,
                                            daemon.currency,
                                            manual_upgrades=True)
                    wizard = InstallWizard(self.config, self.app, self.plugins,
                                           daemon.currency, storage)
                    try:
                        wallet = wizard.run_and_get_wallet()
                    except UserCancelled:
                        pass
                    except GoBack as e:
                        print_error(
                            '[start_new_window] Exception caught (GoBack)', e)
                    finally:
                        wizard.terminate()
                    if not wallet:
                        return
                    wallet.start_threads(daemon.network)
                    daemon.add_wallet(wallet)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                if '2fa' in str(e):
                    d = QMessageBox(
                        QMessageBox.Warning, _('Error'),
                        '2FA wallets for Bitcoin Cash are currently unsupported by <a href="https://api.trustedcoin.com/#/">TrustedCoin</a>. Follow <a href="https://github.com/Electron-Cash/Electron-Cash/issues/41#issuecomment-357468208">this guide</a> in order to recover your funds.'
                    )
                    d.exec_()
                else:
                    d = QMessageBox(QMessageBox.Warning, _('Error'),
                                    'Cannot load wallet:\n' + str(e))
                    d.exec_()
                return
            w = self.create_window_for_wallet(wallet, daemon.currency)
        if uri:
            w.pay_to_URI(uri)
        w.bring_to_top()
        w.setWindowState(w.windowState() & ~QtCore.Qt.WindowMinimized
                         | QtCore.Qt.WindowActive)

        # this will activate the window
        w.activateWindow()

        return w
Ejemplo n.º 4
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.'''
        path = standardize_path(
            path)  # just make sure some plugin didn't give us a symlink
        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)
                if not wallet:
                    storage = WalletStorage(path, manual_upgrades=True)
                    wizard = InstallWizard(self.config, self.app, self.plugins,
                                           storage)
                    try:
                        wallet = wizard.run_and_get_wallet()
                    except UserCancelled:
                        pass
                    except GoBack as e:
                        self.print_error(
                            '[start_new_window] Exception caught (GoBack)', e)
                    finally:
                        wizard.terminate()
                        del wizard
                        gc.collect(
                        )  # wizard sticks around in memory sometimes, otherwise :/
                    if not wallet:
                        return
                    wallet.start_threads(self.daemon.network)
                    self.daemon.add_wallet(wallet)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                if '2fa' in str(e):
                    self.warning(
                        title=_('Error'),
                        message=
                        '2FA wallets for Bitcoin Cash are currently unsupported by <a href="https://api.trustedcoin.com/#/">TrustedCoin</a>. Follow <a href="https://github.com/Electron-Cash/Electron-Cash/issues/41#issuecomment-357468208">this guide</a> in order to recover your funds.'
                    )
                else:
                    self.warning(title=_('Error'),
                                 message='Cannot load wallet:\n' + str(e))
                return
            w = self.create_window_for_wallet(wallet)
        if uri:
            w.pay_to_URI(uri)
        w.bring_to_top()
        w.setWindowState(w.windowState() & ~Qt.WindowMinimized
                         | Qt.WindowActive)

        # this will activate the window
        w.activateWindow()
        return w
Ejemplo n.º 5
0
    def run(self):
        network = Network.get_instance()
        if not network:
            self.notify_offline()
            return

        for i, p in enumerate(self.DERIVATION_PATHS):
            if self.aborting:
                return
            k = keystore.from_seed(self.seed,
                                   '',
                                   derivation=p,
                                   seed_type=self.seed_type)
            p_safe = p.replace('/', '_').replace("'", 'h')
            storage_path = os.path.join(
                tempfile.gettempdir(), p_safe + '_' +
                random.getrandbits(32).to_bytes(4, 'big').hex()[:8] +
                "_not_saved_")
            tmp_storage = WalletStorage(storage_path, in_memory_only=True)
            tmp_storage.put('seed_type', self.seed_type)
            tmp_storage.put('keystore', k.dump())
            wallet = Standard_Wallet(tmp_storage)
            try:
                wallet.start_threads(network)
                wallet.synchronize()
                wallet.print_error("Scanning", p)
                synched = False
                for ctr in range(25):
                    try:
                        wallet.wait_until_synchronized(timeout=1.0)
                        synched = True
                    except TimeoutException:
                        wallet.print_error(f'timeout try {ctr+1}/25')
                    if self.aborting:
                        return
                if not synched:
                    wallet.print_error("Timeout on", p)
                    self.notify_timedout(i)
                    continue
                while network.is_connecting():
                    time.sleep(0.1)
                    if self.aborting:
                        return
                num_tx = len(wallet.get_history())
                self.update_table_cb(i, str(num_tx))
            finally:
                wallet.clear_history()
                wallet.stop_threads()
Ejemplo n.º 6
0
 def load_wallet_by_name(self, path):
     if not path:
         return
     wallet = self.daemon.load_wallet(path, None)
     if wallet:
         if wallet != self.wallet:
             self.stop_wallet()
             self.load_wallet(wallet)
             self.on_resume()
     else:
         Logger.debug('Electrum: Wallet not found. Launching install wizard')
         storage = WalletStorage(path)
         wizard = Factory.InstallWizard(self.electrum_config, storage)
         wizard.bind(on_wizard_complete=self.on_wizard_complete)
         action = wizard.storage.get_action()
         wizard.run(action)
Ejemplo n.º 7
0
 def on_filename(filename):
     path = os.path.join(wallet_folder, filename)
     wallet_from_memory = get_wallet_from_daemon(path)
     try:
         if wallet_from_memory:
             self.temp_storage = wallet_from_memory.storage
         else:
             self.temp_storage = WalletStorage(path, manual_upgrades=True)
         self.next_button.setEnabled(True)
     except IOError:
         self.temp_storage = None
         self.next_button.setEnabled(False)
     if self.temp_storage:
         if not self.temp_storage.file_exists():
             msg =_("This file does not exist.") + '\n' \
                   + _("Press 'Next' to create this wallet, or choose another file.")
             pw = False
         elif not wallet_from_memory:
             if self.temp_storage.is_encrypted_with_user_pw():
                 msg = _("This file is encrypted with a password.") + '\n' \
                       + _('Enter your password or choose another file.')
                 pw = True
             elif self.temp_storage.is_encrypted_with_hw_device():
                 msg = _("This file is encrypted using a hardware device.") + '\n' \
                       + _("Press 'Next' to choose device to decrypt.")
                 pw = False
             else:
                 msg = _("Press 'Next' to open this wallet.")
                 pw = False
         else:
             msg = _("This file is already open in memory.") + "\n" \
                 + _("Press 'Next' to create/focus window.")
             pw = False
     else:
         msg = _('Cannot read file')
         pw = False
     self.msg_label.setText(msg)
     if pw:
         self.pw_label.show()
         self.pw_e.show()
         self.pw_e.setFocus()
     else:
         self.pw_label.hide()
         self.pw_e.hide()
Ejemplo n.º 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:
            try:
                wallet = self.daemon.load_wallet(path, None)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                d = QMessageBox(QMessageBox.Warning, _('Error'),
                                'Cannot load wallet:\n' + str(e))
                d.exec_()
                return
            if not wallet:
                storage = WalletStorage(path, manual_upgrades=True)
                wizard = InstallWizard(self.config, self.app, self.plugins,
                                       storage)
                try:
                    wallet = wizard.run_and_get_wallet()
                except UserCancelled:
                    pass
                except GoBack as e:
                    print_error('[start_new_window] Exception caught (GoBack)',
                                e)
                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)
        w.bring_to_top()
        w.setWindowState(w.windowState() & ~QtCore.Qt.WindowMinimized
                         | QtCore.Qt.WindowActive)

        # this will activate the window
        w.activateWindow()
        return w
Ejemplo n.º 9
0
    def __init__(self, config, daemon, plugins):
        self.config = config
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists:
            print(f"Wallet not found. try '{SCRIPT_NAME} create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:', stream=None)
            storage.decrypt(password)

        self.done = 0
        self.last_balance = ""

        set_verbosity(False)

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""

        self.wallet = Wallet(storage)
        self.wallet.start_threads(self.network)
        self.contacts = self.wallet.contacts

        self.network.register_callback(
            self.on_network,
            ["wallet_updated", "blockchain_updated", "banner"])
        self.commands = [
            _("[h] - displays this help text"),
            _("[i] - display transaction history"),
            _("[o] - enter payment order"),
            _("[p] - print stored payment order"),
            _("[s] - send stored payment order"),
            _("[r] - show own receipt addresses"),
            _("[c] - display contacts"),
            _("[b] - print server banner"),
            _("[q] - quit"),
        ]
        self.num_commands = len(self.commands)
Ejemplo n.º 10
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()
             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
Ejemplo n.º 11
0
    def select_storage(
        self, path, get_wallet_from_daemon
    ) -> Tuple[str, Optional[WalletStorage]]:
        vbox = QtWidgets.QVBoxLayout()
        vbox.addWidget(
            QtWidgets.QLabel(
                _('Create a new wallet or load an existing wallet from file.'))
        )
        vbox.addSpacing(20)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(QtWidgets.QLabel(_('Wallet name') + ':'))
        self.name_e = QtWidgets.QLineEdit()
        self.name_e.setToolTip(
            _("Enter a wallet name (new or existing), or the path to a wallet file.")
        )
        hbox.addWidget(self.name_e)
        button = QtWidgets.QPushButton(_('Load...'))
        button.setToolTip(_("Open a file selection dialog to load a wallet file."))
        hbox.addWidget(button)
        vbox.addLayout(hbox)
        vbox.addSpacing(20)

        self.msg_label = QtWidgets.QLabel('')
        vbox.addWidget(self.msg_label)
        hbox2 = QtWidgets.QHBoxLayout()
        self.pw_e = PasswordLineEdit('', self)
        self.pw_e.setFixedWidth(17 * char_width_in_lineedit())
        self.pw_label = QtWidgets.QLabel(_('Password') + ':')
        hbox2.addWidget(self.pw_label)
        hbox2.addWidget(self.pw_e)
        hbox2.addStretch()
        vbox.addLayout(hbox2)
        self.set_layout(vbox, title=_(f'{PROJECT_NAME} wallet'))

        self.temp_storage = WalletStorage(path, manual_upgrades=True)
        wallet_folder = os.path.dirname(self.temp_storage.path)

        def on_choose():
            path, __ = QtWidgets.QFileDialog.getOpenFileName(self, "Select your wallet file", wallet_folder)
            if path:
                self.name_e.setText(path)

        def on_filename(filename):
            path = os.path.join(wallet_folder, filename)
            wallet_from_memory = get_wallet_from_daemon(path)
            try:
                if wallet_from_memory:
                    self.temp_storage = wallet_from_memory.storage
                else:
                    self.temp_storage = WalletStorage(path, manual_upgrades=True)
                self.next_button.setEnabled(True)
            except IOError:
                self.temp_storage = None
                self.next_button.setEnabled(False)
            if self.temp_storage:
                if not self.temp_storage.file_exists():
                    msg =_("This file does not exist.") + '\n' \
                          + _("Press 'Next' to create this wallet, or choose another file.")
                    pw = False
                elif not wallet_from_memory:
                    if self.temp_storage.is_encrypted_with_user_pw():
                        msg = _("This file is encrypted with a password.") + '\n' \
                              + _('Enter your password or choose another file.')
                        pw = True
                    elif self.temp_storage.is_encrypted_with_hw_device():
                        msg = _("This file is encrypted using a hardware device.") + '\n' \
                              + _("Press 'Next' to choose device to decrypt.")
                        pw = False
                    else:
                        msg = _("Press 'Next' to open this wallet.")
                        pw = False
                else:
                    msg = _("This file is already open in memory.") + "\n" \
                        + _("Press 'Next' to create/focus window.")
                    pw = False
            else:
                msg = _('Cannot read file')
                pw = False
            self.msg_label.setText(msg)
            if pw:
                self.pw_label.show()
                self.pw_e.show()
                self.pw_e.setFocus()
            else:
                self.pw_label.hide()
                self.pw_e.hide()

        button.clicked.connect(on_choose)
        self.name_e.textChanged.connect(on_filename)
        n = os.path.basename(self.temp_storage.path)
        self.name_e.setText(n)

        while True:
            if self.loop.exec_() != 2:  # 2 = next
                raise UserCancelled
            if self.temp_storage.file_exists() and not self.temp_storage.is_encrypted():
                break
            if not self.temp_storage.file_exists():
                break
            wallet_from_memory = get_wallet_from_daemon(self.temp_storage.path)
            if wallet_from_memory:
                raise WalletAlreadyOpenInMemory(wallet_from_memory)
            if self.temp_storage.file_exists() and self.temp_storage.is_encrypted():
                if self.temp_storage.is_encrypted_with_user_pw():
                    password = self.pw_e.text()
                    try:
                        self.temp_storage.decrypt(password)
                        break
                    except InvalidPassword as e:
                        QtWidgets.QMessageBox.information(None, _('Error'), str(e))
                        continue
                    except BaseException as e:
                        traceback.print_exc(file=sys.stdout)
                        QtWidgets.QMessageBox.information(None, _('Error'), str(e))
                        raise UserCancelled()
                elif self.temp_storage.is_encrypted_with_hw_device():
                    try:
                        self.run(
                            'choose_hw_device',
                            HWD_SETUP_DECRYPT_WALLET,
                            storage=self.temp_storage
                        )
                    except InvalidPassword as e:
                        QtWidgets.QMessageBox.information(
                            None, _('Error'),
                            _('Failed to decrypt using this hardware device.') + '\n' +
                            _('If you use a passphrase, make sure it is correct.'))
                        self.reset_stack()
                        return self.select_storage(path, get_wallet_from_daemon)
                    except BaseException as e:
                        traceback.print_exc(file=sys.stdout)
                        QtWidgets.QMessageBox.information(None, _('Error'), str(e))
                        raise UserCancelled()
                    if self.temp_storage.is_past_initial_decryption():
                        break
                    else:
                        raise UserCancelled()
                else:
                    raise Exception('Unexpected encryption version')
        return self.temp_storage.path, (self.temp_storage if self.temp_storage.file_exists() else None)
Ejemplo n.º 12
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.

        `path=None` is a special usage which will raise the last activated
        window or open the 'last wallet' if no windows are open.'''

        if not path:
            if not self.windows:
                # This branch is taken if nothing is currently open but
                # path == None, in which case set path=last wallet
                self.config.open_last_wallet()
                path = self.config.get_wallet_path()
            elif self._last_active_window:
                # This branch is taken if we have windows open and we have
                # _last_active_window defined, in which case we specify
                # that this window should be activated by setting path
                # so that the for loop below will trigger on this window.
                w = self._last_active_window()  # weak ref -> strong ref
                if w and w in self.windows:  # check ref still alive
                    # this will cause the last active window to be used in the
                    # for loop below
                    path = w.wallet.storage.path

        # NB: path may still be None here if it came in as None from args and
        # if the above logic couldn't select a window to use -- in which case
        # we'll end up picking self.windows[0]

        path = path and standardize_path(
            path)  # just make sure some plugin didn't give us a symlink
        for w in self.windows:
            if not path or w.wallet.storage.path == path:
                path = w.wallet.storage.path  # remember path in case it was None
                w.bring_to_top()
                break
        else:
            try:

                try:
                    wallet = self.daemon.load_wallet(path, None)
                except BaseException as e:
                    self.print_error(repr(e))
                    if self.windows:
                        # *Not* starting up. Propagate exception out to present
                        # error message box to user.
                        raise e
                    # We're just starting up, so we are tolerant of bad wallets
                    # and just want to proceed to the InstallWizard so the user
                    # can either specify a different wallet or create a new one.
                    # (See issue #1189 where before they would get stuck)
                    path = self.get_new_wallet_path(
                    )  # give up on this unknown wallet and try a new name.. note if things get really bad this will raise FileNotFoundError and the app aborts here.
                    wallet = None  # fall thru to wizard
                if not wallet:
                    storage = WalletStorage(path, manual_upgrades=True)
                    wizard = InstallWizard(self.config, self.app, self.plugins,
                                           storage, 'New/Restore Wallet')
                    try:
                        wallet = wizard.run_and_get_wallet()
                    except UserCancelled:
                        pass
                    except GoBack as e:
                        self.print_error(
                            '[start_new_window] Exception caught (GoBack)', e)
                    finally:
                        wizard.terminate()
                        del wizard
                        gc.collect(
                        )  # wizard sticks around in memory sometimes, otherwise :/
                    if not wallet:
                        return
                    wallet.start_threads(self.daemon.network)
                    self.daemon.add_wallet(wallet)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                if '2fa' in str(e):
                    self.warning(
                        title=_('Error'),
                        message=
                        '2FA wallets for Bitcoin Cash are currently unsupported by <a href="https://api.trustedcoin.com/#/">TrustedCoin</a>. Follow <a href="https://github.com/Electron-Cash/Electron-Cash/issues/41#issuecomment-357468208">this guide</a> in order to recover your funds.'
                    )
                else:
                    self.warning(title=_('Error'),
                                 message='Cannot load wallet:\n' + str(e),
                                 icon=QMessageBox.Critical)
                return
            w = self.create_window_for_wallet(wallet)
        if uri:
            w.pay_to_URI(uri)
        w.bring_to_top()
        w.setWindowState(w.windowState() & ~Qt.WindowMinimized
                         | Qt.WindowActive)

        # this will activate the window
        w.activateWindow()
        return w
Ejemplo n.º 13
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.'''
        path = standardize_path(path)  # just make sure some plugin didn't give us a symlink
        for w in self.windows:
            if w.wallet.storage.path == path:
                w.bring_to_top()
                break
        else:
            try:

                if not self.windows:
                    self.warn_if_no_secp()

                try:
                    wallet = self.daemon.load_wallet(path, None)
                except BaseException as e:
                    self.print_error(repr(e))
                    if self.windows:
                        # *Not* starting up. Propagate exception out to present
                        # error message box to user.
                        raise e
                    # We're just starting up, so we are tolerant of bad wallets
                    # and just want to proceed to the InstallWizard so the user
                    # can either specify a different wallet or create a new one.
                    # (See issue #1189 where before they would get stuck)
                    path = self.get_new_wallet_path()  # give up on this unknown wallet and try a new name.. note if things get really bad this will raise FileNotFoundError and the app aborts here.
                    wallet = None  # fall thru to wizard
                if not wallet:
                    storage = WalletStorage(path, manual_upgrades=True)
                    wizard = InstallWizard(self.config, self.app, self.plugins, storage)
                    try:
                        wallet, password = wizard.run_and_get_wallet() or (None, None)
                    except UserCancelled:
                        pass
                    except GoBack as e:
                        self.print_error('[start_new_window] Exception caught (GoBack)', e)
                    finally:
                        wizard.terminate()
                        del wizard
                        gc.collect() # wizard sticks around in memory sometimes, otherwise :/
                    if not wallet:
                        return
                    wallet.start_threads(self.daemon.network)
                    self.daemon.add_wallet(wallet)
                    self._cache_password(wallet, password)
            except BaseException as e:
                traceback.print_exc(file=sys.stdout)
                if '2fa' in str(e):
                    self.warning(title=_('Error'), message = '2FA wallets for Bitcoin Cash are currently unsupported by <a href="https://api.trustedcoin.com/#/">TrustedCoin</a>. Follow <a href="https://github.com/Electron-Cash/Electron-Cash/issues/41#issuecomment-357468208">this guide</a> in order to recover your funds.')
                else:
                    self.warning(title=_('Error'), message = 'Cannot load wallet:\n' + str(e), icon=QMessageBox.Critical)
                return
            w = self.create_window_for_wallet(wallet)
        if uri:
            w.pay_to_URI(uri)
        w.bring_to_top()
        w.setWindowState(w.windowState() & ~Qt.WindowMinimized | Qt.WindowActive)

        # this will activate the window
        w.activateWindow()
        return w