mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 09:45:18 +00:00
Fix some more regressions and trustedcoin plugin
This commit is contained in:
parent
fd66e15d3d
commit
6178f5a28f
3 changed files with 39 additions and 36 deletions
|
@ -73,8 +73,8 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
# Set for base base class
|
# Set for base base class
|
||||||
self.plugins = plugins
|
self.plugins = plugins
|
||||||
self.language_for_seed = config.get('language')
|
self.language_for_seed = config.get('language')
|
||||||
self.setMinimumSize(518, 360)
|
self.setMinimumSize(530, 370)
|
||||||
self.setMaximumSize(518, 360)
|
self.setMaximumSize(530, 370)
|
||||||
self.connect(self, QtCore.SIGNAL('accept'), self.accept)
|
self.connect(self, QtCore.SIGNAL('accept'), self.accept)
|
||||||
self.title = WWLabel()
|
self.title = WWLabel()
|
||||||
self.main_widget = QWidget()
|
self.main_widget = QWidget()
|
||||||
|
@ -109,6 +109,7 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
self.set_icon(':icons/electrum.png')
|
self.set_icon(':icons/electrum.png')
|
||||||
self.show()
|
self.show()
|
||||||
self.raise_()
|
self.raise_()
|
||||||
|
self.refresh_gui() # Need for QT on MacOSX. Lame.
|
||||||
|
|
||||||
def finished(self):
|
def finished(self):
|
||||||
'''Ensure the dialog is closed.'''
|
'''Ensure the dialog is closed.'''
|
||||||
|
@ -117,19 +118,20 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
|
|
||||||
def set_icon(self, filename):
|
def set_icon(self, filename):
|
||||||
prior_filename, self.icon_filename = self.icon_filename, filename
|
prior_filename, self.icon_filename = self.icon_filename, filename
|
||||||
self.logo.setPixmap(QPixmap(filename).scaledToWidth(70))
|
self.logo.setPixmap(QPixmap(filename).scaledToWidth(60))
|
||||||
return prior_filename
|
return prior_filename
|
||||||
|
|
||||||
def set_main_layout(self, layout, title=None, raise_on_cancel=True):
|
def set_main_layout(self, layout, title=None, raise_on_cancel=True,
|
||||||
|
next_enabled=True):
|
||||||
self.title.setText(title or "")
|
self.title.setText(title or "")
|
||||||
self.title.setVisible(bool(title))
|
self.title.setVisible(bool(title))
|
||||||
# Get rid of any prior layout
|
# Get rid of any prior layout by assigning it to a temporary widget
|
||||||
prior_layout = self.main_widget.layout()
|
prior_layout = self.main_widget.layout()
|
||||||
if prior_layout:
|
if prior_layout:
|
||||||
QWidget().setLayout(prior_layout)
|
QWidget().setLayout(prior_layout)
|
||||||
self.main_widget.setLayout(layout)
|
self.main_widget.setLayout(layout)
|
||||||
self.cancel_button.setEnabled(True)
|
self.cancel_button.setEnabled(True)
|
||||||
self.next_button.setEnabled(True)
|
self.next_button.setEnabled(next_enabled)
|
||||||
self.main_widget.setVisible(True)
|
self.main_widget.setVisible(True)
|
||||||
self.please_wait.setVisible(False)
|
self.please_wait.setVisible(False)
|
||||||
result = self.loop.exec_()
|
result = self.loop.exec_()
|
||||||
|
@ -165,13 +167,12 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
def request_seed(self, title, is_valid=None):
|
def request_seed(self, title, is_valid=None):
|
||||||
is_valid = is_valid or Wallet.is_any
|
is_valid = is_valid or Wallet.is_any
|
||||||
slayout = SeedInputLayout()
|
slayout = SeedInputLayout()
|
||||||
self.next_button.setEnabled(False)
|
|
||||||
def sanitized_seed():
|
def sanitized_seed():
|
||||||
return clean_text(slayout.seed_edit())
|
return clean_text(slayout.seed_edit())
|
||||||
def set_enabled():
|
def set_enabled():
|
||||||
self.next_button.setEnabled(is_valid(sanitized_seed()))
|
self.next_button.setEnabled(is_valid(sanitized_seed()))
|
||||||
slayout.seed_edit().textChanged.connect(set_enabled)
|
slayout.seed_edit().textChanged.connect(set_enabled)
|
||||||
self.set_main_layout(slayout.layout(), title)
|
self.set_main_layout(slayout.layout(), title, next_enabled=False)
|
||||||
return sanitized_seed()
|
return sanitized_seed()
|
||||||
|
|
||||||
def show_seed(self, seed):
|
def show_seed(self, seed):
|
||||||
|
@ -211,6 +212,9 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
return self.pw_layout(msg or MSG_ENTER_PASSWORD, PW_NEW)
|
return self.pw_layout(msg or MSG_ENTER_PASSWORD, PW_NEW)
|
||||||
|
|
||||||
def show_restore(self, wallet, network):
|
def show_restore(self, wallet, network):
|
||||||
|
# FIXME: these messages are shown after the install wizard is
|
||||||
|
# finished and the window closed. On MacOSX they appear parented
|
||||||
|
# with a re-appeared ghost install wizard window...
|
||||||
if network:
|
if network:
|
||||||
def task():
|
def task():
|
||||||
wallet.wait_until_synchronized()
|
wallet.wait_until_synchronized()
|
||||||
|
@ -282,7 +286,6 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
innerVbox.addLayout(layout.layout())
|
innerVbox.addLayout(layout.layout())
|
||||||
entries.append(layout.seed_edit())
|
entries.append(layout.seed_edit())
|
||||||
|
|
||||||
self.next_button.setEnabled(False)
|
|
||||||
def get_texts():
|
def get_texts():
|
||||||
return [clean_text(entry) for entry in entries]
|
return [clean_text(entry) for entry in entries]
|
||||||
def set_enabled():
|
def set_enabled():
|
||||||
|
@ -295,7 +298,7 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
self.next_button.setEnabled(all_valid and not has_dups)
|
self.next_button.setEnabled(all_valid and not has_dups)
|
||||||
for e in entries:
|
for e in entries:
|
||||||
e.textChanged.connect(set_enabled)
|
e.textChanged.connect(set_enabled)
|
||||||
self.set_main_layout(vbox)
|
self.set_main_layout(vbox, next_enabled=False)
|
||||||
return get_texts()
|
return get_texts()
|
||||||
|
|
||||||
def choose_server(self, network):
|
def choose_server(self, network):
|
||||||
|
@ -321,8 +324,7 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||||
|
|
||||||
def query_choice(self, msg, choices):
|
def query_choice(self, msg, choices):
|
||||||
clayout = ChoicesLayout(msg, choices)
|
clayout = ChoicesLayout(msg, choices)
|
||||||
self.next_button.setEnabled(bool(choices))
|
self.set_main_layout(clayout.layout(), next_enabled=bool(choices))
|
||||||
self.set_main_layout(clayout.layout())
|
|
||||||
return clayout.selected_index()
|
return clayout.selected_index()
|
||||||
|
|
||||||
def query_multisig(self, action):
|
def query_multisig(self, action):
|
||||||
|
|
|
@ -102,15 +102,15 @@ class Plugin(TrustedCoinPlugin):
|
||||||
return WaitingDialog(window, 'Getting billing information...', task,
|
return WaitingDialog(window, 'Getting billing information...', task,
|
||||||
on_finished)
|
on_finished)
|
||||||
|
|
||||||
def show_disclaimer(self, wallet, window):
|
def confirm(self, window, msg):
|
||||||
prior_icon = window.set_icon(':icons/trustedcoin.png')
|
|
||||||
label = QLabel('\n\n'.join(DISCLAIMER))
|
|
||||||
label.setWordWrap(True)
|
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
vbox.addWidget(label)
|
vbox.addWidget(WWLabel(msg))
|
||||||
window.set_main_layout(vbox)
|
window.set_main_layout(vbox)
|
||||||
|
|
||||||
|
def show_disclaimer(self, wallet, window):
|
||||||
|
window.set_icon(':icons/trustedcoin.png')
|
||||||
|
self.confirm(window, '\n\n'.join(DISCLAIMER))
|
||||||
self.set_enabled(wallet, True)
|
self.set_enabled(wallet, True)
|
||||||
window.set_icon(prior_icon)
|
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def abort_send(self, window):
|
def abort_send(self, window):
|
||||||
|
@ -216,7 +216,6 @@ class Plugin(TrustedCoinPlugin):
|
||||||
|
|
||||||
def accept_terms_of_use(self, window):
|
def accept_terms_of_use(self, window):
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
window.set_layout(vbox)
|
|
||||||
vbox.addWidget(QLabel(_("Terms of Service")))
|
vbox.addWidget(QLabel(_("Terms of Service")))
|
||||||
|
|
||||||
tos_e = QTextEdit()
|
tos_e = QTextEdit()
|
||||||
|
@ -226,10 +225,10 @@ class Plugin(TrustedCoinPlugin):
|
||||||
vbox.addWidget(QLabel(_("Please enter your e-mail address")))
|
vbox.addWidget(QLabel(_("Please enter your e-mail address")))
|
||||||
email_e = QLineEdit()
|
email_e = QLineEdit()
|
||||||
vbox.addWidget(email_e)
|
vbox.addWidget(email_e)
|
||||||
vbox.addStretch()
|
|
||||||
accept_button = OkButton(window, _('Accept'))
|
next_button = window.next_button
|
||||||
accept_button.setEnabled(False)
|
prior_button_text = next_button.text()
|
||||||
vbox.addLayout(Buttons(CancelButton(window), accept_button))
|
next_button.setText(_('Accept'))
|
||||||
|
|
||||||
def request_TOS():
|
def request_TOS():
|
||||||
tos = server.get_terms_of_service()
|
tos = server.get_terms_of_service()
|
||||||
|
@ -239,24 +238,26 @@ class Plugin(TrustedCoinPlugin):
|
||||||
def on_result():
|
def on_result():
|
||||||
tos_e.setText(self.TOS)
|
tos_e.setText(self.TOS)
|
||||||
|
|
||||||
|
def set_enabled():
|
||||||
|
next_button.setEnabled(re.match(regexp,email_e.text()) is not None)
|
||||||
|
|
||||||
window.connect(window, SIGNAL('twofactor:TOS'), on_result)
|
window.connect(window, SIGNAL('twofactor:TOS'), on_result)
|
||||||
t = Thread(target=request_TOS)
|
t = Thread(target=request_TOS)
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
regexp = r"[^@]+@[^@]+\.[^@]+"
|
regexp = r"[^@]+@[^@]+\.[^@]+"
|
||||||
email_e.textChanged.connect(lambda: accept_button.setEnabled(re.match(regexp,email_e.text()) is not None))
|
email_e.textChanged.connect(set_enabled)
|
||||||
email_e.setFocus(True)
|
email_e.setFocus(True)
|
||||||
|
|
||||||
if not window.exec_():
|
window.set_main_layout(vbox, next_enabled=False)
|
||||||
raise wizard.UserCancelled
|
next_button.setText(prior_button_text)
|
||||||
|
|
||||||
return str(email_e.text())
|
return str(email_e.text())
|
||||||
|
|
||||||
|
|
||||||
def setup_google_auth(self, window, _id, otp_secret):
|
def setup_google_auth(self, window, _id, otp_secret):
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
window.set_layout(vbox)
|
|
||||||
if otp_secret is not None:
|
if otp_secret is not None:
|
||||||
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret)
|
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret)
|
||||||
vbox.addWidget(QLabel("Please scan this QR code in Google Authenticator."))
|
vbox.addWidget(QLabel("Please scan this QR code in Google Authenticator."))
|
||||||
|
@ -270,20 +271,20 @@ class Plugin(TrustedCoinPlugin):
|
||||||
msg = _('Google Authenticator code:')
|
msg = _('Google Authenticator code:')
|
||||||
|
|
||||||
hbox = QHBoxLayout()
|
hbox = QHBoxLayout()
|
||||||
hbox.addWidget(QLabel(msg))
|
hbox.addWidget(WWLabel(msg))
|
||||||
pw = AmountEdit(None, is_int = True)
|
pw = AmountEdit(None, is_int = True)
|
||||||
pw.setFocus(True)
|
pw.setFocus(True)
|
||||||
|
pw.setMaximumWidth(50)
|
||||||
hbox.addWidget(pw)
|
hbox.addWidget(pw)
|
||||||
hbox.addStretch(1)
|
|
||||||
vbox.addLayout(hbox)
|
vbox.addLayout(hbox)
|
||||||
|
|
||||||
b = OkButton(window, _('Next'))
|
def set_enabled():
|
||||||
b.setEnabled(False)
|
window.next_button.setEnabled(len(pw.text()) == 6)
|
||||||
vbox.addLayout(Buttons(CancelButton(window), b))
|
pw.textChanged.connect(set_enabled)
|
||||||
pw.textChanged.connect(lambda: b.setEnabled(len(pw.text())==6))
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if not window.exec_():
|
if not window.set_main_layout(vbox, next_enabled=False,
|
||||||
|
raise_on_cancel=False):
|
||||||
return False
|
return False
|
||||||
otp = pw.get_amount()
|
otp = pw.get_amount()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -345,7 +345,7 @@ class TrustedCoinPlugin(BasePlugin):
|
||||||
_('If you are online, click on "%s" to continue.') % _('Next')
|
_('If you are online, click on "%s" to continue.') % _('Next')
|
||||||
]
|
]
|
||||||
msg = '\n\n'.join(msg)
|
msg = '\n\n'.join(msg)
|
||||||
window.confirm(msg)
|
self.confirm(window, msg)
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def do_clear(self, window):
|
def do_clear(self, window):
|
||||||
|
@ -361,7 +361,7 @@ class TrustedCoinPlugin(BasePlugin):
|
||||||
words = seed.split()
|
words = seed.split()
|
||||||
n = len(words)/2
|
n = len(words)/2
|
||||||
wallet.add_xprv_from_seed(' '.join(words[0:n]), 'x1/', password)
|
wallet.add_xprv_from_seed(' '.join(words[0:n]), 'x1/', password)
|
||||||
wallet.add_xpub_from_seed(' '.join(words[n:]), 'x2/', password)
|
wallet.add_xpub_from_seed(' '.join(words[n:]), 'x2/')
|
||||||
|
|
||||||
restore_third_key(wallet)
|
restore_third_key(wallet)
|
||||||
wallet.create_main_account()
|
wallet.create_main_account()
|
||||||
|
|
Loading…
Add table
Reference in a new issue