Skip to content

Commit a33b3a2

Browse files
authored
Merge pull request #130 from TheBlueMatt/2018-08-fuzz-fixes-6
Fix crash introduced in #124
2 parents a66e597 + 32e2f7e commit a33b3a2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/ln/channel.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,10 +1018,13 @@ impl Channel {
10181018
for (idx, htlc) in self.pending_htlcs.iter().enumerate() {
10191019
if !htlc.outbound && htlc.payment_hash == payment_hash_calc &&
10201020
htlc.state != HTLCState::LocalRemoved && htlc.state != HTLCState::LocalRemovedAwaitingCommitment {
1021-
if pending_idx != std::usize::MAX {
1022-
panic!("Duplicate HTLC payment_hash, ChannelManager should have prevented this!");
1021+
if let Some(PendingHTLCStatus::Fail(_)) = htlc.pending_forward_state {
1022+
} else {
1023+
if pending_idx != std::usize::MAX {
1024+
panic!("Duplicate HTLC payment_hash, ChannelManager should have prevented this!");
1025+
}
1026+
pending_idx = idx;
10231027
}
1024-
pending_idx = idx;
10251028
}
10261029
}
10271030
if pending_idx == std::usize::MAX {

src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,6 @@ mod tests {
22562256
chain_monitor: Arc<chaininterface::ChainWatchInterfaceUtil>,
22572257
tx_broadcaster: Arc<test_utils::TestBroadcaster>,
22582258
chan_monitor: Arc<test_utils::TestChannelMonitor>,
2259-
node_id: SecretKey,
22602259
node: Arc<ChannelManager>,
22612260
router: Router,
22622261
}
@@ -2803,7 +2802,7 @@ mod tests {
28032802
};
28042803
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();
28052804
let router = Router::new(PublicKey::from_secret_key(&secp_ctx, &node_id), Arc::clone(&logger));
2806-
nodes.push(Node { feeest, chain_monitor, tx_broadcaster, chan_monitor, node_id, node, router });
2805+
nodes.push(Node { feeest, chain_monitor, tx_broadcaster, chan_monitor, node, router });
28072806
}
28082807

28092808
nodes

0 commit comments

Comments
 (0)