@@ -72,9 +72,9 @@ use crate::ln::msgs::{
7272 MessageSendEvent,
7373};
7474use crate::ln::onion_payment::{
75- check_incoming_htlc_cltv, create_fwd_pending_htlc_info, create_recv_pending_htlc_info ,
76- decode_incoming_update_add_htlc_onion, invalid_payment_err_data, ForwardInfo, HopConnector ,
77- InboundHTLCErr, NextPacketDetails,
75+ check_incoming_htlc_cltv, create_fwd_pending_htlc_info, create_new_update_add_htlc ,
76+ create_recv_pending_htlc_info, decode_incoming_update_add_htlc_onion, invalid_payment_err_data ,
77+ ForwardInfo, HopConnector, InboundHTLCErr, NextPacketDetails,
7878};
7979use crate::ln::onion_utils::{self};
8080use crate::ln::onion_utils::{
@@ -6852,6 +6852,7 @@ where
68526852 pub(crate) fn process_pending_update_add_htlcs(&self) -> bool {
68536853 let mut should_persist = false;
68546854 let mut decode_update_add_htlcs = new_hash_map();
6855+ let mut dummy_update_add_htlcs = new_hash_map();
68556856 mem::swap(&mut decode_update_add_htlcs, &mut self.decode_update_add_htlcs.lock().unwrap());
68566857
68576858 let get_htlc_failure_type = |outgoing_scid_opt: Option<u64>, payment_hash: PaymentHash| {
@@ -6915,7 +6916,39 @@ where
69156916 &*self.logger,
69166917 &self.secp_ctx,
69176918 ) {
6918- Ok(decoded_onion) => decoded_onion,
6919+ Ok(decoded_onion) => match decoded_onion {
6920+ (
6921+ onion_utils::Hop::Dummy {
6922+ intro_node_blinding_point,
6923+ next_hop_hmac,
6924+ new_packet_bytes,
6925+ ..
6926+ },
6927+ Some(NextPacketDetails { next_packet_pubkey, forward_info }),
6928+ ) => {
6929+ debug_assert!(
6930+ forward_info.is_none(),
6931+ "Dummy hops must not contain any forward info, since they are not actually forwarded."
6932+ );
6933+ let new_update_add_htlc = create_new_update_add_htlc(
6934+ update_add_htlc.clone(),
6935+ &*self.node_signer,
6936+ &self.secp_ctx,
6937+ intro_node_blinding_point,
6938+ next_packet_pubkey,
6939+ next_hop_hmac,
6940+ new_packet_bytes,
6941+ );
6942+
6943+ dummy_update_add_htlcs
6944+ .entry(incoming_scid_alias)
6945+ .or_insert_with(Vec::new)
6946+ .push(new_update_add_htlc);
6947+
6948+ continue;
6949+ },
6950+ _ => decoded_onion,
6951+ },
69196952
69206953 Err((htlc_fail, reason)) => {
69216954 let failure_type = HTLCHandlingFailureType::InvalidOnion;
@@ -7072,6 +7105,11 @@ where
70727105 ));
70737106 }
70747107 }
7108+
7109+ // Replace the decode queue with the peeled dummy HTLCs so they can be processed in the next iteration.
7110+ let mut decode_update_add_htlc_source = self.decode_update_add_htlcs.lock().unwrap();
7111+ mem::swap(&mut *decode_update_add_htlc_source, &mut dummy_update_add_htlcs);
7112+
70757113 should_persist
70767114 }
70777115
0 commit comments