Update auto-generated bindings to LDK 0.0.121
[ldk-c-bindings] / lightning-c-bindings / src / lightning / blinded_path / payment.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 //! Data structures and methods for constructing [`BlindedPath`]s to send a payment over.
10 //!
11 //! [`BlindedPath`]: crate::blinded_path::BlindedPath
12
13 use alloc::str::FromStr;
14 use alloc::string::String;
15 use core::ffi::c_void;
16 use core::convert::Infallible;
17 use bitcoin::hashes::Hash;
18 use crate::c_types::*;
19 #[cfg(feature="no-std")]
20 use alloc::{vec::Vec, boxed::Box};
21
22
23 use lightning::blinded_path::payment::ForwardNode as nativeForwardNodeImport;
24 pub(crate) type nativeForwardNode = nativeForwardNodeImport;
25
26 /// An intermediate node, its outbound channel, and relay parameters.
27 #[must_use]
28 #[repr(C)]
29 pub struct ForwardNode {
30         /// A pointer to the opaque Rust object.
31
32         /// Nearly everywhere, inner must be non-null, however in places where
33         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
34         pub inner: *mut nativeForwardNode,
35         /// Indicates that this is the only struct which contains the same pointer.
36
37         /// Rust functions which take ownership of an object provided via an argument require
38         /// this to be true and invalidate the object pointed to by inner.
39         pub is_owned: bool,
40 }
41
42 impl Drop for ForwardNode {
43         fn drop(&mut self) {
44                 if self.is_owned && !<*mut nativeForwardNode>::is_null(self.inner) {
45                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
46                 }
47         }
48 }
49 /// Frees any resources used by the ForwardNode, if is_owned is set and inner is non-NULL.
50 #[no_mangle]
51 pub extern "C" fn ForwardNode_free(this_obj: ForwardNode) { }
52 #[allow(unused)]
53 /// Used only if an object of this type is returned as a trait impl by a method
54 pub(crate) extern "C" fn ForwardNode_free_void(this_ptr: *mut c_void) {
55         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeForwardNode) };
56 }
57 #[allow(unused)]
58 impl ForwardNode {
59         pub(crate) fn get_native_ref(&self) -> &'static nativeForwardNode {
60                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
61         }
62         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeForwardNode {
63                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
64         }
65         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
66         pub(crate) fn take_inner(mut self) -> *mut nativeForwardNode {
67                 assert!(self.is_owned);
68                 let ret = ObjOps::untweak_ptr(self.inner);
69                 self.inner = core::ptr::null_mut();
70                 ret
71         }
72 }
73 /// The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also
74 /// used for [`BlindedPayInfo`] construction.
75 #[no_mangle]
76 pub extern "C" fn ForwardNode_get_tlvs(this_ptr: &ForwardNode) -> crate::lightning::blinded_path::payment::ForwardTlvs {
77         let mut inner_val = &mut this_ptr.get_native_mut_ref().tlvs;
78         crate::lightning::blinded_path::payment::ForwardTlvs { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::ForwardTlvs<>) as *mut _) }, is_owned: false }
79 }
80 /// The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also
81 /// used for [`BlindedPayInfo`] construction.
82 #[no_mangle]
83 pub extern "C" fn ForwardNode_set_tlvs(this_ptr: &mut ForwardNode, mut val: crate::lightning::blinded_path::payment::ForwardTlvs) {
84         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tlvs = *unsafe { Box::from_raw(val.take_inner()) };
85 }
86 /// This node's pubkey.
87 #[no_mangle]
88 pub extern "C" fn ForwardNode_get_node_id(this_ptr: &ForwardNode) -> crate::c_types::PublicKey {
89         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
90         crate::c_types::PublicKey::from_rust(&inner_val)
91 }
92 /// This node's pubkey.
93 #[no_mangle]
94 pub extern "C" fn ForwardNode_set_node_id(this_ptr: &mut ForwardNode, mut val: crate::c_types::PublicKey) {
95         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
96 }
97 /// The maximum value, in msat, that may be accepted by this node.
98 #[no_mangle]
99 pub extern "C" fn ForwardNode_get_htlc_maximum_msat(this_ptr: &ForwardNode) -> u64 {
100         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
101         *inner_val
102 }
103 /// The maximum value, in msat, that may be accepted by this node.
104 #[no_mangle]
105 pub extern "C" fn ForwardNode_set_htlc_maximum_msat(this_ptr: &mut ForwardNode, mut val: u64) {
106         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
107 }
108 /// Constructs a new ForwardNode given each field
109 #[must_use]
110 #[no_mangle]
111 pub extern "C" fn ForwardNode_new(mut tlvs_arg: crate::lightning::blinded_path::payment::ForwardTlvs, mut node_id_arg: crate::c_types::PublicKey, mut htlc_maximum_msat_arg: u64) -> ForwardNode {
112         ForwardNode { inner: ObjOps::heap_alloc(nativeForwardNode {
113                 tlvs: *unsafe { Box::from_raw(tlvs_arg.take_inner()) },
114                 node_id: node_id_arg.into_rust(),
115                 htlc_maximum_msat: htlc_maximum_msat_arg,
116         }), is_owned: true }
117 }
118 impl Clone for ForwardNode {
119         fn clone(&self) -> Self {
120                 Self {
121                         inner: if <*mut nativeForwardNode>::is_null(self.inner) { core::ptr::null_mut() } else {
122                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
123                         is_owned: true,
124                 }
125         }
126 }
127 #[allow(unused)]
128 /// Used only if an object of this type is returned as a trait impl by a method
129 pub(crate) extern "C" fn ForwardNode_clone_void(this_ptr: *const c_void) -> *mut c_void {
130         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeForwardNode)).clone() })) as *mut c_void
131 }
132 #[no_mangle]
133 /// Creates a copy of the ForwardNode
134 pub extern "C" fn ForwardNode_clone(orig: &ForwardNode) -> ForwardNode {
135         orig.clone()
136 }
137 /// Get a string which allows debug introspection of a ForwardNode object
138 pub extern "C" fn ForwardNode_debug_str_void(o: *const c_void) -> Str {
139         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::ForwardNode }).into()}
140
141 use lightning::blinded_path::payment::ForwardTlvs as nativeForwardTlvsImport;
142 pub(crate) type nativeForwardTlvs = nativeForwardTlvsImport;
143
144 /// Data to construct a [`BlindedHop`] for forwarding a payment.
145 #[must_use]
146 #[repr(C)]
147 pub struct ForwardTlvs {
148         /// A pointer to the opaque Rust object.
149
150         /// Nearly everywhere, inner must be non-null, however in places where
151         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
152         pub inner: *mut nativeForwardTlvs,
153         /// Indicates that this is the only struct which contains the same pointer.
154
155         /// Rust functions which take ownership of an object provided via an argument require
156         /// this to be true and invalidate the object pointed to by inner.
157         pub is_owned: bool,
158 }
159
160 impl Drop for ForwardTlvs {
161         fn drop(&mut self) {
162                 if self.is_owned && !<*mut nativeForwardTlvs>::is_null(self.inner) {
163                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
164                 }
165         }
166 }
167 /// Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL.
168 #[no_mangle]
169 pub extern "C" fn ForwardTlvs_free(this_obj: ForwardTlvs) { }
170 #[allow(unused)]
171 /// Used only if an object of this type is returned as a trait impl by a method
172 pub(crate) extern "C" fn ForwardTlvs_free_void(this_ptr: *mut c_void) {
173         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeForwardTlvs) };
174 }
175 #[allow(unused)]
176 impl ForwardTlvs {
177         pub(crate) fn get_native_ref(&self) -> &'static nativeForwardTlvs {
178                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
179         }
180         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeForwardTlvs {
181                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
182         }
183         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
184         pub(crate) fn take_inner(mut self) -> *mut nativeForwardTlvs {
185                 assert!(self.is_owned);
186                 let ret = ObjOps::untweak_ptr(self.inner);
187                 self.inner = core::ptr::null_mut();
188                 ret
189         }
190 }
191 /// The short channel id this payment should be forwarded out over.
192 #[no_mangle]
193 pub extern "C" fn ForwardTlvs_get_short_channel_id(this_ptr: &ForwardTlvs) -> u64 {
194         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
195         *inner_val
196 }
197 /// The short channel id this payment should be forwarded out over.
198 #[no_mangle]
199 pub extern "C" fn ForwardTlvs_set_short_channel_id(this_ptr: &mut ForwardTlvs, mut val: u64) {
200         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
201 }
202 /// Payment parameters for relaying over [`Self::short_channel_id`].
203 #[no_mangle]
204 pub extern "C" fn ForwardTlvs_get_payment_relay(this_ptr: &ForwardTlvs) -> crate::lightning::blinded_path::payment::PaymentRelay {
205         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_relay;
206         crate::lightning::blinded_path::payment::PaymentRelay { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::PaymentRelay<>) as *mut _) }, is_owned: false }
207 }
208 /// Payment parameters for relaying over [`Self::short_channel_id`].
209 #[no_mangle]
210 pub extern "C" fn ForwardTlvs_set_payment_relay(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::blinded_path::payment::PaymentRelay) {
211         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_relay = *unsafe { Box::from_raw(val.take_inner()) };
212 }
213 /// Payment constraints for relaying over [`Self::short_channel_id`].
214 #[no_mangle]
215 pub extern "C" fn ForwardTlvs_get_payment_constraints(this_ptr: &ForwardTlvs) -> crate::lightning::blinded_path::payment::PaymentConstraints {
216         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_constraints;
217         crate::lightning::blinded_path::payment::PaymentConstraints { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::PaymentConstraints<>) as *mut _) }, is_owned: false }
218 }
219 /// Payment constraints for relaying over [`Self::short_channel_id`].
220 #[no_mangle]
221 pub extern "C" fn ForwardTlvs_set_payment_constraints(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::blinded_path::payment::PaymentConstraints) {
222         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_constraints = *unsafe { Box::from_raw(val.take_inner()) };
223 }
224 /// Supported and required features when relaying a payment onion containing this object's
225 /// corresponding [`BlindedHop::encrypted_payload`].
226 ///
227 /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
228 #[no_mangle]
229 pub extern "C" fn ForwardTlvs_get_features(this_ptr: &ForwardTlvs) -> crate::lightning::ln::features::BlindedHopFeatures {
230         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
231         crate::lightning::ln::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false }
232 }
233 /// Supported and required features when relaying a payment onion containing this object's
234 /// corresponding [`BlindedHop::encrypted_payload`].
235 ///
236 /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
237 #[no_mangle]
238 pub extern "C" fn ForwardTlvs_set_features(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
239         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
240 }
241 /// Constructs a new ForwardTlvs given each field
242 #[must_use]
243 #[no_mangle]
244 pub extern "C" fn ForwardTlvs_new(mut short_channel_id_arg: u64, mut payment_relay_arg: crate::lightning::blinded_path::payment::PaymentRelay, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints, mut features_arg: crate::lightning::ln::features::BlindedHopFeatures) -> ForwardTlvs {
245         ForwardTlvs { inner: ObjOps::heap_alloc(nativeForwardTlvs {
246                 short_channel_id: short_channel_id_arg,
247                 payment_relay: *unsafe { Box::from_raw(payment_relay_arg.take_inner()) },
248                 payment_constraints: *unsafe { Box::from_raw(payment_constraints_arg.take_inner()) },
249                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
250         }), is_owned: true }
251 }
252 impl Clone for ForwardTlvs {
253         fn clone(&self) -> Self {
254                 Self {
255                         inner: if <*mut nativeForwardTlvs>::is_null(self.inner) { core::ptr::null_mut() } else {
256                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
257                         is_owned: true,
258                 }
259         }
260 }
261 #[allow(unused)]
262 /// Used only if an object of this type is returned as a trait impl by a method
263 pub(crate) extern "C" fn ForwardTlvs_clone_void(this_ptr: *const c_void) -> *mut c_void {
264         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeForwardTlvs)).clone() })) as *mut c_void
265 }
266 #[no_mangle]
267 /// Creates a copy of the ForwardTlvs
268 pub extern "C" fn ForwardTlvs_clone(orig: &ForwardTlvs) -> ForwardTlvs {
269         orig.clone()
270 }
271 /// Get a string which allows debug introspection of a ForwardTlvs object
272 pub extern "C" fn ForwardTlvs_debug_str_void(o: *const c_void) -> Str {
273         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::ForwardTlvs }).into()}
274
275 use lightning::blinded_path::payment::ReceiveTlvs as nativeReceiveTlvsImport;
276 pub(crate) type nativeReceiveTlvs = nativeReceiveTlvsImport;
277
278 /// Data to construct a [`BlindedHop`] for receiving a payment. This payload is custom to LDK and
279 /// may not be valid if received by another lightning implementation.
280 #[must_use]
281 #[repr(C)]
282 pub struct ReceiveTlvs {
283         /// A pointer to the opaque Rust object.
284
285         /// Nearly everywhere, inner must be non-null, however in places where
286         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
287         pub inner: *mut nativeReceiveTlvs,
288         /// Indicates that this is the only struct which contains the same pointer.
289
290         /// Rust functions which take ownership of an object provided via an argument require
291         /// this to be true and invalidate the object pointed to by inner.
292         pub is_owned: bool,
293 }
294
295 impl Drop for ReceiveTlvs {
296         fn drop(&mut self) {
297                 if self.is_owned && !<*mut nativeReceiveTlvs>::is_null(self.inner) {
298                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
299                 }
300         }
301 }
302 /// Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL.
303 #[no_mangle]
304 pub extern "C" fn ReceiveTlvs_free(this_obj: ReceiveTlvs) { }
305 #[allow(unused)]
306 /// Used only if an object of this type is returned as a trait impl by a method
307 pub(crate) extern "C" fn ReceiveTlvs_free_void(this_ptr: *mut c_void) {
308         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReceiveTlvs) };
309 }
310 #[allow(unused)]
311 impl ReceiveTlvs {
312         pub(crate) fn get_native_ref(&self) -> &'static nativeReceiveTlvs {
313                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
314         }
315         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReceiveTlvs {
316                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
317         }
318         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
319         pub(crate) fn take_inner(mut self) -> *mut nativeReceiveTlvs {
320                 assert!(self.is_owned);
321                 let ret = ObjOps::untweak_ptr(self.inner);
322                 self.inner = core::ptr::null_mut();
323                 ret
324         }
325 }
326 /// Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
327 #[no_mangle]
328 pub extern "C" fn ReceiveTlvs_get_payment_secret(this_ptr: &ReceiveTlvs) -> *const [u8; 32] {
329         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
330         &inner_val.0
331 }
332 /// Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
333 #[no_mangle]
334 pub extern "C" fn ReceiveTlvs_set_payment_secret(this_ptr: &mut ReceiveTlvs, mut val: crate::c_types::ThirtyTwoBytes) {
335         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::PaymentSecret(val.data);
336 }
337 /// Constraints for the receiver of this payment.
338 #[no_mangle]
339 pub extern "C" fn ReceiveTlvs_get_payment_constraints(this_ptr: &ReceiveTlvs) -> crate::lightning::blinded_path::payment::PaymentConstraints {
340         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_constraints;
341         crate::lightning::blinded_path::payment::PaymentConstraints { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::PaymentConstraints<>) as *mut _) }, is_owned: false }
342 }
343 /// Constraints for the receiver of this payment.
344 #[no_mangle]
345 pub extern "C" fn ReceiveTlvs_set_payment_constraints(this_ptr: &mut ReceiveTlvs, mut val: crate::lightning::blinded_path::payment::PaymentConstraints) {
346         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_constraints = *unsafe { Box::from_raw(val.take_inner()) };
347 }
348 /// Constructs a new ReceiveTlvs given each field
349 #[must_use]
350 #[no_mangle]
351 pub extern "C" fn ReceiveTlvs_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints) -> ReceiveTlvs {
352         ReceiveTlvs { inner: ObjOps::heap_alloc(nativeReceiveTlvs {
353                 payment_secret: ::lightning::ln::PaymentSecret(payment_secret_arg.data),
354                 payment_constraints: *unsafe { Box::from_raw(payment_constraints_arg.take_inner()) },
355         }), is_owned: true }
356 }
357 impl Clone for ReceiveTlvs {
358         fn clone(&self) -> Self {
359                 Self {
360                         inner: if <*mut nativeReceiveTlvs>::is_null(self.inner) { core::ptr::null_mut() } else {
361                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
362                         is_owned: true,
363                 }
364         }
365 }
366 #[allow(unused)]
367 /// Used only if an object of this type is returned as a trait impl by a method
368 pub(crate) extern "C" fn ReceiveTlvs_clone_void(this_ptr: *const c_void) -> *mut c_void {
369         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReceiveTlvs)).clone() })) as *mut c_void
370 }
371 #[no_mangle]
372 /// Creates a copy of the ReceiveTlvs
373 pub extern "C" fn ReceiveTlvs_clone(orig: &ReceiveTlvs) -> ReceiveTlvs {
374         orig.clone()
375 }
376 /// Get a string which allows debug introspection of a ReceiveTlvs object
377 pub extern "C" fn ReceiveTlvs_debug_str_void(o: *const c_void) -> Str {
378         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::ReceiveTlvs }).into()}
379
380 use lightning::blinded_path::payment::PaymentRelay as nativePaymentRelayImport;
381 pub(crate) type nativePaymentRelay = nativePaymentRelayImport;
382
383 /// Parameters for relaying over a given [`BlindedHop`].
384 ///
385 /// [`BlindedHop`]: crate::blinded_path::BlindedHop
386 #[must_use]
387 #[repr(C)]
388 pub struct PaymentRelay {
389         /// A pointer to the opaque Rust object.
390
391         /// Nearly everywhere, inner must be non-null, however in places where
392         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
393         pub inner: *mut nativePaymentRelay,
394         /// Indicates that this is the only struct which contains the same pointer.
395
396         /// Rust functions which take ownership of an object provided via an argument require
397         /// this to be true and invalidate the object pointed to by inner.
398         pub is_owned: bool,
399 }
400
401 impl Drop for PaymentRelay {
402         fn drop(&mut self) {
403                 if self.is_owned && !<*mut nativePaymentRelay>::is_null(self.inner) {
404                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
405                 }
406         }
407 }
408 /// Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL.
409 #[no_mangle]
410 pub extern "C" fn PaymentRelay_free(this_obj: PaymentRelay) { }
411 #[allow(unused)]
412 /// Used only if an object of this type is returned as a trait impl by a method
413 pub(crate) extern "C" fn PaymentRelay_free_void(this_ptr: *mut c_void) {
414         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePaymentRelay) };
415 }
416 #[allow(unused)]
417 impl PaymentRelay {
418         pub(crate) fn get_native_ref(&self) -> &'static nativePaymentRelay {
419                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
420         }
421         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentRelay {
422                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
423         }
424         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
425         pub(crate) fn take_inner(mut self) -> *mut nativePaymentRelay {
426                 assert!(self.is_owned);
427                 let ret = ObjOps::untweak_ptr(self.inner);
428                 self.inner = core::ptr::null_mut();
429                 ret
430         }
431 }
432 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`].
433 #[no_mangle]
434 pub extern "C" fn PaymentRelay_get_cltv_expiry_delta(this_ptr: &PaymentRelay) -> u16 {
435         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
436         *inner_val
437 }
438 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`].
439 #[no_mangle]
440 pub extern "C" fn PaymentRelay_set_cltv_expiry_delta(this_ptr: &mut PaymentRelay, mut val: u16) {
441         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
442 }
443 /// Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over
444 /// this [`BlindedHop`], (i.e., 10,000 is 1%).
445 #[no_mangle]
446 pub extern "C" fn PaymentRelay_get_fee_proportional_millionths(this_ptr: &PaymentRelay) -> u32 {
447         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
448         *inner_val
449 }
450 /// Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over
451 /// this [`BlindedHop`], (i.e., 10,000 is 1%).
452 #[no_mangle]
453 pub extern "C" fn PaymentRelay_set_fee_proportional_millionths(this_ptr: &mut PaymentRelay, mut val: u32) {
454         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
455 }
456 /// Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`].
457 #[no_mangle]
458 pub extern "C" fn PaymentRelay_get_fee_base_msat(this_ptr: &PaymentRelay) -> u32 {
459         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
460         *inner_val
461 }
462 /// Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`].
463 #[no_mangle]
464 pub extern "C" fn PaymentRelay_set_fee_base_msat(this_ptr: &mut PaymentRelay, mut val: u32) {
465         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
466 }
467 /// Constructs a new PaymentRelay given each field
468 #[must_use]
469 #[no_mangle]
470 pub extern "C" fn PaymentRelay_new(mut cltv_expiry_delta_arg: u16, mut fee_proportional_millionths_arg: u32, mut fee_base_msat_arg: u32) -> PaymentRelay {
471         PaymentRelay { inner: ObjOps::heap_alloc(nativePaymentRelay {
472                 cltv_expiry_delta: cltv_expiry_delta_arg,
473                 fee_proportional_millionths: fee_proportional_millionths_arg,
474                 fee_base_msat: fee_base_msat_arg,
475         }), is_owned: true }
476 }
477 impl Clone for PaymentRelay {
478         fn clone(&self) -> Self {
479                 Self {
480                         inner: if <*mut nativePaymentRelay>::is_null(self.inner) { core::ptr::null_mut() } else {
481                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
482                         is_owned: true,
483                 }
484         }
485 }
486 #[allow(unused)]
487 /// Used only if an object of this type is returned as a trait impl by a method
488 pub(crate) extern "C" fn PaymentRelay_clone_void(this_ptr: *const c_void) -> *mut c_void {
489         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePaymentRelay)).clone() })) as *mut c_void
490 }
491 #[no_mangle]
492 /// Creates a copy of the PaymentRelay
493 pub extern "C" fn PaymentRelay_clone(orig: &PaymentRelay) -> PaymentRelay {
494         orig.clone()
495 }
496 /// Get a string which allows debug introspection of a PaymentRelay object
497 pub extern "C" fn PaymentRelay_debug_str_void(o: *const c_void) -> Str {
498         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::PaymentRelay }).into()}
499
500 use lightning::blinded_path::payment::PaymentConstraints as nativePaymentConstraintsImport;
501 pub(crate) type nativePaymentConstraints = nativePaymentConstraintsImport;
502
503 /// Constraints for relaying over a given [`BlindedHop`].
504 ///
505 /// [`BlindedHop`]: crate::blinded_path::BlindedHop
506 #[must_use]
507 #[repr(C)]
508 pub struct PaymentConstraints {
509         /// A pointer to the opaque Rust object.
510
511         /// Nearly everywhere, inner must be non-null, however in places where
512         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
513         pub inner: *mut nativePaymentConstraints,
514         /// Indicates that this is the only struct which contains the same pointer.
515
516         /// Rust functions which take ownership of an object provided via an argument require
517         /// this to be true and invalidate the object pointed to by inner.
518         pub is_owned: bool,
519 }
520
521 impl Drop for PaymentConstraints {
522         fn drop(&mut self) {
523                 if self.is_owned && !<*mut nativePaymentConstraints>::is_null(self.inner) {
524                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
525                 }
526         }
527 }
528 /// Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL.
529 #[no_mangle]
530 pub extern "C" fn PaymentConstraints_free(this_obj: PaymentConstraints) { }
531 #[allow(unused)]
532 /// Used only if an object of this type is returned as a trait impl by a method
533 pub(crate) extern "C" fn PaymentConstraints_free_void(this_ptr: *mut c_void) {
534         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePaymentConstraints) };
535 }
536 #[allow(unused)]
537 impl PaymentConstraints {
538         pub(crate) fn get_native_ref(&self) -> &'static nativePaymentConstraints {
539                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
540         }
541         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentConstraints {
542                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
543         }
544         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
545         pub(crate) fn take_inner(mut self) -> *mut nativePaymentConstraints {
546                 assert!(self.is_owned);
547                 let ret = ObjOps::untweak_ptr(self.inner);
548                 self.inner = core::ptr::null_mut();
549                 ret
550         }
551 }
552 /// The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`].
553 #[no_mangle]
554 pub extern "C" fn PaymentConstraints_get_max_cltv_expiry(this_ptr: &PaymentConstraints) -> u32 {
555         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_cltv_expiry;
556         *inner_val
557 }
558 /// The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`].
559 #[no_mangle]
560 pub extern "C" fn PaymentConstraints_set_max_cltv_expiry(this_ptr: &mut PaymentConstraints, mut val: u32) {
561         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_cltv_expiry = val;
562 }
563 /// The minimum value, in msat, that may be accepted by the node corresponding to this
564 /// [`BlindedHop`].
565 #[no_mangle]
566 pub extern "C" fn PaymentConstraints_get_htlc_minimum_msat(this_ptr: &PaymentConstraints) -> u64 {
567         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
568         *inner_val
569 }
570 /// The minimum value, in msat, that may be accepted by the node corresponding to this
571 /// [`BlindedHop`].
572 #[no_mangle]
573 pub extern "C" fn PaymentConstraints_set_htlc_minimum_msat(this_ptr: &mut PaymentConstraints, mut val: u64) {
574         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
575 }
576 /// Constructs a new PaymentConstraints given each field
577 #[must_use]
578 #[no_mangle]
579 pub extern "C" fn PaymentConstraints_new(mut max_cltv_expiry_arg: u32, mut htlc_minimum_msat_arg: u64) -> PaymentConstraints {
580         PaymentConstraints { inner: ObjOps::heap_alloc(nativePaymentConstraints {
581                 max_cltv_expiry: max_cltv_expiry_arg,
582                 htlc_minimum_msat: htlc_minimum_msat_arg,
583         }), is_owned: true }
584 }
585 impl Clone for PaymentConstraints {
586         fn clone(&self) -> Self {
587                 Self {
588                         inner: if <*mut nativePaymentConstraints>::is_null(self.inner) { core::ptr::null_mut() } else {
589                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
590                         is_owned: true,
591                 }
592         }
593 }
594 #[allow(unused)]
595 /// Used only if an object of this type is returned as a trait impl by a method
596 pub(crate) extern "C" fn PaymentConstraints_clone_void(this_ptr: *const c_void) -> *mut c_void {
597         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePaymentConstraints)).clone() })) as *mut c_void
598 }
599 #[no_mangle]
600 /// Creates a copy of the PaymentConstraints
601 pub extern "C" fn PaymentConstraints_clone(orig: &PaymentConstraints) -> PaymentConstraints {
602         orig.clone()
603 }
604 /// Get a string which allows debug introspection of a PaymentConstraints object
605 pub extern "C" fn PaymentConstraints_debug_str_void(o: *const c_void) -> Str {
606         alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::PaymentConstraints }).into()}
607 #[no_mangle]
608 /// Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read
609 pub extern "C" fn ForwardTlvs_write(obj: &crate::lightning::blinded_path::payment::ForwardTlvs) -> crate::c_types::derived::CVec_u8Z {
610         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
611 }
612 #[allow(unused)]
613 pub(crate) extern "C" fn ForwardTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
614         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeForwardTlvs) })
615 }
616 #[no_mangle]
617 /// Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read
618 pub extern "C" fn ReceiveTlvs_write(obj: &crate::lightning::blinded_path::payment::ReceiveTlvs) -> crate::c_types::derived::CVec_u8Z {
619         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
620 }
621 #[allow(unused)]
622 pub(crate) extern "C" fn ReceiveTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
623         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReceiveTlvs) })
624 }
625 #[no_mangle]
626 /// Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read
627 pub extern "C" fn PaymentRelay_write(obj: &crate::lightning::blinded_path::payment::PaymentRelay) -> crate::c_types::derived::CVec_u8Z {
628         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
629 }
630 #[allow(unused)]
631 pub(crate) extern "C" fn PaymentRelay_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
632         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentRelay) })
633 }
634 #[no_mangle]
635 /// Read a PaymentRelay from a byte array, created by PaymentRelay_write
636 pub extern "C" fn PaymentRelay_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentRelayDecodeErrorZ {
637         let res: Result<lightning::blinded_path::payment::PaymentRelay, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
638         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::PaymentRelay { 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() };
639         local_res
640 }
641 #[no_mangle]
642 /// Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read
643 pub extern "C" fn PaymentConstraints_write(obj: &crate::lightning::blinded_path::payment::PaymentConstraints) -> crate::c_types::derived::CVec_u8Z {
644         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
645 }
646 #[allow(unused)]
647 pub(crate) extern "C" fn PaymentConstraints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
648         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentConstraints) })
649 }
650 #[no_mangle]
651 /// Read a PaymentConstraints from a byte array, created by PaymentConstraints_write
652 pub extern "C" fn PaymentConstraints_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentConstraintsDecodeErrorZ {
653         let res: Result<lightning::blinded_path::payment::PaymentConstraints, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
654         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::PaymentConstraints { 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() };
655         local_res
656 }