Merge pull request #130 from TheBlueMatt/2018-08-fuzz-fixes-6
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Sun, 26 Aug 2018 19:36:58 +0000 (15:36 -0400)
committerGitHub <noreply@github.com>
Sun, 26 Aug 2018 19:36:58 +0000 (15:36 -0400)
 Fix crash introduced in #124

src/ln/channel.rs
src/ln/channelmanager.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 {
index 20e6f3739ec63ee3eee62715cd21bb8a21f4805e..a360c376a16282f450c2b7b8dc62f10547e89f98 100644 (file)
@@ -2256,7 +2256,6 @@ mod tests {
                chain_monitor: Arc<chaininterface::ChainWatchInterfaceUtil>,
                tx_broadcaster: Arc<test_utils::TestBroadcaster>,
                chan_monitor: Arc<test_utils::TestChannelMonitor>,
-               node_id: SecretKey,
                node: Arc<ChannelManager>,
                router: Router,
        }
@@ -2803,7 +2802,7 @@ mod tests {
                        };
                        let node = ChannelManager::new(node_id.clone(), 0, true, Network::Testnet, feeest.clone(), chan_monitor.clone(), chain_monitor.clone(), tx_broadcaster.clone(), Arc::clone(&logger)).unwrap();
                        let router = Router::new(PublicKey::from_secret_key(&secp_ctx, &node_id), Arc::clone(&logger));
-                       nodes.push(Node { feeest, chain_monitor, tx_broadcaster, chan_monitor, node_id, node, router });
+                       nodes.push(Node { feeest, chain_monitor, tx_broadcaster, chan_monitor, node, router });
                }
 
                nodes