@@ -61,7 +61,7 @@ use crate::routing::router::{BlindedTail, FixedRouter, InFlightHtlcs, Path, Paye
6161use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, InboundHTLCErr, NextPacketDetails};
6262use crate::ln::msgs;
6363use crate::ln::onion_utils;
64- use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
64+ use crate::ln::onion_utils::{Hop, HTLCFailReason, INVALID_ONION_BLINDING};
6565use crate::ln::msgs::{ChannelMessageHandler, CommitmentUpdate, DecodeError, LightningError};
6666#[cfg(test)]
6767use crate::ln::outbound_payment;
@@ -4427,27 +4427,16 @@ where
44274427 }
44284428 }
44294429 match decoded_hop {
4430- onion_utils::Hop::Receive(next_hop_data) => {
4431- // OUR PAYMENT!
4432- let current_height: u32 = self.best_block.read().unwrap().height;
4433- match create_recv_pending_htlc_info(msgs::InboundOnionPayload::Receive(next_hop_data), shared_secret, msg.payment_hash,
4434- msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
4435- current_height)
4436- {
4437- Ok(info) => {
4438- // Note that we could obviously respond immediately with an update_fulfill_htlc
4439- // message, however that would leak that we are the recipient of this payment, so
4440- // instead we stay symmetric with the forwarding case, only responding (after a
4441- // delay) once they've send us a commitment_signed!
4442- PendingHTLCStatus::Forward(info)
4443- },
4444- Err(InboundHTLCErr { err_code, err_data, msg }) => return_err!(msg, err_code, &err_data)
4445- }
4446- },
4447- onion_utils::Hop::BlindedReceive(next_hop_data) => {
4430+ onion_utils::Hop::Receive { .. } | onion_utils::Hop::BlindedReceive { .. } => {
4431+ let inbound_onion_payload = match decoded_hop {
4432+ Hop::Receive { hop_data, .. } => msgs::InboundOnionPayload::Receive(hop_data),
4433+ Hop::BlindedReceive { hop_data, .. } => msgs::InboundOnionPayload::BlindedReceive(hop_data),
4434+ _ => unreachable!()
4435+ };
4436+
44484437 // OUR PAYMENT!
44494438 let current_height: u32 = self.best_block.read().unwrap().height;
4450- match create_recv_pending_htlc_info(msgs::InboundOnionPayload::BlindedReceive(next_hop_data) , shared_secret, msg.payment_hash,
4439+ match create_recv_pending_htlc_info(inbound_onion_payload , shared_secret, msg.payment_hash,
44514440 msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
44524441 current_height)
44534442 {
@@ -4461,14 +4450,14 @@ where
44614450 Err(InboundHTLCErr { err_code, err_data, msg }) => return_err!(msg, err_code, &err_data)
44624451 }
44634452 },
4464- onion_utils::Hop::Forward { next_hop_data, next_hop_hmac, new_packet_bytes } => {
4453+ onion_utils::Hop::Forward { next_hop_data, next_hop_hmac, new_packet_bytes, .. } => {
44654454 match create_fwd_pending_htlc_info(msg, msgs::InboundOnionPayload::Forward(next_hop_data), next_hop_hmac,
44664455 new_packet_bytes, shared_secret, next_packet_pubkey_opt) {
44674456 Ok(info) => PendingHTLCStatus::Forward(info),
44684457 Err(InboundHTLCErr { err_code, err_data, msg }) => return_err!(msg, err_code, &err_data)
44694458 }
44704459 },
4471- onion_utils::Hop::BlindedForward { next_hop_data, next_hop_hmac, new_packet_bytes } => {
4460+ onion_utils::Hop::BlindedForward { next_hop_data, next_hop_hmac, new_packet_bytes, .. } => {
44724461 match create_fwd_pending_htlc_info(msg, msgs::InboundOnionPayload::BlindedForward(next_hop_data), next_hop_hmac,
44734462 new_packet_bytes, shared_secret, next_packet_pubkey_opt) {
44744463 Ok(info) => PendingHTLCStatus::Forward(info),
@@ -5696,7 +5685,7 @@ where
56965685 let mut htlc_forwards = Vec::new();
56975686 let mut htlc_fails = Vec::new();
56985687 for update_add_htlc in &update_add_htlcs {
5699- let (next_hop, shared_secret, next_packet_details_opt) = match decode_incoming_update_add_htlc_onion(
5688+ let (next_hop, next_packet_details_opt) = match decode_incoming_update_add_htlc_onion(
57005689 &update_add_htlc, &*self.node_signer, &*self.logger, &self.secp_ctx
57015690 ) {
57025691 Ok(decoded_onion) => decoded_onion,
@@ -5708,6 +5697,7 @@ where
57085697
57095698 let is_intro_node_blinded_forward = next_hop.is_intro_node_blinded_forward();
57105699 let outgoing_scid_opt = next_packet_details_opt.as_ref().map(|d| d.outgoing_scid);
5700+ let shared_secret = next_hop.shared_secret().secret_bytes();
57115701
57125702 // Process the HTLC on the incoming channel.
57135703 match self.do_funded_channel_callback(incoming_scid, |chan: &mut FundedChannel<SP>| {
@@ -5868,8 +5858,8 @@ where
58685858 if phantom_pubkey_res.is_ok() && fake_scid::is_valid_phantom(&self.fake_scid_rand_bytes, short_chan_id, &self.chain_hash) {
58695859 let phantom_shared_secret = self.node_signer.ecdh(Recipient::PhantomNode, &onion_packet.public_key.unwrap(), None).unwrap().secret_bytes();
58705860 let next_hop = match onion_utils::decode_next_payment_hop(
5871- phantom_shared_secret , &onion_packet.hop_data, onion_packet.hmac ,
5872- payment_hash, None, &*self.node_signer
5861+ Recipient::PhantomNode , &onion_packet.public_key.unwrap(), & onion_packet.hop_data ,
5862+ onion_packet.hmac, payment_hash, None, &*self.node_signer
58735863 ) {
58745864 Ok(res) => res,
58755865 Err(onion_utils::OnionDecodeErr::Malformed { err_msg, err_code }) => {
@@ -5885,8 +5875,8 @@ where
58855875 },
58865876 };
58875877 let inbound_onion_payload = match next_hop {
5888- onion_utils::Hop::Receive( hop_data) => msgs::InboundOnionPayload::Receive(hop_data),
5889- onion_utils::Hop::BlindedReceive( hop_data) => msgs::InboundOnionPayload::BlindedReceive(hop_data),
5878+ onion_utils::Hop::Receive { hop_data, .. } => msgs::InboundOnionPayload::Receive(hop_data),
5879+ onion_utils::Hop::BlindedReceive { hop_data, .. } => msgs::InboundOnionPayload::BlindedReceive(hop_data),
58905880 _ => panic!()
58915881 };
58925882 let current_height: u32 = self.best_block.read().unwrap().height;
0 commit comments