tStart watchtower if run_watchtower is set, even if lightning is not activated (fix #5896). Fix parameters of sweepstore.add_sweep_tx, rm dead code. - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit cded582fe94c21ffffe2e037503e2f8307176e08 DIR parent e876cb0d931fc5fe9fd7763d15aa59112cfdd357 HTML Author: ThomasV <thomasv@electrum.org> Date: Sun, 2 Feb 2020 12:10:10 +0100 Start watchtower if run_watchtower is set, even if lightning is not activated (fix #5896). Fix parameters of sweepstore.add_sweep_tx, rm dead code. Diffstat: M electrum/lnwatcher.py | 12 +++--------- M electrum/network.py | 10 +++++----- 2 files changed, 8 insertions(+), 14 deletions(-) --- DIR diff --git a/electrum/lnwatcher.py b/electrum/lnwatcher.py t@@ -77,11 +77,10 @@ class SweepStore(SqlDB): return set([r[0] for r in c.fetchall()]) @sql - def add_sweep_tx(self, funding_outpoint, ctn, prevout, tx: Transaction): + def add_sweep_tx(self, funding_outpoint, ctn, prevout, raw_tx): c = self.conn.cursor() - assert tx.is_complete() - raw_tx = bfh(tx.serialize()) - c.execute("""INSERT INTO sweep_txs (funding_outpoint, ctn, prevout, tx) VALUES (?,?,?,?)""", (funding_outpoint, ctn, prevout, raw_tx)) + assert Transaction(raw_tx).is_complete() + c.execute("""INSERT INTO sweep_txs (funding_outpoint, ctn, prevout, tx) VALUES (?,?,?,?)""", (funding_outpoint, ctn, prevout, bfh(raw_tx))) self.conn.commit() @sql t@@ -298,11 +297,6 @@ class WatchTower(LNWatcher): return await self.sweepstore.get_num_tx(outpoint) return self.network.run_from_another_thread(f()) - def add_sweep_tx(self, funding_outpoint: str, ctn:int, prevout: str, tx: str): - async def f(): - return await self.sweepstore.add_sweep_tx(funding_outpoint, ctn, prevout, tx) - return self.network.run_from_another_thread(f()) - def list_sweep_tx(self): async def f(): return await self.sweepstore.list_sweep_tx() DIR diff --git a/electrum/network.py b/electrum/network.py t@@ -311,21 +311,21 @@ class Network(Logger): self.channel_db = None # type: Optional[ChannelDB] self.lngossip = None # type: Optional[LNGossip] self.local_watchtower = None # type: Optional[WatchTower] + if self.config.get('run_watchtower', False): + from . import lnwatcher + self.local_watchtower = lnwatcher.WatchTower(self) + self.local_watchtower.start_network(self) + asyncio.ensure_future(self.local_watchtower.start_watching()) def maybe_init_lightning(self): if self.channel_db is None: - from . import lnwatcher from . import lnworker from . import lnrouter from . import channel_db self.channel_db = channel_db.ChannelDB(self) self.path_finder = lnrouter.LNPathFinder(self.channel_db) self.lngossip = lnworker.LNGossip(self) - self.local_watchtower = lnwatcher.WatchTower(self) if self.config.get('local_watchtower', False) else None self.lngossip.start_network(self) - if self.local_watchtower: - self.local_watchtower.start_network(self) - asyncio.ensure_future(self.local_watchtower.start_watching) def run_from_another_thread(self, coro, *, timeout=None): assert self._loop_thread != threading.current_thread(), 'must not be called from network thread'