From b0cfc2ab140b8573bcd712b7118ae089b5b0d8cd Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 24 Aug 2022 10:15:44 +0200 Subject: [PATCH] qml: add channel backup option to channel details page --- electrum/gui/qml/components/ChannelDetails.qml | 13 +++++++++++-- electrum/gui/qml/qechanneldetails.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qml/components/ChannelDetails.qml b/electrum/gui/qml/components/ChannelDetails.qml index e08f1cfc6..e0050c93e 100644 --- a/electrum/gui/qml/components/ChannelDetails.qml +++ b/electrum/gui/qml/components/ChannelDetails.qml @@ -22,8 +22,17 @@ Pane { icon.color: 'transparent' action: Action { text: qsTr('Backup'); - enabled: false - onTriggered: {} + enabled: true + onTriggered: { + var dialog = app.genericShareDialog.createObject(root, + { + title: qsTr('Channel Backup for %1').arg(channeldetails.short_cid), + text: channeldetails.channelBackup(), + text_help: channeldetails.channelBackupHelpText() + } + ) + dialog.open() + } icon.source: '../../icons/file.png' } } diff --git a/electrum/gui/qml/qechanneldetails.py b/electrum/gui/qml/qechanneldetails.py index a7cd3e507..216fbd870 100644 --- a/electrum/gui/qml/qechanneldetails.py +++ b/electrum/gui/qml/qechanneldetails.py @@ -188,3 +188,15 @@ class QEChannelDetails(QObject, QtEventListener): @pyqtSlot() def deleteChannel(self): self._wallet.wallet.lnworker.remove_channel(self._channel.channel_id) + + @pyqtSlot(result=str) + def channelBackup(self): + return self._wallet.wallet.lnworker.export_channel_backup(self._channel.channel_id) + + @pyqtSlot(result=str) + def channelBackupHelpText(self): + return ' '.join([ + _("Channel backups can be imported in another instance of the same wallet, by scanning this QR code."), + _("Please note that channel backups cannot be used to restore your channels."), + _("If you lose your wallet file, the only thing you can do with a backup is to request your channel to be closed, so that your funds will be sent on-chain."), + ])