Skip to content

Commit bacd32d

Browse files
committed
Ledger device model specific error messages
Instead of saying "Ledger Nano S and X", give the correct name depending on whether the device model client is being used.
1 parent 875dd2f commit bacd32d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

hwilib/devices/ledger.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,31 +328,31 @@ def display_address(self, keypath, p2sh_p2wpkh, bech32):
328328

329329
# Setup a new device
330330
def setup_device(self, label='', passphrase=''):
331-
raise UnavailableActionError('The Ledger Nano S and X do not support software setup')
331+
raise UnavailableActionError('The {} does not support software setup'.format(self.type))
332332

333333
# Wipe this device
334334
def wipe_device(self):
335-
raise UnavailableActionError('The Ledger Nano S and X do not support wiping via software')
335+
raise UnavailableActionError('The {} does not support wiping via software'.format(self.type))
336336

337337
# Restore device from mnemonic or xprv
338338
def restore_device(self, label='', word_count=24):
339-
raise UnavailableActionError('The Ledger Nano S and X do not support restoring via software')
339+
raise UnavailableActionError('The {} does not support restoring via software'.format(self.type))
340340

341341
# Begin backup process
342342
def backup_device(self, label='', passphrase=''):
343-
raise UnavailableActionError('The Ledger Nano S and X do not support creating a backup via software')
343+
raise UnavailableActionError('The {} does not support creating a backup via software'.format(self.type))
344344

345345
# Close the device
346346
def close(self):
347347
self.dongle.close()
348348

349349
# Prompt pin
350350
def prompt_pin(self):
351-
raise UnavailableActionError('The Ledger Nano S and X do not need a PIN sent from the host')
351+
raise UnavailableActionError('The {} does not need a PIN sent from the host'.format(self.type))
352352

353353
# Send pin
354354
def send_pin(self, pin):
355-
raise UnavailableActionError('The Ledger Nano S and X do not need a PIN sent from the host')
355+
raise UnavailableActionError('The {} does not need a PIN sent from the host'.format(self.type))
356356

357357
# Toggle passphrase
358358
def toggle_passphrase(self):

test/test_ledger.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,41 @@ def test_pin(self):
6161
result = self.do_command(self.dev_args + ['promptpin'])
6262
self.assertIn('error', result)
6363
self.assertIn('code', result)
64-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not need a PIN sent from the host')
64+
self.assertEqual(result['error'], 'The Ledger Nano S does not need a PIN sent from the host')
6565
self.assertEqual(result['code'], -9)
6666

6767
result = self.do_command(self.dev_args + ['sendpin', '1234'])
6868
self.assertIn('error', result)
6969
self.assertIn('code', result)
70-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not need a PIN sent from the host')
70+
self.assertEqual(result['error'], 'The Ledger Nano S does not need a PIN sent from the host')
7171
self.assertEqual(result['code'], -9)
7272

7373
def test_setup(self):
7474
result = self.do_command(self.dev_args + ['-i', 'setup'])
7575
self.assertIn('error', result)
7676
self.assertIn('code', result)
77-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support software setup')
77+
self.assertEqual(result['error'], 'The Ledger Nano S does not support software setup')
7878
self.assertEqual(result['code'], -9)
7979

8080
def test_wipe(self):
8181
result = self.do_command(self.dev_args + ['wipe'])
8282
self.assertIn('error', result)
8383
self.assertIn('code', result)
84-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support wiping via software')
84+
self.assertEqual(result['error'], 'The Ledger Nano S does not support wiping via software')
8585
self.assertEqual(result['code'], -9)
8686

8787
def test_restore(self):
8888
result = self.do_command(self.dev_args + ['-i', 'restore'])
8989
self.assertIn('error', result)
9090
self.assertIn('code', result)
91-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support restoring via software')
91+
self.assertEqual(result['error'], 'The Ledger Nano S does not support restoring via software')
9292
self.assertEqual(result['code'], -9)
9393

9494
def test_backup(self):
9595
result = self.do_command(self.dev_args + ['backup'])
9696
self.assertIn('error', result)
9797
self.assertIn('code', result)
98-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support creating a backup via software')
98+
self.assertEqual(result['error'], 'The Ledger Nano S does not support creating a backup via software')
9999
self.assertEqual(result['code'], -9)
100100

101101
class TestLedgerGetXpub(DeviceTestCase):

0 commit comments

Comments
 (0)