Skip to content

Commit c561442

Browse files
committed
f Add docs and do not print error_code's removed Display string
1 parent 671fd4d commit c561442

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,22 +1383,20 @@ where
13831383
if debug_field_size > 0 && err_packet.failuremsg.len() >= 4 + debug_field_size {
13841384
log_info!(
13851385
logger,
1386-
"Onion Error[from {}: {:?}({:#x}) {}({})] {}",
1386+
"Onion Error[from {}: {:?}({:#x}) {}({})]",
13871387
route_hop.pubkey(),
13881388
error_code,
13891389
error_code.failure_code(),
13901390
debug_field,
13911391
log_bytes!(&err_packet.failuremsg[4..4 + debug_field_size]),
1392-
error_code
13931392
);
13941393
} else {
13951394
log_info!(
13961395
logger,
1397-
"Onion Error[from {}: {:?}({:#x})] {}",
1396+
"Onion Error[from {}: {:?}({:#x})]",
13981397
route_hop.pubkey(),
13991398
error_code,
14001399
error_code.failure_code(),
1401-
error_code
14021400
);
14031401
}
14041402

@@ -1652,6 +1650,7 @@ impl LocalHTLCFailureReason {
16521650
}
16531651
}
16541652

1653+
/// Returns the name of an error's data field and its expected length.
16551654
fn get_onion_debug_field(&self) -> (&'static str, usize) {
16561655
match self {
16571656
Self::InvalidOnionVersion | Self::InvalidOnionHMAC | Self::InvalidOnionKey => {
@@ -1681,7 +1680,9 @@ impl LocalHTLCFailureReason {
16811680
self.failure_code() & NODE == NODE
16821681
}
16831682

1684-
/// Returns true if the failure is only sent by the final recipient.
1683+
/// Returns true if the failure is only sent by the final recipient. Note that this function
1684+
/// only checks [`LocalHTLCFailureReason`] variants that represent bolt 04 errors directly,
1685+
/// as it's intended to analyze errors we've received as a sender.
16851686
fn is_recipient_failure(&self) -> bool {
16861687
self.failure_code() == LocalHTLCFailureReason::IncorrectPaymentDetails.failure_code()
16871688
|| *self == LocalHTLCFailureReason::FinalIncorrectCLTVExpiry

0 commit comments

Comments
 (0)