From 32d62ada96faab954bbcee4fc5d9ec58d2eff482 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 18 Mar 2020 21:10:22 -0400 Subject: [PATCH] Remove bogus mon_update_id += 1 fulfilling already-fulfilled HTLCs If we call get_update_fulfill_htlc (in this case via ChannelManager::claim_funds_internal -> Channel::get_update_fulfill_htlc_and_commit) and it finds that we already have a holding-cell pending HTLC claim, it will return no monitor update but leave latest_monitor_update_id incremented. If we later go and add a new monitor update we'll panic as the updates appear to have been applied out-of-order. --- lightning/src/ln/channel.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index a9565af9..b4c0a90c 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -1200,6 +1200,8 @@ impl Channel { match pending_update { &HTLCUpdateAwaitingACK::ClaimHTLC { htlc_id, .. } => { if htlc_id_arg == htlc_id { + // Make sure we don't leave latest_monitor_update_id incremented here: + self.latest_monitor_update_id -= 1; return Ok((None, None)); } }, -- 2.30.2