def __init__(self, chan: AbstractChannel, app, **kwargs): Popup.__init__(self, **kwargs) Logger.__init__(self) self.chan = chan self.is_funded = chan.get_state() == ChannelState.FUNDED self.can_be_deleted = chan.can_be_deleted() self.funding_txid = chan.funding_outpoint.txid self.app = app self.short_id = format_short_channel_id(chan.short_channel_id) self.capacity = self.app.format_amount_and_units(chan.get_capacity()) self.state = chan.get_state_for_GUI() self.title = _('Channel Backup')
def from_channel(cls, chan: AbstractChannel) -> 'ChannelFeatureIcons': feats = [] if chan.is_backup(): feats.append(ChanFeatBackup()) if chan.is_imported: feats.append(ChanFeatNoOnchainBackup()) else: feats.append(ChanFeatChannel()) if chan.lnworker.is_trampoline_peer(chan.node_id): feats.append(ChanFeatTrampoline()) if not chan.has_onchain_backup(): feats.append(ChanFeatNoOnchainBackup()) return ChannelFeatureIcons(feats)
def __init__(self, chan: AbstractChannel, app: 'ElectrumWindow', **kwargs): super(ChannelBackupPopup, self).__init__(**kwargs) self.chan = chan self.app = app self.short_id = format_short_channel_id(chan.short_channel_id) self.state = chan.get_state_for_GUI() self.title = _('Channel Backup')
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, whitespaces=True) 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, whitespaces=True) + ')' 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 _update_chan_frozen_bg(self, *, chan: AbstractChannel, items: Sequence[QStandardItem]): assert self._default_item_bg_brush is not None # frozen for sending item = items[self.Columns.LOCAL_BALANCE] if chan.is_frozen_for_sending(): item.setBackground(ColorScheme.BLUE.as_color(True)) item.setToolTip(_("This channel is frozen for sending. It will not be used for outgoing payments.")) else: item.setBackground(self._default_item_bg_brush) item.setToolTip("") # frozen for receiving item = items[self.Columns.REMOTE_BALANCE] if chan.is_frozen_for_receiving(): item.setBackground(ColorScheme.BLUE.as_color(True)) item.setToolTip(_("This channel is frozen for receiving. It will not be included in invoices.")) else: item.setBackground(self._default_item_bg_brush) item.setToolTip("")
def __init__(self, chan: AbstractChannel, channels_list, **kwargs): Popup.__init__(self, **kwargs) Logger.__init__(self) self.chan = chan self.channels_list = channels_list self.app = channels_list.app self.short_id = format_short_channel_id(chan.short_channel_id) self.state = chan.get_state_for_GUI() self.title = _('Channel Backup')