diff --git a/cmd.py b/cmd.py index 21dde28e01..b845795f3e 100755 --- a/cmd.py +++ b/cmd.py @@ -107,6 +107,9 @@ class Commands(object): def set_label(self, args): return self.client.apply_settings(label=args.label) + def change_pin(self, args): + return self.client.change_pin(args.remove) + def load_device(self, args): if not args.mnemonic and not args.xprv: raise Exception("Please provide mnemonic or xprv") @@ -146,6 +149,7 @@ class Commands(object): get_features.help = 'Retrieve device features and settings' get_public_node.help = 'Get public node of given path' set_label.help = 'Set new wallet label' + change_pin.help = 'Change new PIN or remove existing' list_coins.help = 'List all supported coin types by the device' load_device.help = 'Load custom configuration to the device' reset_device.help = 'Perform factory reset of the device and generate new seed' @@ -176,6 +180,10 @@ class Commands(object): # (('-c', '--clear'), {'action': 'store_true', 'default': False}) ) + change_pin.arguments = ( + (('-r', '--remove'), {'action': 'store_true', 'default': False}), + ) + load_device.arguments = ( (('-m', '--mnemonic'), {'type': str, 'nargs': '+'}), (('-x', '--xprv'), {'type': str}), diff --git a/tests/config.py b/tests/config.py index 56963adfcf..31cf06ae5f 100644 --- a/tests/config.py +++ b/tests/config.py @@ -5,8 +5,8 @@ from trezorlib.transport_pipe import PipeTransport from trezorlib.transport_hid import HidTransport from trezorlib.transport_socket import SocketTransportClient -use_real = True -use_pipe = False +use_real = False +use_pipe = True if use_real: diff --git a/tests/test.py b/tests/test.py index a9a5b26fd5..5ec3fa3251 100755 --- a/tests/test.py +++ b/tests/test.py @@ -1,4 +1,25 @@ #!/usr/bin/python +''' +* ApplySettings workflow, zistit cez Features ci sa zmeny aplikovali +* WipeDevice workflow, zistit cez Features ci to prebehlo +* LoadDevice workflow, zistit cez Features ci to prebehlo +* ResetDevice workflow + +- zrejme v sucinnosti s inymi testami + * ButtonRequest/ButtonAck workflow (vyvolat napr. pomocou GetEntropy, myslim ze ten GetEntropy vyzaduje PIN, ale ja by som to dal na button) + * PinMatrixRequest/PinMatrixAck workflow (vyvolat napr. pomocou ChangePin) + * PassphraseRequest/PassphraseAck workflow (vyvolat napr. pomocou GetAddress) + +* rozsirit test_sign.tx o viac transakcii (zlozitejsich) + +- chceme v tomto release(?) + * SignMessage workflow + * VerifyMessage workflow + +* otestovat session handling (tento test bude zrejme failovat na RPi) +''' + + ''' import sys sys.path = ['../',] + sys.path diff --git a/trezorlib/client.py b/trezorlib/client.py index a32a52ccde..6a40d7954d 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -123,6 +123,11 @@ class TrezorClient(object): return out + def change_pin(self, remove=False): + ret = self.call(proto.ChangePin(remove=remove)) + self.init_device() # Re-read features + return ret + def _pprint(self, msg): return "<%s>:\n%s" % (msg.__class__.__name__, msg) diff --git a/trezorlib/pinmatrix.py b/trezorlib/pinmatrix.py index 162bc7d34f..24f6ea473f 100644 --- a/trezorlib/pinmatrix.py +++ b/trezorlib/pinmatrix.py @@ -15,6 +15,7 @@ class PinButton(QPushButton): def _pressed(self): self.password.setText(self.password.text() + str(self.encoded_value)) + print self.encoded_value self.password.setFocus() class PinMatrixWidget(QWidget): @@ -40,11 +41,12 @@ class PinMatrixWidget(QWidget): grid = QGridLayout() grid.setSpacing(0) - for x in range(9): - button = PinButton(self.password, x + 1) - button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - button.setFocusPolicy(Qt.NoFocus) - grid.addWidget(button, x / 3, x % 3) + for y in range(3)[::-1]: + for x in range(3): + button = PinButton(self.password, x + y * 3 + 1) + button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + button.setFocusPolicy(Qt.NoFocus) + grid.addWidget(button, 3 - y, x) hbox = QHBoxLayout() hbox.addWidget(self.password)