qml: fix channel double add to list on open, better display errors
This commit is contained in:
@@ -100,7 +100,7 @@ Pane {
|
||||
columns: 2
|
||||
|
||||
Label {
|
||||
text: qsTr('Channel name')
|
||||
text: qsTr('Node name')
|
||||
color: Material.accentColor
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ ElDialog {
|
||||
visible: false
|
||||
iconStyle: InfoTextArea.IconStyle.Error
|
||||
width: parent.width
|
||||
textFormat: TextEdit.PlainText
|
||||
}
|
||||
|
||||
InfoTextArea {
|
||||
|
||||
@@ -14,6 +14,7 @@ GridLayout {
|
||||
}
|
||||
|
||||
property int iconStyle: InfoTextArea.IconStyle.Info
|
||||
property alias textFormat: infotext.textFormat
|
||||
|
||||
columns: 1
|
||||
rowSpacing: 0
|
||||
@@ -31,7 +32,7 @@ GridLayout {
|
||||
readOnly: true
|
||||
rightPadding: constants.paddingLarge
|
||||
leftPadding: 2*constants.iconSizeLarge
|
||||
wrapMode: TextInput.WordWrap
|
||||
wrapMode: TextInput.Wrap
|
||||
textFormat: TextEdit.RichText
|
||||
background: Rectangle {
|
||||
color: Qt.rgba(1,1,1,0.05) // whiten 5%
|
||||
|
||||
@@ -39,12 +39,6 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
||||
if wallet == self.wallet:
|
||||
self.on_channel_updated(channel)
|
||||
|
||||
# elif event == 'channels_updated':
|
||||
@qt_event_listener
|
||||
def on_event_channels_updated(self, wallet):
|
||||
if wallet == self.wallet:
|
||||
self.init_model() # TODO: remove/add less crude than full re-init
|
||||
|
||||
def on_destroy(self):
|
||||
self.unregister_callbacks()
|
||||
|
||||
@@ -124,6 +118,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
||||
i = i + 1
|
||||
|
||||
def do_update(self, modelindex, channel):
|
||||
self._logger.debug(f'updating our channel {channel.short_id_for_GUI()}')
|
||||
modelitem = self.channels[modelindex]
|
||||
modelitem.update(self.channel_to_model(channel))
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import threading
|
||||
from concurrent.futures import CancelledError
|
||||
from asyncio.exceptions import TimeoutError
|
||||
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||
|
||||
from electrum.i18n import _
|
||||
from electrum.gui import messages
|
||||
from electrum.lnutil import extract_nodeid, LNPeerAddr, ln_dummy_address
|
||||
from electrum.lnworker import hardcoded_trampoline_nodes
|
||||
@@ -168,6 +171,7 @@ class QEChannelOpener(QObject, AuthMixin):
|
||||
lnworker = self._wallet.wallet.lnworker
|
||||
|
||||
def open_thread():
|
||||
error = None
|
||||
try:
|
||||
chan, _funding_tx = lnworker.open_channel(
|
||||
connect_str=conn_str,
|
||||
@@ -175,13 +179,19 @@ class QEChannelOpener(QObject, AuthMixin):
|
||||
funding_sat=funding_sat,
|
||||
push_amt_sat=0,
|
||||
password=password)
|
||||
self._logger.debug('opening channel succeeded')
|
||||
self.channelOpenSuccess.emit(chan.channel_id.hex(), chan.has_onchain_backup())
|
||||
except (CancelledError,TimeoutError):
|
||||
error = _('Could not connect to channel peer')
|
||||
except Exception as e:
|
||||
self._logger.exception("Problem opening channel: %s", repr(e))
|
||||
self.channelOpenError.emit(repr(e))
|
||||
return
|
||||
error = str(e)
|
||||
if not error:
|
||||
error = repr(e)
|
||||
finally:
|
||||
if error:
|
||||
self._logger.exception("Problem opening channel: %s", error)
|
||||
self.channelOpenError.emit(error)
|
||||
|
||||
self._logger.debug('opening channel succeeded')
|
||||
self.channelOpenSuccess.emit(chan.channel_id.hex(), chan.has_onchain_backup())
|
||||
|
||||
self._logger.debug('starting open thread')
|
||||
self.channelOpening.emit(conn_str)
|
||||
|
||||
Reference in New Issue
Block a user