|
1 | 1 | #! /usr/bin/env python3
|
2 | 2 |
|
3 | 3 | from .commands import backup_device, displayaddress, enumerate, find_device, \
|
4 |
| - get_client, getmasterxpub, getxpub, getkeypool, getdescriptors, prompt_pin, restore_device, send_pin, setup_device, \ |
| 4 | + get_client_class, get_client, getmasterxpub, getxpub, getkeypool, getdescriptors, prompt_pin, restore_device, send_pin, setup_device, \ |
5 | 5 | signmessage, signtx, wipe_device, install_udev_rules
|
6 | 6 | from .errors import (
|
7 | 7 | handle_errors,
|
| 8 | + BAD_ARGUMENT, |
8 | 9 | DEVICE_CONN_ERROR,
|
9 | 10 | HELP_TEXT,
|
10 | 11 | MISSING_ARGUMENTS,
|
@@ -68,6 +69,10 @@ def send_pin_handler(args, client):
|
68 | 69 | def install_udev_rules_handler(args):
|
69 | 70 | return install_udev_rules('udev', args.location)
|
70 | 71 |
|
| 72 | +def getfeatures_handler(args): |
| 73 | + client_class = get_client_class(args.device_type) |
| 74 | + return client_class.get_features() |
| 75 | + |
71 | 76 | class HWIHelpFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
|
72 | 77 | pass
|
73 | 78 |
|
@@ -180,6 +185,9 @@ def process_commands(cli_args):
|
180 | 185 | sendpin_parser.add_argument('pin', help='The numeric positions of the PIN')
|
181 | 186 | sendpin_parser.set_defaults(func=send_pin_handler)
|
182 | 187 |
|
| 188 | + getfeatures_parser = subparsers.add_parser('getfeatures', help='Returns the supported features for the given device type') |
| 189 | + getfeatures_parser.set_defaults(func=getfeatures_handler) |
| 190 | + |
183 | 191 | if sys.platform.startswith("linux"):
|
184 | 192 | udevrules_parser = subparsers.add_parser('installudevrules', help='Install and load the udev rule files for the hardware wallet devices')
|
185 | 193 | udevrules_parser.add_argument('--location', help='The path where the udev rules files will be copied', default='/etc/udev/rules.d/')
|
@@ -226,6 +234,14 @@ def process_commands(cli_args):
|
226 | 234 | result = args.func(args)
|
227 | 235 | return result
|
228 | 236 |
|
| 237 | + # Do get features |
| 238 | + if command == 'getfeatures': |
| 239 | + if not args.device_type: |
| 240 | + return {'error': 'Device type needs to be specified to get features', 'code': BAD_ARGUMENT} |
| 241 | + with handle_errors(result=result, debug=args.debug): |
| 242 | + result = args.func(args) |
| 243 | + return result |
| 244 | + |
229 | 245 | # Auto detect if we are using fingerprint or type to identify device
|
230 | 246 | if args.fingerprint or (args.device_type and not args.device_path):
|
231 | 247 | client = find_device(args.device_path, args.password, args.device_type, args.fingerprint)
|
|
0 commit comments