From: Matt Corallo Date: Thu, 19 Mar 2020 01:10:22 +0000 (-0400) Subject: Remove bogus mon_update_id += 1 fulfilling already-fulfilled HTLCs X-Git-Tag: v0.0.12~98^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=32d62ada96faab954bbcee4fc5d9ec58d2eff482;p=rust-lightning 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. --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index a9565af9e..b4c0a90cb 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)); } },