@@ -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::{
@@ -6851,6 +6851,7 @@ where
68516851 pub(crate) fn process_pending_update_add_htlcs(&self) -> bool {
68526852 let mut should_persist = false;
68536853 let mut decode_update_add_htlcs = new_hash_map();
6854+ let mut dummy_update_add_htlcs = new_hash_map();
68546855 mem::swap(&mut decode_update_add_htlcs, &mut self.decode_update_add_htlcs.lock().unwrap());
68556856
68566857 let get_htlc_failure_type = |outgoing_scid_opt: Option<u64>, payment_hash: PaymentHash| {
@@ -6914,7 +6915,39 @@ where
69146915 &*self.logger,
69156916 &self.secp_ctx,
69166917 ) {
6917- Ok(decoded_onion) => decoded_onion,
6918+ Ok(decoded_onion) => match decoded_onion {
6919+ (
6920+ onion_utils::Hop::Dummy {
6921+ intro_node_blinding_point,
6922+ next_hop_hmac,
6923+ new_packet_bytes,
6924+ ..
6925+ },
6926+ Some(NextPacketDetails { next_packet_pubkey, forward_info }),
6927+ ) => {
6928+ debug_assert!(
6929+ forward_info.is_none(),
6930+ "Dummy hops must not contain any forward info, since they are not actually forwarded."
6931+ );
6932+ let new_update_add_htlc = create_new_update_add_htlc(
6933+ update_add_htlc.clone(),
6934+ &*self.node_signer,
6935+ &self.secp_ctx,
6936+ intro_node_blinding_point,
6937+ next_packet_pubkey,
6938+ next_hop_hmac,
6939+ new_packet_bytes,
6940+ );
6941+
6942+ dummy_update_add_htlcs
6943+ .entry(incoming_scid_alias)
6944+ .or_insert_with(Vec::new)
6945+ .push(new_update_add_htlc);
6946+
6947+ continue;
6948+ },
6949+ _ => decoded_onion,
6950+ },
69186951
69196952 Err((htlc_fail, reason)) => {
69206953 let failure_type = HTLCHandlingFailureType::InvalidOnion;
@@ -7071,6 +7104,11 @@ where
70717104 ));
70727105 }
70737106 }
7107+
7108+ // Replace the decode queue with the peeled dummy HTLCs so they can be processed in the next iteration.
7109+ let mut decode_update_add_htlc_source = self.decode_update_add_htlcs.lock().unwrap();
7110+ mem::swap(&mut *decode_update_add_htlc_source, &mut dummy_update_add_htlcs);
7111+
70747112 should_persist
70757113 }
70767114
0 commit comments