@@ -2881,11 +2881,14 @@ where
2881
2881
macro_rules! return_malformed_err {
2882
2882
($msg: expr, $err_code: expr) => {
2883
2883
{
2884
+ let sha256_of_onion = if msg.blinding_point.is_some() { [0; 32] } else {
2885
+ Sha256::hash(&msg.onion_routing_packet.hop_data).into_inner()
2886
+ };
2884
2887
log_info!(self.logger, "Failed to accept/forward incoming HTLC: {}", $msg);
2885
2888
return Err(HTLCFailureMsg::Malformed(msgs::UpdateFailMalformedHTLC {
2886
2889
channel_id: msg.channel_id,
2887
2890
htlc_id: msg.htlc_id,
2888
- sha256_of_onion: Sha256::hash(&msg.onion_routing_packet.hop_data).into_inner() ,
2891
+ sha256_of_onion,
2889
2892
failure_code: $err_code,
2890
2893
}));
2891
2894
}
@@ -2929,6 +2932,15 @@ where
2929
2932
}
2930
2933
}
2931
2934
}
2935
+ macro_rules! return_blinded_htlc_err {
2936
+ ($msg: expr) => {
2937
+ if msg.blinding_point.is_some() {
2938
+ return_malformed_err!($msg, INVALID_ONION_BLINDING);
2939
+ } else {
2940
+ return_err!($msg, INVALID_ONION_BLINDING, [0; 32]);
2941
+ }
2942
+ }
2943
+ }
2932
2944
2933
2945
let next_hop = match onion_utils::decode_next_payment_hop(shared_secret,
2934
2946
&msg.onion_routing_packet.hop_data[..], msg.onion_routing_packet.hmac, msg.payment_hash,
@@ -2952,13 +2964,22 @@ where
2952
2964
msg.onion_routing_packet.public_key.unwrap(), &shared_secret);
2953
2965
(short_channel_id, amt_to_forward, outgoing_cltv_value, Some(next_packet_pk))
2954
2966
},
2967
+ onion_utils::Hop::Forward {
2968
+ next_hop_data: msgs::InboundOnionPayload::BlindedForward { .. }, ..
2969
+ } => {
2970
+ return_blinded_htlc_err!("Forwarding blinded HTLCs is not supported yet");
2971
+ },
2955
2972
// We'll do receive checks in [`Self::construct_pending_htlc_info`] so we have access to the
2956
2973
// inbound channel's state.
2957
2974
onion_utils::Hop::Receive { .. } => return Ok((next_hop, shared_secret, None)),
2958
2975
onion_utils::Hop::Forward { next_hop_data: msgs::InboundOnionPayload::Receive { .. }, .. } => {
2959
2976
return_err!("Final Node OnionHopData provided for us as an intermediary node", 0x4000 | 22, &[0; 0]);
2960
2977
},
2961
- _ => todo!()
2978
+ onion_utils::Hop::Forward {
2979
+ next_hop_data: msgs::InboundOnionPayload::BlindedReceive { .. }, ..
2980
+ } => {
2981
+ return_blinded_htlc_err!("Blinded final node onion provided for us as an intermediary node");
2982
+ }
2962
2983
};
2963
2984
2964
2985
// Perform outbound checks here instead of in [`Self::construct_pending_htlc_info`] because we
0 commit comments