Trezor: all four available device initializations
Trezor and KeepKey devices can now be initialized by: - device-generated seed - existing seed - BIP39 mnemonic - master private key
This commit is contained in:
@@ -332,6 +332,11 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||
def query_choice(self, msg, choices):
|
||||
vbox = QVBoxLayout()
|
||||
self.set_layout(vbox)
|
||||
if len(msg) > 50:
|
||||
label = QLabel(msg)
|
||||
label.setWordWrap(True)
|
||||
vbox.addWidget(label)
|
||||
msg = ""
|
||||
gb2 = QGroupBox(msg)
|
||||
vbox.addWidget(gb2)
|
||||
|
||||
@@ -402,54 +407,87 @@ class InstallWizard(WindowModalDialog, WizardBase):
|
||||
if not self.exec_():
|
||||
raise UserCancelled
|
||||
|
||||
def request_trezor_reset_settings(self, device):
|
||||
def request_trezor_init_settings(self, method, device):
|
||||
vbox = QVBoxLayout()
|
||||
|
||||
main_label = QLabel(_("Choose how to initialize your %s device:")
|
||||
% device)
|
||||
main_label = QLabel(_("Initialization settings for your %s:") % device)
|
||||
vbox.addWidget(main_label)
|
||||
|
||||
msg = _("Select your seed length and strength:")
|
||||
choices = [
|
||||
_("12 words (low)"),
|
||||
_("18 words (medium)"),
|
||||
_("24 words (high)"),
|
||||
]
|
||||
gb = QGroupBox(msg)
|
||||
vbox1 = QVBoxLayout()
|
||||
gb.setLayout(vbox1)
|
||||
bg = QButtonGroup()
|
||||
for i, choice in enumerate(choices):
|
||||
rb = QRadioButton(gb)
|
||||
rb.setText(choice)
|
||||
bg.addButton(rb)
|
||||
bg.setId(rb, i)
|
||||
vbox1.addWidget(rb)
|
||||
rb.setChecked(True)
|
||||
vbox.addWidget(gb)
|
||||
OK_button = OkButton(self, _('Next'))
|
||||
|
||||
if method in [self.TIM_NEW, self.TIM_RECOVER]:
|
||||
gb = QGroupBox()
|
||||
vbox1 = QVBoxLayout()
|
||||
gb.setLayout(vbox1)
|
||||
vbox.addWidget(gb)
|
||||
gb.setTitle(_("Select your seed length:"))
|
||||
choices = [
|
||||
_("12 words"),
|
||||
_("18 words"),
|
||||
_("24 words"),
|
||||
]
|
||||
bg = QButtonGroup()
|
||||
for i, choice in enumerate(choices):
|
||||
rb = QRadioButton(gb)
|
||||
rb.setText(choice)
|
||||
bg.addButton(rb)
|
||||
bg.setId(rb, i)
|
||||
vbox1.addWidget(rb)
|
||||
rb.setChecked(True)
|
||||
cb_pin = QCheckBox(_('Enable PIN protection'))
|
||||
cb_pin.setChecked(True)
|
||||
else:
|
||||
text = QTextEdit()
|
||||
text.setMaximumHeight(60)
|
||||
vbox.addWidget(text)
|
||||
if method == self.TIM_MNEMONIC:
|
||||
msg = _("Enter your BIP39 mnemonic:")
|
||||
else:
|
||||
msg = _("Enter the master private key beginning with xprv:")
|
||||
def set_enabled():
|
||||
OK_button.setEnabled(Wallet.is_xprv(
|
||||
self.get_seed_text(text)))
|
||||
text.textChanged.connect(set_enabled)
|
||||
OK_button.setEnabled(False)
|
||||
|
||||
vbox.addWidget(QLabel(msg))
|
||||
pin = QLineEdit()
|
||||
pin.setValidator(QRegExpValidator(QRegExp('[1-9]{0,10}')))
|
||||
pin.setMaximumWidth(100)
|
||||
hbox_pin = QHBoxLayout()
|
||||
hbox_pin.addWidget(QLabel(_("Enter your PIN (digits 1-9):")))
|
||||
hbox_pin.addWidget(pin)
|
||||
hbox_pin.addStretch(1)
|
||||
|
||||
label = QLabel(_("Enter a label to name your device:"))
|
||||
name = QLineEdit()
|
||||
hl = QHBoxLayout()
|
||||
hl.addWidget(label)
|
||||
hl.addWidget(name)
|
||||
hl.addStretch(2)
|
||||
hl.addStretch(1)
|
||||
vbox.addLayout(hl)
|
||||
|
||||
cb_pin = QCheckBox(_('Enable PIN protection'))
|
||||
cb_pin.setChecked(True)
|
||||
vbox.addWidget(cb_pin)
|
||||
if method in [self.TIM_NEW, self.TIM_RECOVER]:
|
||||
vbox.addWidget(cb_pin)
|
||||
else:
|
||||
vbox.addLayout(hbox_pin)
|
||||
|
||||
cb_phrase = QCheckBox(_('Enable Passphrase protection'))
|
||||
cb_phrase.setChecked(False)
|
||||
vbox.addWidget(cb_phrase)
|
||||
|
||||
vbox.addStretch(1)
|
||||
vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next'))))
|
||||
vbox.addLayout(Buttons(CancelButton(self), OK_button))
|
||||
self.set_layout(vbox)
|
||||
|
||||
if not self.exec_():
|
||||
raise UserCancelled
|
||||
|
||||
return (bg.checkedId(), unicode(name.text()),
|
||||
cb_pin.isChecked(), cb_phrase.isChecked())
|
||||
if method in [self.TIM_NEW, self.TIM_RECOVER]:
|
||||
item = bg.checkedId()
|
||||
pin = cb_pin.isChecked()
|
||||
else:
|
||||
item = ' '.join(str(self.get_seed_text(text)).split())
|
||||
pin = str(pin.text())
|
||||
|
||||
return (item, unicode(name.text()), pin, cb_phrase.isChecked())
|
||||
|
||||
Reference in New Issue
Block a user