electrum

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

commit d480d0b265068ce0cc7a5a279b98e4af85bbc3ee
parent b476681af7f884c50997181dc3f714a0a1f507bf
Author: ghost43 <somber.night@protonmail.com>
Date:   Tue, 15 Oct 2019 13:43:17 +0000

Merge pull request #5700 from fiatjaf/bugfixopenchannel

fix expected returned peer address values when opening channel.
Diffstat:
Melectrum/channel_db.py | 3++-
Melectrum/lnworker.py | 6+++---
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/electrum/channel_db.py b/electrum/channel_db.py @@ -250,7 +250,8 @@ class ChannelDB(SqlDB): self._channels = {} # type: Dict[bytes, ChannelInfo] self._policies = {} self._nodes = {} - self._addresses = defaultdict(set) + # node_id -> (host, port, ts) + self._addresses = defaultdict(set) # type: Dict[bytes, Set[Tuple[str, int, int]]] self._channels_for_node = defaultdict(set) self.data_loaded = asyncio.Event() self.network = network # only for callback diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -251,7 +251,7 @@ class LNWorker(Logger): return peers @staticmethod - def choose_preferred_address(addr_list: List[Tuple[str, int]]) -> Tuple[str, int]: + def choose_preferred_address(addr_list: Sequence[Tuple[str, int, int]]) -> Tuple[str, int, int]: assert len(addr_list) >= 1 # choose first one that is an IP for host, port, timestamp in addr_list: @@ -793,9 +793,9 @@ class LNWallet(LNWorker): host, port = split_host_port(rest) else: addrs = self.channel_db.get_node_addresses(node_id) - if len(addrs) == 0: + if not addrs: raise ConnStringFormatError(_('Don\'t know any addresses for node:') + ' ' + bh2u(node_id)) - host, port = self.choose_preferred_address(addrs) + host, port, timestamp = self.choose_preferred_address(addrs) try: socket.getaddrinfo(host, int(port)) except socket.gaierror: