]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove bogus mon_update_id += 1 fulfilling already-fulfilled HTLCs
authorMatt Corallo <git@bluematt.me>
Thu, 19 Mar 2020 01:10:22 +0000 (21:10 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 19 Mar 2020 23:20:27 +0000 (19:20 -0400)
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

index a9565af9e06baf013a33384561e1bf1c12fc827a..b4c0a90cb3964e3cf99ae3d857ad5d4d4e04346b 100644 (file)
@@ -1200,6 +1200,8 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                                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));
                                                }
                                        },