mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
move wrapper definition outside of main_window class
This commit is contained in:
parent
e1ce3aace7
commit
a600873cf9
1 changed files with 25 additions and 24 deletions
|
@ -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()
|
||||
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue