Browse Source

channels_list: improve menu for backups

patch-4
ThomasV 4 years ago
parent
commit
27dcfba98d
  1. 12
      electrum/gui/kivy/uix/dialogs/lightning_channels.py
  2. 9
      electrum/gui/qt/channels_list.py

12
electrum/gui/kivy/uix/dialogs/lightning_channels.py

@ -9,7 +9,7 @@ from .fee_dialog import FeeDialog
from electrum.util import bh2u from electrum.util import bh2u
from electrum.logging import Logger from electrum.logging import Logger
from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id from electrum.lnutil import LOCAL, REMOTE, format_short_channel_id
from electrum.lnchannel import AbstractChannel, Channel from electrum.lnchannel import AbstractChannel, Channel, ChannelState
from electrum.gui.kivy.i18n import _ from electrum.gui.kivy.i18n import _
from .question import Question from .question import Question
from electrum.transaction import PartialTxOutput, Transaction from electrum.transaction import PartialTxOutput, Transaction
@ -334,8 +334,8 @@ Builder.load_string(r'''
<ChannelBackupPopup@Popup>: <ChannelBackupPopup@Popup>:
id: popuproot id: popuproot
data: [] data: []
is_closed: False is_funded: False
is_redeemed: False is_imported: False
node_id:'' node_id:''
short_id:'' short_id:''
initiator:'' initiator:''
@ -401,12 +401,13 @@ Builder.load_string(r'''
height: '48dp' height: '48dp'
text: _('Request force-close') text: _('Request force-close')
on_release: root.request_force_close() on_release: root.request_force_close()
disabled: root.is_closed disabled: not root.is_funded
Button: Button:
size_hint: 0.5, None size_hint: 0.5, None
height: '48dp' height: '48dp'
text: _('Delete') text: _('Delete')
on_release: root.remove_backup() on_release: root.remove_backup()
disabled: not root.is_imported
''') ''')
@ -416,6 +417,9 @@ class ChannelBackupPopup(Popup, Logger):
Popup.__init__(self, **kwargs) Popup.__init__(self, **kwargs)
Logger.__init__(self) Logger.__init__(self)
self.chan = chan self.chan = chan
self.is_funded = chan.get_state() == ChannelState.FUNDED
self.is_imported = chan.is_imported
self.funding_txid = chan.funding_outpoint.txid
self.app = app self.app = app
self.short_id = format_short_channel_id(chan.short_channel_id) self.short_id = format_short_channel_id(chan.short_channel_id)
self.capacity = self.app.format_amount_and_units(chan.get_capacity()) self.capacity = self.app.format_amount_and_units(chan.get_capacity())

9
electrum/gui/qt/channels_list.py

@ -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, ChannelBackup, Channel from electrum.lnchannel import AbstractChannel, PeerState, ChannelBackup, Channel, ChannelState
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
@ -207,8 +207,13 @@ class ChannelsList(MyTreeView):
if not item: if not item:
return return
channel_id = idx.sibling(idx.row(), self.Columns.NODE_ALIAS).data(ROLE_CHANNEL_ID) channel_id = idx.sibling(idx.row(), self.Columns.NODE_ALIAS).data(ROLE_CHANNEL_ID)
if channel_id in self.lnworker.channel_backups: chan = self.lnworker.channel_backups.get(channel_id)
if chan:
funding_tx = self.parent.wallet.db.get_transaction(chan.funding_outpoint.txid)
menu.addAction(_("View funding transaction"), lambda: self.parent.show_transaction(funding_tx))
if chan.get_state() == ChannelState.FUNDED:
menu.addAction(_("Request force-close"), lambda: self.request_force_close(channel_id)) menu.addAction(_("Request force-close"), lambda: self.request_force_close(channel_id))
if chan.is_imported:
menu.addAction(_("Delete"), lambda: self.remove_channel_backup(channel_id)) menu.addAction(_("Delete"), lambda: self.remove_channel_backup(channel_id))
menu.exec_(self.viewport().mapToGlobal(position)) menu.exec_(self.viewport().mapToGlobal(position))
return return

Loading…
Cancel
Save