qml: add lightning network status indicator in top bar, add channel peers to NetworkOverview
This commit is contained in:
@@ -173,6 +173,15 @@ Pane {
|
||||
visible: !Config.useGossip
|
||||
}
|
||||
|
||||
Label {
|
||||
visible: Daemon.currentWallet.isLightning
|
||||
text: qsTr('Channel peers:');
|
||||
color: Material.accentColor
|
||||
}
|
||||
Label {
|
||||
visible: Daemon.currentWallet.isLightning
|
||||
text: Daemon.currentWallet.lightningNumPeers
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import QtQuick 2.6
|
||||
|
||||
Image {
|
||||
id: root
|
||||
|
||||
sourceSize.width: constants.iconSizeMedium
|
||||
sourceSize.height: constants.iconSizeMedium
|
||||
|
||||
source: Daemon.currentWallet.lightningNumPeers
|
||||
? '../../../icons/lightning.png'
|
||||
: '../../../icons/lightning_disconnected.png'
|
||||
}
|
||||
@@ -108,6 +108,10 @@ ApplicationWindow
|
||||
scale: 1.5
|
||||
}
|
||||
|
||||
LightningNetworkStatusIndicator {
|
||||
visible: Daemon.currentWallet.isLightning
|
||||
}
|
||||
|
||||
OnchainNetworkStatusIndicator { }
|
||||
|
||||
Rectangle {
|
||||
|
||||
@@ -71,6 +71,7 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
otpRequested = pyqtSignal()
|
||||
otpSuccess = pyqtSignal()
|
||||
otpFailed = pyqtSignal([str,str], arguments=['code','message'])
|
||||
peersUpdated = pyqtSignal()
|
||||
|
||||
_network_signal = pyqtSignal(str, object)
|
||||
|
||||
@@ -198,11 +199,13 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
def on_event_channel(self, wallet, channel):
|
||||
if wallet == self.wallet:
|
||||
self.balanceChanged.emit()
|
||||
self.peersUpdated.emit()
|
||||
|
||||
@event_listener
|
||||
def on_event_channels_updated(self, wallet):
|
||||
if wallet == self.wallet:
|
||||
self.balanceChanged.emit()
|
||||
self.peersUpdated.emit()
|
||||
|
||||
@qt_event_listener
|
||||
def on_event_payment_succeeded(self, wallet, key):
|
||||
@@ -421,8 +424,6 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
def lightningBalance(self):
|
||||
if self.isLightning:
|
||||
self._lightningbalance.satsInt = int(self.wallet.lnworker.get_balance())
|
||||
# else:
|
||||
# self._lightningbalance.satsInt = 0
|
||||
return self._lightningbalance
|
||||
|
||||
@pyqtProperty(QEAmount, notify=balanceChanged)
|
||||
@@ -443,6 +444,12 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
self._lightningcanreceive.satsInt = int(self.wallet.lnworker.num_sats_can_receive())
|
||||
return self._lightningcanreceive
|
||||
|
||||
@pyqtProperty(int, notify=peersUpdated)
|
||||
def lightningNumPeers(self):
|
||||
if self.isLightning:
|
||||
return self.wallet.lnworker.num_peers()
|
||||
return 0
|
||||
|
||||
@pyqtSlot()
|
||||
def enableLightning(self):
|
||||
self.wallet.init_lightning(password=None) # TODO pass password if needed
|
||||
|
||||
Reference in New Issue
Block a user