Skip to content

Commit 4ba8338

Browse files
committed
Construct from-message HTLCFailReason via a constructor method
1 parent fe3cf29 commit 4ba8338

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ impl HTLCFailReason {
309309
Self::Reason { failure_code, data: Vec::new() }
310310
}
311311

312+
pub(super) fn from_msg(msg: &msgs::UpdateFailHTLC) -> Self {
313+
Self::LightningError { err: msg.reason.clone() }
314+
}
315+
312316
fn get_encrypted_failure_packet(&self, incoming_packet_shared_secret: &[u8; 32], phantom_shared_secret: &Option<[u8; 32]>) -> msgs::OnionErrorPacket {
313317
match self {
314318
HTLCFailReason::Reason { ref failure_code, ref data } => {
@@ -5125,7 +5129,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
51255129
if chan.get().get_counterparty_node_id() != *counterparty_node_id {
51265130
return Err(MsgHandleErrInternal::send_err_msg_no_close("Got a message for a channel from the wrong node!".to_owned(), msg.channel_id));
51275131
}
5128-
try_chan_entry!(self, chan.get_mut().update_fail_htlc(&msg, HTLCFailReason::LightningError { err: msg.reason.clone() }), chan);
5132+
try_chan_entry!(self, chan.get_mut().update_fail_htlc(&msg, HTLCFailReason::from_msg(msg)), chan);
51295133
},
51305134
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close("Failed to find corresponding channel".to_owned(), msg.channel_id))
51315135
}

0 commit comments

Comments
 (0)