@@ -6419,15 +6419,15 @@ where
64196419 },
64206420 }) => {
64216421 let cltv_expiry = routing.incoming_cltv_expiry();
6422- macro_rules! failure_handler {
6423- ($msg: expr, $reason: expr, $err_data: expr, $phantom_ss: expr, $next_hop_unknown: expr) => {
6424- let logger = WithContext::from(
6425- &self.logger ,
6426- forwarding_counterparty ,
6427- Some(prev_channel_id),
6428- Some(payment_hash),
6429- );
6430- log_info!(logger, "Failed to accept/forward incoming HTLC: {}", $ msg);
6422+ let logger = WithContext::from(
6423+ &self.logger,
6424+ forwarding_counterparty,
6425+ Some(prev_channel_id) ,
6426+ Some(payment_hash) ,
6427+ );
6428+ let mut failure_handler =
6429+ |msg, reason, err_data, phantom_ss, next_hop_unknown| {
6430+ log_info!(logger, "Failed to accept/forward incoming HTLC: {}", msg);
64316431
64326432 let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
64336433 short_channel_id: prev_short_channel_id,
@@ -6437,12 +6437,12 @@ where
64376437 counterparty_node_id: prev_counterparty_node_id,
64386438 htlc_id: prev_htlc_id,
64396439 incoming_packet_shared_secret: incoming_shared_secret,
6440- phantom_shared_secret: $ phantom_ss,
6440+ phantom_shared_secret: phantom_ss,
64416441 blinded_failure: routing.blinded_failure(),
64426442 cltv_expiry,
64436443 });
64446444
6445- let reason = if $ next_hop_unknown {
6445+ let failure_type = if next_hop_unknown {
64466446 HTLCHandlingFailureType::InvalidForward {
64476447 requested_forward_scid: short_chan_id,
64486448 }
@@ -6453,22 +6453,11 @@ where
64536453 failed_forwards.push((
64546454 htlc_source,
64556455 payment_hash,
6456- HTLCFailReason::reason($ reason, $ err_data),
6457- reason ,
6456+ HTLCFailReason::reason(reason, err_data),
6457+ failure_type ,
64586458 ));
6459- continue;
64606459 };
6461- }
6462- macro_rules! fail_forward {
6463- ($msg: expr, $reason: expr, $err_data: expr, $phantom_ss: expr) => {{
6464- failure_handler!($msg, $reason, $err_data, $phantom_ss, true);
6465- }};
6466- }
6467- macro_rules! failed_payment {
6468- ($msg: expr, $reason: expr, $err_data: expr, $phantom_ss: expr) => {{
6469- failure_handler!($msg, $reason, $err_data, $phantom_ss, false);
6470- }};
6471- }
6460+
64726461 if let PendingHTLCRouting::Forward { ref onion_packet, .. } = routing {
64736462 let phantom_pubkey_res =
64746463 self.node_signer.get_node_id(Recipient::PhantomNode);
@@ -6496,12 +6485,14 @@ where
64966485 // `update_fail_malformed_htlc`, meaning here we encrypt the error as
64976486 // if it came from us (the second-to-last hop) but contains the sha256
64986487 // of the onion.
6499- failed_payment! (
6488+ failure_handler (
65006489 err_msg,
65016490 reason,
65026491 sha256_of_onion.to_vec(),
6503- None
6492+ None,
6493+ false,
65046494 );
6495+ continue;
65056496 },
65066497 Err(onion_utils::OnionDecodeErr::Relay {
65076498 err_msg,
@@ -6510,12 +6501,14 @@ where
65106501 ..
65116502 }) => {
65126503 let phantom_shared_secret = shared_secret.secret_bytes();
6513- failed_payment! (
6504+ failure_handler (
65146505 err_msg,
65156506 reason,
65166507 Vec::new(),
6517- Some(phantom_shared_secret)
6508+ Some(phantom_shared_secret),
6509+ false,
65186510 );
6511+ continue;
65196512 },
65206513 };
65216514 let phantom_shared_secret = next_hop.shared_secret().secret_bytes();
@@ -6540,31 +6533,42 @@ where
65406533 prev_user_channel_id,
65416534 vec![(info, prev_htlc_id)],
65426535 )),
6543- Err(InboundHTLCErr { reason, err_data, msg }) => failed_payment!(
6544- msg,
6545- reason,
6546- err_data,
6547- Some(phantom_shared_secret)
6548- ),
6536+ Err(InboundHTLCErr { reason, err_data, msg }) => {
6537+ failure_handler(
6538+ msg,
6539+ reason,
6540+ err_data,
6541+ Some(phantom_shared_secret),
6542+ false,
6543+ );
6544+ continue;
6545+ },
65496546 }
65506547 } else {
6551- fail_forward!(
6552- format!(
6553- "Unknown short channel id {} for forward HTLC",
6554- short_chan_id
6555- ),
6548+ let msg = format!(
6549+ "Unknown short channel id {} for forward HTLC",
6550+ short_chan_id
6551+ );
6552+ failure_handler(
6553+ &msg,
65566554 LocalHTLCFailureReason::UnknownNextPeer,
65576555 Vec::new(),
6558- None
6556+ None,
6557+ true,
65596558 );
6559+ continue;
65606560 }
65616561 } else {
6562- fail_forward!(
6563- format!("Unknown short channel id {} for forward HTLC", short_chan_id),
6562+ let msg =
6563+ format!("Unknown short channel id {} for forward HTLC", short_chan_id);
6564+ failure_handler(
6565+ &msg,
65646566 LocalHTLCFailureReason::UnknownNextPeer,
65656567 Vec::new(),
6566- None
6568+ None,
6569+ true,
65676570 );
6571+ continue;
65686572 }
65696573 },
65706574 HTLCForwardInfo::FailHTLC { .. } | HTLCForwardInfo::FailMalformedHTLC { .. } => {
0 commit comments