|
1 | 1 | # Trezor interaction script
|
2 | 2 |
|
3 |
| -from ..hwwclient import HardwareWalletClient |
| 3 | +from ..hwwclient import DeviceFeature, HardwareWalletClient, SupportedFeatures |
4 | 4 | from ..errors import ActionCanceledError, BadArgumentError, DeviceAlreadyInitError, DeviceAlreadyUnlockedError, DeviceConnectionError, DEVICE_NOT_INITIALIZED, DeviceNotReadyError, UnavailableActionError, common_err_msgs, handle_errors
|
5 | 5 | from .trezorlib.client import TrezorClient as Trezor
|
6 | 6 | from .trezorlib.debuglink import TrezorClientDebugLink
|
@@ -437,18 +437,74 @@ def send_pin(self, pin):
|
437 | 437 | # Get HWI features for this device
|
438 | 438 | @classmethod
|
439 | 439 | def get_features(self):
|
440 |
| - raise NotImplementedError('The {} does not implement this method'.format(self.type)) |
| 440 | + raise UnavailableActionError('A specific Trezor model must be specified to get the features') |
441 | 441 |
|
442 | 442 | class Trezor1Client(TrezorClient):
|
| 443 | + |
| 444 | + # Setup features |
| 445 | + features = SupportedFeatures() |
| 446 | + features.getxpub = DeviceFeature.SUPPORTED |
| 447 | + features.signmessage = DeviceFeature.SUPPORTED |
| 448 | + features.setup = DeviceFeature.SUPPORTED |
| 449 | + features.wipe = DeviceFeature.SUPPORTED |
| 450 | + features.recover = DeviceFeature.SUPPORTED |
| 451 | + features.backup = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 452 | + features.sign_p2pkh = DeviceFeature.SUPPORTED |
| 453 | + features.sign_p2sh_p2wpkh = DeviceFeature.SUPPORTED |
| 454 | + features.sign_p2wpkh = DeviceFeature.SUPPORTED |
| 455 | + features.sign_multi_p2sh = DeviceFeature.SUPPORTED |
| 456 | + features.sign_multi_p2sh_p2wsh = DeviceFeature.SUPPORTED |
| 457 | + features.sign_multi_p2wsh = DeviceFeature.SUPPORTED |
| 458 | + features.sign_multi_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 459 | + features.sign_arbitrary_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 460 | + features.sign_arbitrary_p2sh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 461 | + features.sign_arbitrary_p2sh_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 462 | + features.sign_arbitrary_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 463 | + features.sign_coinjoin = DeviceFeature.SUPPORTED |
| 464 | + features.sign_mixed_segwit = DeviceFeature.SUPPORTED |
| 465 | + features.display_address = DeviceFeature.SUPPORTED |
| 466 | + |
443 | 467 | def __init__(self, path, password='', expert=False):
|
444 | 468 | super(Trezor1Client, self).__init__(path, password, expert)
|
445 | 469 | self.type = 'Trezor 1'
|
446 | 470 |
|
| 471 | + @classmethod |
| 472 | + def get_features(self): |
| 473 | + return self.features.get_printable_dict() |
| 474 | + |
447 | 475 | class TrezorTClient(TrezorClient):
|
| 476 | + |
| 477 | + # Setup features |
| 478 | + features = SupportedFeatures() |
| 479 | + features.getxpub = DeviceFeature.SUPPORTED |
| 480 | + features.signmessage = DeviceFeature.SUPPORTED |
| 481 | + features.setup = DeviceFeature.SUPPORTED |
| 482 | + features.wipe = DeviceFeature.SUPPORTED |
| 483 | + features.recover = DeviceFeature.SUPPORTED |
| 484 | + features.backup = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 485 | + features.sign_p2pkh = DeviceFeature.SUPPORTED |
| 486 | + features.sign_p2sh_p2wpkh = DeviceFeature.SUPPORTED |
| 487 | + features.sign_p2wpkh = DeviceFeature.SUPPORTED |
| 488 | + features.sign_multi_p2sh = DeviceFeature.SUPPORTED |
| 489 | + features.sign_multi_p2sh_p2wsh = DeviceFeature.SUPPORTED |
| 490 | + features.sign_multi_p2wsh = DeviceFeature.SUPPORTED |
| 491 | + features.sign_multi_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 492 | + features.sign_arbitrary_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 493 | + features.sign_arbitrary_p2sh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 494 | + features.sign_arbitrary_p2sh_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 495 | + features.sign_arbitrary_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 496 | + features.sign_coinjoin = DeviceFeature.SUPPORTED |
| 497 | + features.sign_mixed_segwit = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 498 | + features.display_address = DeviceFeature.SUPPORTED |
| 499 | + |
448 | 500 | def __init__(self, path, password='', expert=False):
|
449 | 501 | super(TrezorTClient, self).__init__(path, password, expert)
|
450 | 502 | self.type = 'Trezor T'
|
451 | 503 |
|
| 504 | + @classmethod |
| 505 | + def get_features(self): |
| 506 | + return self.features.get_printable_dict() |
| 507 | + |
452 | 508 | def enumerate(password=''):
|
453 | 509 | results = []
|
454 | 510 | for dev in enumerate_devices():
|
|
0 commit comments