tlnworker: fix race - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 09c3e52e62d1bcc1ed46c7b48ecda2105c7ad50c DIR parent 53802ba3821e88b1d5ecd3e373041cbd0d7537db HTML Author: SomberNight <somber.night@protonmail.com> Date: Mon, 8 Oct 2018 20:26:44 +0200 lnworker: fix race sometimes a reestablished channel would not get marked "open" Diffstat: M electrum/lnworker.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py t@@ -3,9 +3,8 @@ import os from decimal import Decimal import random import time -from typing import Optional, Sequence, Tuple, List +from typing import Optional, Sequence, Tuple, List, Dict import threading -from functools import partial import socket import dns.resolver t@@ -17,7 +16,7 @@ from . import bitcoin from .keystore import BIP32_KeyStore from .bitcoin import sha256, COIN from .util import bh2u, bfh, PrintError, InvoiceError, resolve_dns_srv, is_ip_address -from .lnbase import Peer, privkey_to_pubkey, aiosafe +from .lnbase import Peer, aiosafe from .lnaddr import lnencode, LnAddr, lndecode from .ecc import der_sig_from_sig_string from .lnhtlc import HTLCStateMachine t@@ -60,7 +59,7 @@ class LNWorker(PrintError): self._last_tried_peer = {} # LNPeerAddr -> unix timestamp self._add_peers_from_config() # wait until we see confirmations - self.network.register_callback(self.on_network_update, ['network_updated', 'verified', 'fee']) # thread safe + self.network.register_callback(self.on_network_update, ['wallet_updated', 'network_updated', 'verified', 'fee']) # thread safe self.network.register_callback(self.on_channel_txo, ['channel_txo']) asyncio.run_coroutine_threadsafe(self.network.main_taskgroup.spawn(self.main_loop()), self.network.asyncio_loop) t@@ -168,6 +167,10 @@ class LNWorker(PrintError): with self.lock: channels = list(self.channels.values()) addr_sync = self.network.lnwatcher.addr_sync + if event in ('verified', 'wallet_updated'): + wallet = args[0] + if wallet != addr_sync: + return for chan in channels: if chan.get_state() == "OPENING": res, depth = self.save_short_chan_id(chan)