diff --git a/electrum/gui/qml/components/Wallets.qml b/electrum/gui/qml/components/Wallets.qml index 179a23df9..00abdf45b 100644 --- a/electrum/gui/qml/components/Wallets.qml +++ b/electrum/gui/qml/components/Wallets.qml @@ -48,7 +48,26 @@ Pane { Label { text: Daemon.currentWallet.isLightning } Label { text: 'has Seed'; color: Material.accentColor } - Label { text: Daemon.currentWallet.hasSeed; Layout.columnSpan: 3 } + Label { text: Daemon.currentWallet.hasSeed } + + RowLayout { + visible: !Daemon.currentWallet.isLightning && Daemon.currentWallet.canHaveLightning + Layout.columnSpan: 2 + Layout.alignment: Qt.AlignHCenter + + Button { + enabled: Daemon.currentWallet.canHaveLightning && !Daemon.currentWallet.isLightning + text: qsTr('Enable Lightning') + onClicked: Daemon.currentWallet.enableLightning() + } + } + + Item { + visible: Daemon.currentWallet.isLightning || !Daemon.currentWallet.canHaveLightning + Layout.columnSpan: 2 + Layout.preferredHeight: 1 + Layout.preferredWidth: 1 + } Label { Layout.columnSpan:4; text: qsTr('Master Public Key'); color: Material.accentColor } diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index 62c185312..c77ca47f7 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -243,6 +243,10 @@ class QEWallet(QObject): def isLightning(self): return bool(self.wallet.lnworker) + @pyqtProperty(bool, notify=dataChanged) + def canHaveLightning(self): + return self.wallet.can_have_lightning() + @pyqtProperty(bool, notify=dataChanged) def hasSeed(self): return self.wallet.has_seed() @@ -318,6 +322,10 @@ class QEWallet(QObject): self._lightningcanreceive = QEAmount(amount_sat=self.wallet.lnworker.num_sats_can_receive()) return self._lightningcanreceive + @pyqtSlot() + def enableLightning(self): + self.wallet.init_lightning(password=None) # TODO pass password if needed + self.isLightningChanged.emit() @pyqtSlot('QString', int, int, bool) def send_onchain(self, address, amount, fee=None, rbf=False):