def import_channel_backup(self, data):
    assert data.startswith('channel_backup:')
    encrypted = data[15:]
    xpub = self.wallet.get_fingerprint()
    decrypted = pw_decode_with_version_and_mac(encrypted, xpub)
    cb_storage = ImportedChannelBackupStorage.from_bytes(decrypted)
    channel_id = cb_storage.channel_id()
    if (channel_id.hex() in self.db.get_dict('channels')):
        raise Exception('Channel already in wallet')
    self.logger.info(f'importing channel backup: {channel_id.hex()}')
    d = self.db.get_dict('imported_channel_backups')
    d[channel_id.hex()] = cb_storage
    with self.lock:
        cb = ChannelBackup(cb_storage, sweep_address=self.sweep_address, lnworker=self)
        self._channel_backups[channel_id] = cb
    self.wallet.save_db()
    util.trigger_callback('channels_updated', self.wallet)
    self.lnwatcher.add_channel(cb.funding_outpoint.to_str(), cb.get_funding_address())
def import_channel_backup(self, data):
    assert data.startswith('channel_backup:')
    encrypted = data[15:]
    xpub = self.wallet.get_fingerprint()
    decrypted = pw_decode_with_version_and_mac(encrypted, xpub)
    cb_storage = ImportedChannelBackupStorage.from_bytes(decrypted)
    channel_id = cb_storage.channel_id()
    if (channel_id.hex() in self.db.get_dict('channels')):
        raise Exception('Channel already in wallet')
    self.logger.info(f'importing channel backup: {channel_id.hex()}')
    d = self.db.get_dict('imported_channel_backups')
    d[channel_id.hex()] = cb_storage
    with self.lock:
        cb = ChannelBackup(cb_storage, sweep_address=self.sweep_address, lnworker=self)
        self._channel_backups[channel_id] = cb
    self.wallet.save_db()
    util.trigger_callback('channels_updated', self.wallet)
    self.lnwatcher.add_channel(cb.funding_outpoint.to_str(), cb.get_funding_address())