@@ -71,9 +71,9 @@ use crate::ln::msgs::{
7171 MessageSendEvent,
7272};
7373use crate::ln::onion_payment::{
74- check_incoming_htlc_cltv, create_fwd_pending_htlc_info, create_recv_pending_htlc_info ,
75- decode_incoming_update_add_htlc_onion, invalid_payment_err_data, ForwardInfo, HopConnector ,
76- InboundHTLCErr, NextPacketDetails,
74+ check_incoming_htlc_cltv, create_fwd_pending_htlc_info, create_new_update_add_htlc ,
75+ create_recv_pending_htlc_info, decode_incoming_update_add_htlc_onion, invalid_payment_err_data ,
76+ ForwardInfo, HopConnector, InboundHTLCErr, NextPacketDetails,
7777};
7878use crate::ln::onion_utils::{self};
7979use crate::ln::onion_utils::{
@@ -6550,6 +6550,7 @@ where
65506550 pub(crate) fn process_pending_update_add_htlcs(&self) -> bool {
65516551 let mut should_persist = false;
65526552 let mut decode_update_add_htlcs = new_hash_map();
6553+ let mut dummy_update_add_htlcs = new_hash_map();
65536554 mem::swap(&mut decode_update_add_htlcs, &mut self.decode_update_add_htlcs.lock().unwrap());
65546555
65556556 let get_htlc_failure_type = |outgoing_scid_opt: Option<u64>, payment_hash: PaymentHash| {
@@ -6613,7 +6614,39 @@ where
66136614 &*self.logger,
66146615 &self.secp_ctx,
66156616 ) {
6616- Ok(decoded_onion) => decoded_onion,
6617+ Ok(decoded_onion) => match decoded_onion {
6618+ (
6619+ onion_utils::Hop::Dummy {
6620+ intro_node_blinding_point,
6621+ next_hop_hmac,
6622+ new_packet_bytes,
6623+ ..
6624+ },
6625+ Some(NextPacketDetails { next_packet_pubkey, forward_info }),
6626+ ) => {
6627+ debug_assert!(
6628+ forward_info.is_none(),
6629+ "Dummy hops must not contain any forward info, since they are not actually forwarded."
6630+ );
6631+ let new_update_add_htlc = create_new_update_add_htlc(
6632+ update_add_htlc.clone(),
6633+ &*self.node_signer,
6634+ &self.secp_ctx,
6635+ intro_node_blinding_point,
6636+ next_packet_pubkey,
6637+ next_hop_hmac,
6638+ new_packet_bytes,
6639+ );
6640+
6641+ dummy_update_add_htlcs
6642+ .entry(incoming_scid_alias)
6643+ .or_insert_with(Vec::new)
6644+ .push(new_update_add_htlc);
6645+
6646+ continue;
6647+ },
6648+ _ => decoded_onion,
6649+ },
66176650
66186651 Err((htlc_fail, reason)) => {
66196652 let failure_type = HTLCHandlingFailureType::InvalidOnion;
@@ -6770,6 +6803,11 @@ where
67706803 ));
67716804 }
67726805 }
6806+
6807+ // Replace the decode queue with the peeled dummy HTLCs so they can be processed in the next iteration.
6808+ let mut decode_update_add_htlc_source = self.decode_update_add_htlcs.lock().unwrap();
6809+ mem::swap(&mut *decode_update_add_htlc_source, &mut dummy_update_add_htlcs);
6810+
67736811 should_persist
67746812 }
67756813
0 commit comments