|
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
|
@@ -432,18 +432,74 @@ def send_pin(self, pin):
|
432 | 432 | # Get HWI features for this device
|
433 | 433 | @classmethod
|
434 | 434 | def get_features(self):
|
435 |
| - raise NotImplementedError('The {} does not implement this method'.format(self.type)) |
| 435 | + raise UnavailableActionError('A specific Trezor model must be specified to get the features') |
436 | 436 |
|
437 | 437 | class Trezor1Client(TrezorClient):
|
| 438 | + |
| 439 | + # Setup features |
| 440 | + features = SupportedFeatures() |
| 441 | + features.getxpub = DeviceFeature.SUPPORTED |
| 442 | + features.signmessage = DeviceFeature.SUPPORTED |
| 443 | + features.setup = DeviceFeature.SUPPORTED |
| 444 | + features.wipe = DeviceFeature.SUPPORTED |
| 445 | + features.recover = DeviceFeature.SUPPORTED |
| 446 | + features.backup = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 447 | + features.sign_p2pkh = DeviceFeature.SUPPORTED |
| 448 | + features.sign_p2sh_p2wpkh = DeviceFeature.SUPPORTED |
| 449 | + features.sign_p2wpkh = DeviceFeature.SUPPORTED |
| 450 | + features.sign_multi_p2sh = DeviceFeature.SUPPORTED |
| 451 | + features.sign_multi_p2sh_p2wsh = DeviceFeature.SUPPORTED |
| 452 | + features.sign_multi_p2wsh = DeviceFeature.SUPPORTED |
| 453 | + features.sign_multi_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 454 | + features.sign_arbitrary_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 455 | + features.sign_arbitrary_p2sh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 456 | + features.sign_arbitrary_p2sh_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 457 | + features.sign_arbitrary_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 458 | + features.sign_coinjoin = DeviceFeature.SUPPORTED |
| 459 | + features.sign_mixed_segwit = DeviceFeature.SUPPORTED |
| 460 | + features.display_address = DeviceFeature.SUPPORTED |
| 461 | + |
438 | 462 | def __init__(self, path, password=''):
|
439 | 463 | super(Trezor1Client, self).__init__(path, password)
|
440 | 464 | self.type = 'Trezor 1'
|
441 | 465 |
|
| 466 | + @classmethod |
| 467 | + def get_features(self): |
| 468 | + return self.features.get_printable_dict() |
| 469 | + |
442 | 470 | class TrezorTClient(TrezorClient):
|
| 471 | + |
| 472 | + # Setup features |
| 473 | + features = SupportedFeatures() |
| 474 | + features.getxpub = DeviceFeature.SUPPORTED |
| 475 | + features.signmessage = DeviceFeature.SUPPORTED |
| 476 | + features.setup = DeviceFeature.SUPPORTED |
| 477 | + features.wipe = DeviceFeature.SUPPORTED |
| 478 | + features.recover = DeviceFeature.SUPPORTED |
| 479 | + features.backup = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 480 | + features.sign_p2pkh = DeviceFeature.SUPPORTED |
| 481 | + features.sign_p2sh_p2wpkh = DeviceFeature.SUPPORTED |
| 482 | + features.sign_p2wpkh = DeviceFeature.SUPPORTED |
| 483 | + features.sign_multi_p2sh = DeviceFeature.SUPPORTED |
| 484 | + features.sign_multi_p2sh_p2wsh = DeviceFeature.SUPPORTED |
| 485 | + features.sign_multi_p2wsh = DeviceFeature.SUPPORTED |
| 486 | + features.sign_multi_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 487 | + features.sign_arbitrary_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 488 | + features.sign_arbitrary_p2sh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 489 | + features.sign_arbitrary_p2sh_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 490 | + features.sign_arbitrary_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 491 | + features.sign_coinjoin = DeviceFeature.SUPPORTED |
| 492 | + features.sign_mixed_segwit = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 493 | + features.display_address = DeviceFeature.SUPPORTED |
| 494 | + |
443 | 495 | def __init__(self, path, password=''):
|
444 | 496 | super(TrezorTClient, self).__init__(path, password)
|
445 | 497 | self.type = 'Trezor T'
|
446 | 498 |
|
| 499 | + @classmethod |
| 500 | + def get_features(self): |
| 501 | + return self.features.get_printable_dict() |
| 502 | + |
447 | 503 | def enumerate(password=''):
|
448 | 504 | results = []
|
449 | 505 | for dev in enumerate_devices():
|
|
0 commit comments