Pin compiler_builtins to 0.1.109 when building std
[ldk-c-bindings] / lightning-c-bindings / src / lightning / blinded_path / mod.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Creating blinded paths and related utilities live here.
10
11 use alloc::str::FromStr;
12 use alloc::string::String;
13 use core::ffi::c_void;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17 #[cfg(feature="no-std")]
18 use alloc::{vec::Vec, boxed::Box};
19
20 pub mod payment;
21 mod message {
22
23 use alloc::str::FromStr;
24 use alloc::string::String;
25 use core::ffi::c_void;
26 use core::convert::Infallible;
27 use bitcoin::hashes::Hash;
28 use crate::c_types::*;
29 #[cfg(feature="no-std")]
30 use alloc::{vec::Vec, boxed::Box};
31
32 }
33 mod utils {
34
35 use alloc::str::FromStr;
36 use alloc::string::String;
37 use core::ffi::c_void;
38 use core::convert::Infallible;
39 use bitcoin::hashes::Hash;
40 use crate::c_types::*;
41 #[cfg(feature="no-std")]
42 use alloc::{vec::Vec, boxed::Box};
43
44 }
45 /// The next hop to forward an onion message along its path.
46 ///
47 /// Note that payment blinded paths always specify their next hop using an explicit node id.
48 #[derive(Clone)]
49 #[must_use]
50 #[repr(C)]
51 pub enum NextMessageHop {
52         /// The node id of the next hop.
53         NodeId(
54                 crate::c_types::PublicKey),
55         /// The short channel id leading to the next hop.
56         ShortChannelId(
57                 u64),
58 }
59 use lightning::blinded_path::NextMessageHop as NextMessageHopImport;
60 pub(crate) type nativeNextMessageHop = NextMessageHopImport;
61
62 impl NextMessageHop {
63         #[allow(unused)]
64         pub(crate) fn to_native(&self) -> nativeNextMessageHop {
65                 match self {
66                         NextMessageHop::NodeId (ref a, ) => {
67                                 let mut a_nonref = Clone::clone(a);
68                                 nativeNextMessageHop::NodeId (
69                                         a_nonref.into_rust(),
70                                 )
71                         },
72                         NextMessageHop::ShortChannelId (ref a, ) => {
73                                 let mut a_nonref = Clone::clone(a);
74                                 nativeNextMessageHop::ShortChannelId (
75                                         a_nonref,
76                                 )
77                         },
78                 }
79         }
80         #[allow(unused)]
81         pub(crate) fn into_native(self) -> nativeNextMessageHop {
82                 match self {
83                         NextMessageHop::NodeId (mut a, ) => {
84                                 nativeNextMessageHop::NodeId (
85                                         a.into_rust(),
86                                 )
87                         },
88                         NextMessageHop::ShortChannelId (mut a, ) => {
89                                 nativeNextMessageHop::ShortChannelId (
90                                         a,
91                                 )
92                         },
93                 }
94         }
95         #[allow(unused)]
96         pub(crate) fn from_native(native: &NextMessageHopImport) -> Self {
97                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNextMessageHop) };
98                 match native {
99                         nativeNextMessageHop::NodeId (ref a, ) => {
100                                 let mut a_nonref = Clone::clone(a);
101                                 NextMessageHop::NodeId (
102                                         crate::c_types::PublicKey::from_rust(&a_nonref),
103                                 )
104                         },
105                         nativeNextMessageHop::ShortChannelId (ref a, ) => {
106                                 let mut a_nonref = Clone::clone(a);
107                                 NextMessageHop::ShortChannelId (
108                                         a_nonref,
109                                 )
110                         },
111                 }
112         }
113         #[allow(unused)]
114         pub(crate) fn native_into(native: nativeNextMessageHop) -> Self {
115                 match native {
116                         nativeNextMessageHop::NodeId (mut a, ) => {
117                                 NextMessageHop::NodeId (
118                                         crate::c_types::PublicKey::from_rust(&a),
119                                 )
120                         },
121                         nativeNextMessageHop::ShortChannelId (mut a, ) => {
122                                 NextMessageHop::ShortChannelId (
123                                         a,
124                                 )
125                         },
126                 }
127         }
128 }
129 /// Frees any resources used by the NextMessageHop
130 #[no_mangle]
131 pub extern "C" fn NextMessageHop_free(this_ptr: NextMessageHop) { }
132 /// Creates a copy of the NextMessageHop
133 #[no_mangle]
134 pub extern "C" fn NextMessageHop_clone(orig: &NextMessageHop) -> NextMessageHop {
135         orig.clone()
136 }
137 #[allow(unused)]
138 /// Used only if an object of this type is returned as a trait impl by a method
139 pub(crate) extern "C" fn NextMessageHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
140         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const NextMessageHop)).clone() })) as *mut c_void
141 }
142 #[allow(unused)]
143 /// Used only if an object of this type is returned as a trait impl by a method
144 pub(crate) extern "C" fn NextMessageHop_free_void(this_ptr: *mut c_void) {
145         let _ = unsafe { Box::from_raw(this_ptr as *mut NextMessageHop) };
146 }
147 #[no_mangle]
148 /// Utility method to constructs a new NodeId-variant NextMessageHop
149 pub extern "C" fn NextMessageHop_node_id(a: crate::c_types::PublicKey) -> NextMessageHop {
150         NextMessageHop::NodeId(a, )
151 }
152 #[no_mangle]
153 /// Utility method to constructs a new ShortChannelId-variant NextMessageHop
154 pub extern "C" fn NextMessageHop_short_channel_id(a: u64) -> NextMessageHop {
155         NextMessageHop::ShortChannelId(a, )
156 }
157 /// Get a string which allows debug introspection of a NextMessageHop object
158 pub extern "C" fn NextMessageHop_debug_str_void(o: *const c_void) -> Str {
159         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::NextMessageHop }).into()}
160 /// Generates a non-cryptographic 64-bit hash of the NextMessageHop.
161 #[no_mangle]
162 pub extern "C" fn NextMessageHop_hash(o: &NextMessageHop) -> u64 {
163         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
164         #[allow(deprecated)]
165         let mut hasher = core::hash::SipHasher::new();
166         core::hash::Hash::hash(&o.to_native(), &mut hasher);
167         core::hash::Hasher::finish(&hasher)
168 }
169 /// Checks if two NextMessageHops contain equal inner contents.
170 /// This ignores pointers and is_owned flags and looks at the values in fields.
171 #[no_mangle]
172 pub extern "C" fn NextMessageHop_eq(a: &NextMessageHop, b: &NextMessageHop) -> bool {
173         if &a.to_native() == &b.to_native() { true } else { false }
174 }
175
176 use lightning::blinded_path::BlindedPath as nativeBlindedPathImport;
177 pub(crate) type nativeBlindedPath = nativeBlindedPathImport;
178
179 /// Onion messages and payments can be sent and received to blinded paths, which serve to hide the
180 /// identity of the recipient.
181 #[must_use]
182 #[repr(C)]
183 pub struct BlindedPath {
184         /// A pointer to the opaque Rust object.
185
186         /// Nearly everywhere, inner must be non-null, however in places where
187         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
188         pub inner: *mut nativeBlindedPath,
189         /// Indicates that this is the only struct which contains the same pointer.
190
191         /// Rust functions which take ownership of an object provided via an argument require
192         /// this to be true and invalidate the object pointed to by inner.
193         pub is_owned: bool,
194 }
195
196 impl Drop for BlindedPath {
197         fn drop(&mut self) {
198                 if self.is_owned && !<*mut nativeBlindedPath>::is_null(self.inner) {
199                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
200                 }
201         }
202 }
203 /// Frees any resources used by the BlindedPath, if is_owned is set and inner is non-NULL.
204 #[no_mangle]
205 pub extern "C" fn BlindedPath_free(this_obj: BlindedPath) { }
206 #[allow(unused)]
207 /// Used only if an object of this type is returned as a trait impl by a method
208 pub(crate) extern "C" fn BlindedPath_free_void(this_ptr: *mut c_void) {
209         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPath) };
210 }
211 #[allow(unused)]
212 impl BlindedPath {
213         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPath {
214                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
215         }
216         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPath {
217                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
218         }
219         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
220         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPath {
221                 assert!(self.is_owned);
222                 let ret = ObjOps::untweak_ptr(self.inner);
223                 self.inner = core::ptr::null_mut();
224                 ret
225         }
226 }
227 /// To send to a blinded path, the sender first finds a route to the unblinded
228 /// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
229 /// message or payment's next hop and forward it along.
230 ///
231 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
232 #[no_mangle]
233 pub extern "C" fn BlindedPath_get_introduction_node(this_ptr: &BlindedPath) -> crate::lightning::blinded_path::IntroductionNode {
234         let mut inner_val = &mut this_ptr.get_native_mut_ref().introduction_node;
235         crate::lightning::blinded_path::IntroductionNode::from_native(inner_val)
236 }
237 /// To send to a blinded path, the sender first finds a route to the unblinded
238 /// `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
239 /// message or payment's next hop and forward it along.
240 ///
241 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
242 #[no_mangle]
243 pub extern "C" fn BlindedPath_set_introduction_node(this_ptr: &mut BlindedPath, mut val: crate::lightning::blinded_path::IntroductionNode) {
244         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.introduction_node = val.into_native();
245 }
246 /// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
247 /// message or payment.
248 ///
249 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
250 #[no_mangle]
251 pub extern "C" fn BlindedPath_get_blinding_point(this_ptr: &BlindedPath) -> crate::c_types::PublicKey {
252         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
253         crate::c_types::PublicKey::from_rust(&inner_val)
254 }
255 /// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
256 /// message or payment.
257 ///
258 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
259 #[no_mangle]
260 pub extern "C" fn BlindedPath_set_blinding_point(this_ptr: &mut BlindedPath, mut val: crate::c_types::PublicKey) {
261         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
262 }
263 /// The hops composing the blinded path.
264 #[no_mangle]
265 pub extern "C" fn BlindedPath_get_blinded_hops(this_ptr: &BlindedPath) -> crate::c_types::derived::CVec_BlindedHopZ {
266         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_hops;
267         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 } }); };
268         local_inner_val.into()
269 }
270 /// The hops composing the blinded path.
271 #[no_mangle]
272 pub extern "C" fn BlindedPath_set_blinded_hops(this_ptr: &mut BlindedPath, mut val: crate::c_types::derived::CVec_BlindedHopZ) {
273         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
274         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_hops = local_val;
275 }
276 /// Constructs a new BlindedPath given each field
277 #[must_use]
278 #[no_mangle]
279 pub extern "C" fn BlindedPath_new(mut introduction_node_arg: crate::lightning::blinded_path::IntroductionNode, mut blinding_point_arg: crate::c_types::PublicKey, mut blinded_hops_arg: crate::c_types::derived::CVec_BlindedHopZ) -> BlindedPath {
280         let mut local_blinded_hops_arg = Vec::new(); for mut item in blinded_hops_arg.into_rust().drain(..) { local_blinded_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
281         BlindedPath { inner: ObjOps::heap_alloc(nativeBlindedPath {
282                 introduction_node: introduction_node_arg.into_native(),
283                 blinding_point: blinding_point_arg.into_rust(),
284                 blinded_hops: local_blinded_hops_arg,
285         }), is_owned: true }
286 }
287 impl Clone for BlindedPath {
288         fn clone(&self) -> Self {
289                 Self {
290                         inner: if <*mut nativeBlindedPath>::is_null(self.inner) { core::ptr::null_mut() } else {
291                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
292                         is_owned: true,
293                 }
294         }
295 }
296 #[allow(unused)]
297 /// Used only if an object of this type is returned as a trait impl by a method
298 pub(crate) extern "C" fn BlindedPath_clone_void(this_ptr: *const c_void) -> *mut c_void {
299         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPath)).clone() })) as *mut c_void
300 }
301 #[no_mangle]
302 /// Creates a copy of the BlindedPath
303 pub extern "C" fn BlindedPath_clone(orig: &BlindedPath) -> BlindedPath {
304         orig.clone()
305 }
306 /// Get a string which allows debug introspection of a BlindedPath object
307 pub extern "C" fn BlindedPath_debug_str_void(o: *const c_void) -> Str {
308         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::BlindedPath }).into()}
309 /// Generates a non-cryptographic 64-bit hash of the BlindedPath.
310 #[no_mangle]
311 pub extern "C" fn BlindedPath_hash(o: &BlindedPath) -> u64 {
312         if o.inner.is_null() { return 0; }
313         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
314         #[allow(deprecated)]
315         let mut hasher = core::hash::SipHasher::new();
316         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
317         core::hash::Hasher::finish(&hasher)
318 }
319 /// Checks if two BlindedPaths contain equal inner contents.
320 /// This ignores pointers and is_owned flags and looks at the values in fields.
321 /// Two objects with NULL inner values will be considered "equal" here.
322 #[no_mangle]
323 pub extern "C" fn BlindedPath_eq(a: &BlindedPath, b: &BlindedPath) -> bool {
324         if a.inner == b.inner { return true; }
325         if a.inner.is_null() || b.inner.is_null() { return false; }
326         if a.get_native_ref() == b.get_native_ref() { true } else { false }
327 }
328 /// The unblinded node in a [`BlindedPath`].
329 #[derive(Clone)]
330 #[must_use]
331 #[repr(C)]
332 pub enum IntroductionNode {
333         /// The node id of the introduction node.
334         NodeId(
335                 crate::c_types::PublicKey),
336         /// The short channel id of the channel leading to the introduction node. The [`Direction`]
337         /// identifies which side of the channel is the introduction node.
338         DirectedShortChannelId(
339                 crate::lightning::blinded_path::Direction,
340                 u64),
341 }
342 use lightning::blinded_path::IntroductionNode as IntroductionNodeImport;
343 pub(crate) type nativeIntroductionNode = IntroductionNodeImport;
344
345 impl IntroductionNode {
346         #[allow(unused)]
347         pub(crate) fn to_native(&self) -> nativeIntroductionNode {
348                 match self {
349                         IntroductionNode::NodeId (ref a, ) => {
350                                 let mut a_nonref = Clone::clone(a);
351                                 nativeIntroductionNode::NodeId (
352                                         a_nonref.into_rust(),
353                                 )
354                         },
355                         IntroductionNode::DirectedShortChannelId (ref a, ref b, ) => {
356                                 let mut a_nonref = Clone::clone(a);
357                                 let mut b_nonref = Clone::clone(b);
358                                 nativeIntroductionNode::DirectedShortChannelId (
359                                         a_nonref.into_native(),
360                                         b_nonref,
361                                 )
362                         },
363                 }
364         }
365         #[allow(unused)]
366         pub(crate) fn into_native(self) -> nativeIntroductionNode {
367                 match self {
368                         IntroductionNode::NodeId (mut a, ) => {
369                                 nativeIntroductionNode::NodeId (
370                                         a.into_rust(),
371                                 )
372                         },
373                         IntroductionNode::DirectedShortChannelId (mut a, mut b, ) => {
374                                 nativeIntroductionNode::DirectedShortChannelId (
375                                         a.into_native(),
376                                         b,
377                                 )
378                         },
379                 }
380         }
381         #[allow(unused)]
382         pub(crate) fn from_native(native: &IntroductionNodeImport) -> Self {
383                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeIntroductionNode) };
384                 match native {
385                         nativeIntroductionNode::NodeId (ref a, ) => {
386                                 let mut a_nonref = Clone::clone(a);
387                                 IntroductionNode::NodeId (
388                                         crate::c_types::PublicKey::from_rust(&a_nonref),
389                                 )
390                         },
391                         nativeIntroductionNode::DirectedShortChannelId (ref a, ref b, ) => {
392                                 let mut a_nonref = Clone::clone(a);
393                                 let mut b_nonref = Clone::clone(b);
394                                 IntroductionNode::DirectedShortChannelId (
395                                         crate::lightning::blinded_path::Direction::native_into(a_nonref),
396                                         b_nonref,
397                                 )
398                         },
399                 }
400         }
401         #[allow(unused)]
402         pub(crate) fn native_into(native: nativeIntroductionNode) -> Self {
403                 match native {
404                         nativeIntroductionNode::NodeId (mut a, ) => {
405                                 IntroductionNode::NodeId (
406                                         crate::c_types::PublicKey::from_rust(&a),
407                                 )
408                         },
409                         nativeIntroductionNode::DirectedShortChannelId (mut a, mut b, ) => {
410                                 IntroductionNode::DirectedShortChannelId (
411                                         crate::lightning::blinded_path::Direction::native_into(a),
412                                         b,
413                                 )
414                         },
415                 }
416         }
417 }
418 /// Frees any resources used by the IntroductionNode
419 #[no_mangle]
420 pub extern "C" fn IntroductionNode_free(this_ptr: IntroductionNode) { }
421 /// Creates a copy of the IntroductionNode
422 #[no_mangle]
423 pub extern "C" fn IntroductionNode_clone(orig: &IntroductionNode) -> IntroductionNode {
424         orig.clone()
425 }
426 #[allow(unused)]
427 /// Used only if an object of this type is returned as a trait impl by a method
428 pub(crate) extern "C" fn IntroductionNode_clone_void(this_ptr: *const c_void) -> *mut c_void {
429         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const IntroductionNode)).clone() })) as *mut c_void
430 }
431 #[allow(unused)]
432 /// Used only if an object of this type is returned as a trait impl by a method
433 pub(crate) extern "C" fn IntroductionNode_free_void(this_ptr: *mut c_void) {
434         let _ = unsafe { Box::from_raw(this_ptr as *mut IntroductionNode) };
435 }
436 #[no_mangle]
437 /// Utility method to constructs a new NodeId-variant IntroductionNode
438 pub extern "C" fn IntroductionNode_node_id(a: crate::c_types::PublicKey) -> IntroductionNode {
439         IntroductionNode::NodeId(a, )
440 }
441 #[no_mangle]
442 /// Utility method to constructs a new DirectedShortChannelId-variant IntroductionNode
443 pub extern "C" fn IntroductionNode_directed_short_channel_id(a: crate::lightning::blinded_path::Direction,b: u64) -> IntroductionNode {
444         IntroductionNode::DirectedShortChannelId(a, b, )
445 }
446 /// Get a string which allows debug introspection of a IntroductionNode object
447 pub extern "C" fn IntroductionNode_debug_str_void(o: *const c_void) -> Str {
448         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::IntroductionNode }).into()}
449 /// Generates a non-cryptographic 64-bit hash of the IntroductionNode.
450 #[no_mangle]
451 pub extern "C" fn IntroductionNode_hash(o: &IntroductionNode) -> u64 {
452         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
453         #[allow(deprecated)]
454         let mut hasher = core::hash::SipHasher::new();
455         core::hash::Hash::hash(&o.to_native(), &mut hasher);
456         core::hash::Hasher::finish(&hasher)
457 }
458 /// Checks if two IntroductionNodes contain equal inner contents.
459 /// This ignores pointers and is_owned flags and looks at the values in fields.
460 #[no_mangle]
461 pub extern "C" fn IntroductionNode_eq(a: &IntroductionNode, b: &IntroductionNode) -> bool {
462         if &a.to_native() == &b.to_native() { true } else { false }
463 }
464 /// The side of a channel that is the [`IntroductionNode`] in a [`BlindedPath`]. [BOLT 7] defines
465 /// which nodes is which in the [`ChannelAnnouncement`] message.
466 ///
467 /// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message
468 /// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement
469 #[derive(Clone)]
470 #[must_use]
471 #[repr(C)]
472 pub enum Direction {
473         /// The lesser node id when compared lexicographically in ascending order.
474         NodeOne,
475         /// The greater node id when compared lexicographically in ascending order.
476         NodeTwo,
477 }
478 use lightning::blinded_path::Direction as DirectionImport;
479 pub(crate) type nativeDirection = DirectionImport;
480
481 impl Direction {
482         #[allow(unused)]
483         pub(crate) fn to_native(&self) -> nativeDirection {
484                 match self {
485                         Direction::NodeOne => nativeDirection::NodeOne,
486                         Direction::NodeTwo => nativeDirection::NodeTwo,
487                 }
488         }
489         #[allow(unused)]
490         pub(crate) fn into_native(self) -> nativeDirection {
491                 match self {
492                         Direction::NodeOne => nativeDirection::NodeOne,
493                         Direction::NodeTwo => nativeDirection::NodeTwo,
494                 }
495         }
496         #[allow(unused)]
497         pub(crate) fn from_native(native: &DirectionImport) -> Self {
498                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeDirection) };
499                 match native {
500                         nativeDirection::NodeOne => Direction::NodeOne,
501                         nativeDirection::NodeTwo => Direction::NodeTwo,
502                 }
503         }
504         #[allow(unused)]
505         pub(crate) fn native_into(native: nativeDirection) -> Self {
506                 match native {
507                         nativeDirection::NodeOne => Direction::NodeOne,
508                         nativeDirection::NodeTwo => Direction::NodeTwo,
509                 }
510         }
511 }
512 /// Creates a copy of the Direction
513 #[no_mangle]
514 pub extern "C" fn Direction_clone(orig: &Direction) -> Direction {
515         orig.clone()
516 }
517 #[allow(unused)]
518 /// Used only if an object of this type is returned as a trait impl by a method
519 pub(crate) extern "C" fn Direction_clone_void(this_ptr: *const c_void) -> *mut c_void {
520         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Direction)).clone() })) as *mut c_void
521 }
522 #[allow(unused)]
523 /// Used only if an object of this type is returned as a trait impl by a method
524 pub(crate) extern "C" fn Direction_free_void(this_ptr: *mut c_void) {
525         let _ = unsafe { Box::from_raw(this_ptr as *mut Direction) };
526 }
527 #[no_mangle]
528 /// Utility method to constructs a new NodeOne-variant Direction
529 pub extern "C" fn Direction_node_one() -> Direction {
530         Direction::NodeOne}
531 #[no_mangle]
532 /// Utility method to constructs a new NodeTwo-variant Direction
533 pub extern "C" fn Direction_node_two() -> Direction {
534         Direction::NodeTwo}
535 /// Get a string which allows debug introspection of a Direction object
536 pub extern "C" fn Direction_debug_str_void(o: *const c_void) -> Str {
537         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::Direction }).into()}
538 /// Generates a non-cryptographic 64-bit hash of the Direction.
539 #[no_mangle]
540 pub extern "C" fn Direction_hash(o: &Direction) -> u64 {
541         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
542         #[allow(deprecated)]
543         let mut hasher = core::hash::SipHasher::new();
544         core::hash::Hash::hash(&o.to_native(), &mut hasher);
545         core::hash::Hasher::finish(&hasher)
546 }
547 /// Checks if two Directions contain equal inner contents.
548 /// This ignores pointers and is_owned flags and looks at the values in fields.
549 #[no_mangle]
550 pub extern "C" fn Direction_eq(a: &Direction, b: &Direction) -> bool {
551         if &a.to_native() == &b.to_native() { true } else { false }
552 }
553 /// An interface for looking up the node id of a channel counterparty for the purpose of forwarding
554 /// an [`OnionMessage`].
555 ///
556 /// [`OnionMessage`]: crate::ln::msgs::OnionMessage
557 #[repr(C)]
558 pub struct NodeIdLookUp {
559         /// An opaque pointer which is passed to your function implementations as an argument.
560         /// This has no meaning in the LDK, and can be NULL or any other value.
561         pub this_arg: *mut c_void,
562         /// Returns the node id of the forwarding node's channel counterparty with `short_channel_id`.
563         ///
564         /// Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized
565         /// by the [`NodeIdLookUp`] and the counterparty to one of that node's peers.
566         ///
567         /// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
568         ///
569         /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
570         pub next_node_id: extern "C" fn (this_arg: *const c_void, short_channel_id: u64) -> crate::c_types::PublicKey,
571         /// Frees any resources associated with this object given its this_arg pointer.
572         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
573         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
574 }
575 unsafe impl Send for NodeIdLookUp {}
576 unsafe impl Sync for NodeIdLookUp {}
577 #[allow(unused)]
578 pub(crate) fn NodeIdLookUp_clone_fields(orig: &NodeIdLookUp) -> NodeIdLookUp {
579         NodeIdLookUp {
580                 this_arg: orig.this_arg,
581                 next_node_id: Clone::clone(&orig.next_node_id),
582                 free: Clone::clone(&orig.free),
583         }
584 }
585
586 use lightning::blinded_path::NodeIdLookUp as rustNodeIdLookUp;
587 impl rustNodeIdLookUp for NodeIdLookUp {
588         fn next_node_id(&self, mut short_channel_id: u64) -> Option<bitcoin::secp256k1::PublicKey> {
589                 let mut ret = (self.next_node_id)(self.this_arg, short_channel_id);
590                 let mut local_ret = if ret.is_null() { None } else { Some( { ret.into_rust() }) };
591                 local_ret
592         }
593 }
594
595 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
596 // directly as a Deref trait in higher-level structs:
597 impl core::ops::Deref for NodeIdLookUp {
598         type Target = Self;
599         fn deref(&self) -> &Self {
600                 self
601         }
602 }
603 impl core::ops::DerefMut for NodeIdLookUp {
604         fn deref_mut(&mut self) -> &mut Self {
605                 self
606         }
607 }
608 /// Calls the free function if one is set
609 #[no_mangle]
610 pub extern "C" fn NodeIdLookUp_free(this_ptr: NodeIdLookUp) { }
611 impl Drop for NodeIdLookUp {
612         fn drop(&mut self) {
613                 if let Some(f) = self.free {
614                         f(self.this_arg);
615                 }
616         }
617 }
618
619 use lightning::blinded_path::EmptyNodeIdLookUp as nativeEmptyNodeIdLookUpImport;
620 pub(crate) type nativeEmptyNodeIdLookUp = nativeEmptyNodeIdLookUpImport;
621
622 /// A [`NodeIdLookUp`] that always returns `None`.
623 #[must_use]
624 #[repr(C)]
625 pub struct EmptyNodeIdLookUp {
626         /// A pointer to the opaque Rust object.
627
628         /// Nearly everywhere, inner must be non-null, however in places where
629         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
630         pub inner: *mut nativeEmptyNodeIdLookUp,
631         /// Indicates that this is the only struct which contains the same pointer.
632
633         /// Rust functions which take ownership of an object provided via an argument require
634         /// this to be true and invalidate the object pointed to by inner.
635         pub is_owned: bool,
636 }
637
638 impl Drop for EmptyNodeIdLookUp {
639         fn drop(&mut self) {
640                 if self.is_owned && !<*mut nativeEmptyNodeIdLookUp>::is_null(self.inner) {
641                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
642                 }
643         }
644 }
645 /// Frees any resources used by the EmptyNodeIdLookUp, if is_owned is set and inner is non-NULL.
646 #[no_mangle]
647 pub extern "C" fn EmptyNodeIdLookUp_free(this_obj: EmptyNodeIdLookUp) { }
648 #[allow(unused)]
649 /// Used only if an object of this type is returned as a trait impl by a method
650 pub(crate) extern "C" fn EmptyNodeIdLookUp_free_void(this_ptr: *mut c_void) {
651         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeEmptyNodeIdLookUp) };
652 }
653 #[allow(unused)]
654 impl EmptyNodeIdLookUp {
655         pub(crate) fn get_native_ref(&self) -> &'static nativeEmptyNodeIdLookUp {
656                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
657         }
658         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeEmptyNodeIdLookUp {
659                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
660         }
661         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
662         pub(crate) fn take_inner(mut self) -> *mut nativeEmptyNodeIdLookUp {
663                 assert!(self.is_owned);
664                 let ret = ObjOps::untweak_ptr(self.inner);
665                 self.inner = core::ptr::null_mut();
666                 ret
667         }
668 }
669 /// Constructs a new EmptyNodeIdLookUp given each field
670 #[must_use]
671 #[no_mangle]
672 pub extern "C" fn EmptyNodeIdLookUp_new() -> EmptyNodeIdLookUp {
673         EmptyNodeIdLookUp { inner: ObjOps::heap_alloc(nativeEmptyNodeIdLookUp {
674         }), is_owned: true }
675 }
676 impl From<nativeEmptyNodeIdLookUp> for crate::lightning::blinded_path::NodeIdLookUp {
677         fn from(obj: nativeEmptyNodeIdLookUp) -> Self {
678                 let rust_obj = crate::lightning::blinded_path::EmptyNodeIdLookUp { inner: ObjOps::heap_alloc(obj), is_owned: true };
679                 let mut ret = EmptyNodeIdLookUp_as_NodeIdLookUp(&rust_obj);
680                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
681                 core::mem::forget(rust_obj);
682                 ret.free = Some(EmptyNodeIdLookUp_free_void);
683                 ret
684         }
685 }
686 /// Constructs a new NodeIdLookUp which calls the relevant methods on this_arg.
687 /// This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is
688 #[no_mangle]
689 pub extern "C" fn EmptyNodeIdLookUp_as_NodeIdLookUp(this_arg: &EmptyNodeIdLookUp) -> crate::lightning::blinded_path::NodeIdLookUp {
690         crate::lightning::blinded_path::NodeIdLookUp {
691                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
692                 free: None,
693                 next_node_id: EmptyNodeIdLookUp_NodeIdLookUp_next_node_id,
694         }
695 }
696
697 #[must_use]
698 extern "C" fn EmptyNodeIdLookUp_NodeIdLookUp_next_node_id(this_arg: *const c_void, mut short_channel_id: u64) -> crate::c_types::PublicKey {
699         let mut ret = <nativeEmptyNodeIdLookUp as lightning::blinded_path::NodeIdLookUp>::next_node_id(unsafe { &mut *(this_arg as *mut nativeEmptyNodeIdLookUp) }, short_channel_id);
700         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
701         local_ret
702 }
703
704
705 use lightning::blinded_path::BlindedHop as nativeBlindedHopImport;
706 pub(crate) type nativeBlindedHop = nativeBlindedHopImport;
707
708 /// An encrypted payload and node id corresponding to a hop in a payment or onion message path, to
709 /// be encoded in the sender's onion packet. These hops cannot be identified by outside observers
710 /// and thus can be used to hide the identity of the recipient.
711 #[must_use]
712 #[repr(C)]
713 pub struct BlindedHop {
714         /// A pointer to the opaque Rust object.
715
716         /// Nearly everywhere, inner must be non-null, however in places where
717         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
718         pub inner: *mut nativeBlindedHop,
719         /// Indicates that this is the only struct which contains the same pointer.
720
721         /// Rust functions which take ownership of an object provided via an argument require
722         /// this to be true and invalidate the object pointed to by inner.
723         pub is_owned: bool,
724 }
725
726 impl Drop for BlindedHop {
727         fn drop(&mut self) {
728                 if self.is_owned && !<*mut nativeBlindedHop>::is_null(self.inner) {
729                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
730                 }
731         }
732 }
733 /// Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL.
734 #[no_mangle]
735 pub extern "C" fn BlindedHop_free(this_obj: BlindedHop) { }
736 #[allow(unused)]
737 /// Used only if an object of this type is returned as a trait impl by a method
738 pub(crate) extern "C" fn BlindedHop_free_void(this_ptr: *mut c_void) {
739         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedHop) };
740 }
741 #[allow(unused)]
742 impl BlindedHop {
743         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedHop {
744                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
745         }
746         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedHop {
747                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
748         }
749         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
750         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedHop {
751                 assert!(self.is_owned);
752                 let ret = ObjOps::untweak_ptr(self.inner);
753                 self.inner = core::ptr::null_mut();
754                 ret
755         }
756 }
757 /// The blinded node id of this hop in a [`BlindedPath`].
758 #[no_mangle]
759 pub extern "C" fn BlindedHop_get_blinded_node_id(this_ptr: &BlindedHop) -> crate::c_types::PublicKey {
760         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_node_id;
761         crate::c_types::PublicKey::from_rust(&inner_val)
762 }
763 /// The blinded node id of this hop in a [`BlindedPath`].
764 #[no_mangle]
765 pub extern "C" fn BlindedHop_set_blinded_node_id(this_ptr: &mut BlindedHop, mut val: crate::c_types::PublicKey) {
766         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_node_id = val.into_rust();
767 }
768 /// The encrypted payload intended for this hop in a [`BlindedPath`].
769 ///
770 /// Returns a copy of the field.
771 #[no_mangle]
772 pub extern "C" fn BlindedHop_get_encrypted_payload(this_ptr: &BlindedHop) -> crate::c_types::derived::CVec_u8Z {
773         let mut inner_val = this_ptr.get_native_mut_ref().encrypted_payload.clone();
774         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
775         local_inner_val.into()
776 }
777 /// The encrypted payload intended for this hop in a [`BlindedPath`].
778 #[no_mangle]
779 pub extern "C" fn BlindedHop_set_encrypted_payload(this_ptr: &mut BlindedHop, mut val: crate::c_types::derived::CVec_u8Z) {
780         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
781         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.encrypted_payload = local_val;
782 }
783 /// Constructs a new BlindedHop given each field
784 #[must_use]
785 #[no_mangle]
786 pub extern "C" fn BlindedHop_new(mut blinded_node_id_arg: crate::c_types::PublicKey, mut encrypted_payload_arg: crate::c_types::derived::CVec_u8Z) -> BlindedHop {
787         let mut local_encrypted_payload_arg = Vec::new(); for mut item in encrypted_payload_arg.into_rust().drain(..) { local_encrypted_payload_arg.push( { item }); };
788         BlindedHop { inner: ObjOps::heap_alloc(nativeBlindedHop {
789                 blinded_node_id: blinded_node_id_arg.into_rust(),
790                 encrypted_payload: local_encrypted_payload_arg,
791         }), is_owned: true }
792 }
793 impl Clone for BlindedHop {
794         fn clone(&self) -> Self {
795                 Self {
796                         inner: if <*mut nativeBlindedHop>::is_null(self.inner) { core::ptr::null_mut() } else {
797                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
798                         is_owned: true,
799                 }
800         }
801 }
802 #[allow(unused)]
803 /// Used only if an object of this type is returned as a trait impl by a method
804 pub(crate) extern "C" fn BlindedHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
805         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedHop)).clone() })) as *mut c_void
806 }
807 #[no_mangle]
808 /// Creates a copy of the BlindedHop
809 pub extern "C" fn BlindedHop_clone(orig: &BlindedHop) -> BlindedHop {
810         orig.clone()
811 }
812 /// Get a string which allows debug introspection of a BlindedHop object
813 pub extern "C" fn BlindedHop_debug_str_void(o: *const c_void) -> Str {
814         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::BlindedHop }).into()}
815 /// Generates a non-cryptographic 64-bit hash of the BlindedHop.
816 #[no_mangle]
817 pub extern "C" fn BlindedHop_hash(o: &BlindedHop) -> u64 {
818         if o.inner.is_null() { return 0; }
819         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
820         #[allow(deprecated)]
821         let mut hasher = core::hash::SipHasher::new();
822         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
823         core::hash::Hasher::finish(&hasher)
824 }
825 /// Checks if two BlindedHops contain equal inner contents.
826 /// This ignores pointers and is_owned flags and looks at the values in fields.
827 /// Two objects with NULL inner values will be considered "equal" here.
828 #[no_mangle]
829 pub extern "C" fn BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> bool {
830         if a.inner == b.inner { return true; }
831         if a.inner.is_null() || b.inner.is_null() { return false; }
832         if a.get_native_ref() == b.get_native_ref() { true } else { false }
833 }
834 /// Create a one-hop blinded path for a message.
835 #[must_use]
836 #[no_mangle]
837 pub extern "C" fn BlindedPath_one_hop_for_message(mut recipient_node_id: crate::c_types::PublicKey, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ {
838         let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_message(recipient_node_id.into_rust(), entropy_source, secp256k1::global::SECP256K1);
839         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
840         local_ret
841 }
842
843 /// Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node
844 /// pubkey in `node_pks` will be the destination node.
845 ///
846 /// Errors if no hops are provided or if `node_pk`(s) are invalid.
847 #[must_use]
848 #[no_mangle]
849 pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ {
850         let mut local_node_pks = Vec::new(); for mut item in node_pks.into_rust().drain(..) { local_node_pks.push( { item.into_rust() }); };
851         let mut ret = lightning::blinded_path::BlindedPath::new_for_message(&local_node_pks[..], entropy_source, secp256k1::global::SECP256K1);
852         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
853         local_ret
854 }
855
856 /// Create a one-hop blinded path for a payment.
857 #[must_use]
858 #[no_mangle]
859 pub extern "C" fn BlindedPath_one_hop_for_payment(mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ {
860         let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_payment(payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, min_final_cltv_expiry_delta, entropy_source, secp256k1::global::SECP256K1);
861         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
862         local_ret
863 }
864
865 /// Create a blinded path for a payment, to be forwarded along `intermediate_nodes`.
866 ///
867 /// Errors if:
868 /// * a provided node id is invalid
869 /// * [`BlindedPayInfo`] calculation results in an integer overflow
870 /// * any unknown features are required in the provided [`ForwardTlvs`]
871 ///
872 /// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
873 #[must_use]
874 #[no_mangle]
875 pub extern "C" fn BlindedPath_new_for_payment(mut intermediate_nodes: crate::c_types::derived::CVec_ForwardNodeZ, mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut htlc_maximum_msat: u64, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ {
876         let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
877         let mut ret = lightning::blinded_path::BlindedPath::new_for_payment(local_intermediate_nodes, payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, htlc_maximum_msat, min_final_cltv_expiry_delta, entropy_source, secp256k1::global::SECP256K1);
878         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
879         local_ret
880 }
881
882 /// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
883 /// it is found in the network graph).
884 ///
885 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
886 #[must_use]
887 #[no_mangle]
888 pub extern "C" fn BlindedPath_public_introduction_node_id(this_arg: &crate::lightning::blinded_path::BlindedPath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::lightning::routing::gossip::NodeId {
889         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.public_introduction_node_id(network_graph.get_native_ref());
890         let mut local_ret = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false };
891         local_ret
892 }
893
894 #[no_mangle]
895 /// Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read
896 pub extern "C" fn BlindedPath_write(obj: &crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CVec_u8Z {
897         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
898 }
899 #[allow(unused)]
900 pub(crate) extern "C" fn BlindedPath_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
901         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPath) })
902 }
903 #[no_mangle]
904 /// Read a BlindedPath from a byte array, created by BlindedPath_write
905 pub extern "C" fn BlindedPath_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPathDecodeErrorZ {
906         let res: Result<lightning::blinded_path::BlindedPath, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
907         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { 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() };
908         local_res
909 }
910 #[no_mangle]
911 /// Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read
912 pub extern "C" fn BlindedHop_write(obj: &crate::lightning::blinded_path::BlindedHop) -> crate::c_types::derived::CVec_u8Z {
913         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
914 }
915 #[allow(unused)]
916 pub(crate) extern "C" fn BlindedHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
917         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedHop) })
918 }
919 #[no_mangle]
920 /// Read a BlindedHop from a byte array, created by BlindedHop_write
921 pub extern "C" fn BlindedHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedHopDecodeErrorZ {
922         let res: Result<lightning::blinded_path::BlindedHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
923         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedHop { 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() };
924         local_res
925 }