Skip to content

Commit 9b89b7e

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 7c5dafa commit 9b89b7e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,11 +2985,12 @@ where
29852985
msg, &self.node_signer, &self.logger, &self.secp_ctx
29862986
)?;
29872987

2988-
let is_blinded = match next_hop {
2988+
let is_intro_node_forward = match next_hop {
29892989
onion_utils::Hop::Forward {
2990+
// TODO: update this when we support blinded forwarding as non-intro node
29902991
next_hop_data: msgs::InboundOnionPayload::BlindedForward { .. }, ..
29912992
} => true,
2992-
_ => false, // TODO: update this when we support receiving to multi-hop blinded paths
2993+
_ => false,
29932994
};
29942995

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

0 commit comments

Comments
 (0)