Skip to content

Commit 9d3b8bd

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 6eca458 commit 9d3b8bd

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
@@ -329,31 +329,31 @@ def display_address(self, keypath, p2sh_p2wpkh, bech32):
329329

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

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

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

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

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

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

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

358358
class LedgerNanoSClient(LedgerClient):
359359
def __init__(self, path, password='', expert=False):

test/test_ledger.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,41 @@ def test_pin(self):
5050
result = self.do_command(self.dev_args + ['promptpin'])
5151
self.assertIn('error', result)
5252
self.assertIn('code', result)
53-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not need a PIN sent from the host')
53+
self.assertEqual(result['error'], 'The Ledger Nano S does not need a PIN sent from the host')
5454
self.assertEqual(result['code'], -9)
5555

5656
result = self.do_command(self.dev_args + ['sendpin', '1234'])
5757
self.assertIn('error', result)
5858
self.assertIn('code', result)
59-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not need a PIN sent from the host')
59+
self.assertEqual(result['error'], 'The Ledger Nano S does not need a PIN sent from the host')
6060
self.assertEqual(result['code'], -9)
6161

6262
def test_setup(self):
6363
result = self.do_command(self.dev_args + ['-i', 'setup'])
6464
self.assertIn('error', result)
6565
self.assertIn('code', result)
66-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support software setup')
66+
self.assertEqual(result['error'], 'The Ledger Nano S does not support software setup')
6767
self.assertEqual(result['code'], -9)
6868

6969
def test_wipe(self):
7070
result = self.do_command(self.dev_args + ['wipe'])
7171
self.assertIn('error', result)
7272
self.assertIn('code', result)
73-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support wiping via software')
73+
self.assertEqual(result['error'], 'The Ledger Nano S does not support wiping via software')
7474
self.assertEqual(result['code'], -9)
7575

7676
def test_restore(self):
7777
result = self.do_command(self.dev_args + ['-i', 'restore'])
7878
self.assertIn('error', result)
7979
self.assertIn('code', result)
80-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support restoring via software')
80+
self.assertEqual(result['error'], 'The Ledger Nano S does not support restoring via software')
8181
self.assertEqual(result['code'], -9)
8282

8383
def test_backup(self):
8484
result = self.do_command(self.dev_args + ['backup'])
8585
self.assertIn('error', result)
8686
self.assertIn('code', result)
87-
self.assertEqual(result['error'], 'The Ledger Nano S and X do not support creating a backup via software')
87+
self.assertEqual(result['error'], 'The Ledger Nano S does not support creating a backup via software')
8888
self.assertEqual(result['code'], -9)
8989

9090
class TestLedgerGetXpub(DeviceTestCase):

0 commit comments

Comments
 (0)