+ /// Returns the source node id of current hop.
+ ///
+ /// Source node id refers to the node forwarding the HTLC through this hop.
+ ///
+ /// For [`Self::FirstHop`] we return payer's node id.
+ #[inline]
+ pub fn source(&self) -> NodeId {
+ match self {
+ CandidateRouteHop::FirstHop { payer_node_id, .. } => **payer_node_id,
+ CandidateRouteHop::PublicHop { info, .. } => *info.source(),
+ CandidateRouteHop::PrivateHop { hint, .. } => hint.src_node_id.into(),
+ CandidateRouteHop::Blinded { hint, .. } => hint.1.introduction_node_id.into(),
+ CandidateRouteHop::OneHopBlinded { hint, .. } => hint.1.introduction_node_id.into(),
+ }
+ }
+ /// Returns the target node id of this hop, if known.
+ ///
+ /// Target node id refers to the node receiving the HTLC after this hop.
+ ///
+ /// For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded
+ /// path is unknown.
+ ///
+ /// For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source,
+ /// and such a return value would be somewhat nonsensical.
+ #[inline]
+ pub fn target(&self) -> Option<NodeId> {
+ match self {
+ CandidateRouteHop::FirstHop { details, .. } => Some(details.counterparty.node_id.into()),
+ CandidateRouteHop::PublicHop { info, .. } => Some(*info.target()),
+ CandidateRouteHop::PrivateHop { target_node_id, .. } => Some(**target_node_id),
+ CandidateRouteHop::Blinded { .. } => None,
+ CandidateRouteHop::OneHopBlinded { .. } => None,
+ }
+ }