Add a restore command and device class restore method to devices
This commit is contained in:
parent
67236e926f
commit
22fff28b1e
@ -214,6 +214,16 @@ def wipe_device(args, client):
|
||||
except UnavailableActionError as e:
|
||||
return {'error': str(e), 'code': UNAVAILABLE_ACTION}
|
||||
|
||||
def restore_device(args, client):
|
||||
try:
|
||||
return client.restore_device(args.label)
|
||||
except UnavailableActionError as e:
|
||||
return {'error': str(e), 'code': UNAVAILABLE_ACTION}
|
||||
except DeviceAlreadyInitError as e:
|
||||
return {'error': str(e), 'code': DEVICE_ALREADY_INIT}
|
||||
except ValueError as e:
|
||||
return {'error': str(e), 'code': BAD_ARGUMENT}
|
||||
|
||||
def process_commands(args):
|
||||
parser = argparse.ArgumentParser(description='Access and send commands to a hardware wallet device. Responses are in JSON format')
|
||||
parser.add_argument('--device-path', '-d', help='Specify the device path of the device to connect to')
|
||||
@ -272,6 +282,10 @@ def process_commands(args):
|
||||
wipedev_parser = subparsers.add_parser('wipe', help='Wipe a device')
|
||||
wipedev_parser.set_defaults(func=wipe_device)
|
||||
|
||||
restore_parser = subparsers.add_parser('restore', help='Initiate the device restoring process')
|
||||
restore_parser.add_argument('--label', '-l', help='The name to give to the device', default='')
|
||||
restore_parser.set_defaults(func=restore_device)
|
||||
|
||||
args = parser.parse_args(args)
|
||||
|
||||
device_path = args.device_path
|
||||
|
||||
@ -108,6 +108,10 @@ class ColdcardClient(HardwareWalletClient):
|
||||
def wipe_device(self):
|
||||
raise NotImplementedError('The Coldcard does not currently implement wipe')
|
||||
|
||||
# Restore device from mnemonic or xprv
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Coldcard does not implement device restoring')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.device.close()
|
||||
|
||||
@ -362,6 +362,10 @@ class DigitalbitboxClient(HardwareWalletClient):
|
||||
def wipe_device(self):
|
||||
raise NotImplementedError('The DigitalBitbox does not currently implement wipe')
|
||||
|
||||
# Restore device from mnemonic or xprv
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Digital Bitbox does not implement device restoring')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.device.close()
|
||||
|
||||
@ -187,6 +187,10 @@ class KeepkeyClient(HardwareWalletClient):
|
||||
def wipe_device(self):
|
||||
raise NotImplementedError('The KeepKey does not currently implement wipe')
|
||||
|
||||
# Restore device from mnemonic or xprv
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Keepkey does not implement device restoring')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.client.close()
|
||||
|
||||
@ -255,6 +255,10 @@ class LedgerClient(HardwareWalletClient):
|
||||
def wipe_device(self):
|
||||
raise NotImplementedError('The Ledger Nano S does not support wiping via software')
|
||||
|
||||
# Restore device from mnemonic or xprv
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Ledger Nano S does not implement device restoring')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.dongle.close()
|
||||
|
||||
@ -198,6 +198,10 @@ class TrezorClient(HardwareWalletClient):
|
||||
def wipe_device(self):
|
||||
raise NotImplementedError('The Trezor does not currently implement wipe')
|
||||
|
||||
# Restore device from mnemonic or xprv
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Trezor does not implement device restoring')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.client.close()
|
||||
|
||||
@ -41,6 +41,10 @@ class HardwareWalletClient(object):
|
||||
raise NotImplementedError('The HardwareWalletClient base class does not '
|
||||
'implement this method')
|
||||
|
||||
# Restore device from mnemonic or xprv
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The HardwareWalletClient base class does not implement this method')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
raise NotImplementedError('The HardwareWalletClient base class does not '
|
||||
|
||||
Loading…
Reference in New Issue
Block a user