Skip to content

Commit 62d86f7

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 969b508 commit 62d86f7

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
@@ -3036,11 +3036,12 @@ where
30363036
msg, &self.node_signer, &self.logger, &self.secp_ctx
30373037
)?;
30383038

3039-
let is_blinded = match next_hop {
3039+
let is_intro_node_forward = match next_hop {
30403040
onion_utils::Hop::Forward {
3041+
// TODO: update this when we support blinded forwarding as non-intro node
30413042
next_hop_data: msgs::InboundOnionPayload::BlindedForward { .. }, ..
30423043
} => true,
3043-
_ => false, // TODO: update this when we support receiving to multi-hop blinded paths
3044+
_ => false,
30443045
};
30453046

30463047
macro_rules! return_err {
@@ -3050,7 +3051,17 @@ where
30503051
WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id)),
30513052
"Failed to accept/forward incoming HTLC: {}", $msg
30523053
);
3053-
let (err_code, err_data) = if is_blinded {
3054+
// If `msg.blinding_point` is set, we must always fail with malformed.
3055+
if msg.blinding_point.is_some() {
3056+
return Err(HTLCFailureMsg::Malformed(msgs::UpdateFailMalformedHTLC {
3057+
channel_id: msg.channel_id,
3058+
htlc_id: msg.htlc_id,
3059+
sha256_of_onion: [0; 32],
3060+
failure_code: INVALID_ONION_BLINDING,
3061+
}));
3062+
}
3063+
3064+
let (err_code, err_data) = if is_intro_node_forward {
30543065
(INVALID_ONION_BLINDING, &[0; 32][..])
30553066
} else { ($err_code, $data) };
30563067
return Err(HTLCFailureMsg::Relay(msgs::UpdateFailHTLC {

0 commit comments

Comments
 (0)