qml: show channelbackups in channel list,
add channelbackups support in qechanneldetails.py, only request-fclose option in CloseChannelDialog
This commit is contained in:
@@ -271,6 +271,7 @@ Pane {
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
visible: channeldetails.isOpen
|
||||||
|
|
||||||
FlatButton {
|
FlatButton {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ ElDialog {
|
|||||||
RadioButton {
|
RadioButton {
|
||||||
ButtonGroup.group: closetypegroup
|
ButtonGroup.group: closetypegroup
|
||||||
property string closetype: 'local_force'
|
property string closetype: 'local_force'
|
||||||
enabled: !closing && channeldetails.canForceClose
|
enabled: !closing && channeldetails.canForceClose && !channeldetails.isBackup
|
||||||
text: qsTr('Local Force-close')
|
text: qsTr('Local Force-close')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ ItemDelegate {
|
|||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: walleticon
|
id: walleticon
|
||||||
source: model.is_trampoline ? '../../../icons/kangaroo.png' : '../../../icons/lightning.png'
|
source: model.is_backup
|
||||||
|
? '../../../icons/nocloud.png'
|
||||||
|
: model.is_trampoline
|
||||||
|
? '../../../icons/kangaroo.png'
|
||||||
|
: '../../../icons/lightning.png'
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
Layout.rowSpan: 3
|
Layout.rowSpan: 3
|
||||||
Layout.preferredWidth: constants.iconSizeLarge
|
Layout.preferredWidth: constants.iconSizeLarge
|
||||||
|
|||||||
@@ -67,9 +67,8 @@ class QEChannelDetails(QObject, QtEventListener):
|
|||||||
self.channelidChanged.emit()
|
self.channelidChanged.emit()
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
lnchannels = self._wallet.wallet.lnworker.channels
|
lnchannels = self._wallet.wallet.lnworker.get_channel_objects()
|
||||||
for channel in lnchannels.values():
|
for channel in lnchannels.values():
|
||||||
#self._logger.debug('%s == %s ?' % (self._channelid, channel.channel_id))
|
|
||||||
if self._channelid == channel.channel_id.hex():
|
if self._channelid == channel.channel_id.hex():
|
||||||
self._channel = channel
|
self._channel = channel
|
||||||
self.channelChanged.emit()
|
self.channelChanged.emit()
|
||||||
@@ -94,6 +93,8 @@ class QEChannelDetails(QObject, QtEventListener):
|
|||||||
|
|
||||||
@pyqtProperty(str, notify=channelChanged)
|
@pyqtProperty(str, notify=channelChanged)
|
||||||
def initiator(self):
|
def initiator(self):
|
||||||
|
if self._channel.is_backup():
|
||||||
|
return ''
|
||||||
return 'Local' if self._channel.constraints.is_initiator else 'Remote'
|
return 'Local' if self._channel.constraints.is_initiator else 'Remote'
|
||||||
|
|
||||||
@pyqtProperty(QEAmount, notify=channelChanged)
|
@pyqtProperty(QEAmount, notify=channelChanged)
|
||||||
@@ -103,12 +104,18 @@ class QEChannelDetails(QObject, QtEventListener):
|
|||||||
|
|
||||||
@pyqtProperty(QEAmount, notify=channelChanged)
|
@pyqtProperty(QEAmount, notify=channelChanged)
|
||||||
def canSend(self):
|
def canSend(self):
|
||||||
self._can_send = QEAmount(amount_sat=self._channel.available_to_spend(LOCAL)/1000)
|
if self._channel.is_backup():
|
||||||
|
self._can_send = QEAmount()
|
||||||
|
else:
|
||||||
|
self._can_send = QEAmount(amount_sat=self._channel.available_to_spend(LOCAL)/1000)
|
||||||
return self._can_send
|
return self._can_send
|
||||||
|
|
||||||
@pyqtProperty(QEAmount, notify=channelChanged)
|
@pyqtProperty(QEAmount, notify=channelChanged)
|
||||||
def canReceive(self):
|
def canReceive(self):
|
||||||
self._can_receive = QEAmount(amount_sat=self._channel.available_to_spend(REMOTE)/1000)
|
if self._channel.is_backup():
|
||||||
|
self._can_receive = QEAmount()
|
||||||
|
else:
|
||||||
|
self._can_receive = QEAmount(amount_sat=self._channel.available_to_spend(REMOTE)/1000)
|
||||||
return self._can_receive
|
return self._can_receive
|
||||||
|
|
||||||
@pyqtProperty(bool, notify=channelChanged)
|
@pyqtProperty(bool, notify=channelChanged)
|
||||||
@@ -121,7 +128,7 @@ class QEChannelDetails(QObject, QtEventListener):
|
|||||||
|
|
||||||
@pyqtProperty(str, notify=channelChanged)
|
@pyqtProperty(str, notify=channelChanged)
|
||||||
def channelType(self):
|
def channelType(self):
|
||||||
return self._channel.storage['channel_type'].name_minimal
|
return self._channel.storage['channel_type'].name_minimal if 'channel_type' in self._channel.storage else 'Channel Backup'
|
||||||
|
|
||||||
@pyqtProperty(bool, notify=channelChanged)
|
@pyqtProperty(bool, notify=channelChanged)
|
||||||
def isOpen(self):
|
def isOpen(self):
|
||||||
@@ -137,7 +144,7 @@ class QEChannelDetails(QObject, QtEventListener):
|
|||||||
|
|
||||||
@pyqtProperty(bool, notify=channelChanged)
|
@pyqtProperty(bool, notify=channelChanged)
|
||||||
def canForceClose(self):
|
def canForceClose(self):
|
||||||
return ChanCloseOption.LOCAL_FCLOSE in self._channel.get_close_options()
|
return any([o in [ChanCloseOption.LOCAL_FCLOSE, ChanCloseOption.REQUEST_REMOTE_FCLOSE] for o in self._channel.get_close_options()])
|
||||||
|
|
||||||
@pyqtProperty(bool, notify=channelChanged)
|
@pyqtProperty(bool, notify=channelChanged)
|
||||||
def canDelete(self):
|
def canDelete(self):
|
||||||
@@ -147,6 +154,10 @@ class QEChannelDetails(QObject, QtEventListener):
|
|||||||
def message_force_close(self, notify=channelChanged):
|
def message_force_close(self, notify=channelChanged):
|
||||||
return _(messages.MSG_REQUEST_FORCE_CLOSE)
|
return _(messages.MSG_REQUEST_FORCE_CLOSE)
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify=channelChanged)
|
||||||
|
def isBackup(self):
|
||||||
|
return self._channel.is_backup()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def freezeForSending(self):
|
def freezeForSending(self):
|
||||||
lnworker = self._channel.lnworker
|
lnworker = self._channel.lnworker
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
|||||||
# define listmodel rolemap
|
# define listmodel rolemap
|
||||||
_ROLE_NAMES=('cid','state','state_code','initiator','capacity','can_send',
|
_ROLE_NAMES=('cid','state','state_code','initiator','capacity','can_send',
|
||||||
'can_receive','l_csv_delay','r_csv_delay','send_frozen','receive_frozen',
|
'can_receive','l_csv_delay','r_csv_delay','send_frozen','receive_frozen',
|
||||||
'type','node_id','node_alias','short_cid','funding_tx','is_trampoline')
|
'type','node_id','node_alias','short_cid','funding_tx','is_trampoline',
|
||||||
|
'is_backup')
|
||||||
_ROLE_KEYS = range(Qt.UserRole, Qt.UserRole + len(_ROLE_NAMES))
|
_ROLE_KEYS = range(Qt.UserRole, Qt.UserRole + len(_ROLE_NAMES))
|
||||||
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))
|
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))
|
||||||
_ROLE_RMAP = dict(zip(_ROLE_NAMES, _ROLE_KEYS))
|
_ROLE_RMAP = dict(zip(_ROLE_NAMES, _ROLE_KEYS))
|
||||||
@@ -72,10 +73,15 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
|||||||
item['short_cid'] = lnc.short_id_for_GUI()
|
item['short_cid'] = lnc.short_id_for_GUI()
|
||||||
item['state'] = lnc.get_state_for_GUI()
|
item['state'] = lnc.get_state_for_GUI()
|
||||||
item['state_code'] = int(lnc.get_state())
|
item['state_code'] = int(lnc.get_state())
|
||||||
item['capacity'] = QEAmount(amount_sat=lnc.get_capacity())
|
item['is_backup'] = lnc.is_backup()
|
||||||
item['can_send'] = QEAmount(amount_msat=lnc.available_to_spend(LOCAL))
|
|
||||||
item['can_receive'] = QEAmount(amount_msat=lnc.available_to_spend(REMOTE))
|
|
||||||
item['is_trampoline'] = lnworker.is_trampoline_peer(lnc.node_id)
|
item['is_trampoline'] = lnworker.is_trampoline_peer(lnc.node_id)
|
||||||
|
item['capacity'] = QEAmount(amount_sat=lnc.get_capacity())
|
||||||
|
if lnc.is_backup():
|
||||||
|
item['can_send'] = QEAmount()
|
||||||
|
item['can_receive'] = QEAmount()
|
||||||
|
else:
|
||||||
|
item['can_send'] = QEAmount(amount_msat=lnc.available_to_spend(LOCAL))
|
||||||
|
item['can_receive'] = QEAmount(amount_msat=lnc.available_to_spend(REMOTE))
|
||||||
return item
|
return item
|
||||||
|
|
||||||
numOpenChannelsChanged = pyqtSignal()
|
numOpenChannelsChanged = pyqtSignal()
|
||||||
@@ -94,9 +100,6 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
|||||||
|
|
||||||
lnchannels = self.wallet.lnworker.get_channel_objects()
|
lnchannels = self.wallet.lnworker.get_channel_objects()
|
||||||
for channel in lnchannels.values():
|
for channel in lnchannels.values():
|
||||||
if channel.is_backup():
|
|
||||||
# not implemented
|
|
||||||
continue
|
|
||||||
item = self.channel_to_model(channel)
|
item = self.channel_to_model(channel)
|
||||||
channels.append(item)
|
channels.append(item)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user