mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-15 15:46:06 +00:00
Implemented ResetDevice
This commit is contained in:
parent
f0e7c61cdd
commit
dc671173d0
20
cmd.py
20
cmd.py
@ -111,9 +111,13 @@ class Commands(object):
|
||||
|
||||
if args.mnemonic:
|
||||
mnemonic = ' '.join(args.mnemonic)
|
||||
return self.client.load_device_by_mnemonic(mnemonic, args.pin, args.passphrase_protection)
|
||||
return self.client.load_device_by_mnemonic(mnemonic, args.pin, args.passphrase_protection, args.label)
|
||||
|
||||
return self.client.load_device_by_xprv(args.xprv, args.pin, args.passphrase_protection)
|
||||
else:
|
||||
return self.client.load_device_by_xprv(args.xprv, args.pin, args.passphrase_protection, args.label)
|
||||
|
||||
def reset_device(self, args):
|
||||
return self.client.reset_device(True, args.strength, args.passphrase, args.pin, args.label)
|
||||
|
||||
def sign_message(self, args):
|
||||
return self.client.sign_message(args.n, args.message)
|
||||
@ -140,6 +144,7 @@ class Commands(object):
|
||||
set_label.help = 'Set new wallet label'
|
||||
set_coin.help = 'Switch device to another crypto currency'
|
||||
load_device.help = 'Load custom configuration to the device'
|
||||
reset_device.help = 'Perform factory reset of the device and generate new seed'
|
||||
sign_message.help = 'Sign message using address of given path'
|
||||
verify_message.help = 'Verify message'
|
||||
firmware_update.help = 'Upload new firmware to device (must be in bootloader mode)'
|
||||
@ -171,6 +176,14 @@ class Commands(object):
|
||||
(('-x', '--xprv'), {'type': str}),
|
||||
(('-p', '--pin'), {'type': str, 'default': ''}),
|
||||
(('-r', '--passphrase-protection'), {'action': 'store_true', 'default': False}),
|
||||
(('-l', '--label'), {'type': str, 'default': ''}),
|
||||
)
|
||||
|
||||
reset_device.arguments = (
|
||||
(('-t', '--strength'), {'type': int, 'choices': [128, 192, 256], 'default': 128}),
|
||||
(('-p', '--pin'), {'action': 'store_true', 'default': False}),
|
||||
(('-r', '--passphrase'), {'action': 'store_true', 'default': False}),
|
||||
(('-l', '--label'), {'type': str, 'default': ''}),
|
||||
)
|
||||
|
||||
sign_message.arguments = (
|
||||
@ -214,6 +227,7 @@ class PinMatrixThread(threading.Thread):
|
||||
from PyQt4.QtCore import QObject, SIGNAL
|
||||
|
||||
a = QApplication(sys.argv)
|
||||
|
||||
matrix = PinMatrixWidget()
|
||||
|
||||
def clicked():
|
||||
@ -240,7 +254,7 @@ def qt_pin_func(input_text, message=None):
|
||||
This is a hack to display Qt window in non-qt application.
|
||||
Qt window just asks for PIN and closes itself, which trigger join().
|
||||
'''
|
||||
if os.getenv('DISPLAY'):
|
||||
if False: # os.getenv('DISPLAY'):
|
||||
# Let's hope that system is configured properly and this won't crash
|
||||
t = PinMatrixThread(input_text, message)
|
||||
t.start()
|
||||
|
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
import binascii
|
||||
|
||||
import ckd_public
|
||||
import tools
|
||||
@ -268,19 +269,36 @@ class TrezorClient(object):
|
||||
return s_inputs
|
||||
'''
|
||||
|
||||
def reset_device(self):
|
||||
def reset_device(self, display_random, strength, passphrase_protection, pin_protection, label):
|
||||
# Begin with device reset workflow
|
||||
raise Exception("Not implemented")
|
||||
resp = self.call(proto.ResetDevice(random=self._get_local_entropy()))
|
||||
self.init_device()
|
||||
msg = proto.ResetDevice(display_random=display_random,
|
||||
strength=strength,
|
||||
language='english',
|
||||
passphrase_protection=bool(passphrase_protection),
|
||||
pin_protection=bool(pin_protection),
|
||||
label=label
|
||||
)
|
||||
print msg
|
||||
resp = self.call(msg)
|
||||
if not isinstance(resp, proto.EntropyRequest):
|
||||
raise Exception("Invalid response, expected EntropyRequest")
|
||||
|
||||
external_entropy = self._get_local_entropy()
|
||||
print "Computer generated entropy:", binascii.hexlify(external_entropy)
|
||||
resp = self.call(proto.EntropyAck(entropy=external_entropy))
|
||||
|
||||
|
||||
return isinstance(resp, proto.Success)
|
||||
|
||||
def load_device_by_mnemonic(self, mnemonic, pin, passphrase_protection):
|
||||
resp = self.call(proto.LoadDevice(mnemonic=mnemonic, pin=pin, passphrase_protection=passphrase_protection))
|
||||
def load_device_by_mnemonic(self, mnemonic, pin, passphrase_protection, label):
|
||||
resp = self.call(proto.LoadDevice(mnemonic=mnemonic, pin=pin,
|
||||
passphrase_protection=passphrase_protection,
|
||||
language='english',
|
||||
label=label))
|
||||
self.init_device()
|
||||
return isinstance(resp, proto.Success)
|
||||
|
||||
def load_device_by_xprv(self, xprv, pin, passphrase_protection):
|
||||
def load_device_by_xprv(self, xprv, pin, passphrase_protection, label):
|
||||
if xprv[0:4] not in ('xprv', 'tprv'):
|
||||
raise Exception("Unknown type of xprv")
|
||||
|
||||
@ -310,7 +328,11 @@ class TrezorClient(object):
|
||||
print 'wtf is this?', len(data[156:])
|
||||
# FIXME
|
||||
|
||||
resp = self.call(proto.LoadDevice(node=node, pin=pin, passphrase_protection=passphrase_protection))
|
||||
resp = self.call(proto.LoadDevice(node=node,
|
||||
pin=pin,
|
||||
passphrase_protection=passphrase_protection,
|
||||
language='english',
|
||||
label=label))
|
||||
self.init_device()
|
||||
return isinstance(resp, proto.Success)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user