Skip to content

Commit 3c1a4da

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 c2be195 commit 3c1a4da

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
@@ -357,31 +357,31 @@ def display_address(self, keypath, p2sh_p2wpkh, bech32, redeem_script=None, desc
357357

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

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

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

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

374374
# Close the device
375375
def close(self):
376376
self.dongle.close()
377377

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

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

386386
# Toggle passphrase
387387
def toggle_passphrase(self):

test/test_ledger.py

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

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

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

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

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

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

103103
class TestLedgerGetXpub(DeviceTestCase):

0 commit comments

Comments
 (0)