Browse Source

kivy: show closing transaction in channel dialog

hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
c3c6b81857
  1. 4
      electrum/gui/kivy/main_window.py
  2. 18
      electrum/gui/kivy/uix/dialogs/lightning_channels.py

4
electrum/gui/kivy/main_window.py

@ -1040,8 +1040,12 @@ class ElectrumWindow(App):
def show_transaction(self, txid): def show_transaction(self, txid):
tx = self.wallet.db.get_transaction(txid) tx = self.wallet.db.get_transaction(txid)
if not tx and self.wallet.lnworker:
tx = self.wallet.lnworker.lnwatcher.db.get_transaction(txid)
if tx: if tx:
self.tx_dialog(tx) self.tx_dialog(tx)
else:
self.show_error(f'Transaction not found {txid}')
def lightning_tx_dialog(self, tx): def lightning_tx_dialog(self, tx):
from .uix.dialogs.lightning_tx_dialog import LightningTxDialog from .uix.dialogs.lightning_tx_dialog import LightningTxDialog

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

@ -96,6 +96,7 @@ Builder.load_string(r'''
initiator:'' initiator:''
capacity:'' capacity:''
funding_txid:'' funding_txid:''
closing_txid:''
state:'' state:''
local_ctn:0 local_ctn:0
remote_ctn:0 remote_ctn:0
@ -104,6 +105,7 @@ Builder.load_string(r'''
feerate:0 feerate:0
can_send:'' can_send:''
can_receive:'' can_receive:''
is_open:False
BoxLayout: BoxLayout:
padding: '12dp', '12dp', '12dp', '12dp' padding: '12dp', '12dp', '12dp', '12dp'
spacing: '12dp' spacing: '12dp'
@ -130,10 +132,10 @@ Builder.load_string(r'''
value: root.capacity value: root.capacity
BoxLabel: BoxLabel:
text: _('Can send') text: _('Can send')
value: root.can_send value: root.can_send if root.is_open else 'n/a'
BoxLabel: BoxLabel:
text: _('Can receive') text: _('Can receive')
value: root.can_receive value: root.can_receive if root.is_open else 'n/a'
BoxLabel: BoxLabel:
text: _('CSV delay') text: _('CSV delay')
value: 'Local: %d\nRemote: %d' % (root.local_csv, root.remote_csv) value: 'Local: %d\nRemote: %d' % (root.local_csv, root.remote_csv)
@ -156,6 +158,14 @@ Builder.load_string(r'''
data: root.funding_txid data: root.funding_txid
name: _('Funding Transaction') name: _('Funding Transaction')
touch_callback: lambda: app.show_transaction(root.funding_txid) touch_callback: lambda: app.show_transaction(root.funding_txid)
TopLabel:
text: _('Closing Transaction')
opacity: int(bool(root.closing_txid))
TxHashLabel:
opacity: int(bool(root.closing_txid))
data: root.closing_txid
name: _('Closing Transaction')
touch_callback: lambda: app.show_transaction(root.closing_txid)
Widget: Widget:
size_hint: 1, 0.1 size_hint: 1, 0.1
Widget: Widget:
@ -207,6 +217,10 @@ class ChannelDetailsPopup(Popup):
self.feerate = chan.get_latest_feerate(LOCAL) self.feerate = chan.get_latest_feerate(LOCAL)
self.can_send = self.app.format_amount_and_units(chan.available_to_spend(LOCAL) // 1000) self.can_send = self.app.format_amount_and_units(chan.available_to_spend(LOCAL) // 1000)
self.can_receive = self.app.format_amount_and_units(chan.available_to_spend(REMOTE) // 1000) self.can_receive = self.app.format_amount_and_units(chan.available_to_spend(REMOTE) // 1000)
self.is_open = chan.is_open()
closed = chan.get_closing_height()
if closed:
self.closing_txid, closing_height, closing_timestamp = closed
def close(self): def close(self):
Question(_('Close channel?'), self._close).open() Question(_('Close channel?'), self._close).open()

Loading…
Cancel
Save