Skip to content

Commit c6d549e

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 348162b commit c6d549e

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
@@ -2986,11 +2986,12 @@ where
29862986
msg, &self.node_signer, &self.logger, &self.secp_ctx
29872987
)?;
29882988

2989-
let is_blinded = match next_hop {
2989+
let is_intro_node_forward = match next_hop {
29902990
onion_utils::Hop::Forward {
2991+
// TODO: update this when we support blinded forwarding as non-intro node
29912992
next_hop_data: msgs::InboundOnionPayload::BlindedForward { .. }, ..
29922993
} => true,
2993-
_ => false, // TODO: update this when we support receiving to multi-hop blinded paths
2994+
_ => false,
29942995
};
29952996

29962997
macro_rules! return_err {
@@ -3000,7 +3001,17 @@ where
30003001
WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id)),
30013002
"Failed to accept/forward incoming HTLC: {}", $msg
30023003
);
3003-
let (err_code, err_data) = if is_blinded {
3004+
// If `msg.blinding_point` is set, we must always fail with malformed.
3005+
if msg.blinding_point.is_some() {
3006+
return Err(HTLCFailureMsg::Malformed(msgs::UpdateFailMalformedHTLC {
3007+
channel_id: msg.channel_id,
3008+
htlc_id: msg.htlc_id,
3009+
sha256_of_onion: [0; 32],
3010+
failure_code: INVALID_ONION_BLINDING,
3011+
}));
3012+
}
3013+
3014+
let (err_code, err_data) = if is_intro_node_forward {
30043015
(INVALID_ONION_BLINDING, &[0; 32][..])
30053016
} else { ($err_code, $data) };
30063017
return Err(HTLCFailureMsg::Relay(msgs::UpdateFailHTLC {

0 commit comments

Comments
 (0)