@@ -167,6 +167,18 @@ pub struct BlindedForward {
167167 // Another field will be added here when we support forwarding as a non-intro node.
168168}
169169
170+ impl PendingHTLCRouting {
171+ // Used to override the onion failure code and data if the HTLC is blinded.
172+ fn blinded_failure(&self) -> Option<BlindedFailure> {
173+ // TODO: needs update when we support receiving to multi-hop blinded paths
174+ if let Self::Forward { blinded: Some(_), .. } = self {
175+ Some(BlindedFailure::FromIntroductionNode)
176+ } else {
177+ None
178+ }
179+ }
180+ }
181+
170182/// Full details of an incoming HTLC, including routing info.
171183#[derive(Clone)] // See Channel::revoke_and_ack for why, tl;dr: Rust bug
172184pub struct PendingHTLCInfo {
@@ -4080,7 +4092,7 @@ where
40804092 htlc_id: payment.prev_htlc_id,
40814093 incoming_packet_shared_secret: payment.forward_info.incoming_shared_secret,
40824094 phantom_shared_secret: None,
4083- blinded_failure: None ,
4095+ blinded_failure: payment.forward_info.routing.blinded_failure() ,
40844096 });
40854097
40864098 let failure_reason = HTLCFailReason::from_failure_code(0x4000 | 10);
@@ -4129,7 +4141,7 @@ where
41294141 htlc_id: prev_htlc_id,
41304142 incoming_packet_shared_secret: incoming_shared_secret,
41314143 phantom_shared_secret: $phantom_ss,
4132- blinded_failure: None ,
4144+ blinded_failure: routing.blinded_failure() ,
41334145 });
41344146
41354147 let reason = if $next_hop_unknown {
@@ -4159,7 +4171,7 @@ where
41594171 }
41604172 }
41614173 }
4162- if let PendingHTLCRouting::Forward { onion_packet, .. } = routing {
4174+ if let PendingHTLCRouting::Forward { ref onion_packet, .. } = routing {
41634175 let phantom_pubkey_res = self.node_signer.get_node_id(Recipient::PhantomNode);
41644176 if phantom_pubkey_res.is_ok() && fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, short_chan_id, &self.chain_hash) {
41654177 let phantom_shared_secret = self.node_signer.ecdh(Recipient::PhantomNode, &onion_packet.public_key.unwrap(), None).unwrap().secret_bytes();
@@ -4234,7 +4246,9 @@ where
42344246 prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
42354247 forward_info: PendingHTLCInfo {
42364248 incoming_shared_secret, payment_hash, outgoing_amt_msat, outgoing_cltv_value,
4237- routing: PendingHTLCRouting::Forward { onion_packet, .. }, skimmed_fee_msat, ..
4249+ routing: PendingHTLCRouting::Forward {
4250+ onion_packet, blinded, ..
4251+ }, skimmed_fee_msat, ..
42384252 },
42394253 }) => {
42404254 log_trace!(self.logger, "Adding HTLC from short id {} with payment_hash {} to channel with short id {} after delay", prev_short_channel_id, &payment_hash, short_chan_id);
@@ -4246,7 +4260,7 @@ where
42464260 incoming_packet_shared_secret: incoming_shared_secret,
42474261 // Phantom payments are only PendingHTLCRouting::Receive.
42484262 phantom_shared_secret: None,
4249- blinded_failure: None ,
4263+ blinded_failure: blinded.map(|_| BlindedFailure::FromIntroductionNode) ,
42504264 });
42514265 if let Err(e) = chan.queue_add_htlc(outgoing_amt_msat,
42524266 payment_hash, outgoing_cltv_value, htlc_source.clone(),
@@ -4301,6 +4315,7 @@ where
43014315 skimmed_fee_msat, ..
43024316 }
43034317 }) => {
4318+ let blinded_failure = routing.blinded_failure();
43044319 let (cltv_expiry, onion_payload, payment_data, phantom_shared_secret, mut onion_fields) = match routing {
43054320 PendingHTLCRouting::Receive { payment_data, payment_metadata, incoming_cltv_expiry, phantom_shared_secret, custom_tlvs } => {
43064321 let _legacy_hop_data = Some(payment_data.clone());
@@ -4330,7 +4345,7 @@ where
43304345 htlc_id: prev_htlc_id,
43314346 incoming_packet_shared_secret: incoming_shared_secret,
43324347 phantom_shared_secret,
4333- blinded_failure: None ,
4348+ blinded_failure,
43344349 },
43354350 // We differentiate the received value from the sender intended value
43364351 // if possible so that we don't prematurely mark MPP payments complete
@@ -6611,7 +6626,7 @@ where
66116626 htlc_id: prev_htlc_id,
66126627 incoming_packet_shared_secret: forward_info.incoming_shared_secret,
66136628 phantom_shared_secret: None,
6614- blinded_failure: None ,
6629+ blinded_failure: forward_info.routing.blinded_failure() ,
66156630 });
66166631
66176632 failed_intercept_forwards.push((htlc_source, forward_info.payment_hash,
@@ -8208,7 +8223,7 @@ where
82088223 incoming_packet_shared_secret: htlc.forward_info.incoming_shared_secret,
82098224 phantom_shared_secret: None,
82108225 outpoint: htlc.prev_funding_outpoint,
8211- blinded_failure: None ,
8226+ blinded_failure: htlc.forward_info.routing.blinded_failure() ,
82128227 });
82138228
82148229 let requested_forward_scid /* intercept scid */ = match htlc.forward_info.routing {
0 commit comments