electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1c9a6f5770c5183aced5238e23d8e31eec8269c2
parent 4961020e01c515735bb885704fb85c7ae6c73ab1
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  8 Jul 2020 01:51:14 +0200

qt wizard: fix scanning qr code when restoring from xpub

fixes #6342

Diffstat:
Melectrum/gui/qt/qrtextedit.py | 6+++---
Melectrum/gui/qt/util.py | 13+++++++++----
2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/electrum/gui/qt/qrtextedit.py b/electrum/gui/qt/qrtextedit.py @@ -60,9 +60,9 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin): def qr_input(self): from electrum import qrscanner - main_window = get_parent_main_window(self) - assert main_window - config = main_window.config + window_or_wizard = get_parent_main_window(self, allow_wizard=True) + assert window_or_wizard + config = window_or_wizard.config try: data = qrscanner.scan_barcode(config.get_video_device()) except BaseException as e: diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py @@ -30,6 +30,7 @@ from electrum.invoices import PR_UNPAID, PR_PAID, PR_EXPIRED, PR_INFLIGHT, PR_UN if TYPE_CHECKING: from .main_window import ElectrumWindow + from .installwizard import InstallWizard if platform.system() == 'Windows': @@ -945,19 +946,23 @@ def export_meta_gui(electrum_window, title, exporter): .format(title, str(filename))) -def get_parent_main_window(widget): +def get_parent_main_window( + widget, *, allow_wizard: bool = False, +) -> Union[None, 'ElectrumWindow', 'InstallWizard']: """Returns a reference to the ElectrumWindow this widget belongs to.""" from .main_window import ElectrumWindow from .transaction_dialog import TxDialog + from .installwizard import InstallWizard for _ in range(100): if widget is None: return None if isinstance(widget, ElectrumWindow): return widget - elif isinstance(widget, TxDialog): + if isinstance(widget, TxDialog): return widget.main_window - else: - widget = widget.parentWidget() + if isinstance(widget, InstallWizard) and allow_wizard: + return widget + widget = widget.parentWidget() return None