commit edba59ef54b4489ddccdbe70b883bfec42be3d3a
parent ddeb176b3da0c4fcbb6cf2b8d85dd319e2a2bf56
Author: SomberNight <somber.night@protonmail.com>
Date: Mon, 25 Nov 2019 21:10:53 +0100
LNPeerAddr: nicer str formatting for IPv6 hosts
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/electrum/lnutil.py b/electrum/lnutil.py
@@ -8,6 +8,8 @@ from collections import namedtuple
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set
import re
+from aiorpcx import NetAddress
+
from .util import bfh, bh2u, inv_dict, UserFacingException
from .crypto import sha256
from .transaction import (Transaction, PartialTransaction, PartialTxInput, TxOutpoint,
@@ -662,7 +664,8 @@ class LNPeerAddr(NamedTuple):
pubkey: bytes
def __str__(self):
- return '{}@{}:{}'.format(bh2u(self.pubkey), self.host, self.port)
+ host_and_port = str(NetAddress(self.host, self.port))
+ return '{}@{}'.format(self.pubkey.hex(), host_and_port)
def get_compressed_pubkey_from_bech32(bech32_pubkey: str) -> bytes: