kivy: implement freezing channels
This commit is contained in:
@@ -244,6 +244,8 @@ Builder.load_string(r'''
|
|||||||
can_receive:''
|
can_receive:''
|
||||||
is_open:False
|
is_open:False
|
||||||
warning: ''
|
warning: ''
|
||||||
|
is_frozen_for_sending: False
|
||||||
|
is_frozen_for_receiving: False
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
padding: '12dp', '12dp', '12dp', '12dp'
|
padding: '12dp', '12dp', '12dp', '12dp'
|
||||||
spacing: '12dp'
|
spacing: '12dp'
|
||||||
@@ -286,6 +288,12 @@ Builder.load_string(r'''
|
|||||||
BoxLabel:
|
BoxLabel:
|
||||||
text: _('Fee rate')
|
text: _('Fee rate')
|
||||||
value: '{} sat/byte'.format(root.feerate)
|
value: '{} sat/byte'.format(root.feerate)
|
||||||
|
BoxLabel:
|
||||||
|
text: _('Frozen (for sending)')
|
||||||
|
value: str(root.is_frozen_for_sending)
|
||||||
|
BoxLabel:
|
||||||
|
text: _('Frozen (for receiving)')
|
||||||
|
value: str(root.is_frozen_for_receiving)
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.1
|
||||||
TopLabel:
|
TopLabel:
|
||||||
@@ -474,16 +482,27 @@ class ChannelDetailsPopup(Popup, Logger):
|
|||||||
self.closing_txid, closing_height, closing_timestamp = closed
|
self.closing_txid, closing_height, closing_timestamp = closed
|
||||||
msg = messages.MSG_NON_TRAMPOLINE_CHANNEL_FROZEN_WITHOUT_GOSSIP
|
msg = messages.MSG_NON_TRAMPOLINE_CHANNEL_FROZEN_WITHOUT_GOSSIP
|
||||||
self.warning = '' if self.app.wallet.lnworker.channel_db or self.app.wallet.lnworker.is_trampoline_peer(chan.node_id) else _('Warning') + ': ' + msg
|
self.warning = '' if self.app.wallet.lnworker.channel_db or self.app.wallet.lnworker.is_trampoline_peer(chan.node_id) else _('Warning') + ': ' + msg
|
||||||
|
self.is_frozen_for_sending = chan.is_frozen_for_sending()
|
||||||
|
self.is_frozen_for_receiving = chan.is_frozen_for_receiving()
|
||||||
self.update_action_dropdown()
|
self.update_action_dropdown()
|
||||||
|
|
||||||
def update_action_dropdown(self):
|
def update_action_dropdown(self):
|
||||||
action_dropdown = self.ids.action_dropdown # type: ActionDropdown
|
action_dropdown = self.ids.action_dropdown # type: ActionDropdown
|
||||||
options = (
|
options = [
|
||||||
ActionButtonOption(text=_('Backup'), func=lambda btn: self.export_backup()),
|
ActionButtonOption(text=_('Backup'), func=lambda btn: self.export_backup()),
|
||||||
ActionButtonOption(text=_('Close channel'), func=lambda btn: self.close(), enabled=not self.is_closed),
|
ActionButtonOption(text=_('Close channel'), func=lambda btn: self.close(), enabled=not self.is_closed),
|
||||||
ActionButtonOption(text=_('Force-close'), func=lambda btn: self.force_close(), enabled=not self.is_closed),
|
ActionButtonOption(text=_('Force-close'), func=lambda btn: self.force_close(), enabled=not self.is_closed),
|
||||||
ActionButtonOption(text=_('Delete'), func=lambda btn: self.remove_channel(), enabled=self.can_be_deleted),
|
ActionButtonOption(text=_('Delete'), func=lambda btn: self.remove_channel(), enabled=self.can_be_deleted),
|
||||||
)
|
]
|
||||||
|
if not self.chan.is_closed():
|
||||||
|
if not self.chan.is_frozen_for_sending():
|
||||||
|
options.append(ActionButtonOption(text=_("Freeze") + "\n(for sending)", func=lambda btn: self.freeze_for_sending()))
|
||||||
|
else:
|
||||||
|
options.append(ActionButtonOption(text=_("Unfreeze") + "\n(for sending)", func=lambda btn: self.freeze_for_sending()))
|
||||||
|
if not self.chan.is_frozen_for_receiving():
|
||||||
|
options.append(ActionButtonOption(text=_("Freeze") + "\n(for receiving)", func=lambda btn: self.freeze_for_receiving()))
|
||||||
|
else:
|
||||||
|
options.append(ActionButtonOption(text=_("Unfreeze") + "\n(for receiving)", func=lambda btn: self.freeze_for_receiving()))
|
||||||
action_dropdown.update(options=options)
|
action_dropdown.update(options=options)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
@@ -574,6 +593,20 @@ class ChannelDetailsPopup(Popup, Logger):
|
|||||||
self.logger.exception("Could not force close channel")
|
self.logger.exception("Could not force close channel")
|
||||||
self.app.show_info(_('Could not force close channel: ') + repr(e)) # repr because str(Exception()) == ''
|
self.app.show_info(_('Could not force close channel: ') + repr(e)) # repr because str(Exception()) == ''
|
||||||
|
|
||||||
|
def freeze_for_sending(self):
|
||||||
|
lnworker = self.chan.lnworker
|
||||||
|
if lnworker.channel_db or lnworker.is_trampoline_peer(self.chan.node_id):
|
||||||
|
self.is_frozen_for_sending = not self.is_frozen_for_sending
|
||||||
|
self.chan.set_frozen_for_sending(self.is_frozen_for_sending)
|
||||||
|
self.update_action_dropdown()
|
||||||
|
else:
|
||||||
|
self.app.show_info(messages.MSG_NON_TRAMPOLINE_CHANNEL_FROZEN_WITHOUT_GOSSIP)
|
||||||
|
|
||||||
|
def freeze_for_receiving(self):
|
||||||
|
self.is_frozen_for_receiving = not self.is_frozen_for_receiving
|
||||||
|
self.chan.set_frozen_for_receiving(self.is_frozen_for_receiving)
|
||||||
|
self.update_action_dropdown()
|
||||||
|
|
||||||
|
|
||||||
class LightningChannelsDialog(Factory.Popup):
|
class LightningChannelsDialog(Factory.Popup):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user