From 7f1b456b93fa2f09a7eca3ada31082331ea7ecb7 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 5 Aug 2019 17:47:42 +0200 Subject: [PATCH] lnhtlc.discard_unsigned_remote_updates: fix edge case --- electrum/lnhtlc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/electrum/lnhtlc.py b/electrum/lnhtlc.py index c9b4bde50..296c63fe9 100644 --- a/electrum/lnhtlc.py +++ b/electrum/lnhtlc.py @@ -181,12 +181,16 @@ class HTLCManager: """Discard updates sent by the remote, that the remote itself did not yet sign (i.e. there was no corresponding commitment_signed msg) """ - # htlcs + # htlcs added for htlc_id, ctns in list(self.log[REMOTE]['locked_in'].items()): if ctns[LOCAL] > self.ctn_latest(LOCAL): del self.log[REMOTE]['locked_in'][htlc_id] del self.log[REMOTE]['adds'][htlc_id] - self.log[REMOTE]['next_htlc_id'] = max(self.log[REMOTE]['locked_in']) + 1 + if self.log[REMOTE]['locked_in']: + self.log[REMOTE]['next_htlc_id'] = max(self.log[REMOTE]['locked_in']) + 1 + else: + self.log[REMOTE]['next_htlc_id'] = 0 + # htlcs removed for log_action in ('settles', 'fails'): for htlc_id, ctns in list(self.log[LOCAL][log_action].items()): if ctns[LOCAL] > self.ctn_latest(LOCAL):