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