@@ -6419,15 +6419,15 @@ where
6419
6419
},
6420
6420
}) => {
6421
6421
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);
6431
6431
6432
6432
let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
6433
6433
short_channel_id: prev_short_channel_id,
@@ -6437,12 +6437,12 @@ where
6437
6437
counterparty_node_id: prev_counterparty_node_id,
6438
6438
htlc_id: prev_htlc_id,
6439
6439
incoming_packet_shared_secret: incoming_shared_secret,
6440
- phantom_shared_secret: $ phantom_ss,
6440
+ phantom_shared_secret: phantom_ss,
6441
6441
blinded_failure: routing.blinded_failure(),
6442
6442
cltv_expiry,
6443
6443
});
6444
6444
6445
- let reason = if $ next_hop_unknown {
6445
+ let failure_type = if next_hop_unknown {
6446
6446
HTLCHandlingFailureType::InvalidForward {
6447
6447
requested_forward_scid: short_chan_id,
6448
6448
}
@@ -6453,22 +6453,11 @@ where
6453
6453
failed_forwards.push((
6454
6454
htlc_source,
6455
6455
payment_hash,
6456
- HTLCFailReason::reason($ reason, $ err_data),
6457
- reason ,
6456
+ HTLCFailReason::reason(reason, err_data),
6457
+ failure_type ,
6458
6458
));
6459
- continue;
6460
6459
};
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
+
6472
6461
if let PendingHTLCRouting::Forward { ref onion_packet, .. } = routing {
6473
6462
let phantom_pubkey_res =
6474
6463
self.node_signer.get_node_id(Recipient::PhantomNode);
@@ -6496,12 +6485,14 @@ where
6496
6485
// `update_fail_malformed_htlc`, meaning here we encrypt the error as
6497
6486
// if it came from us (the second-to-last hop) but contains the sha256
6498
6487
// of the onion.
6499
- failed_payment! (
6488
+ failure_handler (
6500
6489
err_msg,
6501
6490
reason,
6502
6491
sha256_of_onion.to_vec(),
6503
- None
6492
+ None,
6493
+ false,
6504
6494
);
6495
+ continue;
6505
6496
},
6506
6497
Err(onion_utils::OnionDecodeErr::Relay {
6507
6498
err_msg,
@@ -6510,12 +6501,14 @@ where
6510
6501
..
6511
6502
}) => {
6512
6503
let phantom_shared_secret = shared_secret.secret_bytes();
6513
- failed_payment! (
6504
+ failure_handler (
6514
6505
err_msg,
6515
6506
reason,
6516
6507
Vec::new(),
6517
- Some(phantom_shared_secret)
6508
+ Some(phantom_shared_secret),
6509
+ false,
6518
6510
);
6511
+ continue;
6519
6512
},
6520
6513
};
6521
6514
let phantom_shared_secret = next_hop.shared_secret().secret_bytes();
@@ -6540,31 +6533,42 @@ where
6540
6533
prev_user_channel_id,
6541
6534
vec![(info, prev_htlc_id)],
6542
6535
)),
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
+ },
6549
6546
}
6550
6547
} 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,
6556
6554
LocalHTLCFailureReason::UnknownNextPeer,
6557
6555
Vec::new(),
6558
- None
6556
+ None,
6557
+ true,
6559
6558
);
6559
+ continue;
6560
6560
}
6561
6561
} 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,
6564
6566
LocalHTLCFailureReason::UnknownNextPeer,
6565
6567
Vec::new(),
6566
- None
6568
+ None,
6569
+ true,
6567
6570
);
6571
+ continue;
6568
6572
}
6569
6573
},
6570
6574
HTLCForwardInfo::FailHTLC { .. } | HTLCForwardInfo::FailMalformedHTLC { .. } => {
0 commit comments