Fix CTNs in should_be_closed_due_to_expiring_htlcs (fixes #7906).
Also fix sending too many fee updates. Rename lnworker.on_channel_update, that name was misleading.
This commit is contained in:
@@ -1576,8 +1576,8 @@ class Channel(AbstractChannel):
|
|||||||
# to the present, then unilaterally close channel
|
# to the present, then unilaterally close channel
|
||||||
recv_htlc_deadline = lnutil.NBLOCK_DEADLINE_BEFORE_EXPIRY_FOR_RECEIVED_HTLCS
|
recv_htlc_deadline = lnutil.NBLOCK_DEADLINE_BEFORE_EXPIRY_FOR_RECEIVED_HTLCS
|
||||||
for sub, dir, ctn in ((LOCAL, RECEIVED, self.get_latest_ctn(LOCAL)),
|
for sub, dir, ctn in ((LOCAL, RECEIVED, self.get_latest_ctn(LOCAL)),
|
||||||
(REMOTE, SENT, self.get_oldest_unrevoked_ctn(LOCAL)),
|
(REMOTE, SENT, self.get_oldest_unrevoked_ctn(REMOTE)),
|
||||||
(REMOTE, SENT, self.get_latest_ctn(LOCAL)),):
|
(REMOTE, SENT, self.get_latest_ctn(REMOTE)),):
|
||||||
for htlc_id, htlc in self.hm.htlcs_by_direction(subject=sub, direction=dir, ctn=ctn).items():
|
for htlc_id, htlc in self.hm.htlcs_by_direction(subject=sub, direction=dir, ctn=ctn).items():
|
||||||
if not self.hm.was_htlc_preimage_released(htlc_id=htlc_id, htlc_proposer=REMOTE):
|
if not self.hm.was_htlc_preimage_released(htlc_id=htlc_id, htlc_proposer=REMOTE):
|
||||||
continue
|
continue
|
||||||
@@ -1588,8 +1588,8 @@ class Channel(AbstractChannel):
|
|||||||
# will unilaterally close the channel and time out the HTLC
|
# will unilaterally close the channel and time out the HTLC
|
||||||
offered_htlc_deadline = lnutil.NBLOCK_DEADLINE_AFTER_EXPIRY_FOR_OFFERED_HTLCS
|
offered_htlc_deadline = lnutil.NBLOCK_DEADLINE_AFTER_EXPIRY_FOR_OFFERED_HTLCS
|
||||||
for sub, dir, ctn in ((LOCAL, SENT, self.get_latest_ctn(LOCAL)),
|
for sub, dir, ctn in ((LOCAL, SENT, self.get_latest_ctn(LOCAL)),
|
||||||
(REMOTE, RECEIVED, self.get_oldest_unrevoked_ctn(LOCAL)),
|
(REMOTE, RECEIVED, self.get_oldest_unrevoked_ctn(REMOTE)),
|
||||||
(REMOTE, RECEIVED, self.get_latest_ctn(LOCAL)),):
|
(REMOTE, RECEIVED, self.get_latest_ctn(REMOTE)),):
|
||||||
for htlc_id, htlc in self.hm.htlcs_by_direction(subject=sub, direction=dir, ctn=ctn).items():
|
for htlc_id, htlc in self.hm.htlcs_by_direction(subject=sub, direction=dir, ctn=ctn).items():
|
||||||
if htlc.cltv_expiry + offered_htlc_deadline > local_height:
|
if htlc.cltv_expiry + offered_htlc_deadline > local_height:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class HTLCManager:
|
|||||||
'locked_in': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
|
'locked_in': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
|
||||||
'settles': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
|
'settles': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
|
||||||
'fails': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
|
'fails': {}, # "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
|
||||||
'fee_updates': {}, # "side who initiated fee update" -> action -> list of FeeUpdates
|
'fee_updates': {}, # "side who initiated fee update" -> index -> list of FeeUpdates
|
||||||
'revack_pending': False,
|
'revack_pending': False,
|
||||||
'next_htlc_id': 0,
|
'next_htlc_id': 0,
|
||||||
'ctn': -1, # oldest unrevoked ctx of sub
|
'ctn': -1, # oldest unrevoked ctx of sub
|
||||||
|
|||||||
@@ -1896,7 +1896,7 @@ class Peer(Logger):
|
|||||||
self.logger.info("FEES HAVE FALLEN")
|
self.logger.info("FEES HAVE FALLEN")
|
||||||
elif feerate_per_kw > chan_fee * 2:
|
elif feerate_per_kw > chan_fee * 2:
|
||||||
self.logger.info("FEES HAVE RISEN")
|
self.logger.info("FEES HAVE RISEN")
|
||||||
elif chan.get_oldest_unrevoked_ctn(REMOTE) == 0:
|
elif chan.get_latest_ctn(REMOTE) == 0:
|
||||||
# workaround eclair issue https://github.com/ACINQ/eclair/issues/1730
|
# workaround eclair issue https://github.com/ACINQ/eclair/issues/1730
|
||||||
self.logger.info("updating fee to bump remote ctn")
|
self.logger.info("updating fee to bump remote ctn")
|
||||||
if feerate_per_kw == chan_fee:
|
if feerate_per_kw == chan_fee:
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ class LNWalletWatcher(LNWatcher):
|
|||||||
closing_txid=closing_txid,
|
closing_txid=closing_txid,
|
||||||
closing_height=closing_height,
|
closing_height=closing_height,
|
||||||
keep_watching=keep_watching)
|
keep_watching=keep_watching)
|
||||||
await self.lnworker.on_channel_update(chan)
|
await self.lnworker.handle_onchain_state(chan)
|
||||||
|
|
||||||
@log_exceptions
|
@log_exceptions
|
||||||
async def do_breach_remedy(self, funding_outpoint, closing_tx, spenders):
|
async def do_breach_remedy(self, funding_outpoint, closing_tx, spenders):
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ class LNGossip(LNWorker):
|
|||||||
orphaned_ids = [c['short_channel_id'] for c in orphaned]
|
orphaned_ids = [c['short_channel_id'] for c in orphaned]
|
||||||
await self.add_new_ids(orphaned_ids)
|
await self.add_new_ids(orphaned_ids)
|
||||||
if categorized_chan_upds.good:
|
if categorized_chan_upds.good:
|
||||||
self.logger.debug(f'on_channel_update: {len(categorized_chan_upds.good)}/{len(chan_upds)}')
|
self.logger.debug(f'process_gossip: {len(categorized_chan_upds.good)}/{len(chan_upds)}')
|
||||||
|
|
||||||
|
|
||||||
class LNWallet(LNWorker):
|
class LNWallet(LNWorker):
|
||||||
@@ -985,7 +985,7 @@ class LNWallet(LNWorker):
|
|||||||
if chan.funding_outpoint.to_str() == txo:
|
if chan.funding_outpoint.to_str() == txo:
|
||||||
return chan
|
return chan
|
||||||
|
|
||||||
async def on_channel_update(self, chan: Channel):
|
async def handle_onchain_state(self, chan: Channel):
|
||||||
if type(chan) is ChannelBackup:
|
if type(chan) is ChannelBackup:
|
||||||
util.trigger_callback('channel', self.wallet, chan)
|
util.trigger_callback('channel', self.wallet, chan)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user