Qt: add "save backup" checkbox to force-close dialog
This commit is contained in:
@@ -125,18 +125,29 @@ class ChannelsList(MyTreeView):
|
|||||||
WaitingDialog(self, 'please wait..', task, self.on_success, self.on_failure)
|
WaitingDialog(self, 'please wait..', task, self.on_success, self.on_failure)
|
||||||
|
|
||||||
def force_close(self, channel_id):
|
def force_close(self, channel_id):
|
||||||
|
self.save_backup = True
|
||||||
|
backup_cb = QCheckBox('Create a backup now', checked=True)
|
||||||
|
def on_checked(b):
|
||||||
|
self.save_backup = bool(b)
|
||||||
|
backup_cb.stateChanged.connect(on_checked)
|
||||||
chan = self.lnworker.channels[channel_id]
|
chan = self.lnworker.channels[channel_id]
|
||||||
to_self_delay = chan.config[REMOTE].to_self_delay
|
to_self_delay = chan.config[REMOTE].to_self_delay
|
||||||
msg = _('Force-close channel?') + '\n\n'\
|
msg = '<b>' + _('Force-close channel?') + '</b><br/>'\
|
||||||
+ _('Funds retrieved from this channel will not be available before {} blocks after forced closure.').format(to_self_delay) + ' '\
|
+ '<p>' + _('If you force-close this channel, the funds you have in it will not be available for {} blocks.').format(to_self_delay) + ' '\
|
||||||
+ _('After that delay, funds will be sent to an address derived from your wallet seed.') + '\n\n'\
|
+ _('After that delay, funds will be swept to an address derived from your wallet seed.') + '</p>'\
|
||||||
+ _('In the meantime, channel funds will not be recoverable from your seed, and might be lost if you lose your wallet.') + ' '\
|
+ '<u>' + _('Please create a backup of your wallet file!') + '</u> '\
|
||||||
+ _('To prevent that, you should have a backup of this channel on another device.')
|
+ '<p>' + _('Funds in this channel will not be recoverable from seed until they are swept back into your wallet, and might be lost if you lose your wallet file.') + ' '\
|
||||||
if self.parent.question(msg):
|
+ _('To prevent that, you should save a backup of your wallet on another device.') + '</p>'
|
||||||
def task():
|
if not self.parent.question(msg, title=_('Force-close channel'), rich_text=True, checkbox=backup_cb):
|
||||||
coro = self.lnworker.force_close_channel(channel_id)
|
return
|
||||||
return self.network.run_from_another_thread(coro)
|
if self.save_backup:
|
||||||
WaitingDialog(self, 'please wait..', task, self.on_success, self.on_failure)
|
if not self.parent.backup_wallet():
|
||||||
|
return
|
||||||
|
return
|
||||||
|
def task():
|
||||||
|
coro = self.lnworker.force_close_channel(channel_id)
|
||||||
|
return self.network.run_from_another_thread(coro)
|
||||||
|
WaitingDialog(self, 'please wait..', task, self.on_success, self.on_failure)
|
||||||
|
|
||||||
def remove_channel(self, channel_id):
|
def remove_channel(self, channel_id):
|
||||||
if self.main_window.question(_('Are you sure you want to delete this channel? This will purge associated transactions from your wallet history.')):
|
if self.main_window.question(_('Are you sure you want to delete this channel? This will purge associated transactions from your wallet history.')):
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
vbox.addWidget(WWLabel(msg))
|
vbox.addWidget(WWLabel(msg))
|
||||||
vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
|
vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
|
||||||
if not d.exec_():
|
if not d.exec_():
|
||||||
return
|
return False
|
||||||
try:
|
try:
|
||||||
new_path = self.wallet.save_backup()
|
new_path = self.wallet.save_backup()
|
||||||
except BaseException as reason:
|
except BaseException as reason:
|
||||||
@@ -635,8 +635,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
if new_path:
|
if new_path:
|
||||||
msg = _("A copy of your wallet file was created in")+" '%s'" % str(new_path)
|
msg = _("A copy of your wallet file was created in")+" '%s'" % str(new_path)
|
||||||
self.show_message(msg, title=_("Wallet backup created"))
|
self.show_message(msg, title=_("Wallet backup created"))
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
self.show_message(_("You need to configure a backup directory in your preferences"), title=_("Backup not created"))
|
self.show_message(_("You need to configure a backup directory in your preferences"), title=_("Backup not created"))
|
||||||
|
return False
|
||||||
|
|
||||||
def update_recently_visited(self, filename):
|
def update_recently_visited(self, filename):
|
||||||
recent = self.config.get('recently_open', [])
|
recent = self.config.get('recently_open', [])
|
||||||
|
|||||||
Reference in New Issue
Block a user