Skip to content

Commit 8cad2ff

Browse files
committed
Sync get_update_fail_htlc, get_update_fulfill_htlc state err result
Both get_update_fail_htlc and get_update_fulfill_htlc should never be called before any HTLC could have been accepted (ie pre-ChannelFunded) nor should they ever be called post-ShutdownComplete as the Channel object should be destroyed at that point. Previously get_update_fulfill_htlc would panic, but get_update_fail_htlc would return an Err. For now make them both panic but we can revisit this if we want to have fewer panics in the future.
1 parent 673912e commit 8cad2ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ impl Channel {
10941094

10951095
pub fn get_update_fail_htlc(&mut self, payment_hash_arg: &[u8; 32], err_packet: msgs::OnionErrorPacket) -> Result<Option<msgs::UpdateFailHTLC>, HandleError> {
10961096
if (self.channel_state & (ChannelState::ChannelFunded as u32)) != (ChannelState::ChannelFunded as u32) {
1097-
return Err(HandleError{err: "Was asked to fail an HTLC when channel was not in an operational state", action: None});
1097+
panic!("Was asked to fail an HTLC when channel was not in an operational state");
10981098
}
10991099
assert_eq!(self.channel_state & ChannelState::ShutdownComplete as u32, 0);
11001100

0 commit comments

Comments
 (0)