+ /// Returns the source node id of current hop.
+ ///
+ /// Source node id refers to the hop forwarding the payment.
+ ///
+ /// For `FirstHop` we return payer's node id.
+ pub fn source(&self) -> NodeId {
+ match self {
+ CandidateRouteHop::FirstHop { node_id, .. } => *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 hop receiving the payment.
+ ///
+ /// For `Blinded` and `OneHopBlinded` we return `None` because next hop is blinded.
+ 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,
+ }
+ }