all GUIs: show local and remote force-close options in a homogeneous way
This commit is contained in:
@@ -493,10 +493,10 @@ class ChannelDetailsPopup(Popup, Logger):
|
||||
|
||||
def update_action_dropdown(self):
|
||||
action_dropdown = self.ids.action_dropdown # type: ActionDropdown
|
||||
close_options = self.chan.get_close_options()
|
||||
options = [
|
||||
ActionButtonOption(text=_('Backup'), func=lambda btn: self.export_backup()),
|
||||
ActionButtonOption(text=_('Close channel'), func=lambda btn: self.close(), enabled=ChanCloseOption.COOP_CLOSE in self.chan.get_close_options()),
|
||||
ActionButtonOption(text=_('Force-close'), func=lambda btn: self.force_close(), enabled=ChanCloseOption.LOCAL_FCLOSE in self.chan.get_close_options()),
|
||||
ActionButtonOption(text=_('Close channel'), func=lambda btn: self.close(close_options), enabled=close_options),
|
||||
ActionButtonOption(text=_('Delete'), func=lambda btn: self.remove_channel(), enabled=self.can_be_deleted),
|
||||
]
|
||||
if not self.chan.is_closed():
|
||||
@@ -510,10 +510,18 @@ class ChannelDetailsPopup(Popup, Logger):
|
||||
options.append(ActionButtonOption(text=_("Unfreeze") + "\n(for receiving)", func=lambda btn: self.freeze_for_receiving()))
|
||||
action_dropdown.update(options=options)
|
||||
|
||||
def close(self):
|
||||
def close(self, close_options):
|
||||
choices = {}
|
||||
if ChanCloseOption.COOP_CLOSE in close_options:
|
||||
choices[0] = _('Cooperative close')
|
||||
if ChanCloseOption.REQUEST_REMOTE_FCLOSE in close_options:
|
||||
choices[1] = _('Request force-close')
|
||||
if ChanCloseOption.LOCAL_FCLOSE in close_options:
|
||||
choices[2] = _('Local force-close')
|
||||
dialog = ChoiceDialog(
|
||||
title=_('Close channel'),
|
||||
choices={0:_('Cooperative close'), 1:_('Request force-close')}, key=0,
|
||||
choices=choices,
|
||||
key = min(choices.keys()),
|
||||
callback=self._close,
|
||||
description=_(messages.MSG_REQUEST_FORCE_CLOSE),
|
||||
keep_choice_order=True)
|
||||
@@ -521,12 +529,15 @@ class ChannelDetailsPopup(Popup, Logger):
|
||||
|
||||
def _close(self, choice):
|
||||
loop = self.app.wallet.network.asyncio_loop
|
||||
if choice == 1:
|
||||
coro = self.app.wallet.lnworker.request_force_close(self.chan.channel_id)
|
||||
msg = _('Request sent')
|
||||
else:
|
||||
if choice == 0:
|
||||
coro = self.app.wallet.lnworker.close_channel(self.chan.channel_id)
|
||||
msg = _('Channel closed')
|
||||
elif choice == 1:
|
||||
coro = self.app.wallet.lnworker.request_force_close(self.chan.channel_id)
|
||||
msg = _('Request sent')
|
||||
elif choice == 2:
|
||||
self.force_close()
|
||||
return
|
||||
f = asyncio.run_coroutine_threadsafe(coro, loop)
|
||||
try:
|
||||
f.result(5)
|
||||
|
||||
Reference in New Issue
Block a user