electrum

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

commit 16626a3386b9a0610261bc79953a33397156b8a5
parent 0723355a0f90aca1e177bb615d44d678c79a73dc
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon, 17 Feb 2020 19:43:21 +0100

lnutil.split_host_port: fix for IPv6 connection string

Diffstat:
Melectrum/gui/qt/main_window.py | 2+-
Melectrum/lnutil.py | 2+-
Melectrum/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 @@ -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 @@ -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<host>[:0-9]+)\](?P<port>:\d+)?$') + ipv6 = re.compile(r'\[(?P<host>[:0-9a-f]+)\](?P<port>:\d+)?$') other = re.compile(r'(?P<host>[^:]+)(?P<port>:\d+)?$') m = ipv6.match(host_port) if not m: diff --git 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"))