tmove wrapper definition outside of main_window class - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit a600873cf9ae9395eae1b71a81634b089205b886 (DIR) parent e1ce3aace7e3143da24115890d9bae78a9f5bcaf (HTM) Author: ThomasV <thomasv@electrum.org> Date: Tue, 11 Feb 2020 11:08:33 +0100 move wrapper definition outside of main_window class Diffstat: M electrum/gui/qt/main_window.py | 49 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 24 deletions(-) --- (DIR) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -124,6 +124,31 @@ class StatusBarButton(QPushButton): self.func() +def protected(func): + '''Password request wrapper. The password is passed to the function + as the 'password' named argument. "None" indicates either an + unencrypted wallet, or the user cancelled the password request. + An empty input is passed as the empty string.''' + def request_password(self, *args, **kwargs): + parent = self.top_level_window() + password = None + while self.wallet.has_keystore_encryption(): + password = self.password_dialog(parent=parent) + if password is None: + # User cancelled password input + return + try: + self.wallet.check_password(password) + break + except Exception as e: + self.show_error(str(e), parent=parent) + continue + + kwargs['password'] = password + return func(self, *args, **kwargs) + return request_password + + class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): payment_request_ok_signal = pyqtSignal() t@@ -1334,30 +1359,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): l = [self.get_contact_payto(key) for key in self.contacts.keys()] self.completions.setStringList(l) - def protected(func): - '''Password request wrapper. The password is passed to the function - as the 'password' named argument. "None" indicates either an - unencrypted wallet, or the user cancelled the password request. - An empty input is passed as the empty string.''' - def request_password(self, *args, **kwargs): - parent = self.top_level_window() - password = None - while self.wallet.has_keystore_encryption(): - password = self.password_dialog(parent=parent) - if password is None: - # User cancelled password input - return - try: - self.wallet.check_password(password) - break - except Exception as e: - self.show_error(str(e), parent=parent) - continue - - kwargs['password'] = password - return func(self, *args, **kwargs) - return request_password - @protected def protect(self, func, args, password): return func(*args, password)