Skip to content

Commit 4edf4f6

Browse files
committed
Merge bitcoin-core#542: keepkey, trezor: Handle if ButtonRequest is sent during sendpin
6fbb2a2 tests: Test sendpin with passphrase (Andrew Chow) 2fa0c94 keepkey, trezor: Handle if ButtonRequest is sent during sendpin (Andrew Chow) Pull request description: Keepkey and Trezor may ask the user for confirmation of their passphrase after the PIN is sent. This could cause some issues as `ButtonRequests` were not being handled by `sendpin`. Additionally, `TrezorClient.call` would not work because it needs access to `TrezorClient.features`, which is not set for the `sendpin` command. In order to resolve this, `TrezorClient.call` is modified to optionally skip the firmware check that requires `TrezorClient.features`, and `sendpin` uses `TrezorClient.call` instead of `TrezorClient.call_raw`. Fixes bitcoin-core#526 Fixes $539 Top commit has no ACKs. Tree-SHA512: 87b0cc2d21f8e4647e17540aa16291aade5cc514efcc2b592484f227a96c2e5be029bd1953e3df00ad1036aa8084fdd5869e9bde990cd5f81968e1e5755f964e
2 parents 8c1b50a + 6fbb2a2 commit 4edf4f6

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

hwilib/devices/trezor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ def send_pin(self, pin: str) -> bool:
737737
raise DeviceAlreadyUnlockedError('The PIN has already been sent to this device')
738738
return False
739739
elif isinstance(resp, messages.PassphraseRequest):
740-
pass_resp = self.client.call_raw(messages.PassphraseAck(passphrase=self.client.ui.get_passphrase(available_on_device=False), on_device=False))
740+
pass_resp = self.client.call(messages.PassphraseAck(passphrase=self.client.ui.get_passphrase(available_on_device=False), on_device=False), check_fw=False)
741741
if isinstance(pass_resp, messages.Deprecated_PassphraseStateRequest):
742742
self.client.call_raw(messages.Deprecated_PassphraseStateAck())
743743
return True

hwilib/devices/trezorlib/client.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ def _callback_button(self, msg):
212212
return self._raw_read()
213213

214214
@tools.session
215-
def call(self, msg):
216-
self.check_firmware_version()
215+
def call(self, msg, check_fw = True):
216+
if check_fw:
217+
self.check_firmware_version()
217218
resp = self.call_raw(msg)
218219
while True:
219220
if isinstance(resp, messages.PinMatrixRequest):

test/test_keepkey.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def test_pins(self):
239239

240240
# Set a PIN
241241
device.wipe(self.client)
242-
load_device_by_mnemonic(client=self.client, mnemonic='alcohol woman abuse must during monitor noble actual mixed trade anger aisle', pin='1234', passphrase_protection=False, label='test')
242+
load_device_by_mnemonic(client=self.client, mnemonic='alcohol woman abuse must during monitor noble actual mixed trade anger aisle', pin='1234', passphrase_protection=True, label='test')
243243
self.client.call(messages.LockDevice())
244244
result = self.do_command(self.dev_args + ['enumerate'])
245245
for dev in result:
@@ -272,7 +272,7 @@ def test_pins(self):
272272
# Send the PIN
273273
self.client.open()
274274
pin = self.client.debug.encode_pin('1234')
275-
result = self.do_command(self.dev_args + ['sendpin', pin])
275+
result = self.do_command(self.dev_args + ["-p", "test", 'sendpin', pin])
276276
self.assertTrue(result['success'])
277277

278278
result = self.do_command(self.dev_args + ['enumerate'])

test/test_trezor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def test_pins(self):
289289
# Send the PIN
290290
self.client.open()
291291
pin = self.client.debug.encode_pin('1234')
292-
result = self.do_command(self.dev_args + ['sendpin', pin])
292+
result = self.do_command(self.dev_args + ["-p", "asdf", 'sendpin', pin])
293293
self.assertTrue(result['success'])
294294

295295
result = self.do_command(self.dev_args + ['enumerate'])

0 commit comments

Comments
 (0)