|
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 |
|
@@ -181,6 +186,9 @@ def process_commands(cli_args): |
181 | 186 | sendpin_parser.add_argument('pin', help='The numeric positions of the PIN') |
182 | 187 | sendpin_parser.set_defaults(func=send_pin_handler) |
183 | 188 |
|
| 189 | + getfeatures_parser = subparsers.add_parser('getfeatures', help='Returns the supported features for the given device type') |
| 190 | + getfeatures_parser.set_defaults(func=getfeatures_handler) |
| 191 | + |
184 | 192 | if sys.platform.startswith("linux"): |
185 | 193 | udevrules_parser = subparsers.add_parser('installudevrules', help='Install and load the udev rule files for the hardware wallet devices') |
186 | 194 | udevrules_parser.add_argument('--location', help='The path where the udev rules files will be copied', default='/etc/udev/rules.d/') |
@@ -227,6 +235,14 @@ def process_commands(cli_args): |
227 | 235 | result = args.func(args) |
228 | 236 | return result |
229 | 237 |
|
| 238 | + # Do get features |
| 239 | + if command == 'getfeatures': |
| 240 | + if not args.device_type: |
| 241 | + return {'error': 'Device type needs to be specified to get features', 'code': BAD_ARGUMENT} |
| 242 | + with handle_errors(result=result, debug=args.debug): |
| 243 | + result = args.func(args) |
| 244 | + return result |
| 245 | + |
230 | 246 | # Auto detect if we are using fingerprint or type to identify device |
231 | 247 | if args.fingerprint or (args.device_type and not args.device_path): |
232 | 248 | client = find_device(args.password, args.device_type, args.fingerprint, args.expert) |
|
0 commit comments