|
|
|
|
@ -223,96 +223,6 @@ class Plugin(TrustedCoinPlugin):
|
|
|
|
|
vbox.addLayout(Buttons(CloseButton(d))) |
|
|
|
|
d.exec_() |
|
|
|
|
|
|
|
|
|
def accept_terms_of_use(self, window): |
|
|
|
|
vbox = QVBoxLayout() |
|
|
|
|
vbox.addWidget(QLabel(_("Terms of Service"))) |
|
|
|
|
|
|
|
|
|
tos_e = TOS() |
|
|
|
|
tos_e.setReadOnly(True) |
|
|
|
|
vbox.addWidget(tos_e) |
|
|
|
|
tos_received = False |
|
|
|
|
|
|
|
|
|
vbox.addWidget(QLabel(_("Please enter your e-mail address"))) |
|
|
|
|
email_e = QLineEdit() |
|
|
|
|
vbox.addWidget(email_e) |
|
|
|
|
|
|
|
|
|
next_button = window.next_button |
|
|
|
|
prior_button_text = next_button.text() |
|
|
|
|
next_button.setText(_('Accept')) |
|
|
|
|
|
|
|
|
|
def request_TOS(): |
|
|
|
|
try: |
|
|
|
|
tos = server.get_terms_of_service() |
|
|
|
|
except Exception as e: |
|
|
|
|
self.logger.exception('Could not retrieve Terms of Service') |
|
|
|
|
tos_e.error_signal.emit(_('Could not retrieve Terms of Service:') |
|
|
|
|
+ '\n' + repr(e)) |
|
|
|
|
return |
|
|
|
|
self.TOS = tos |
|
|
|
|
tos_e.tos_signal.emit() |
|
|
|
|
|
|
|
|
|
def on_result(): |
|
|
|
|
tos_e.setText(self.TOS) |
|
|
|
|
nonlocal tos_received |
|
|
|
|
tos_received = True |
|
|
|
|
set_enabled() |
|
|
|
|
|
|
|
|
|
def on_error(msg): |
|
|
|
|
window.show_error(str(msg)) |
|
|
|
|
window.terminate() |
|
|
|
|
|
|
|
|
|
def set_enabled(): |
|
|
|
|
next_button.setEnabled(tos_received and is_valid_email(email_e.text())) |
|
|
|
|
|
|
|
|
|
tos_e.tos_signal.connect(on_result) |
|
|
|
|
tos_e.error_signal.connect(on_error) |
|
|
|
|
t = threading.Thread(target=request_TOS) |
|
|
|
|
t.daemon = True |
|
|
|
|
t.start() |
|
|
|
|
email_e.textChanged.connect(set_enabled) |
|
|
|
|
email_e.setFocus(True) |
|
|
|
|
window.exec_layout(vbox, next_enabled=False) |
|
|
|
|
next_button.setText(prior_button_text) |
|
|
|
|
email = str(email_e.text()) |
|
|
|
|
self.create_remote_key(email, window) |
|
|
|
|
|
|
|
|
|
def request_otp_dialog(self, window, short_id, otp_secret, xpub3): |
|
|
|
|
vbox = QVBoxLayout() |
|
|
|
|
if otp_secret is not None: |
|
|
|
|
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret) |
|
|
|
|
l = QLabel("Please scan the following QR code in Google Authenticator. You may as well use the following key: %s"%otp_secret) |
|
|
|
|
l.setWordWrap(True) |
|
|
|
|
vbox.addWidget(l) |
|
|
|
|
qrw = QRCodeWidget(uri) |
|
|
|
|
vbox.addWidget(qrw, 1) |
|
|
|
|
msg = _('Then, enter your Google Authenticator code:') |
|
|
|
|
else: |
|
|
|
|
label = QLabel( |
|
|
|
|
"This wallet is already registered with TrustedCoin. " |
|
|
|
|
"To finalize wallet creation, please enter your Google Authenticator Code. " |
|
|
|
|
) |
|
|
|
|
label.setWordWrap(1) |
|
|
|
|
vbox.addWidget(label) |
|
|
|
|
msg = _('Google Authenticator code:') |
|
|
|
|
hbox = QHBoxLayout() |
|
|
|
|
hbox.addWidget(WWLabel(msg)) |
|
|
|
|
pw = AmountEdit(None, is_int = True) |
|
|
|
|
pw.setFocus(True) |
|
|
|
|
pw.setMaximumWidth(50) |
|
|
|
|
hbox.addWidget(pw) |
|
|
|
|
vbox.addLayout(hbox) |
|
|
|
|
cb_lost = QCheckBox(_("I have lost my Google Authenticator account")) |
|
|
|
|
cb_lost.setToolTip(_("Check this box to request a new secret. You will need to retype your seed.")) |
|
|
|
|
vbox.addWidget(cb_lost) |
|
|
|
|
cb_lost.setVisible(otp_secret is None) |
|
|
|
|
def set_enabled(): |
|
|
|
|
b = True if cb_lost.isChecked() else len(pw.text()) == 6 |
|
|
|
|
window.next_button.setEnabled(b) |
|
|
|
|
pw.textChanged.connect(set_enabled) |
|
|
|
|
cb_lost.toggled.connect(set_enabled) |
|
|
|
|
window.exec_layout(vbox, next_enabled=False, raise_on_cancel=False) |
|
|
|
|
self.check_otp(window, short_id, otp_secret, xpub3, pw.get_amount(), cb_lost.isChecked()) |
|
|
|
|
|
|
|
|
|
@hook |
|
|
|
|
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'): |
|
|
|
|
wizard.trustedcoin_qhelper = TrustedcoinPluginQObject(self, wizard, None) |
|
|
|
|
|