Browse Source

lnutil.split_host_port: fix for IPv6 connection string

hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
16626a3386
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/gui/qt/main_window.py
  2. 2
      electrum/lnutil.py
  3. 2
      electrum/tests/test_lnutil.py

2
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):

2
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:

2
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"))

Loading…
Cancel
Save