+/// Creates parameters for paying to a blinded payee from the provided invoice. Sets
+/// [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and
+/// [`PaymentParameters::expiry_time`].
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PaymentParameters_from_bolt12_invoice(invoice: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::routing::router::PaymentParameters {
+ let mut ret = lightning::routing::router::PaymentParameters::from_bolt12_invoice(invoice.get_native_ref());
+ crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// Creates parameters for paying to a blinded payee from the provided blinded route hints.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn PaymentParameters_blinded(mut blinded_route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> crate::lightning::routing::router::PaymentParameters {
+ let mut local_blinded_route_hints = Vec::new(); for mut item in blinded_route_hints.into_rust().drain(..) { local_blinded_route_hints.push( { let (mut orig_blinded_route_hints_0_0, mut orig_blinded_route_hints_0_1) = item.to_rust(); let mut local_blinded_route_hints_0 = (*unsafe { Box::from_raw(orig_blinded_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_blinded_route_hints_0_1.take_inner()) }); local_blinded_route_hints_0 }); };
+ let mut ret = lightning::routing::router::PaymentParameters::blinded(local_blinded_route_hints);
+ crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// The recipient of a payment, differing based on whether they've hidden their identity with route
+/// blinding.
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum Payee {
+ /// The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves
+ /// will be included in the final [`Route`].
+ Blinded {
+ /// Aggregated routing info and blinded paths, for routing to the payee without knowing their
+ /// node id.
+ route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ,
+ /// Features supported by the payee.
+ ///
+ /// May be set from the payee's invoice. May be `None` if the invoice does not contain any
+ /// features.
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ features: crate::lightning::ln::features::Bolt12InvoiceFeatures,
+ },
+ /// The recipient included these route hints in their BOLT11 invoice.
+ Clear {
+ /// The node id of the payee.
+ node_id: crate::c_types::PublicKey,
+ /// Hints for routing to the payee, containing channels connecting the payee to public nodes.
+ route_hints: crate::c_types::derived::CVec_RouteHintZ,
+ /// Features supported by the payee.
+ ///
+ /// May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
+ /// does not contain any features.
+ ///
+ /// [`for_keysend`]: PaymentParameters::for_keysend
+ ///
+ /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
+ features: crate::lightning::ln::features::Bolt11InvoiceFeatures,
+ /// The minimum CLTV delta at the end of the route. This value must not be zero.
+ final_cltv_expiry_delta: u32,
+ },
+}
+use lightning::routing::router::Payee as PayeeImport;
+pub(crate) type nativePayee = PayeeImport;
+
+impl Payee {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativePayee {
+ match self {
+ Payee::Blinded {ref route_hints, ref features, } => {
+ let mut route_hints_nonref = Clone::clone(route_hints);
+ let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item.to_rust(); let mut local_route_hints_nonref_0 = (*unsafe { Box::from_raw(orig_route_hints_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_nonref_0_1.take_inner()) }); local_route_hints_nonref_0 }); };
+ let mut features_nonref = Clone::clone(features);
+ let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) };
+ nativePayee::Blinded {
+ route_hints: local_route_hints_nonref,
+ features: local_features_nonref,
+ }
+ },
+ Payee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => {
+ let mut node_id_nonref = Clone::clone(node_id);
+ let mut route_hints_nonref = Clone::clone(route_hints);
+ let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut features_nonref = Clone::clone(features);
+ let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) };
+ let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta);
+ nativePayee::Clear {
+ node_id: node_id_nonref.into_rust(),
+ route_hints: local_route_hints_nonref,
+ features: local_features_nonref,
+ final_cltv_expiry_delta: final_cltv_expiry_delta_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativePayee {
+ match self {
+ Payee::Blinded {mut route_hints, mut features, } => {
+ let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item.to_rust(); let mut local_route_hints_0 = (*unsafe { Box::from_raw(orig_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_0_1.take_inner()) }); local_route_hints_0 }); };
+ let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) };
+ nativePayee::Blinded {
+ route_hints: local_route_hints,
+ features: local_features,
+ }
+ },
+ Payee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => {
+ let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) };
+ nativePayee::Clear {
+ node_id: node_id.into_rust(),
+ route_hints: local_route_hints,
+ features: local_features,
+ final_cltv_expiry_delta: final_cltv_expiry_delta,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &PayeeImport) -> Self {
+ let native = unsafe { &*(native as *const _ as *const c_void as *const nativePayee) };
+ match native {
+ nativePayee::Blinded {ref route_hints, ref features, } => {
+ let mut route_hints_nonref = Clone::clone(route_hints);
+ let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item; let mut local_route_hints_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_1), is_owned: true }).into(); local_route_hints_nonref_0 }); };
+ let mut features_nonref = Clone::clone(features);
+ let mut local_features_nonref = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true };
+ Payee::Blinded {
+ route_hints: local_route_hints_nonref.into(),
+ features: local_features_nonref,
+ }
+ },
+ nativePayee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => {
+ let mut node_id_nonref = Clone::clone(node_id);
+ let mut route_hints_nonref = Clone::clone(route_hints);
+ let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ let mut features_nonref = Clone::clone(features);
+ let mut local_features_nonref = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true };
+ let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta);
+ Payee::Clear {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+ route_hints: local_route_hints_nonref.into(),
+ features: local_features_nonref,
+ final_cltv_expiry_delta: final_cltv_expiry_delta_nonref,
+ }
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativePayee) -> Self {
+ match native {
+ nativePayee::Blinded {mut route_hints, mut features, } => {
+ let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item; let mut local_route_hints_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_0_1), is_owned: true }).into(); local_route_hints_0 }); };
+ let mut local_features = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true };
+ Payee::Blinded {
+ route_hints: local_route_hints.into(),
+ features: local_features,
+ }
+ },
+ nativePayee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => {
+ let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+ let mut local_features = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true };
+ Payee::Clear {
+ node_id: crate::c_types::PublicKey::from_rust(&node_id),
+ route_hints: local_route_hints.into(),
+ features: local_features,
+ final_cltv_expiry_delta: final_cltv_expiry_delta,
+ }
+ },
+ }
+ }
+}
+/// Frees any resources used by the Payee
+#[no_mangle]
+pub extern "C" fn Payee_free(this_ptr: Payee) { }
+/// Creates a copy of the Payee
+#[no_mangle]
+pub extern "C" fn Payee_clone(orig: &Payee) -> Payee {
+ orig.clone()
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Payee_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Payee)).clone() })) as *mut c_void
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Payee_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut Payee) };
+}
+#[no_mangle]
+/// Utility method to constructs a new Blinded-variant Payee
+pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, features: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> Payee {
+ Payee::Blinded {
+ route_hints,
+ features,
+ }
+}
+#[no_mangle]
+/// Utility method to constructs a new Clear-variant Payee
+pub extern "C" fn Payee_clear(node_id: crate::c_types::PublicKey, route_hints: crate::c_types::derived::CVec_RouteHintZ, features: crate::lightning::ln::features::Bolt11InvoiceFeatures, final_cltv_expiry_delta: u32) -> Payee {
+ Payee::Clear {
+ node_id,
+ route_hints,
+ features,
+ final_cltv_expiry_delta,
+ }
+}
+/// Get a string which allows debug introspection of a Payee object
+pub extern "C" fn Payee_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::Payee }).into()}
+/// Generates a non-cryptographic 64-bit hash of the Payee.
+#[no_mangle]
+pub extern "C" fn Payee_hash(o: &Payee) -> u64 {
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(&o.to_native(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two Payees contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn Payee_eq(a: &Payee, b: &Payee) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
+
+use lightning::routing::router::RouteHint as nativeRouteHintImport;
+pub(crate) type nativeRouteHint = nativeRouteHintImport;
+
+/// A list of hops along a payment path terminating with a channel to the recipient.
+#[must_use]
+#[repr(C)]
+pub struct RouteHint {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeRouteHint,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for RouteHint {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn RouteHint_free(this_obj: RouteHint) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHint) };
+}
+#[allow(unused)]
+impl RouteHint {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHint {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHint {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+#[no_mangle]
+pub extern "C" fn RouteHint_get_a(this_ptr: &RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().0;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHintHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHintHop<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+#[no_mangle]
+pub extern "C" fn RouteHint_set_a(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::CVec_RouteHintHopZ) {
+ let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = local_val;
+}
+/// Constructs a new RouteHint given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RouteHint_new(mut a_arg: crate::c_types::derived::CVec_RouteHintHopZ) -> RouteHint {
+ let mut local_a_arg = Vec::new(); for mut item in a_arg.into_rust().drain(..) { local_a_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ RouteHint { inner: ObjOps::heap_alloc(lightning::routing::router::RouteHint (
+ local_a_arg,
+ )), is_owned: true }
+}
+impl Clone for RouteHint {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeRouteHint>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHint)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the RouteHint
+pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a RouteHint object
+pub extern "C" fn RouteHint_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHint }).into()}
+/// Generates a non-cryptographic 64-bit hash of the RouteHint.
+#[no_mangle]
+pub extern "C" fn RouteHint_hash(o: &RouteHint) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two RouteHints contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
+#[no_mangle]
+/// Serialize the RouteHint object into a byte array which can be read by RouteHint_read
+pub extern "C" fn RouteHint_write(obj: &crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[allow(unused)]
+pub(crate) extern "C" fn RouteHint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHint) })
+}
+#[no_mangle]
+/// Read a RouteHint from a byte array, created by RouteHint_write
+pub extern "C" fn RouteHint_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintDecodeErrorZ {
+ let res: Result<lightning::routing::router::RouteHint, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
+ local_res
+}
+
+use lightning::routing::router::RouteHintHop as nativeRouteHintHopImport;
+pub(crate) type nativeRouteHintHop = nativeRouteHintHopImport;
+
+/// A channel descriptor for a hop along a payment path.
+///
+/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are
+/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as
+/// fields not supported in BOLT 11 will be stripped.
+#[must_use]
+#[repr(C)]
+pub struct RouteHintHop {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeRouteHintHop,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for RouteHintHop {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHintHop) };
+}
+#[allow(unused)]
+impl RouteHintHop {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHintHop {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHintHop {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeRouteHintHop {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The node_id of the non-target end of the route
+#[no_mangle]
+pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().src_node_id;
+ crate::c_types::PublicKey::from_rust(&inner_val)
+}
+/// The node_id of the non-target end of the route
+#[no_mangle]
+pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.src_node_id = val.into_rust();
+}
+/// The short_channel_id of this channel
+#[no_mangle]
+pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
+ *inner_val
+}
+/// The short_channel_id of this channel
+#[no_mangle]
+pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
+}
+/// The fees which must be paid to use this channel
+#[no_mangle]
+pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning::routing::gossip::RoutingFees {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().fees;
+ crate::lightning::routing::gossip::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::RoutingFees<>) as *mut _) }, is_owned: false }
+}
+/// The fees which must be paid to use this channel
+#[no_mangle]
+pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning::routing::gossip::RoutingFees) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The difference in CLTV values between this node and the next node.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
+ *inner_val
+}
+/// The difference in CLTV values between this node and the next node.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
+}
+/// The minimum value, in msat, which must be relayed to the next hop.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// The minimum value, in msat, which must be relayed to the next hop.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = local_val;
+}
+/// The maximum value in msat available for routing with a single HTLC.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
+ let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
+ local_inner_val
+}
+/// The maximum value in msat available for routing with a single HTLC.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) {
+ let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val;
+}
+/// Constructs a new RouteHintHop given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RouteHintHop_new(mut src_node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: u64, mut fees_arg: crate::lightning::routing::gossip::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHintHop {
+ let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None };
+ let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None };
+ RouteHintHop { inner: ObjOps::heap_alloc(nativeRouteHintHop {
+ src_node_id: src_node_id_arg.into_rust(),
+ short_channel_id: short_channel_id_arg,
+ fees: *unsafe { Box::from_raw(fees_arg.take_inner()) },
+ cltv_expiry_delta: cltv_expiry_delta_arg,
+ htlc_minimum_msat: local_htlc_minimum_msat_arg,
+ htlc_maximum_msat: local_htlc_maximum_msat_arg,
+ }), is_owned: true }
+}
+impl Clone for RouteHintHop {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHintHop)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the RouteHintHop
+pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a RouteHintHop object
+pub extern "C" fn RouteHintHop_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHintHop }).into()}
+/// Generates a non-cryptographic 64-bit hash of the RouteHintHop.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> u64 {
+ if o.inner.is_null() { return 0; }
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
+ #[allow(deprecated)]
+ let mut hasher = core::hash::SipHasher::new();
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
+}
+/// Checks if two RouteHintHops contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+/// Two objects with NULL inner values will be considered "equal" here.
+#[no_mangle]
+pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> bool {
+ if a.inner == b.inner { return true; }
+ if a.inner.is_null() || b.inner.is_null() { return false; }
+ if a.get_native_ref() == b.get_native_ref() { true } else { false }
+}
+#[no_mangle]
+/// Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read
+pub extern "C" fn RouteHintHop_write(obj: &crate::lightning::routing::router::RouteHintHop) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[allow(unused)]
+pub(crate) extern "C" fn RouteHintHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHintHop) })
+}
+#[no_mangle]
+/// Read a RouteHintHop from a byte array, created by RouteHintHop_write
+pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintHopDecodeErrorZ {
+ let res: Result<lightning::routing::router::RouteHintHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteHintHop { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
+ local_res
+}
+
+use lightning::routing::router::FirstHopCandidate as nativeFirstHopCandidateImport;
+pub(crate) type nativeFirstHopCandidate = nativeFirstHopCandidateImport<'static, >;
+
+/// A [`CandidateRouteHop::FirstHop`] entry.
+#[must_use]
+#[repr(C)]
+pub struct FirstHopCandidate {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeFirstHopCandidate,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for FirstHopCandidate {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeFirstHopCandidate>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn FirstHopCandidate_free(this_obj: FirstHopCandidate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn FirstHopCandidate_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeFirstHopCandidate) };
+}
+#[allow(unused)]
+impl FirstHopCandidate {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeFirstHopCandidate {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeFirstHopCandidate {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeFirstHopCandidate {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for FirstHopCandidate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeFirstHopCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn FirstHopCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFirstHopCandidate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the FirstHopCandidate
+pub extern "C" fn FirstHopCandidate_clone(orig: &FirstHopCandidate) -> FirstHopCandidate {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a FirstHopCandidate object
+pub extern "C" fn FirstHopCandidate_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::FirstHopCandidate }).into()}
+
+use lightning::routing::router::PublicHopCandidate as nativePublicHopCandidateImport;
+pub(crate) type nativePublicHopCandidate = nativePublicHopCandidateImport<'static, >;
+
+/// A [`CandidateRouteHop::PublicHop`] entry.
+#[must_use]
+#[repr(C)]
+pub struct PublicHopCandidate {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePublicHopCandidate,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for PublicHopCandidate {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativePublicHopCandidate>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn PublicHopCandidate_free(this_obj: PublicHopCandidate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PublicHopCandidate_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativePublicHopCandidate) };
+}
+#[allow(unused)]
+impl PublicHopCandidate {
+ pub(crate) fn get_native_ref(&self) -> &'static nativePublicHopCandidate {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePublicHopCandidate {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativePublicHopCandidate {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The short channel ID of the channel, i.e. the identifier by which we refer to this
+/// channel.
+#[no_mangle]
+pub extern "C" fn PublicHopCandidate_get_short_channel_id(this_ptr: &PublicHopCandidate) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
+ *inner_val
+}
+/// The short channel ID of the channel, i.e. the identifier by which we refer to this
+/// channel.
+#[no_mangle]
+pub extern "C" fn PublicHopCandidate_set_short_channel_id(this_ptr: &mut PublicHopCandidate, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
+}
+impl Clone for PublicHopCandidate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativePublicHopCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PublicHopCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePublicHopCandidate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the PublicHopCandidate
+pub extern "C" fn PublicHopCandidate_clone(orig: &PublicHopCandidate) -> PublicHopCandidate {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a PublicHopCandidate object
+pub extern "C" fn PublicHopCandidate_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::PublicHopCandidate }).into()}
+
+use lightning::routing::router::PrivateHopCandidate as nativePrivateHopCandidateImport;
+pub(crate) type nativePrivateHopCandidate = nativePrivateHopCandidateImport<'static, >;
+
+/// A [`CandidateRouteHop::PrivateHop`] entry.
+#[must_use]
+#[repr(C)]
+pub struct PrivateHopCandidate {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativePrivateHopCandidate,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for PrivateHopCandidate {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativePrivateHopCandidate>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn PrivateHopCandidate_free(this_obj: PrivateHopCandidate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PrivateHopCandidate_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrivateHopCandidate) };
+}
+#[allow(unused)]
+impl PrivateHopCandidate {
+ pub(crate) fn get_native_ref(&self) -> &'static nativePrivateHopCandidate {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePrivateHopCandidate {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativePrivateHopCandidate {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+impl Clone for PrivateHopCandidate {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativePrivateHopCandidate>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn PrivateHopCandidate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePrivateHopCandidate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the PrivateHopCandidate
+pub extern "C" fn PrivateHopCandidate_clone(orig: &PrivateHopCandidate) -> PrivateHopCandidate {
+ orig.clone()
+}
+/// Get a string which allows debug introspection of a PrivateHopCandidate object
+pub extern "C" fn PrivateHopCandidate_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::PrivateHopCandidate }).into()}
+
+use lightning::routing::router::BlindedPathCandidate as nativeBlindedPathCandidateImport;
+pub(crate) type nativeBlindedPathCandidate = nativeBlindedPathCandidateImport<'static, >;