Skip to content

Commit 03b84f0

Browse files
Add node_id to onion util internal struct FailureLearnings.
Will be used to ensure correctness when we store previously failed blinded paths to avoid retrying over them.
1 parent cbcf9de commit 03b84f0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
462462
network_update: Option<NetworkUpdate>,
463463
short_channel_id: Option<u64>,
464464
payment_failed_permanently: bool,
465+
node_id: Option<PublicKey>,
465466
}
466467
let mut res: Option<FailureLearnings> = None;
467468
let mut htlc_msat = *first_hop_htlc_msat;
@@ -487,7 +488,8 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
487488
error_code_ret = Some(BADONION | PERM | 24); // invalid_onion_blinding
488489
error_packet_ret = Some(vec![0; 32]);
489490
res = Some(FailureLearnings {
490-
network_update: None, short_channel_id: None, payment_failed_permanently: false
491+
network_update: None, short_channel_id: None, payment_failed_permanently: false,
492+
node_id: None,
491493
});
492494
return
493495
},
@@ -519,7 +521,8 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
519521
}
520522

521523
res = Some(FailureLearnings {
522-
network_update: None, short_channel_id: None, payment_failed_permanently: false
524+
network_update: None, short_channel_id: None, payment_failed_permanently: false,
525+
node_id: Some(route_hop.pubkey)
523526
});
524527
return
525528
}
@@ -549,7 +552,8 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
549552
});
550553
let short_channel_id = Some(route_hop.short_channel_id);
551554
res = Some(FailureLearnings {
552-
network_update, short_channel_id, payment_failed_permanently: is_from_final_node
555+
network_update, short_channel_id, payment_failed_permanently: is_from_final_node,
556+
node_id: Some(route_hop.pubkey),
553557
});
554558
return
555559
}
@@ -705,7 +709,8 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
705709

706710
res = Some(FailureLearnings {
707711
network_update, short_channel_id,
708-
payment_failed_permanently: error_code & PERM == PERM && is_from_final_node
712+
payment_failed_permanently: error_code & PERM == PERM && is_from_final_node,
713+
node_id: Some(route_hop.pubkey),
709714
});
710715

711716
let (description, title) = errors::get_onion_error_description(error_code);
@@ -716,7 +721,7 @@ pub(super) fn process_onion_failure<T: secp256k1::Signing, L: Deref>(
716721
}
717722
}).expect("Route that we sent via spontaneously grew invalid keys in the middle of it?");
718723
if let Some(FailureLearnings {
719-
network_update, short_channel_id, payment_failed_permanently
724+
network_update, short_channel_id, payment_failed_permanently, node_id
720725
}) = res {
721726
DecodedOnionFailure {
722727
network_update, short_channel_id, payment_failed_permanently,

0 commit comments

Comments
 (0)