Skip to content

Commit ea6a93b

Browse files
Add redundant blinded HTLC failure check for posterity.
Although this new check is unreachable right now, it helps prevent potential future errors where we incorrectly fail blinded HTLCs with an unblinded error.
1 parent dd4eaca commit ea6a93b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lightning/src/ln/channelmanager.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -3025,11 +3025,12 @@ where
30253025
msg, &self.node_signer, &self.logger, &self.secp_ctx
30263026
)?;
30273027

3028-
let is_blinded = match next_hop {
3028+
let is_intro_node_forward = match next_hop {
30293029
onion_utils::Hop::Forward {
3030+
// TODO: update this when we support blinded forwarding as non-intro node
30303031
next_hop_data: msgs::InboundOnionPayload::BlindedForward { .. }, ..
30313032
} => true,
3032-
_ => false, // TODO: update this when we support receiving to multi-hop blinded paths
3033+
_ => false,
30333034
};
30343035

30353036
macro_rules! return_err {
@@ -3039,7 +3040,17 @@ where
30393040
WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id)),
30403041
"Failed to accept/forward incoming HTLC: {}", $msg
30413042
);
3042-
let (err_code, err_data) = if is_blinded {
3043+
// If `msg.blinding_point` is set, we must always fail with malformed.
3044+
if msg.blinding_point.is_some() {
3045+
return Err(HTLCFailureMsg::Malformed(msgs::UpdateFailMalformedHTLC {
3046+
channel_id: msg.channel_id,
3047+
htlc_id: msg.htlc_id,
3048+
sha256_of_onion: [0; 32],
3049+
failure_code: INVALID_ONION_BLINDING,
3050+
}));
3051+
}
3052+
3053+
let (err_code, err_data) = if is_intro_node_forward {
30433054
(INVALID_ONION_BLINDING, &[0; 32][..])
30443055
} else { ($err_code, $data) };
30453056
return Err(HTLCFailureMsg::Relay(msgs::UpdateFailHTLC {

0 commit comments

Comments
 (0)