commit 7c77d7c1761d8a399ab16c33647d78132b9d5ffb
parent a059fa0c1f3655f010db30cde543ae236586982c
Author: ThomasV <thomasv@electrum.org>
Date: Fri, 6 Mar 2020 05:50:45 +0100
kivy: improve channel detaild dialog
Diffstat:
3 files changed, 86 insertions(+), 40 deletions(-)
diff --git a/electrum/gui/kivy/main.kv b/electrum/gui/kivy/main.kv
@@ -155,10 +155,11 @@
touched: False
padding: '10dp', '10dp'
background_color: .3, .3, .3, 1
+ touch_callback: lambda: app.on_ref_label(self)
on_touch_down:
touch = args[1]
touched = bool(self.collide_point(*touch.pos))
- if touched: app.on_ref_label(self)
+ if touched: self.touch_callback()
if touched: self.touched = True
canvas.before:
Color:
diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
@@ -1038,6 +1038,11 @@ class ElectrumWindow(App):
d = TxDialog(self, tx)
d.open()
+ def show_transaction(self, txid):
+ tx = self.wallet.db.get_transaction(txid)
+ if tx:
+ self.tx_dialog(tx)
+
def lightning_tx_dialog(self, tx):
from .uix.dialogs.lightning_tx_dialog import LightningTxDialog
d = LightningTxDialog(self, tx)
diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py
@@ -85,31 +85,81 @@ Builder.load_string(r'''
text: _('New...')
on_press: popup.app.popup_dialog('lightning_open_channel_dialog')
-<ChannelDetailsList@RecycleView>:
- scroll_type: ['bars', 'content']
- scroll_wheel_distance: dp(114)
- bar_width: dp(10)
- viewclass: 'BoxLabel'
- RecycleBoxLayout:
- default_size: None, dp(56)
- default_size_hint: 1, None
- size_hint_y: None
- height: self.minimum_height
- orientation: 'vertical'
- spacing: dp(2)
<ChannelDetailsPopup@Popup>:
id: popuproot
data: []
is_closed: False
is_redeemed: False
+ node_id:''
+ short_id:''
+ initiator:''
+ capacity:''
+ funding_txid:''
+ state:''
+ local_ctn:0
+ remote_ctn:0
+ local_csv:0
+ remote_csv:0
+ feerate:0
+ can_send:''
+ can_receive:''
BoxLayout:
+ padding: '12dp', '12dp', '12dp', '12dp'
+ spacing: '12dp'
orientation: 'vertical'
ScrollView:
- ChannelDetailsList:
- data: popuproot.data
+ scroll_type: ['bars', 'content']
+ scroll_wheel_distance: dp(114)
+ BoxLayout:
+ orientation: 'vertical'
+ height: self.minimum_height
+ size_hint_y: None
+ spacing: '5dp'
+ BoxLabel:
+ text: _('Channel ID')
+ value: root.short_id
+ BoxLabel:
+ text: _('State')
+ value: root.state
+ BoxLabel:
+ text: _('Initiator')
+ value: root.initiator
+ BoxLabel:
+ text: _('Capacity')
+ value: root.capacity
+ BoxLabel:
+ text: _('Can send')
+ value: root.can_send
+ BoxLabel:
+ text: _('Can receive')
+ value: root.can_receive
+ BoxLabel:
+ text: _('CSV delay')
+ value: 'Local: %d\nRemote: %d' % (root.local_csv, root.remote_csv)
+ BoxLabel:
+ text: _('CTN')
+ value: 'Local: %d\nRemote: %d' % (root.local_ctn, root.remote_ctn)
+ BoxLabel:
+ text: _('Fee rate')
+ value: '%d sat/kilobyte' % (root.feerate)
+ Widget:
+ size_hint: 1, 0.1
+ TopLabel:
+ text: _('Remote Node ID')
+ TxHashLabel:
+ data: root.node_id
+ name: _('Remote Node ID')
+ TopLabel:
+ text: _('Funding Transaction')
+ TxHashLabel:
+ data: root.funding_txid
+ name: _('Funding Transaction')
+ touch_callback: lambda: app.show_transaction(root.funding_txid)
+ Widget:
+ size_hint: 1, 0.1
Widget:
- size_hint: 1, 0.1
+ size_hint: 1, 0.05
BoxLayout:
size_hint: 1, None
height: '48dp'
@@ -131,11 +181,6 @@ Builder.load_string(r'''
text: _('Delete')
on_release: root.remove_channel()
disabled: not root.is_redeemed
- Button:
- size_hint: 0.5, None
- height: '48dp'
- text: _('Dismiss')
- on_release: root.dismiss()
''')
@@ -148,25 +193,20 @@ class ChannelDetailsPopup(Popup):
self.app = app
self.chan = chan
self.title = _('Channel details')
- self.data = [{'text': key, 'value': str(value)} for key, value in self.details().items()]
-
- def details(self):
- chan = self.chan
- status = self.app.wallet.lnworker.get_channel_status(chan)
- return {
- _('Short Chan ID'): format_short_channel_id(chan.short_channel_id),
- _('Initiator'): 'Local' if chan.constraints.is_initiator else 'Remote',
- _('State'): status,
- _('Local CTN'): chan.get_latest_ctn(LOCAL),
- _('Remote CTN'): chan.get_latest_ctn(REMOTE),
- _('Capacity'): self.app.format_amount_and_units(chan.constraints.capacity),
- _('Can send'): self.app.format_amount_and_units(chan.available_to_spend(LOCAL) // 1000),
- _('Can receive'): self.app.format_amount_and_units(chan.available_to_spend(REMOTE) // 1000),
- _('Current feerate'): str(chan.get_latest_feerate(LOCAL)),
- _('Node ID'): bh2u(chan.node_id),
- _('Channel ID'): bh2u(chan.channel_id),
- _('Funding TXID'): chan.funding_outpoint.txid,
- }
+ self.node_id = bh2u(chan.node_id)
+ self.channel_id = bh2u(chan.channel_id)
+ self.funding_txid = chan.funding_outpoint.txid
+ self.short_id = format_short_channel_id(chan.short_channel_id)
+ self.capacity = self.app.format_amount_and_units(chan.constraints.capacity)
+ self.state = self.app.wallet.lnworker.get_channel_status(chan)
+ self.local_ctn = chan.get_latest_ctn(LOCAL)
+ self.remote_ctn = chan.get_latest_ctn(REMOTE)
+ self.local_csv = chan.config[LOCAL].to_self_delay
+ self.remote_csv = chan.config[REMOTE].to_self_delay
+ self.initiator = 'Local' if chan.constraints.is_initiator else 'Remote'
+ self.feerate = chan.get_latest_feerate(LOCAL)
+ 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)
def close(self):
Question(_('Close channel?'), self._close).open()