Browse Source

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.
hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
cded582fe9
  1. 12
      electrum/lnwatcher.py
  2. 10
      electrum/network.py

12
electrum/lnwatcher.py

@ -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
@ -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()

10
electrum/network.py

@ -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'

Loading…
Cancel
Save