qt channels dialog: fix for channel backups
This commit is contained in:
@@ -11,7 +11,7 @@ from PyQt5.QtGui import QFont, QStandardItem, QBrush
|
|||||||
|
|
||||||
from electrum.util import bh2u, NotEnoughFunds, NoDynamicFeeEstimates
|
from electrum.util import bh2u, NotEnoughFunds, NoDynamicFeeEstimates
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.lnchannel import AbstractChannel, PeerState
|
from electrum.lnchannel import AbstractChannel, PeerState, ChannelBackup, Channel
|
||||||
from electrum.wallet import Abstract_Wallet
|
from electrum.wallet import Abstract_Wallet
|
||||||
from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id, LN_MAX_FUNDING_SAT
|
from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id, LN_MAX_FUNDING_SAT
|
||||||
from electrum.lnworker import LNWallet
|
from electrum.lnworker import LNWallet
|
||||||
@@ -68,24 +68,32 @@ class ChannelsList(MyTreeView):
|
|||||||
self.lnbackups = self.parent.wallet.lnbackups
|
self.lnbackups = self.parent.wallet.lnbackups
|
||||||
self.setSortingEnabled(True)
|
self.setSortingEnabled(True)
|
||||||
|
|
||||||
def format_fields(self, chan):
|
def format_fields(self, chan: AbstractChannel) -> Sequence[str]:
|
||||||
labels = {}
|
labels = {}
|
||||||
for subject in (REMOTE, LOCAL):
|
for subject in (REMOTE, LOCAL):
|
||||||
can_send = chan.available_to_spend(subject) / 1000
|
if isinstance(chan, Channel):
|
||||||
label = self.parent.format_amount(can_send)
|
can_send = chan.available_to_spend(subject) / 1000
|
||||||
other = subject.inverted()
|
label = self.parent.format_amount(can_send)
|
||||||
bal_other = chan.balance(other)//1000
|
other = subject.inverted()
|
||||||
bal_minus_htlcs_other = chan.balance_minus_outgoing_htlcs(other)//1000
|
bal_other = chan.balance(other)//1000
|
||||||
if bal_other != bal_minus_htlcs_other:
|
bal_minus_htlcs_other = chan.balance_minus_outgoing_htlcs(other)//1000
|
||||||
label += ' (+' + self.parent.format_amount(bal_other - bal_minus_htlcs_other) + ')'
|
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
|
labels[subject] = label
|
||||||
status = chan.get_state_for_GUI()
|
status = chan.get_state_for_GUI()
|
||||||
closed = chan.is_closed()
|
closed = chan.is_closed()
|
||||||
node_alias = self.lnworker.get_node_alias(chan.node_id)
|
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 [
|
return [
|
||||||
chan.short_id_for_GUI(),
|
chan.short_id_for_GUI(),
|
||||||
node_alias,
|
node_alias,
|
||||||
self.parent.format_amount(chan.constraints.capacity),
|
capacity_str,
|
||||||
'' if closed else labels[LOCAL],
|
'' if closed else labels[LOCAL],
|
||||||
'' if closed else labels[REMOTE],
|
'' if closed else labels[REMOTE],
|
||||||
status
|
status
|
||||||
|
|||||||
Reference in New Issue
Block a user