|
2 | 2 |
|
3 | 3 | from typing import Dict, Union
|
4 | 4 |
|
5 |
| -from ..hwwclient import HardwareWalletClient |
| 5 | +from ..hwwclient import ( |
| 6 | + DeviceFeature, |
| 7 | + HardwareWalletClient, |
| 8 | + SupportedFeatures, |
| 9 | +) |
6 | 10 | from ..errors import (
|
7 | 11 | ActionCanceledError,
|
8 | 12 | BadArgumentError,
|
@@ -554,18 +558,74 @@ def toggle_passphrase(self):
|
554 | 558 | # Get HWI features for this device
|
555 | 559 | @classmethod
|
556 | 560 | def get_features(self):
|
557 |
| - raise NotImplementedError('The {} does not implement this method'.format(self.type)) |
| 561 | + raise UnavailableActionError('A specific Trezor model must be specified to get the features') |
558 | 562 |
|
559 | 563 | class Trezor1Client(TrezorClient):
|
| 564 | + |
| 565 | + # Setup features |
| 566 | + features = SupportedFeatures() |
| 567 | + features.getxpub = DeviceFeature.SUPPORTED |
| 568 | + features.signmessage = DeviceFeature.SUPPORTED |
| 569 | + features.setup = DeviceFeature.SUPPORTED |
| 570 | + features.wipe = DeviceFeature.SUPPORTED |
| 571 | + features.recover = DeviceFeature.SUPPORTED |
| 572 | + features.backup = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 573 | + features.sign_p2pkh = DeviceFeature.SUPPORTED |
| 574 | + features.sign_p2sh_p2wpkh = DeviceFeature.SUPPORTED |
| 575 | + features.sign_p2wpkh = DeviceFeature.SUPPORTED |
| 576 | + features.sign_multi_p2sh = DeviceFeature.SUPPORTED |
| 577 | + features.sign_multi_p2sh_p2wsh = DeviceFeature.SUPPORTED |
| 578 | + features.sign_multi_p2wsh = DeviceFeature.SUPPORTED |
| 579 | + features.sign_multi_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 580 | + features.sign_arbitrary_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 581 | + features.sign_arbitrary_p2sh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 582 | + features.sign_arbitrary_p2sh_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 583 | + features.sign_arbitrary_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 584 | + features.sign_coinjoin = DeviceFeature.SUPPORTED |
| 585 | + features.sign_mixed_segwit = DeviceFeature.SUPPORTED |
| 586 | + features.display_address = DeviceFeature.SUPPORTED |
| 587 | + |
560 | 588 | def __init__(self, path, password='', expert=False):
|
561 | 589 | super(Trezor1Client, self).__init__(path, password, expert)
|
562 | 590 | self.type = 'Trezor 1'
|
563 | 591 |
|
| 592 | + @classmethod |
| 593 | + def get_features(self): |
| 594 | + return self.features.get_printable_dict() |
| 595 | + |
564 | 596 | class TrezorTClient(TrezorClient):
|
| 597 | + |
| 598 | + # Setup features |
| 599 | + features = SupportedFeatures() |
| 600 | + features.getxpub = DeviceFeature.SUPPORTED |
| 601 | + features.signmessage = DeviceFeature.SUPPORTED |
| 602 | + features.setup = DeviceFeature.SUPPORTED |
| 603 | + features.wipe = DeviceFeature.SUPPORTED |
| 604 | + features.recover = DeviceFeature.SUPPORTED |
| 605 | + features.backup = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 606 | + features.sign_p2pkh = DeviceFeature.SUPPORTED |
| 607 | + features.sign_p2sh_p2wpkh = DeviceFeature.SUPPORTED |
| 608 | + features.sign_p2wpkh = DeviceFeature.SUPPORTED |
| 609 | + features.sign_multi_p2sh = DeviceFeature.SUPPORTED |
| 610 | + features.sign_multi_p2sh_p2wsh = DeviceFeature.SUPPORTED |
| 611 | + features.sign_multi_p2wsh = DeviceFeature.SUPPORTED |
| 612 | + features.sign_multi_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 613 | + features.sign_arbitrary_bare = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 614 | + features.sign_arbitrary_p2sh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 615 | + features.sign_arbitrary_p2sh_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 616 | + features.sign_arbitrary_p2wsh = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 617 | + features.sign_coinjoin = DeviceFeature.SUPPORTED |
| 618 | + features.sign_mixed_segwit = DeviceFeature.FIRMWARE_NOT_SUPPORTED |
| 619 | + features.display_address = DeviceFeature.SUPPORTED |
| 620 | + |
565 | 621 | def __init__(self, path, password='', expert=False):
|
566 | 622 | super(TrezorTClient, self).__init__(path, password, expert)
|
567 | 623 | self.type = 'Trezor T'
|
568 | 624 |
|
| 625 | + @classmethod |
| 626 | + def get_features(self): |
| 627 | + return self.features.get_printable_dict() |
| 628 | + |
569 | 629 | def enumerate(password=''):
|
570 | 630 | results = []
|
571 | 631 | for dev in enumerate_devices():
|
|
0 commit comments