+pub(crate) type nativeRouteHop = nativeRouteHopImport;
+
+/// A hop in a route, and additional metadata about it. \"Hop\" is defined as a node and the channel
+/// that leads to it.
+#[must_use]
+#[repr(C)]
+pub struct RouteHop {
+ /// 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 nativeRouteHop,
+ /// 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 RouteHop {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn RouteHop_free(this_obj: RouteHop) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RouteHop_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHop) };
+}
+#[allow(unused)]
+impl RouteHop {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHop {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHop {
+ 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 nativeRouteHop {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The node_id of the node at this hop.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_pubkey(this_ptr: &RouteHop) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().pubkey;
+ crate::c_types::PublicKey::from_rust(&inner_val)
+}
+/// The node_id of the node at this hop.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pubkey = val.into_rust();
+}
+/// The node_announcement features of the node at this hop. For the last hop, these may be
+/// amended to match the features present in the invoice this node generated.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().node_features;
+ crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false }
+}
+/// The node_announcement features of the node at this hop. For the last hop, these may be
+/// amended to match the features present in the invoice this node generated.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::NodeFeatures) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_features = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The channel that should be used from the previous hop to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
+ *inner_val
+}
+/// The channel that should be used from the previous hop to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
+}
+/// The channel_announcement features of the channel that should be used from the previous hop
+/// to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_features;
+ crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false }
+}
+/// The channel_announcement features of the channel that should be used from the previous hop
+/// to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::ChannelFeatures) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_features = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The fee taken on this hop (for paying for the use of the *next* channel in the path).
+/// If this is the last hop in [`Path::hops`]:
+/// * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
+/// * otherwise, this is the full value of this [`Path`]'s part of the payment
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_msat;
+ *inner_val
+}
+/// The fee taken on this hop (for paying for the use of the *next* channel in the path).
+/// If this is the last hop in [`Path::hops`]:
+/// * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path
+/// * otherwise, this is the full value of this [`Path`]'s part of the payment
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_msat = val;
+}
+/// The CLTV delta added for this hop.
+/// If this is the last hop in [`Path::hops`]:
+/// * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
+/// * otherwise, this is the CLTV delta expected at the destination
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
+ *inner_val
+}
+/// The CLTV delta added for this hop.
+/// If this is the last hop in [`Path::hops`]:
+/// * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path
+/// * otherwise, this is the CLTV delta expected at the destination
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
+}
+/// Indicates whether this hop is possibly announced in the public network graph.
+///
+/// Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
+/// either know for sure it's announced in the public graph, or if any public channels exist
+/// for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
+/// the channel to be unannounced.
+///
+/// Will be `true` for objects serialized with LDK version 0.0.116 and before.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_maybe_announced_channel(this_ptr: &RouteHop) -> bool {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().maybe_announced_channel;
+ *inner_val
+}
+/// Indicates whether this hop is possibly announced in the public network graph.
+///
+/// Will be `true` if there is a possibility that the channel is publicly known, i.e., if we
+/// either know for sure it's announced in the public graph, or if any public channels exist
+/// for which the given `short_channel_id` could be an alias for. Will be `false` if we believe
+/// the channel to be unannounced.
+///
+/// Will be `true` for objects serialized with LDK version 0.0.116 and before.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_maybe_announced_channel(this_ptr: &mut RouteHop, mut val: bool) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.maybe_announced_channel = val;
+}
+/// Constructs a new RouteHop given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::lightning::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::lightning::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32, mut maybe_announced_channel_arg: bool) -> RouteHop {
+ RouteHop { inner: ObjOps::heap_alloc(nativeRouteHop {
+ pubkey: pubkey_arg.into_rust(),
+ node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) },
+ short_channel_id: short_channel_id_arg,
+ channel_features: *unsafe { Box::from_raw(channel_features_arg.take_inner()) },
+ fee_msat: fee_msat_arg,
+ cltv_expiry_delta: cltv_expiry_delta_arg,
+ maybe_announced_channel: maybe_announced_channel_arg,
+ }), is_owned: true }
+}
+impl Clone for RouteHop {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeRouteHop>::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 RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHop)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the RouteHop
+pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop {
+ orig.clone()
+}
+/// Generates a non-cryptographic 64-bit hash of the RouteHop.
+#[no_mangle]
+pub extern "C" fn RouteHop_hash(o: &RouteHop) -> 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 RouteHops 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 RouteHop_eq(a: &RouteHop, b: &RouteHop) -> 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 RouteHop object into a byte array which can be read by RouteHop_read
+pub extern "C" fn RouteHop_write(obj: &crate::lightning::routing::router::RouteHop) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[allow(unused)]
+pub(crate) extern "C" fn RouteHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHop) })
+}
+#[no_mangle]
+/// Read a RouteHop from a byte array, created by RouteHop_write
+pub extern "C" fn RouteHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHopDecodeErrorZ {
+ let res: Result<lightning::routing::router::RouteHop, 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::RouteHop { 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::BlindedTail as nativeBlindedTailImport;
+pub(crate) type nativeBlindedTail = nativeBlindedTailImport;
+
+/// The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in
+/// their [`Bolt12Invoice`].
+///
+/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+#[must_use]
+#[repr(C)]
+pub struct BlindedTail {
+ /// 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 nativeBlindedTail,
+ /// 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 BlindedTail {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeBlindedTail>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn BlindedTail_free(this_obj: BlindedTail) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn BlindedTail_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedTail) };
+}
+#[allow(unused)]
+impl BlindedTail {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedTail {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedTail {
+ 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 nativeBlindedTail {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The hops of the [`BlindedPath`] provided by the recipient.
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn BlindedTail_get_hops(this_ptr: &BlindedTail) -> crate::c_types::derived::CVec_BlindedHopZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().hops;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::blinded_path::BlindedHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::blinded_path::BlindedHop<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// The hops of the [`BlindedPath`] provided by the recipient.
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn BlindedTail_set_hops(this_ptr: &mut BlindedTail, mut val: crate::c_types::derived::CVec_BlindedHopZ) {
+ 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) }.hops = local_val;
+}
+/// The blinding point of the [`BlindedPath`] provided by the recipient.
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn BlindedTail_get_blinding_point(this_ptr: &BlindedTail) -> crate::c_types::PublicKey {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
+ crate::c_types::PublicKey::from_rust(&inner_val)
+}
+/// The blinding point of the [`BlindedPath`] provided by the recipient.
+///
+/// [`BlindedPath`]: crate::blinded_path::BlindedPath
+#[no_mangle]
+pub extern "C" fn BlindedTail_set_blinding_point(this_ptr: &mut BlindedTail, mut val: crate::c_types::PublicKey) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
+}
+/// Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
+/// inferring the destination. May be 0.
+#[no_mangle]
+pub extern "C" fn BlindedTail_get_excess_final_cltv_expiry_delta(this_ptr: &BlindedTail) -> u32 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().excess_final_cltv_expiry_delta;
+ *inner_val
+}
+/// Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
+/// inferring the destination. May be 0.
+#[no_mangle]
+pub extern "C" fn BlindedTail_set_excess_final_cltv_expiry_delta(this_ptr: &mut BlindedTail, mut val: u32) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_final_cltv_expiry_delta = val;
+}
+/// The total amount paid on this [`Path`], excluding the fees.
+#[no_mangle]
+pub extern "C" fn BlindedTail_get_final_value_msat(this_ptr: &BlindedTail) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().final_value_msat;
+ *inner_val
+}
+/// The total amount paid on this [`Path`], excluding the fees.
+#[no_mangle]
+pub extern "C" fn BlindedTail_set_final_value_msat(this_ptr: &mut BlindedTail, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_value_msat = val;
+}
+/// Constructs a new BlindedTail given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn BlindedTail_new(mut hops_arg: crate::c_types::derived::CVec_BlindedHopZ, mut blinding_point_arg: crate::c_types::PublicKey, mut excess_final_cltv_expiry_delta_arg: u32, mut final_value_msat_arg: u64) -> BlindedTail {
+ let mut local_hops_arg = Vec::new(); for mut item in hops_arg.into_rust().drain(..) { local_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ BlindedTail { inner: ObjOps::heap_alloc(nativeBlindedTail {
+ hops: local_hops_arg,
+ blinding_point: blinding_point_arg.into_rust(),
+ excess_final_cltv_expiry_delta: excess_final_cltv_expiry_delta_arg,
+ final_value_msat: final_value_msat_arg,
+ }), is_owned: true }
+}
+impl Clone for BlindedTail {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeBlindedTail>::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 BlindedTail_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedTail)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the BlindedTail
+pub extern "C" fn BlindedTail_clone(orig: &BlindedTail) -> BlindedTail {
+ orig.clone()
+}
+/// Generates a non-cryptographic 64-bit hash of the BlindedTail.
+#[no_mangle]
+pub extern "C" fn BlindedTail_hash(o: &BlindedTail) -> 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 BlindedTails 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 BlindedTail_eq(a: &BlindedTail, b: &BlindedTail) -> 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 BlindedTail object into a byte array which can be read by BlindedTail_read
+pub extern "C" fn BlindedTail_write(obj: &crate::lightning::routing::router::BlindedTail) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[allow(unused)]
+pub(crate) extern "C" fn BlindedTail_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedTail) })
+}
+#[no_mangle]
+/// Read a BlindedTail from a byte array, created by BlindedTail_write
+pub extern "C" fn BlindedTail_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedTailDecodeErrorZ {
+ let res: Result<lightning::routing::router::BlindedTail, 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::BlindedTail { 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::Path as nativePathImport;
+pub(crate) type nativePath = nativePathImport;
+
+/// A path in a [`Route`] to the payment recipient. Must always be at least length one.
+/// If no [`Path::blinded_tail`] is present, then [`Path::hops`] length may be up to 19.
+#[must_use]
+#[repr(C)]
+pub struct Path {
+ /// 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 nativePath,
+ /// 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 Path {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativePath>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the Path, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn Path_free(this_obj: Path) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Path_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativePath) };
+}
+#[allow(unused)]
+impl Path {
+ pub(crate) fn get_native_ref(&self) -> &'static nativePath {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePath {
+ 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 nativePath {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The list of unblinded hops in this [`Path`]. Must be at least length one.
+#[no_mangle]
+pub extern "C" fn Path_get_hops(this_ptr: &Path) -> crate::c_types::derived::CVec_RouteHopZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().hops;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHop<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// The list of unblinded hops in this [`Path`]. Must be at least length one.
+#[no_mangle]
+pub extern "C" fn Path_set_hops(this_ptr: &mut Path, mut val: crate::c_types::derived::CVec_RouteHopZ) {
+ 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) }.hops = local_val;
+}
+/// The blinded path at which this path terminates, if we're sending to one, and its metadata.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn Path_get_blinded_tail(this_ptr: &Path) -> crate::lightning::routing::router::BlindedTail {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_tail;
+ let mut local_inner_val = crate::lightning::routing::router::BlindedTail { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::BlindedTail<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The blinded path at which this path terminates, if we're sending to one, and its metadata.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn Path_set_blinded_tail(this_ptr: &mut Path, mut val: crate::lightning::routing::router::BlindedTail) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_tail = local_val;
+}
+/// Constructs a new Path given each field
+///
+/// Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Path_new(mut hops_arg: crate::c_types::derived::CVec_RouteHopZ, mut blinded_tail_arg: crate::lightning::routing::router::BlindedTail) -> Path {
+ let mut local_hops_arg = Vec::new(); for mut item in hops_arg.into_rust().drain(..) { local_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_blinded_tail_arg = if blinded_tail_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(blinded_tail_arg.take_inner()) } }) };
+ Path { inner: ObjOps::heap_alloc(nativePath {
+ hops: local_hops_arg,
+ blinded_tail: local_blinded_tail_arg,
+ }), is_owned: true }
+}
+impl Clone for Path {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativePath>::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 Path_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePath)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the Path
+pub extern "C" fn Path_clone(orig: &Path) -> Path {
+ orig.clone()
+}
+/// Generates a non-cryptographic 64-bit hash of the Path.
+#[no_mangle]
+pub extern "C" fn Path_hash(o: &Path) -> 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 Paths 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 Path_eq(a: &Path, b: &Path) -> 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 }
+}
+/// Gets the fees for a given path, excluding any excess paid to the recipient.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Path_fee_msat(this_arg: &crate::lightning::routing::router::Path) -> u64 {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fee_msat();
+ ret
+}
+
+/// Gets the total amount paid on this [`Path`], excluding the fees.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Path_final_value_msat(this_arg: &crate::lightning::routing::router::Path) -> u64 {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.final_value_msat();
+ ret
+}
+
+/// Gets the final hop's CLTV expiry delta.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Path_final_cltv_expiry_delta(this_arg: &crate::lightning::routing::router::Path) -> crate::c_types::derived::COption_u32Z {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.final_cltv_expiry_delta();
+ let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { ret.unwrap() }) };
+ local_ret
+}
+
+
+use lightning::routing::router::Route as nativeRouteImport;
+pub(crate) type nativeRoute = nativeRouteImport;
+
+/// A route directs a payment from the sender (us) to the recipient. If the recipient supports MPP,
+/// it can take multiple paths. Each path is composed of one or more hops through the network.
+#[must_use]
+#[repr(C)]
+pub struct Route {
+ /// 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 nativeRoute,
+ /// 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 Route {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the Route, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn Route_free(this_obj: Route) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Route_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRoute) };
+}
+#[allow(unused)]
+impl Route {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeRoute {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoute {
+ 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 nativeRoute {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no
+/// [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be
+/// the same.
+#[no_mangle]
+pub extern "C" fn Route_get_paths(this_ptr: &Route) -> crate::c_types::derived::CVec_PathZ {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().paths;
+ let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false } }); };
+ local_inner_val.into()
+}
+/// The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no
+/// [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be
+/// the same.
+#[no_mangle]
+pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_PathZ) {
+ 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) }.paths = local_val;
+}
+/// The `route_params` parameter passed to [`find_route`].
+///
+/// This is used by `ChannelManager` to track information which may be required for retries.
+///
+/// Will be `None` for objects serialized with LDK versions prior to 0.0.117.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn Route_get_route_params(this_ptr: &Route) -> crate::lightning::routing::router::RouteParameters {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().route_params;
+ let mut local_inner_val = crate::lightning::routing::router::RouteParameters { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::RouteParameters<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The `route_params` parameter passed to [`find_route`].
+///
+/// This is used by `ChannelManager` to track information which may be required for retries.
+///
+/// Will be `None` for objects serialized with LDK versions prior to 0.0.117.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn Route_set_route_params(this_ptr: &mut Route, mut val: crate::lightning::routing::router::RouteParameters) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.route_params = local_val;
+}
+/// Constructs a new Route given each field
+///
+/// Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Route_new(mut paths_arg: crate::c_types::derived::CVec_PathZ, mut route_params_arg: crate::lightning::routing::router::RouteParameters) -> Route {
+ let mut local_paths_arg = Vec::new(); for mut item in paths_arg.into_rust().drain(..) { local_paths_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+ let mut local_route_params_arg = if route_params_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(route_params_arg.take_inner()) } }) };
+ Route { inner: ObjOps::heap_alloc(nativeRoute {
+ paths: local_paths_arg,
+ route_params: local_route_params_arg,
+ }), is_owned: true }
+}
+impl Clone for Route {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeRoute>::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 Route_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRoute)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the Route
+pub extern "C" fn Route_clone(orig: &Route) -> Route {
+ orig.clone()
+}
+/// Generates a non-cryptographic 64-bit hash of the Route.
+#[no_mangle]
+pub extern "C" fn Route_hash(o: &Route) -> 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 Routes 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 Route_eq(a: &Route, b: &Route) -> 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 }
+}
+/// Returns the total amount of fees paid on this [`Route`].
+///
+/// For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to
+/// the recipient, which can happen in excess of the amount passed to [`find_route`] via
+/// [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits.
+///
+/// [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Route_get_total_fees(this_arg: &crate::lightning::routing::router::Route) -> u64 {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_fees();
+ ret
+}
+
+/// Returns the total amount paid on this [`Route`], excluding the fees.
+///
+/// Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if
+/// we had to reach the [`htlc_minimum_msat`] limits.
+///
+/// [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Route_get_total_amount(this_arg: &crate::lightning::routing::router::Route) -> u64 {
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_amount();
+ ret
+}
+
+#[no_mangle]
+/// Serialize the Route object into a byte array which can be read by Route_read
+pub extern "C" fn Route_write(obj: &crate::lightning::routing::router::Route) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[allow(unused)]
+pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) })
+}
+#[no_mangle]
+/// Read a Route from a byte array, created by Route_write
+pub extern "C" fn Route_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteDecodeErrorZ {
+ let res: Result<lightning::routing::router::Route, 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::Route { 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::RouteParameters as nativeRouteParametersImport;
+pub(crate) type nativeRouteParameters = nativeRouteParametersImport;
+
+/// Parameters needed to find a [`Route`].
+///
+/// Passed to [`find_route`] and [`build_route_from_hops`].
+#[must_use]
+#[repr(C)]
+pub struct RouteParameters {
+ /// 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 nativeRouteParameters,
+ /// 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 RouteParameters {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeRouteParameters>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn RouteParameters_free(this_obj: RouteParameters) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn RouteParameters_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteParameters) };
+}
+#[allow(unused)]
+impl RouteParameters {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeRouteParameters {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteParameters {
+ 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 nativeRouteParameters {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The parameters of the failed payment path.
+#[no_mangle]
+pub extern "C" fn RouteParameters_get_payment_params(this_ptr: &RouteParameters) -> crate::lightning::routing::router::PaymentParameters {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_params;
+ crate::lightning::routing::router::PaymentParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::router::PaymentParameters<>) as *mut _) }, is_owned: false }
+}
+/// The parameters of the failed payment path.
+#[no_mangle]
+pub extern "C" fn RouteParameters_set_payment_params(this_ptr: &mut RouteParameters, mut val: crate::lightning::routing::router::PaymentParameters) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_params = *unsafe { Box::from_raw(val.take_inner()) };
+}
+/// The amount in msats sent on the failed payment path.
+#[no_mangle]
+pub extern "C" fn RouteParameters_get_final_value_msat(this_ptr: &RouteParameters) -> u64 {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().final_value_msat;
+ *inner_val
+}
+/// The amount in msats sent on the failed payment path.
+#[no_mangle]
+pub extern "C" fn RouteParameters_set_final_value_msat(this_ptr: &mut RouteParameters, mut val: u64) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.final_value_msat = val;
+}
+/// The maximum total fees, in millisatoshi, that may accrue during route finding.
+///
+/// This limit also applies to the total fees that may arise while retrying failed payment
+/// paths.
+///
+/// Note that values below a few sats may result in some paths being spuriously ignored.
+#[no_mangle]
+pub extern "C" fn RouteParameters_get_max_total_routing_fee_msat(this_ptr: &RouteParameters) -> crate::c_types::derived::COption_u64Z {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().max_total_routing_fee_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 total fees, in millisatoshi, that may accrue during route finding.
+///
+/// This limit also applies to the total fees that may arise while retrying failed payment
+/// paths.
+///
+/// Note that values below a few sats may result in some paths being spuriously ignored.
+#[no_mangle]
+pub extern "C" fn RouteParameters_set_max_total_routing_fee_msat(this_ptr: &mut RouteParameters, 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) }.max_total_routing_fee_msat = local_val;
+}
+/// Constructs a new RouteParameters given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RouteParameters_new(mut payment_params_arg: crate::lightning::routing::router::PaymentParameters, mut final_value_msat_arg: u64, mut max_total_routing_fee_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteParameters {
+ let mut local_max_total_routing_fee_msat_arg = if max_total_routing_fee_msat_arg.is_some() { Some( { max_total_routing_fee_msat_arg.take() }) } else { None };
+ RouteParameters { inner: ObjOps::heap_alloc(nativeRouteParameters {
+ payment_params: *unsafe { Box::from_raw(payment_params_arg.take_inner()) },
+ final_value_msat: final_value_msat_arg,
+ max_total_routing_fee_msat: local_max_total_routing_fee_msat_arg,
+ }), is_owned: true }
+}
+impl Clone for RouteParameters {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeRouteParameters>::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 RouteParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteParameters)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the RouteParameters
+pub extern "C" fn RouteParameters_clone(orig: &RouteParameters) -> RouteParameters {
+ orig.clone()
+}
+/// Generates a non-cryptographic 64-bit hash of the RouteParameters.
+#[no_mangle]
+pub extern "C" fn RouteParameters_hash(o: &RouteParameters) -> 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 RouteParameterss 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 RouteParameters_eq(a: &RouteParameters, b: &RouteParameters) -> 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 }
+}
+/// Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount.
+///
+/// [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RouteParameters_from_payment_params_and_value(mut payment_params: crate::lightning::routing::router::PaymentParameters, mut final_value_msat: u64) -> crate::lightning::routing::router::RouteParameters {
+ let mut ret = lightning::routing::router::RouteParameters::from_payment_params_and_value(*unsafe { Box::from_raw(payment_params.take_inner()) }, final_value_msat);
+ crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+#[no_mangle]
+/// Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read
+pub extern "C" fn RouteParameters_write(obj: &crate::lightning::routing::router::RouteParameters) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[allow(unused)]
+pub(crate) extern "C" fn RouteParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteParameters) })
+}
+#[no_mangle]
+/// Read a RouteParameters from a byte array, created by RouteParameters_write
+pub extern "C" fn RouteParameters_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteParametersDecodeErrorZ {
+ let res: Result<lightning::routing::router::RouteParameters, 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::RouteParameters { 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
+}
+/// Maximum total CTLV difference we allow for a full payment path.
+
+#[no_mangle]
+pub static DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA: u32 = lightning::routing::router::DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA;
+/// Maximum number of paths we allow an (MPP) payment to have.