def format_fields( self, chan: AbstractChannel) -> Dict['ChannelsList.Columns', str]: labels = {} for subject in (REMOTE, LOCAL): if isinstance(chan, Channel): can_send = chan.available_to_spend(subject) / 1000 label = self.parent.format_amount(can_send) other = subject.inverted() bal_other = chan.balance(other) // 1000 bal_minus_htlcs_other = chan.balance_minus_outgoing_htlcs( other) // 1000 if bal_other != bal_minus_htlcs_other: label += ' (+' + self.parent.format_amount( bal_other - bal_minus_htlcs_other) + ')' else: assert isinstance(chan, ChannelBackup) label = '' labels[subject] = label status = chan.get_state_for_GUI() closed = chan.is_closed() node_alias = self.lnworker.get_node_alias( chan.node_id) or chan.node_id.hex() capacity_str = self.parent.format_amount(chan.get_capacity(), whitespaces=True) return { self.Columns.SHORT_CHANID: chan.short_id_for_GUI(), self.Columns.NODE_ALIAS: node_alias, self.Columns.FEATURES: '', self.Columns.CAPACITY: capacity_str, self.Columns.LOCAL_BALANCE: '' if closed else labels[LOCAL], self.Columns.REMOTE_BALANCE: '' if closed else labels[REMOTE], self.Columns.CHANNEL_STATUS: status, }
def format_fields(self, chan: AbstractChannel) -> Sequence[str]: labels = {} for subject in (REMOTE, LOCAL): if isinstance(chan, Channel): can_send = chan.available_to_spend(subject) / 1000 label = self.parent.format_amount(can_send) other = subject.inverted() bal_other = chan.balance(other) // 1000 bal_minus_htlcs_other = chan.balance_minus_outgoing_htlcs( other) // 1000 if bal_other != bal_minus_htlcs_other: label += ' (+' + self.parent.format_amount( bal_other - bal_minus_htlcs_other) + ')' else: assert isinstance(chan, ChannelBackup) label = '' labels[subject] = label status = chan.get_state_for_GUI() closed = chan.is_closed() node_alias = self.lnworker.get_node_alias(chan.node_id) if isinstance(chan, Channel): capacity_str = self.parent.format_amount(chan.constraints.capacity) else: capacity_str = '' return [ chan.short_id_for_GUI(), node_alias, capacity_str, '' if closed else labels[LOCAL], '' if closed else labels[REMOTE], status ]