Fix bug with save_funding_height, save_closing_height
(it would enter a state where only closing_height was saved)
This commit is contained in:
@@ -174,6 +174,9 @@ class LNWatcher(AddressSynchronizer):
|
||||
await self.check_onchain_situation(address, outpoint)
|
||||
|
||||
async def check_onchain_situation(self, address, funding_outpoint):
|
||||
# early return if address has not been added yet
|
||||
if not self.is_mine(address):
|
||||
return
|
||||
spenders = self.inspect_tx_candidate(funding_outpoint, 0)
|
||||
# inspect_tx_candidate might have added new addresses, in which case we return ealy
|
||||
if not self.is_up_to_date():
|
||||
@@ -335,16 +338,21 @@ class LNWalletWatcher(LNWatcher):
|
||||
@ignore_exceptions
|
||||
@log_exceptions
|
||||
async def update_channel_state(self, funding_outpoint, funding_txid, funding_height, closing_txid, closing_height, keep_watching):
|
||||
# note: state transitions are irreversible, but
|
||||
# save_funding_height, save_closing_height are reversible
|
||||
chan = self.lnworker.channel_by_txo(funding_outpoint)
|
||||
if not chan:
|
||||
return
|
||||
if funding_height.height == TX_HEIGHT_LOCAL:
|
||||
chan.delete_funding_height()
|
||||
chan.delete_closing_height()
|
||||
await self.lnworker.update_unfunded_channel(chan, funding_txid)
|
||||
elif closing_height.height == TX_HEIGHT_LOCAL:
|
||||
chan.save_funding_height(funding_txid, funding_height.height, funding_height.timestamp)
|
||||
chan.delete_closing_height()
|
||||
await self.lnworker.update_open_channel(chan, funding_txid, funding_height)
|
||||
else:
|
||||
chan.save_funding_height(funding_txid, funding_height.height, funding_height.timestamp)
|
||||
chan.save_closing_height(closing_txid, closing_height.height, closing_height.timestamp)
|
||||
await self.lnworker.update_closed_channel(chan, funding_txid, funding_height, closing_txid, closing_height, keep_watching)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user