electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c872c3194f4fa4638bd6d3f50b21b449111b8c50
parent 46e59d18f5a69694ea139eba6883ec7f2b633468
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 13 Nov 2020 19:21:37 +0100

qt "open channel" dialog: detect invalid remote node id sooner

and avoid the "please wait" text to be interpreted as a node id

related #6705

Diffstat:
Melectrum/gui/qt/channels_list.py | 5+++--
Melectrum/gui/qt/main_window.py | 7++++++-
Melectrum/lnutil.py | 3++-
3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py @@ -357,8 +357,9 @@ class ChannelsList(MyTreeView): self.parent.wallet.network.start_gossip() nodeid = bh2u(lnworker.lnrater.suggest_peer() or b'') if not nodeid: - remote_nodeid.setText( - "Please wait until the graph is synchronized to 30%.") + remote_nodeid.setText("") + remote_nodeid.setPlaceholderText( + "Please wait until the graph is synchronized to 30%, and then try again.") else: remote_nodeid.setText(nodeid) remote_nodeid.repaint() # macOS hack for #6269 diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -74,7 +74,7 @@ from electrum.network import Network, TxBroadcastError, BestEffortRequestFailed, from electrum.exchange_rate import FxThread from electrum.simple_config import SimpleConfig from electrum.logging import Logger -from electrum.lnutil import ln_dummy_address +from electrum.lnutil import ln_dummy_address, extract_nodeid, ConnStringFormatError from electrum.lnaddr import lndecode, LnDecodeException from .exception_window import Exception_Hook @@ -1757,6 +1757,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): return make_tx def open_channel(self, connect_str, funding_sat, push_amt): + try: + extract_nodeid(connect_str) + except ConnStringFormatError as e: + self.main_window.show_error(str(e)) + return # use ConfirmTxDialog # we need to know the fee before we broadcast, because the txid is required make_tx = self.mktx_for_open_channel(funding_sat) diff --git a/electrum/lnutil.py b/electrum/lnutil.py @@ -1203,7 +1203,8 @@ def extract_nodeid(connect_contents: str) -> Tuple[bytes, str]: raise ConnStringFormatError(_('At least a hostname must be supplied after the at symbol.')) try: node_id = bfh(nodeid_hex) - assert len(node_id) == 33, len(node_id) + if len(node_id) != 33: + raise Exception() except: raise ConnStringFormatError(_('Invalid node ID, must be 33 bytes and hexadecimal')) return node_id, rest