mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 23:08:36 +01:00
Fix crash introduced in #124
I'm rapidly starting to regret holding failed HTLCs in Channel, given we allow them to violate the no-duplicate-hashes precondition. Found by fuzzer
This commit is contained in:
parent
a66e597e95
commit
4f77c812a4
1 changed files with 6 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue