From 01b9cee6439e1e2b592f246787f1e7cc3f228364 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 17 Apr 2023 11:41:02 +0200 Subject: [PATCH] qml: add recoverable channels warning to OpenChannelDialog --- .../gui/qml/components/OpenChannelDialog.qml | 28 +++++++++++++++++++ electrum/gui/qml/qewallet.py | 8 ++++++ 2 files changed, 36 insertions(+) diff --git a/electrum/gui/qml/components/OpenChannelDialog.qml b/electrum/gui/qml/components/OpenChannelDialog.qml index 51a1b104c..8fa5585ba 100644 --- a/electrum/gui/qml/components/OpenChannelDialog.qml +++ b/electrum/gui/qml/components/OpenChannelDialog.qml @@ -39,6 +39,34 @@ ElDialog { columns: 4 + InfoTextArea { + Layout.fillWidth: true + Layout.columnSpan: 4 + visible: !Daemon.currentWallet.lightningHasDeterministicNodeId + iconStyle: InfoTextArea.IconStyle.Warn + text: Daemon.currentWallet.seedType == 'segwit' + ? [ qsTr('Your channels cannot be recovered from seed, because they were created with an old version of Electrum.'), + qsTr('This means that you must save a backup of your wallet everytime you create a new channel.'), + '\n\n', + qsTr('If you want this wallet to have recoverable channels, you must close your existing channels and restore this wallet from seed.') + ].join(' ') + : [ qsTr('Your channels cannot be recovered from seed.'), + qsTr('This means that you must save a backup of your wallet everytime you create a new channel.'), + '\n\n', + qsTr('If you want to have recoverable channels, you must create a new wallet with an Electrum seed') + ].join(' ') + } + + InfoTextArea { + Layout.fillWidth: true + Layout.columnSpan: 4 + visible: Daemon.currentWallet.lightningHasDeterministicNodeId && !Config.useRecoverableChannels + iconStyle: InfoTextArea.IconStyle.Warn + text: [ qsTr('You currently have recoverable channels setting disabled.'), + qsTr('This means your channels cannot be recovered from seed.') + ].join(' ') + } + Label { text: qsTr('Node') color: Material.accentColor diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index 54bcbc334..a6e6ca346 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -360,6 +360,10 @@ class QEWallet(AuthMixin, QObject, QtEventListener): return self.wallet.txin_type return self.wallet.get_txin_type(self.wallet.dummy_address()) + @pyqtProperty(str, notify=dataChanged) + def seedType(self): + return self.wallet.db.get('seed_type') + @pyqtProperty(bool, notify=dataChanged) def isWatchOnly(self): return self.wallet.is_watching_only() @@ -394,6 +398,10 @@ class QEWallet(AuthMixin, QObject, QtEventListener): def lightningNodePubkey(self): return self.wallet.lnworker.node_keypair.pubkey.hex() if self.wallet.lnworker else '' + @pyqtProperty(bool, notify=dataChanged) + def lightningHasDeterministicNodeId(self): + return self.wallet.lnworker.has_deterministic_node_id() if self.wallet.lnworker else False + @pyqtProperty(str, notify=dataChanged) def derivationPrefix(self): keystores = self.wallet.get_keystores()