Fix crash introduced in #124
[rust-lightning] / src / ln / channel.rs
index 47c05de2ab989ab69c00a8f219efb63adebb527a..d6e23a2839274fc5b84ecbc0e7e2d870469bbb0d 100644 (file)
@@ -1018,10 +1018,13 @@ impl Channel {
                for (idx, htlc) in self.pending_htlcs.iter().enumerate() {
                        if !htlc.outbound && htlc.payment_hash == payment_hash_calc &&
                                        htlc.state != HTLCState::LocalRemoved && htlc.state != HTLCState::LocalRemovedAwaitingCommitment {
-                               if pending_idx != std::usize::MAX {
-                                       panic!("Duplicate HTLC payment_hash, ChannelManager should have prevented this!");
+                               if let Some(PendingHTLCStatus::Fail(_)) = htlc.pending_forward_state {
+                               } else {
+                                       if pending_idx != std::usize::MAX {
+                                               panic!("Duplicate HTLC payment_hash, ChannelManager should have prevented this!");
+                                       }
+                                       pending_idx = idx;
                                }
-                               pending_idx = idx;
                        }
                }
                if pending_idx == std::usize::MAX {