tkivy: call register_callback only from main_window. Display CTN in channel details. - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit b99a71d1b377599e3265dc7a285a8f86b708f39c DIR parent e79253b5e067ef513f4dbd9f8750497a04897927 HTML Author: ThomasV <thomasv@electrum.org> Date: Sat, 31 Aug 2019 10:13:20 +0200 kivy: call register_callback only from main_window. Display CTN in channel details. Diffstat: M electrum/gui/kivy/main_window.py | 10 ++++++++++ M electrum/gui/kivy/uix/dialogs/ligh… | 10 ++-------- 2 files changed, 12 insertions(+), 8 deletions(-) --- DIR diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py t@@ -517,6 +517,8 @@ class ElectrumWindow(App): self.network.register_callback(self.on_quotes, ['on_quotes']) self.network.register_callback(self.on_history, ['on_history']) self.network.register_callback(self.on_payment_received, ['payment_received']) + self.network.register_callback(self.on_channels, ['channels']) + self.network.register_callback(self.on_channel, ['channel']) # load wallet self.load_wallet_by_name(self.electrum_config.get_wallet_path()) # URI passed in config t@@ -637,6 +639,14 @@ class ElectrumWindow(App): self._channels_dialog = LightningChannelsDialog(self) self._channels_dialog.open() + def on_channel(self, evt, chan): + if self._channels_dialog: + Clock.schedule_once(lambda dt: self._channels_dialog.update()) + + def on_channels(self, evt): + if self._channels_dialog: + Clock.schedule_once(lambda dt: self._channels_dialog.update()) + def popup_dialog(self, name): if name == 'settings': self.settings_dialog() DIR diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py t@@ -130,6 +130,8 @@ class ChannelDetailsPopup(Popup): _('Short Chan ID'): format_short_channel_id(chan.short_channel_id), _('Initiator'): 'Local' if chan.constraints.is_initiator else 'Remote', _('State'): chan.get_state(), + _('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), _('Current feerate'): str(chan.get_latest_feerate(LOCAL)), t@@ -176,8 +178,6 @@ class LightningChannelsDialog(Factory.Popup): super(LightningChannelsDialog, self).__init__() self.clocks = [] self.app = app - self.app.wallet.network.register_callback(self.on_channels, ['channels']) - self.app.wallet.network.register_callback(self.on_channel, ['channel']) self.update() def show_item(self, obj): t@@ -200,12 +200,6 @@ class LightningChannelsDialog(Factory.Popup): labels[REMOTE], ] - def on_channel(self, evt, chan): - Clock.schedule_once(lambda dt: self.update()) - - def on_channels(self, evt): - Clock.schedule_once(lambda dt: self.update()) - def update_item(self, item): chan = item._chan item.status = chan.get_state()