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.
This commit is contained in:
@@ -77,11 +77,10 @@ class SweepStore(SqlDB):
|
|||||||
return set([r[0] for r in c.fetchall()])
|
return set([r[0] for r in c.fetchall()])
|
||||||
|
|
||||||
@sql
|
@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()
|
c = self.conn.cursor()
|
||||||
assert tx.is_complete()
|
assert Transaction(raw_tx).is_complete()
|
||||||
raw_tx = bfh(tx.serialize())
|
c.execute("""INSERT INTO sweep_txs (funding_outpoint, ctn, prevout, tx) VALUES (?,?,?,?)""", (funding_outpoint, ctn, prevout, bfh(raw_tx)))
|
||||||
c.execute("""INSERT INTO sweep_txs (funding_outpoint, ctn, prevout, tx) VALUES (?,?,?,?)""", (funding_outpoint, ctn, prevout, raw_tx))
|
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
@sql
|
@sql
|
||||||
@@ -298,11 +297,6 @@ class WatchTower(LNWatcher):
|
|||||||
return await self.sweepstore.get_num_tx(outpoint)
|
return await self.sweepstore.get_num_tx(outpoint)
|
||||||
return self.network.run_from_another_thread(f())
|
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):
|
def list_sweep_tx(self):
|
||||||
async def f():
|
async def f():
|
||||||
return await self.sweepstore.list_sweep_tx()
|
return await self.sweepstore.list_sweep_tx()
|
||||||
|
|||||||
@@ -311,21 +311,21 @@ class Network(Logger):
|
|||||||
self.channel_db = None # type: Optional[ChannelDB]
|
self.channel_db = None # type: Optional[ChannelDB]
|
||||||
self.lngossip = None # type: Optional[LNGossip]
|
self.lngossip = None # type: Optional[LNGossip]
|
||||||
self.local_watchtower = None # type: Optional[WatchTower]
|
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):
|
def maybe_init_lightning(self):
|
||||||
if self.channel_db is None:
|
if self.channel_db is None:
|
||||||
from . import lnwatcher
|
|
||||||
from . import lnworker
|
from . import lnworker
|
||||||
from . import lnrouter
|
from . import lnrouter
|
||||||
from . import channel_db
|
from . import channel_db
|
||||||
self.channel_db = channel_db.ChannelDB(self)
|
self.channel_db = channel_db.ChannelDB(self)
|
||||||
self.path_finder = lnrouter.LNPathFinder(self.channel_db)
|
self.path_finder = lnrouter.LNPathFinder(self.channel_db)
|
||||||
self.lngossip = lnworker.LNGossip(self)
|
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)
|
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):
|
def run_from_another_thread(self, coro, *, timeout=None):
|
||||||
assert self._loop_thread != threading.current_thread(), 'must not be called from network thread'
|
assert self._loop_thread != threading.current_thread(), 'must not be called from network thread'
|
||||||
|
|||||||
Reference in New Issue
Block a user