+/// Get a string which allows debug introspection of a OneHopBlindedPathCandidate object
+pub extern "C" fn OneHopBlindedPathCandidate_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::OneHopBlindedPathCandidate }).into()}
+/// A wrapper around the various hop representations.
+///
+/// Can be used to examine the properties of a hop,
+/// potentially to decide whether to include it in a route.
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum CandidateRouteHop {
+ /// A hop from the payer, where the outbound liquidity is known.
+ FirstHop(
+ crate::lightning::routing::router::FirstHopCandidate),
+ /// A hop found in the [`ReadOnlyNetworkGraph`].
+ PublicHop(
+ crate::lightning::routing::router::PublicHopCandidate),
+ /// A private hop communicated by the payee, generally via a BOLT 11 invoice.
+ ///
+ /// Because BOLT 11 route hints can take multiple hops to get to the destination, this may not
+ /// terminate at the payee.
+ PrivateHop(
+ crate::lightning::routing::router::PrivateHopCandidate),
+ /// A blinded path which starts with an introduction point and ultimately terminates with the
+ /// payee.
+ ///
+ /// Because we don't know the payee's identity, [`CandidateRouteHop::target`] will return
+ /// `None` in this state.
+ ///
+ /// Because blinded paths are \"all or nothing\", and we cannot use just one part of a blinded
+ /// path, the full path is treated as a single [`CandidateRouteHop`].
+ Blinded(
+ crate::lightning::routing::router::BlindedPathCandidate),
+ /// Similar to [`Self::Blinded`], but the path here only has one hop.
+ ///
+ /// While we treat this similarly to [`CandidateRouteHop::Blinded`] in many respects (e.g.
+ /// returning `None` from [`CandidateRouteHop::target`]), in this case we do actually know the
+ /// payee's identity - it's the introduction point!
+ ///
+ /// [`BlindedPayInfo`] provided for 1-hop blinded paths is ignored because it is meant to apply
+ /// to the hops *between* the introduction node and the destination.
+ ///
+ /// This primarily exists to track that we need to included a blinded path at the end of our
+ /// [`Route`], even though it doesn't actually add an additional hop in the payment.
+ ///
+ /// [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo
+ OneHopBlinded(
+ crate::lightning::routing::router::OneHopBlindedPathCandidate),
+}
+use lightning::routing::router::CandidateRouteHop as CandidateRouteHopImport;
+pub(crate) type nativeCandidateRouteHop = CandidateRouteHopImport<'static, >;
+
+impl CandidateRouteHop {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeCandidateRouteHop {
+ match self {
+ CandidateRouteHop::FirstHop (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ nativeCandidateRouteHop::FirstHop (
+ *unsafe { Box::from_raw(a_nonref.take_inner()) },
+ )
+ },
+ CandidateRouteHop::PublicHop (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ nativeCandidateRouteHop::PublicHop (
+ *unsafe { Box::from_raw(a_nonref.take_inner()) },
+ )
+ },
+ CandidateRouteHop::PrivateHop (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ nativeCandidateRouteHop::PrivateHop (
+ *unsafe { Box::from_raw(a_nonref.take_inner()) },
+ )
+ },
+ CandidateRouteHop::Blinded (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ nativeCandidateRouteHop::Blinded (
+ *unsafe { Box::from_raw(a_nonref.take_inner()) },
+ )
+ },
+ CandidateRouteHop::OneHopBlinded (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ nativeCandidateRouteHop::OneHopBlinded (
+ *unsafe { Box::from_raw(a_nonref.take_inner()) },
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeCandidateRouteHop {
+ match self {
+ CandidateRouteHop::FirstHop (mut a, ) => {
+ nativeCandidateRouteHop::FirstHop (
+ *unsafe { Box::from_raw(a.take_inner()) },
+ )
+ },
+ CandidateRouteHop::PublicHop (mut a, ) => {
+ nativeCandidateRouteHop::PublicHop (
+ *unsafe { Box::from_raw(a.take_inner()) },
+ )
+ },
+ CandidateRouteHop::PrivateHop (mut a, ) => {
+ nativeCandidateRouteHop::PrivateHop (
+ *unsafe { Box::from_raw(a.take_inner()) },
+ )
+ },
+ CandidateRouteHop::Blinded (mut a, ) => {
+ nativeCandidateRouteHop::Blinded (
+ *unsafe { Box::from_raw(a.take_inner()) },
+ )
+ },
+ CandidateRouteHop::OneHopBlinded (mut a, ) => {
+ nativeCandidateRouteHop::OneHopBlinded (
+ *unsafe { Box::from_raw(a.take_inner()) },
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &CandidateRouteHopImport<'_, >) -> Self {
+ let native = unsafe { &*(native as *const _ as *const c_void as *const nativeCandidateRouteHop) };
+ match native {
+ nativeCandidateRouteHop::FirstHop (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ CandidateRouteHop::FirstHop (
+ crate::lightning::routing::router::FirstHopCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::PublicHop (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ CandidateRouteHop::PublicHop (
+ crate::lightning::routing::router::PublicHopCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::PrivateHop (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ CandidateRouteHop::PrivateHop (
+ crate::lightning::routing::router::PrivateHopCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::Blinded (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ CandidateRouteHop::Blinded (
+ crate::lightning::routing::router::BlindedPathCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::OneHopBlinded (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ CandidateRouteHop::OneHopBlinded (
+ crate::lightning::routing::router::OneHopBlindedPathCandidate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeCandidateRouteHop) -> Self {
+ match native {
+ nativeCandidateRouteHop::FirstHop (mut a, ) => {
+ CandidateRouteHop::FirstHop (
+ crate::lightning::routing::router::FirstHopCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::PublicHop (mut a, ) => {
+ CandidateRouteHop::PublicHop (
+ crate::lightning::routing::router::PublicHopCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::PrivateHop (mut a, ) => {
+ CandidateRouteHop::PrivateHop (
+ crate::lightning::routing::router::PrivateHopCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::Blinded (mut a, ) => {
+ CandidateRouteHop::Blinded (
+ crate::lightning::routing::router::BlindedPathCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
+ )
+ },
+ nativeCandidateRouteHop::OneHopBlinded (mut a, ) => {
+ CandidateRouteHop::OneHopBlinded (
+ crate::lightning::routing::router::OneHopBlindedPathCandidate { inner: ObjOps::heap_alloc(a), is_owned: true },
+ )
+ },
+ }
+ }
+}
+/// Frees any resources used by the CandidateRouteHop
+#[no_mangle]
+pub extern "C" fn CandidateRouteHop_free(this_ptr: CandidateRouteHop) { }
+/// Creates a copy of the CandidateRouteHop