Skip to content

Commit c91c4be

Browse files
authored
Merge pull request #139 from TheBlueMatt/2018-08-fuzz-fixes-7
Fix crash that #127 intended to fix but did not completely fix
2 parents a1aaea5 + 3fbbd9e commit c91c4be

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/ln/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,6 @@ impl Channel {
11331133
let mut htlc_amount_msat = 0;
11341134
for htlc in self.pending_htlcs.iter_mut() {
11351135
if !htlc.outbound && htlc.payment_hash == *payment_hash_arg {
1136-
if htlc_id != 0 {
1137-
panic!("Duplicate HTLC payment_hash, you probably re-used payment preimages, NEVER DO THIS!");
1138-
}
11391136
if htlc.state == HTLCState::Committed {
11401137
htlc.state = HTLCState::LocalRemoved;
11411138
} else if htlc.state == HTLCState::RemoteAnnounced {
@@ -1152,6 +1149,9 @@ impl Channel {
11521149
} else {
11531150
panic!("Have an inbound HTLC when not awaiting remote revoke that had a garbage state");
11541151
}
1152+
if htlc_id != 0 {
1153+
panic!("Duplicate HTLC payment_hash, you probably re-used payment preimages, NEVER DO THIS!");
1154+
}
11551155
htlc_id = htlc.htlc_id;
11561156
htlc_amount_msat += htlc.amount_msat;
11571157
}

src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,6 @@ mod tests {
22742274
}
22752275

22762276
struct Node {
2277-
feeest: Arc<test_utils::TestFeeEstimator>,
22782277
chain_monitor: Arc<chaininterface::ChainWatchInterfaceUtil>,
22792278
tx_broadcaster: Arc<test_utils::TestBroadcaster>,
22802279
chan_monitor: Arc<test_utils::TestChannelMonitor>,
@@ -2827,7 +2826,7 @@ mod tests {
28272826
};
28282827
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();
28292828
let router = Router::new(PublicKey::from_secret_key(&secp_ctx, &node_id), Arc::clone(&logger));
2830-
nodes.push(Node { feeest, chain_monitor, tx_broadcaster, chan_monitor, node, router });
2829+
nodes.push(Node { chain_monitor, tx_broadcaster, chan_monitor, node, router });
28312830
}
28322831

28332832
nodes

0 commit comments

Comments
 (0)