From 16626a3386b9a0610261bc79953a33397156b8a5 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 17 Feb 2020 19:43:21 +0100 Subject: [PATCH] lnutil.split_host_port: fix for IPv6 connection string --- electrum/gui/qt/main_window.py | 2 +- electrum/lnutil.py | 2 +- electrum/tests/test_lnutil.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 412c25b57..3c9673d1e 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -1685,7 +1685,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): def on_failure(exc_info): type_, e, traceback = exc_info - self.show_error(_('Could not open channel: {}').format(e)) + self.show_error(_('Could not open channel: {}').format(repr(e))) WaitingDialog(self, _('Opening channel...'), task, on_success, on_failure) def query_choice(self, msg, choices): diff --git a/electrum/lnutil.py b/electrum/lnutil.py index 4ef9a747b..65326f178 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -716,7 +716,7 @@ def make_closing_tx(local_funding_pubkey: bytes, remote_funding_pubkey: bytes, def split_host_port(host_port: str) -> Tuple[str, str]: # port returned as string - ipv6 = re.compile(r'\[(?P[:0-9]+)\](?P:\d+)?$') + ipv6 = re.compile(r'\[(?P[:0-9a-f]+)\](?P:\d+)?$') other = re.compile(r'(?P[^:]+)(?P:\d+)?$') m = ipv6.match(host_port) if not m: diff --git a/electrum/tests/test_lnutil.py b/electrum/tests/test_lnutil.py index fafde9185..c115d1817 100644 --- a/electrum/tests/test_lnutil.py +++ b/electrum/tests/test_lnutil.py @@ -693,6 +693,8 @@ class TestLNUtil(ElectrumTestCase): def test_split_host_port(self): self.assertEqual(split_host_port("[::1]:8000"), ("::1", "8000")) self.assertEqual(split_host_port("[::1]"), ("::1", "9735")) + self.assertEqual(split_host_port("[2601:602:8800:9a:dc59:a4ff:fede:24a9]:9735"), ("2601:602:8800:9a:dc59:a4ff:fede:24a9", "9735")) + self.assertEqual(split_host_port("[2601:602:8800::a4ff:fede:24a9]:9735"), ("2601:602:8800::a4ff:fede:24a9", "9735")) self.assertEqual(split_host_port("kæn.guru:8000"), ("kæn.guru", "8000")) self.assertEqual(split_host_port("kæn.guru"), ("kæn.guru", "9735")) self.assertEqual(split_host_port("127.0.0.1:8000"), ("127.0.0.1", "8000"))