Browse Source

qml: fix channel double add to list on open, better display errors

patch-4
Sander van Grieken 3 years ago
parent
commit
b9f381a133
  1. 2
      electrum/gui/qml/components/ChannelDetails.qml
  2. 1
      electrum/gui/qml/components/ChannelOpenProgressDialog.qml
  3. 3
      electrum/gui/qml/components/controls/InfoTextArea.qml
  4. 7
      electrum/gui/qml/qechannellistmodel.py
  5. 20
      electrum/gui/qml/qechannelopener.py

2
electrum/gui/qml/components/ChannelDetails.qml

@ -100,7 +100,7 @@ Pane {
columns: 2 columns: 2
Label { Label {
text: qsTr('Channel name') text: qsTr('Node name')
color: Material.accentColor color: Material.accentColor
} }

1
electrum/gui/qml/components/ChannelOpenProgressDialog.qml

@ -104,6 +104,7 @@ ElDialog {
visible: false visible: false
iconStyle: InfoTextArea.IconStyle.Error iconStyle: InfoTextArea.IconStyle.Error
width: parent.width width: parent.width
textFormat: TextEdit.PlainText
} }
InfoTextArea { InfoTextArea {

3
electrum/gui/qml/components/controls/InfoTextArea.qml

@ -14,6 +14,7 @@ GridLayout {
} }
property int iconStyle: InfoTextArea.IconStyle.Info property int iconStyle: InfoTextArea.IconStyle.Info
property alias textFormat: infotext.textFormat
columns: 1 columns: 1
rowSpacing: 0 rowSpacing: 0
@ -31,7 +32,7 @@ GridLayout {
readOnly: true readOnly: true
rightPadding: constants.paddingLarge rightPadding: constants.paddingLarge
leftPadding: 2*constants.iconSizeLarge leftPadding: 2*constants.iconSizeLarge
wrapMode: TextInput.WordWrap wrapMode: TextInput.Wrap
textFormat: TextEdit.RichText textFormat: TextEdit.RichText
background: Rectangle { background: Rectangle {
color: Qt.rgba(1,1,1,0.05) // whiten 5% color: Qt.rgba(1,1,1,0.05) // whiten 5%

7
electrum/gui/qml/qechannellistmodel.py

@ -39,12 +39,6 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
if wallet == self.wallet: if wallet == self.wallet:
self.on_channel_updated(channel) 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): def on_destroy(self):
self.unregister_callbacks() self.unregister_callbacks()
@ -124,6 +118,7 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
i = i + 1 i = i + 1
def do_update(self, modelindex, channel): def do_update(self, modelindex, channel):
self._logger.debug(f'updating our channel {channel.short_id_for_GUI()}')
modelitem = self.channels[modelindex] modelitem = self.channels[modelindex]
modelitem.update(self.channel_to_model(channel)) modelitem.update(self.channel_to_model(channel))

20
electrum/gui/qml/qechannelopener.py

@ -1,7 +1,10 @@
import threading import threading
from concurrent.futures import CancelledError
from asyncio.exceptions import TimeoutError
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
from electrum.i18n import _
from electrum.gui import messages from electrum.gui import messages
from electrum.lnutil import extract_nodeid, LNPeerAddr, ln_dummy_address from electrum.lnutil import extract_nodeid, LNPeerAddr, ln_dummy_address
from electrum.lnworker import hardcoded_trampoline_nodes from electrum.lnworker import hardcoded_trampoline_nodes
@ -168,6 +171,7 @@ class QEChannelOpener(QObject, AuthMixin):
lnworker = self._wallet.wallet.lnworker lnworker = self._wallet.wallet.lnworker
def open_thread(): def open_thread():
error = None
try: try:
chan, _funding_tx = lnworker.open_channel( chan, _funding_tx = lnworker.open_channel(
connect_str=conn_str, connect_str=conn_str,
@ -175,13 +179,19 @@ class QEChannelOpener(QObject, AuthMixin):
funding_sat=funding_sat, funding_sat=funding_sat,
push_amt_sat=0, push_amt_sat=0,
password=password) 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: except Exception as e:
self._logger.exception("Problem opening channel: %s", repr(e)) error = str(e)
self.channelOpenError.emit(repr(e)) if not error:
return 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._logger.debug('starting open thread')
self.channelOpening.emit(conn_str) self.channelOpening.emit(conn_str)

Loading…
Cancel
Save