def add_new_channel(self, chan: Channel):
    self.add_channel(chan)
    channels_db = self.db.get_dict('channels')
    channels_db[chan.channel_id.hex()] = chan.storage
    for addr in chan.get_wallet_addresses_channel_might_want_reserved():
        self.wallet.set_reserved_state_of_address(addr, reserved=True)
    try:
        self.save_channel(chan)
        backup_dir = self.config.get_backup_dir()
        if (backup_dir is not None):
            self.wallet.save_backup(backup_dir)
    except:
        chan.set_state(ChannelState.REDEEMED)
        self.remove_channel(chan.channel_id)
        raise
def add_new_channel(self, chan: Channel):
    self.add_channel(chan)
    channels_db = self.db.get_dict('channels')
    channels_db[chan.channel_id.hex()] = chan.storage
    for addr in chan.get_wallet_addresses_channel_might_want_reserved():
        self.wallet.set_reserved_state_of_address(addr, reserved=True)
    try:
        self.save_channel(chan)
        backup_dir = self.config.get_backup_dir()
        if (backup_dir is not None):
            self.wallet.save_backup(backup_dir)
    except:
        chan.set_state(ChannelState.REDEEMED)
        self.remove_channel(chan.channel_id)
        raise