|
1 | 1 | #! /usr/bin/env python3
|
2 | 2 |
|
3 |
| -from .commands import backup_device, displayaddress, enumerate, find_device, \ |
4 |
| - get_client, getmasterxpub, getxpub, getkeypool, getdescriptors, prompt_pin, toggle_passphrase, restore_device, send_pin, setup_device, \ |
5 |
| - signmessage, signtx, wipe_device, install_udev_rules |
| 3 | +from .commands import ( |
| 4 | + backup_device, |
| 5 | + displayaddress, |
| 6 | + enumerate, |
| 7 | + find_device, |
| 8 | + get_client_class, |
| 9 | + get_client, |
| 10 | + getmasterxpub, |
| 11 | + getxpub, |
| 12 | + getkeypool, |
| 13 | + getdescriptors, |
| 14 | + prompt_pin, |
| 15 | + toggle_passphrase, |
| 16 | + restore_device, |
| 17 | + send_pin, |
| 18 | + setup_device, |
| 19 | + signmessage, |
| 20 | + signtx, |
| 21 | + wipe_device, |
| 22 | + install_udev_rules, |
| 23 | +) |
6 | 24 | from .errors import (
|
7 | 25 | handle_errors,
|
| 26 | + BAD_ARGUMENT, |
8 | 27 | DEVICE_CONN_ERROR,
|
9 | 28 | HELP_TEXT,
|
10 | 29 | MISSING_ARGUMENTS,
|
@@ -71,6 +90,10 @@ def send_pin_handler(args, client):
|
71 | 90 | def install_udev_rules_handler(args):
|
72 | 91 | return install_udev_rules('udev', args.location)
|
73 | 92 |
|
| 93 | +def getfeatures_handler(args): |
| 94 | + client_class = get_client_class(args.device_type) |
| 95 | + return client_class.get_features() |
| 96 | + |
74 | 97 | class HWIHelpFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
|
75 | 98 | pass
|
76 | 99 |
|
@@ -188,6 +211,9 @@ def process_commands(cli_args):
|
188 | 211 | sendpin_parser.add_argument('pin', help='The numeric positions of the PIN')
|
189 | 212 | sendpin_parser.set_defaults(func=send_pin_handler)
|
190 | 213 |
|
| 214 | + getfeatures_parser = subparsers.add_parser('getfeatures', help='Returns the supported features for the given device type') |
| 215 | + getfeatures_parser.set_defaults(func=getfeatures_handler) |
| 216 | + |
191 | 217 | if sys.platform.startswith("linux"):
|
192 | 218 | udevrules_parser = subparsers.add_parser('installudevrules', help='Install and load the udev rule files for the hardware wallet devices')
|
193 | 219 | udevrules_parser.add_argument('--location', help='The path where the udev rules files will be copied', default='/etc/udev/rules.d/')
|
@@ -234,6 +260,14 @@ def process_commands(cli_args):
|
234 | 260 | result = args.func(args)
|
235 | 261 | return result
|
236 | 262 |
|
| 263 | + # Do get features |
| 264 | + if command == 'getfeatures': |
| 265 | + if not args.device_type: |
| 266 | + return {'error': 'Device type needs to be specified to get features', 'code': BAD_ARGUMENT} |
| 267 | + with handle_errors(result=result, debug=args.debug): |
| 268 | + result = args.func(args) |
| 269 | + return result |
| 270 | + |
237 | 271 | # Auto detect if we are using fingerprint or type to identify device
|
238 | 272 | if args.fingerprint or (args.device_type and not args.device_path):
|
239 | 273 | client = find_device(args.password, args.device_type, args.fingerprint, args.expert)
|
|
0 commit comments