auto-remove redeemed channel backups. fix indentation.
This commit is contained in:
@@ -282,13 +282,16 @@ class AbstractChannel(Logger, ABC):
|
||||
if funding_height.height == TX_HEIGHT_LOCAL:
|
||||
self.update_unfunded_state()
|
||||
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:
|
||||
self.update_closed_state(funding_txid=funding_txid,
|
||||
funding_height=funding_height,
|
||||
closing_txid=closing_txid,
|
||||
closing_height=closing_height,
|
||||
keep_watching=keep_watching)
|
||||
self.update_closed_state(
|
||||
funding_txid=funding_txid,
|
||||
funding_height=funding_height,
|
||||
closing_txid=closing_txid,
|
||||
closing_height=closing_height,
|
||||
keep_watching=keep_watching)
|
||||
|
||||
def update_unfunded_state(self):
|
||||
self.delete_funding_height()
|
||||
@@ -314,7 +317,7 @@ class AbstractChannel(Logger, ABC):
|
||||
break
|
||||
else:
|
||||
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)
|
||||
|
||||
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:
|
||||
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
|
||||
def sweep_address(self) -> str:
|
||||
|
||||
@@ -425,11 +425,12 @@ class LNWalletWatcher(LNWatcher):
|
||||
chan = self.lnworker.channel_by_txo(funding_outpoint)
|
||||
if not chan:
|
||||
return
|
||||
chan.update_onchain_state(funding_txid=funding_txid,
|
||||
funding_height=funding_height,
|
||||
closing_txid=closing_txid,
|
||||
closing_height=closing_height,
|
||||
keep_watching=keep_watching)
|
||||
chan.update_onchain_state(
|
||||
funding_txid=funding_txid,
|
||||
funding_height=funding_height,
|
||||
closing_txid=closing_txid,
|
||||
closing_height=closing_height,
|
||||
keep_watching=keep_watching)
|
||||
await self.lnworker.on_channel_update(chan)
|
||||
|
||||
@log_exceptions
|
||||
|
||||
Reference in New Issue
Block a user