Browse Source

auto-remove redeemed channel backups. fix indentation.

patch-4
ThomasV 3 years ago
parent
commit
02e4569086
  1. 20
      electrum/lnchannel.py
  2. 11
      electrum/lnwatcher.py

20
electrum/lnchannel.py

@ -282,13 +282,16 @@ class AbstractChannel(Logger, ABC):
if funding_height.height == TX_HEIGHT_LOCAL: if funding_height.height == TX_HEIGHT_LOCAL:
self.update_unfunded_state() self.update_unfunded_state()
elif closing_height.height == TX_HEIGHT_LOCAL: elif closing_height.height == TX_HEIGHT_LOCAL:
self.update_funded_state(funding_txid=funding_txid, funding_height=funding_height) self.update_funded_state(
funding_txid=funding_txid,
funding_height=funding_height)
else: else:
self.update_closed_state(funding_txid=funding_txid, self.update_closed_state(
funding_height=funding_height, funding_txid=funding_txid,
closing_txid=closing_txid, funding_height=funding_height,
closing_height=closing_height, closing_txid=closing_txid,
keep_watching=keep_watching) closing_height=closing_height,
keep_watching=keep_watching)
def update_unfunded_state(self): def update_unfunded_state(self):
self.delete_funding_height() self.delete_funding_height()
@ -314,7 +317,7 @@ class AbstractChannel(Logger, ABC):
break break
else: else:
now = int(time.time()) now = int(time.time())
if now - self.storage.get('init_timestamp', 0) > CHANNEL_OPENING_TIMEOUT: if self.lnworker and (now - self.storage.get('init_timestamp', 0) > CHANNEL_OPENING_TIMEOUT):
self.lnworker.remove_channel(self.channel_id) self.lnworker.remove_channel(self.channel_id)
def update_funded_state(self, *, funding_txid: str, funding_height: TxMinedInfo) -> None: def update_funded_state(self, *, funding_txid: str, funding_height: TxMinedInfo) -> None:
@ -348,6 +351,9 @@ class AbstractChannel(Logger, ABC):
if self.get_state() == ChannelState.CLOSED and not keep_watching: if self.get_state() == ChannelState.CLOSED and not keep_watching:
self.set_state(ChannelState.REDEEMED) self.set_state(ChannelState.REDEEMED)
if self.lnworker and self.is_backup():
# auto-remove redeemed backups
self.lnworker.remove_channel_backup(self.channel_id)
@property @property
def sweep_address(self) -> str: def sweep_address(self) -> str:

11
electrum/lnwatcher.py

@ -425,11 +425,12 @@ class LNWalletWatcher(LNWatcher):
chan = self.lnworker.channel_by_txo(funding_outpoint) chan = self.lnworker.channel_by_txo(funding_outpoint)
if not chan: if not chan:
return return
chan.update_onchain_state(funding_txid=funding_txid, chan.update_onchain_state(
funding_height=funding_height, funding_txid=funding_txid,
closing_txid=closing_txid, funding_height=funding_height,
closing_height=closing_height, closing_txid=closing_txid,
keep_watching=keep_watching) closing_height=closing_height,
keep_watching=keep_watching)
await self.lnworker.on_channel_update(chan) await self.lnworker.on_channel_update(chan)
@log_exceptions @log_exceptions

Loading…
Cancel
Save