Add backup command and device class methods for backing up
This commit is contained in:
parent
22fff28b1e
commit
0fd460853e
@ -224,6 +224,14 @@ def restore_device(args, client):
|
||||
except ValueError as e:
|
||||
return {'error': str(e), 'code': BAD_ARGUMENT}
|
||||
|
||||
def backup_device(args, client):
|
||||
try:
|
||||
return client.backup_device(args.label, args.backup_passphrase)
|
||||
except UnavailableActionError as e:
|
||||
return {'error': str(e), 'code': UNAVAILABLE_ACTION}
|
||||
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')
|
||||
@ -286,6 +294,11 @@ def process_commands(args):
|
||||
restore_parser.add_argument('--label', '-l', help='The name to give to the device', default='')
|
||||
restore_parser.set_defaults(func=restore_device)
|
||||
|
||||
backup_parser = subparsers.add_parser('backup', help='Initiate the device backup creation process')
|
||||
backup_parser.add_argument('--label', '-l', help='The name to give to the device', default='')
|
||||
backup_parser.add_argument('--backup_passphrase', '-b', help='The passphrase to use for the backup, if applicable', default='')
|
||||
backup_parser.set_defaults(func=backup_device)
|
||||
|
||||
args = parser.parse_args(args)
|
||||
|
||||
device_path = args.device_path
|
||||
|
||||
@ -112,6 +112,10 @@ class ColdcardClient(HardwareWalletClient):
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Coldcard does not implement device restoring')
|
||||
|
||||
# Begin backup process
|
||||
def backup_device(self, label='', passphrase=''):
|
||||
raise NotImplementedError('The Coldcard does not implement this method')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.device.close()
|
||||
|
||||
@ -366,6 +366,10 @@ class DigitalbitboxClient(HardwareWalletClient):
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Digital Bitbox does not implement device restoring')
|
||||
|
||||
# Begin backup process
|
||||
def backup_device(self, label='', passphrase=''):
|
||||
raise NotImplementedError('The Digital BitBox does not implement this method')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.device.close()
|
||||
|
||||
@ -191,6 +191,10 @@ class KeepkeyClient(HardwareWalletClient):
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Keepkey does not implement device restoring')
|
||||
|
||||
# Begin backup process
|
||||
def backup_device(self, label='', passphrase=''):
|
||||
raise NotImplementedError('The Keepkey does not implement this method')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.client.close()
|
||||
|
||||
@ -259,6 +259,10 @@ class LedgerClient(HardwareWalletClient):
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Ledger Nano S does not implement device restoring')
|
||||
|
||||
# Begin backup process
|
||||
def backup_device(self, label='', passphrase=''):
|
||||
raise NotImplementedError('The Ledger Nano S does not implement this method')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.dongle.close()
|
||||
|
||||
@ -202,6 +202,10 @@ class TrezorClient(HardwareWalletClient):
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The Trezor does not implement device restoring')
|
||||
|
||||
# Begin backup process
|
||||
def backup_device(self, label='', passphrase=''):
|
||||
raise NotImplementedError('The Trezor does not implement this method')
|
||||
|
||||
# Close the device
|
||||
def close(self):
|
||||
self.client.close()
|
||||
|
||||
@ -45,6 +45,10 @@ class HardwareWalletClient(object):
|
||||
def restore_device(self, label=''):
|
||||
raise NotImplementedError('The HardwareWalletClient base class does not implement this method')
|
||||
|
||||
# Begin backup process
|
||||
def backup_device(self, label='', passphrase=''):
|
||||
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