Skip to content

Commit c299765

Browse files
valentinewallaceyellowred
authored andcommitted
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 c4ed064 commit c299765

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
@@ -3023,11 +3023,12 @@ where
30233023
msg, &self.node_signer, &self.logger, &self.secp_ctx
30243024
)?;
30253025

3026-
let is_blinded = match next_hop {
3026+
let is_intro_node_forward = match next_hop {
30273027
onion_utils::Hop::Forward {
3028+
// TODO: update this when we support blinded forwarding as non-intro node
30283029
next_hop_data: msgs::InboundOnionPayload::BlindedForward { .. }, ..
30293030
} => true,
3030-
_ => false, // TODO: update this when we support receiving to multi-hop blinded paths
3031+
_ => false,
30313032
};
30323033

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

0 commit comments

Comments
 (0)