Update auto-generated bindings to LDK 0.0.121
[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
46 use lightning::blinded_path::BlindedPath as nativeBlindedPathImport;
47 pub(crate) type nativeBlindedPath = nativeBlindedPathImport;
48
49 /// Onion messages and payments can be sent and received to blinded paths, which serve to hide the
50 /// identity of the recipient.
51 #[must_use]
52 #[repr(C)]
53 pub struct BlindedPath {
54         /// A pointer to the opaque Rust object.
55
56         /// Nearly everywhere, inner must be non-null, however in places where
57         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
58         pub inner: *mut nativeBlindedPath,
59         /// Indicates that this is the only struct which contains the same pointer.
60
61         /// Rust functions which take ownership of an object provided via an argument require
62         /// this to be true and invalidate the object pointed to by inner.
63         pub is_owned: bool,
64 }
65
66 impl Drop for BlindedPath {
67         fn drop(&mut self) {
68                 if self.is_owned && !<*mut nativeBlindedPath>::is_null(self.inner) {
69                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
70                 }
71         }
72 }
73 /// Frees any resources used by the BlindedPath, if is_owned is set and inner is non-NULL.
74 #[no_mangle]
75 pub extern "C" fn BlindedPath_free(this_obj: BlindedPath) { }
76 #[allow(unused)]
77 /// Used only if an object of this type is returned as a trait impl by a method
78 pub(crate) extern "C" fn BlindedPath_free_void(this_ptr: *mut c_void) {
79         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPath) };
80 }
81 #[allow(unused)]
82 impl BlindedPath {
83         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPath {
84                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
85         }
86         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPath {
87                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
88         }
89         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
90         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPath {
91                 assert!(self.is_owned);
92                 let ret = ObjOps::untweak_ptr(self.inner);
93                 self.inner = core::ptr::null_mut();
94                 ret
95         }
96 }
97 /// To send to a blinded path, the sender first finds a route to the unblinded
98 /// `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion
99 /// message or payment's next hop and forward it along.
100 ///
101 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
102 #[no_mangle]
103 pub extern "C" fn BlindedPath_get_introduction_node_id(this_ptr: &BlindedPath) -> crate::c_types::PublicKey {
104         let mut inner_val = &mut this_ptr.get_native_mut_ref().introduction_node_id;
105         crate::c_types::PublicKey::from_rust(&inner_val)
106 }
107 /// To send to a blinded path, the sender first finds a route to the unblinded
108 /// `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion
109 /// message or payment's next hop and forward it along.
110 ///
111 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
112 #[no_mangle]
113 pub extern "C" fn BlindedPath_set_introduction_node_id(this_ptr: &mut BlindedPath, mut val: crate::c_types::PublicKey) {
114         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.introduction_node_id = val.into_rust();
115 }
116 /// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
117 /// message or payment.
118 ///
119 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
120 #[no_mangle]
121 pub extern "C" fn BlindedPath_get_blinding_point(this_ptr: &BlindedPath) -> crate::c_types::PublicKey {
122         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point;
123         crate::c_types::PublicKey::from_rust(&inner_val)
124 }
125 /// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
126 /// message or payment.
127 ///
128 /// [`encrypted_payload`]: BlindedHop::encrypted_payload
129 #[no_mangle]
130 pub extern "C" fn BlindedPath_set_blinding_point(this_ptr: &mut BlindedPath, mut val: crate::c_types::PublicKey) {
131         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust();
132 }
133 /// The hops composing the blinded path.
134 #[no_mangle]
135 pub extern "C" fn BlindedPath_get_blinded_hops(this_ptr: &BlindedPath) -> crate::c_types::derived::CVec_BlindedHopZ {
136         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_hops;
137         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 } }); };
138         local_inner_val.into()
139 }
140 /// The hops composing the blinded path.
141 #[no_mangle]
142 pub extern "C" fn BlindedPath_set_blinded_hops(this_ptr: &mut BlindedPath, mut val: crate::c_types::derived::CVec_BlindedHopZ) {
143         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
144         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_hops = local_val;
145 }
146 /// Constructs a new BlindedPath given each field
147 #[must_use]
148 #[no_mangle]
149 pub extern "C" fn BlindedPath_new(mut introduction_node_id_arg: crate::c_types::PublicKey, mut blinding_point_arg: crate::c_types::PublicKey, mut blinded_hops_arg: crate::c_types::derived::CVec_BlindedHopZ) -> BlindedPath {
150         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()) } }); };
151         BlindedPath { inner: ObjOps::heap_alloc(nativeBlindedPath {
152                 introduction_node_id: introduction_node_id_arg.into_rust(),
153                 blinding_point: blinding_point_arg.into_rust(),
154                 blinded_hops: local_blinded_hops_arg,
155         }), is_owned: true }
156 }
157 impl Clone for BlindedPath {
158         fn clone(&self) -> Self {
159                 Self {
160                         inner: if <*mut nativeBlindedPath>::is_null(self.inner) { core::ptr::null_mut() } else {
161                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
162                         is_owned: true,
163                 }
164         }
165 }
166 #[allow(unused)]
167 /// Used only if an object of this type is returned as a trait impl by a method
168 pub(crate) extern "C" fn BlindedPath_clone_void(this_ptr: *const c_void) -> *mut c_void {
169         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPath)).clone() })) as *mut c_void
170 }
171 #[no_mangle]
172 /// Creates a copy of the BlindedPath
173 pub extern "C" fn BlindedPath_clone(orig: &BlindedPath) -> BlindedPath {
174         orig.clone()
175 }
176 /// Get a string which allows debug introspection of a BlindedPath object
177 pub extern "C" fn BlindedPath_debug_str_void(o: *const c_void) -> Str {
178         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::BlindedPath }).into()}
179 /// Generates a non-cryptographic 64-bit hash of the BlindedPath.
180 #[no_mangle]
181 pub extern "C" fn BlindedPath_hash(o: &BlindedPath) -> u64 {
182         if o.inner.is_null() { return 0; }
183         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
184         #[allow(deprecated)]
185         let mut hasher = core::hash::SipHasher::new();
186         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
187         core::hash::Hasher::finish(&hasher)
188 }
189 /// Checks if two BlindedPaths contain equal inner contents.
190 /// This ignores pointers and is_owned flags and looks at the values in fields.
191 /// Two objects with NULL inner values will be considered "equal" here.
192 #[no_mangle]
193 pub extern "C" fn BlindedPath_eq(a: &BlindedPath, b: &BlindedPath) -> bool {
194         if a.inner == b.inner { return true; }
195         if a.inner.is_null() || b.inner.is_null() { return false; }
196         if a.get_native_ref() == b.get_native_ref() { true } else { false }
197 }
198
199 use lightning::blinded_path::BlindedHop as nativeBlindedHopImport;
200 pub(crate) type nativeBlindedHop = nativeBlindedHopImport;
201
202 /// An encrypted payload and node id corresponding to a hop in a payment or onion message path, to
203 /// be encoded in the sender's onion packet. These hops cannot be identified by outside observers
204 /// and thus can be used to hide the identity of the recipient.
205 #[must_use]
206 #[repr(C)]
207 pub struct BlindedHop {
208         /// A pointer to the opaque Rust object.
209
210         /// Nearly everywhere, inner must be non-null, however in places where
211         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
212         pub inner: *mut nativeBlindedHop,
213         /// Indicates that this is the only struct which contains the same pointer.
214
215         /// Rust functions which take ownership of an object provided via an argument require
216         /// this to be true and invalidate the object pointed to by inner.
217         pub is_owned: bool,
218 }
219
220 impl Drop for BlindedHop {
221         fn drop(&mut self) {
222                 if self.is_owned && !<*mut nativeBlindedHop>::is_null(self.inner) {
223                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
224                 }
225         }
226 }
227 /// Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL.
228 #[no_mangle]
229 pub extern "C" fn BlindedHop_free(this_obj: BlindedHop) { }
230 #[allow(unused)]
231 /// Used only if an object of this type is returned as a trait impl by a method
232 pub(crate) extern "C" fn BlindedHop_free_void(this_ptr: *mut c_void) {
233         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedHop) };
234 }
235 #[allow(unused)]
236 impl BlindedHop {
237         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedHop {
238                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
239         }
240         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedHop {
241                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
242         }
243         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
244         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedHop {
245                 assert!(self.is_owned);
246                 let ret = ObjOps::untweak_ptr(self.inner);
247                 self.inner = core::ptr::null_mut();
248                 ret
249         }
250 }
251 /// The blinded node id of this hop in a [`BlindedPath`].
252 #[no_mangle]
253 pub extern "C" fn BlindedHop_get_blinded_node_id(this_ptr: &BlindedHop) -> crate::c_types::PublicKey {
254         let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_node_id;
255         crate::c_types::PublicKey::from_rust(&inner_val)
256 }
257 /// The blinded node id of this hop in a [`BlindedPath`].
258 #[no_mangle]
259 pub extern "C" fn BlindedHop_set_blinded_node_id(this_ptr: &mut BlindedHop, mut val: crate::c_types::PublicKey) {
260         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_node_id = val.into_rust();
261 }
262 /// The encrypted payload intended for this hop in a [`BlindedPath`].
263 ///
264 /// Returns a copy of the field.
265 #[no_mangle]
266 pub extern "C" fn BlindedHop_get_encrypted_payload(this_ptr: &BlindedHop) -> crate::c_types::derived::CVec_u8Z {
267         let mut inner_val = this_ptr.get_native_mut_ref().encrypted_payload.clone();
268         let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); };
269         local_inner_val.into()
270 }
271 /// The encrypted payload intended for this hop in a [`BlindedPath`].
272 #[no_mangle]
273 pub extern "C" fn BlindedHop_set_encrypted_payload(this_ptr: &mut BlindedHop, mut val: crate::c_types::derived::CVec_u8Z) {
274         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); };
275         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.encrypted_payload = local_val;
276 }
277 /// Constructs a new BlindedHop given each field
278 #[must_use]
279 #[no_mangle]
280 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 {
281         let mut local_encrypted_payload_arg = Vec::new(); for mut item in encrypted_payload_arg.into_rust().drain(..) { local_encrypted_payload_arg.push( { item }); };
282         BlindedHop { inner: ObjOps::heap_alloc(nativeBlindedHop {
283                 blinded_node_id: blinded_node_id_arg.into_rust(),
284                 encrypted_payload: local_encrypted_payload_arg,
285         }), is_owned: true }
286 }
287 impl Clone for BlindedHop {
288         fn clone(&self) -> Self {
289                 Self {
290                         inner: if <*mut nativeBlindedHop>::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 BlindedHop_clone_void(this_ptr: *const c_void) -> *mut c_void {
299         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedHop)).clone() })) as *mut c_void
300 }
301 #[no_mangle]
302 /// Creates a copy of the BlindedHop
303 pub extern "C" fn BlindedHop_clone(orig: &BlindedHop) -> BlindedHop {
304         orig.clone()
305 }
306 /// Get a string which allows debug introspection of a BlindedHop object
307 pub extern "C" fn BlindedHop_debug_str_void(o: *const c_void) -> Str {
308         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::BlindedHop }).into()}
309 /// Generates a non-cryptographic 64-bit hash of the BlindedHop.
310 #[no_mangle]
311 pub extern "C" fn BlindedHop_hash(o: &BlindedHop) -> 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 BlindedHops 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 BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> 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 /// Create a one-hop blinded path for a message.
329 #[must_use]
330 #[no_mangle]
331 pub extern "C" fn BlindedPath_one_hop_for_message(mut recipient_node_id: crate::c_types::PublicKey, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ {
332         let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_message(recipient_node_id.into_rust(), entropy_source, secp256k1::global::SECP256K1);
333         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() };
334         local_ret
335 }
336
337 /// Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node
338 /// pubkey in `node_pks` will be the destination node.
339 ///
340 /// Errors if no hops are provided or if `node_pk`(s) are invalid.
341 #[must_use]
342 #[no_mangle]
343 pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ {
344         let mut local_node_pks = Vec::new(); for mut item in node_pks.into_rust().drain(..) { local_node_pks.push( { item.into_rust() }); };
345         let mut ret = lightning::blinded_path::BlindedPath::new_for_message(&local_node_pks[..], entropy_source, secp256k1::global::SECP256K1);
346         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() };
347         local_ret
348 }
349
350 /// Create a one-hop blinded path for a payment.
351 #[must_use]
352 #[no_mangle]
353 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, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ {
354         let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_payment(payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, entropy_source, secp256k1::global::SECP256K1);
355         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() };
356         local_ret
357 }
358
359 /// Create a blinded path for a payment, to be forwarded along `intermediate_nodes`.
360 ///
361 /// Errors if:
362 /// * a provided node id is invalid
363 /// * [`BlindedPayInfo`] calculation results in an integer overflow
364 /// * any unknown features are required in the provided [`ForwardTlvs`]
365 ///
366 /// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs
367 #[must_use]
368 #[no_mangle]
369 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, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ {
370         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()) } }); };
371         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, entropy_source, secp256k1::global::SECP256K1);
372         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() };
373         local_ret
374 }
375
376 #[no_mangle]
377 /// Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read
378 pub extern "C" fn BlindedPath_write(obj: &crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CVec_u8Z {
379         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
380 }
381 #[allow(unused)]
382 pub(crate) extern "C" fn BlindedPath_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
383         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPath) })
384 }
385 #[no_mangle]
386 /// Read a BlindedPath from a byte array, created by BlindedPath_write
387 pub extern "C" fn BlindedPath_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPathDecodeErrorZ {
388         let res: Result<lightning::blinded_path::BlindedPath, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
389         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() };
390         local_res
391 }
392 #[no_mangle]
393 /// Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read
394 pub extern "C" fn BlindedHop_write(obj: &crate::lightning::blinded_path::BlindedHop) -> crate::c_types::derived::CVec_u8Z {
395         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
396 }
397 #[allow(unused)]
398 pub(crate) extern "C" fn BlindedHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
399         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedHop) })
400 }
401 #[no_mangle]
402 /// Read a BlindedHop from a byte array, created by BlindedHop_write
403 pub extern "C" fn BlindedHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedHopDecodeErrorZ {
404         let res: Result<lightning::blinded_path::BlindedHop, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
405         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() };
406         local_res
407 }