1
0

wizard: trezor init

This commit is contained in:
ThomasV
2016-08-24 05:58:41 +02:00
parent 9366e37fb0
commit 8edca91390
4 changed files with 66 additions and 66 deletions

View File

@@ -176,12 +176,57 @@ class QtHandler(QtHandlerBase):
self.character_dialog.get_char(msg.word_pos, msg.character_pos)
self.done.set()
def request_trezor_init_settings(self, method, device):
wizard = self.win
def qt_plugin_class(base_plugin_class):
class QtPlugin(base_plugin_class):
# Derived classes must provide the following class-static variables:
# icon_file
# pin_matrix_widget_class
def create_handler(self, window):
return QtHandler(window, self.pin_matrix_widget_class(), self.device)
@hook
def load_wallet(self, wallet, window):
for keystore in wallet.get_keystores():
if type(keystore) != self.keystore_class:
continue
button = StatusBarButton(QIcon(self.icon_file), self.device,
partial(self.settings_dialog, window))
window.statusBar().addPermanentWidget(button)
keystore.handler = self.create_handler(window)
keystore.thread = TaskThread(window, window.on_error)
# Trigger a pairing
keystore.thread.add(partial(self.get_client, keystore))
@hook
def receive_menu(self, menu, addrs, wallet):
for keystore in wallet.get_keystores():
if type(keystore) == self.keystore_class and len(addrs) == 1:
def show_address():
keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
menu.addAction(_("Show on %s") % self.device, show_address)
def settings_dialog(self, window):
device_id = self.choose_device(window)
if device_id:
SettingsDialog(window, self, device_id).exec_()
def choose_device(self, window):
'''This dialog box should be usable even if the user has
forgotten their PIN or it is in bootloader mode.'''
keystore = window.wallet.get_keystore()
device_id = self.device_manager().xpub_id(keystore.xpub)
if not device_id:
info = self.device_manager().select_device(keystore.handler, self)
device_id = info.device.id_
return device_id
def request_trezor_init_settings(self, wizard, method, device):
vbox = QVBoxLayout()
next_enabled=True
next_enabled = True
label = QLabel(_("Enter a label to name your device:"))
name = QLineEdit()
hl = QHBoxLayout()
@@ -260,54 +305,6 @@ class QtHandler(QtHandlerBase):
return (item, unicode(name.text()), pin, cb_phrase.isChecked())
def qt_plugin_class(base_plugin_class):
class QtPlugin(base_plugin_class):
# Derived classes must provide the following class-static variables:
# icon_file
# pin_matrix_widget_class
def create_handler(self, window):
return QtHandler(window, self.pin_matrix_widget_class(), self.device)
@hook
def load_wallet(self, wallet, window):
for keystore in wallet.get_keystores():
if type(keystore) != self.keystore_class:
continue
button = StatusBarButton(QIcon(self.icon_file), self.device,
partial(self.settings_dialog, window))
window.statusBar().addPermanentWidget(button)
keystore.handler = self.create_handler(window)
keystore.thread = TaskThread(window, window.on_error)
# Trigger a pairing
keystore.thread.add(partial(self.get_client, keystore))
@hook
def receive_menu(self, menu, addrs, wallet):
for keystore in wallet.get_keystores():
if type(keystore) == self.keystore_class and len(addrs) == 1:
def show_address():
keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
menu.addAction(_("Show on %s") % self.device, show_address)
def settings_dialog(self, window):
device_id = self.choose_device(window)
if device_id:
SettingsDialog(window, self, device_id).exec_()
def choose_device(self, window):
'''This dialog box should be usable even if the user has
forgotten their PIN or it is in bootloader mode.'''
keystore = window.wallet.get_keystore()
device_id = self.device_manager().xpub_id(keystore.xpub)
if not device_id:
info = self.device_manager().select_device(keystore.handler, self)
device_id = info.device.id_
return device_id
return QtPlugin