mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-09 15:00:58 +00:00
Refactored client.call() to allow PIN/OTP in any order
This commit is contained in:
parent
c164eba47b
commit
f16ade99e0
@ -65,27 +65,27 @@ class BitkeyClient(object):
|
|||||||
if self.debuglink:
|
if self.debuglink:
|
||||||
otp = self.debuglink.read_otp()
|
otp = self.debuglink.read_otp()
|
||||||
if self.debug_otp:
|
if self.debug_otp:
|
||||||
self.transport.write(otp)
|
msg2 = otp
|
||||||
else:
|
else:
|
||||||
self.transport.write(proto.OtpAck(otp='__42__'))
|
msg2 = proto.OtpAck(otp='__42__')
|
||||||
else:
|
else:
|
||||||
otp = self.input_func("OTP required: ", resp.message)
|
otp = self.input_func("OTP required: ", resp.message)
|
||||||
self.transport.write(proto.OtpAck(otp=otp))
|
msg2 = proto.OtpAck(otp=otp)
|
||||||
|
|
||||||
resp = self.transport.read()
|
return self.call(msg2, button, tries)
|
||||||
|
|
||||||
if isinstance(resp, proto.PinRequest):
|
if isinstance(resp, proto.PinRequest):
|
||||||
if self.debuglink:
|
if self.debuglink:
|
||||||
pin = self.debuglink.read_pin()
|
pin = self.debuglink.read_pin()
|
||||||
if self.debug_pin:
|
if self.debug_pin:
|
||||||
self.transport.write(pin)
|
msg2 = pin
|
||||||
else:
|
else:
|
||||||
self.transport.write(proto.PinAck(pin='__42__'))
|
msg2 = proto.PinAck(pin='__42__')
|
||||||
else:
|
else:
|
||||||
pin = self.input_func("PIN required: ", resp.message)
|
pin = self.input_func("PIN required: ", resp.message)
|
||||||
self.transport.write(proto.PinAck(pin=pin))
|
msg2 = proto.PinAck(pin=pin)
|
||||||
|
|
||||||
resp = self.transport.read()
|
return self.call(msg2, button, tries)
|
||||||
|
|
||||||
if isinstance(resp, proto.Failure):
|
if isinstance(resp, proto.Failure):
|
||||||
self.message_func(resp.message)
|
self.message_func(resp.message)
|
||||||
@ -104,6 +104,7 @@ class BitkeyClient(object):
|
|||||||
self.message_func("PIN is invalid, let's try again...")
|
self.message_func("PIN is invalid, let's try again...")
|
||||||
|
|
||||||
return self.call(msg, button, tries-1)
|
return self.call(msg, button, tries-1)
|
||||||
|
|
||||||
if isinstance(resp, proto.Failure):
|
if isinstance(resp, proto.Failure):
|
||||||
raise Exception(resp.code, resp.message)
|
raise Exception(resp.code, resp.message)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user