@@ -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 handling_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+ handling_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();
@@ -6541,35 +6534,41 @@ where
65416534 vec![(info, prev_htlc_id)],
65426535 )),
65436536 Err(InboundHTLCErr { reason, err_data, msg }) => {
6544- failed_payment! (
6537+ failure_handler (
65456538 msg,
65466539 reason,
65476540 err_data,
6548- Some(phantom_shared_secret)
6549- )
6541+ Some(phantom_shared_secret),
6542+ false,
6543+ );
6544+ continue;
65506545 },
65516546 }
65526547 } else {
65536548 let msg = format!(
65546549 "Unknown short channel id {} for forward HTLC",
65556550 short_chan_id
65566551 );
6557- fail_forward! (
6558- msg,
6552+ failure_handler (
6553+ & msg,
65596554 LocalHTLCFailureReason::UnknownNextPeer,
65606555 Vec::new(),
6561- None
6556+ None,
6557+ true,
65626558 );
6559+ continue;
65636560 }
65646561 } else {
65656562 let msg =
65666563 format!("Unknown short channel id {} for forward HTLC", short_chan_id);
6567- fail_forward! (
6568- msg,
6564+ failure_handler (
6565+ & msg,
65696566 LocalHTLCFailureReason::UnknownNextPeer,
65706567 Vec::new(),
6571- None
6568+ None,
6569+ true,
65726570 );
6571+ continue;
65736572 }
65746573 },
65756574 HTLCForwardInfo::FailHTLC { .. } | HTLCForwardInfo::FailMalformedHTLC { .. } => {
0 commit comments