Update auto-generated bindings
[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 *mut 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
138 use lightning::blinded_path::payment::ForwardTlvs as nativeForwardTlvsImport;
139 pub(crate) type nativeForwardTlvs = nativeForwardTlvsImport;
140
141 /// Data to construct a [`BlindedHop`] for forwarding a payment.
142 #[must_use]
143 #[repr(C)]
144 pub struct ForwardTlvs {
145         /// A pointer to the opaque Rust object.
146
147         /// Nearly everywhere, inner must be non-null, however in places where
148         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
149         pub inner: *mut nativeForwardTlvs,
150         /// Indicates that this is the only struct which contains the same pointer.
151
152         /// Rust functions which take ownership of an object provided via an argument require
153         /// this to be true and invalidate the object pointed to by inner.
154         pub is_owned: bool,
155 }
156
157 impl Drop for ForwardTlvs {
158         fn drop(&mut self) {
159                 if self.is_owned && !<*mut nativeForwardTlvs>::is_null(self.inner) {
160                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
161                 }
162         }
163 }
164 /// Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL.
165 #[no_mangle]
166 pub extern "C" fn ForwardTlvs_free(this_obj: ForwardTlvs) { }
167 #[allow(unused)]
168 /// Used only if an object of this type is returned as a trait impl by a method
169 pub(crate) extern "C" fn ForwardTlvs_free_void(this_ptr: *mut c_void) {
170         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeForwardTlvs) };
171 }
172 #[allow(unused)]
173 impl ForwardTlvs {
174         pub(crate) fn get_native_ref(&self) -> &'static nativeForwardTlvs {
175                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
176         }
177         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeForwardTlvs {
178                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
179         }
180         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
181         pub(crate) fn take_inner(mut self) -> *mut nativeForwardTlvs {
182                 assert!(self.is_owned);
183                 let ret = ObjOps::untweak_ptr(self.inner);
184                 self.inner = core::ptr::null_mut();
185                 ret
186         }
187 }
188 /// The short channel id this payment should be forwarded out over.
189 #[no_mangle]
190 pub extern "C" fn ForwardTlvs_get_short_channel_id(this_ptr: &ForwardTlvs) -> u64 {
191         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
192         *inner_val
193 }
194 /// The short channel id this payment should be forwarded out over.
195 #[no_mangle]
196 pub extern "C" fn ForwardTlvs_set_short_channel_id(this_ptr: &mut ForwardTlvs, mut val: u64) {
197         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val;
198 }
199 /// Payment parameters for relaying over [`Self::short_channel_id`].
200 #[no_mangle]
201 pub extern "C" fn ForwardTlvs_get_payment_relay(this_ptr: &ForwardTlvs) -> crate::lightning::blinded_path::payment::PaymentRelay {
202         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_relay;
203         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 }
204 }
205 /// Payment parameters for relaying over [`Self::short_channel_id`].
206 #[no_mangle]
207 pub extern "C" fn ForwardTlvs_set_payment_relay(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::blinded_path::payment::PaymentRelay) {
208         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_relay = *unsafe { Box::from_raw(val.take_inner()) };
209 }
210 /// Payment constraints for relaying over [`Self::short_channel_id`].
211 #[no_mangle]
212 pub extern "C" fn ForwardTlvs_get_payment_constraints(this_ptr: &ForwardTlvs) -> crate::lightning::blinded_path::payment::PaymentConstraints {
213         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_constraints;
214         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 }
215 }
216 /// Payment constraints for relaying over [`Self::short_channel_id`].
217 #[no_mangle]
218 pub extern "C" fn ForwardTlvs_set_payment_constraints(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::blinded_path::payment::PaymentConstraints) {
219         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_constraints = *unsafe { Box::from_raw(val.take_inner()) };
220 }
221 /// Supported and required features when relaying a payment onion containing this object's
222 /// corresponding [`BlindedHop::encrypted_payload`].
223 ///
224 /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
225 #[no_mangle]
226 pub extern "C" fn ForwardTlvs_get_features(this_ptr: &ForwardTlvs) -> crate::lightning::ln::features::BlindedHopFeatures {
227         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
228         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 }
229 }
230 /// Supported and required features when relaying a payment onion containing this object's
231 /// corresponding [`BlindedHop::encrypted_payload`].
232 ///
233 /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload
234 #[no_mangle]
235 pub extern "C" fn ForwardTlvs_set_features(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
236         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
237 }
238 /// Constructs a new ForwardTlvs given each field
239 #[must_use]
240 #[no_mangle]
241 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 {
242         ForwardTlvs { inner: ObjOps::heap_alloc(nativeForwardTlvs {
243                 short_channel_id: short_channel_id_arg,
244                 payment_relay: *unsafe { Box::from_raw(payment_relay_arg.take_inner()) },
245                 payment_constraints: *unsafe { Box::from_raw(payment_constraints_arg.take_inner()) },
246                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
247         }), is_owned: true }
248 }
249 impl Clone for ForwardTlvs {
250         fn clone(&self) -> Self {
251                 Self {
252                         inner: if <*mut nativeForwardTlvs>::is_null(self.inner) { core::ptr::null_mut() } else {
253                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
254                         is_owned: true,
255                 }
256         }
257 }
258 #[allow(unused)]
259 /// Used only if an object of this type is returned as a trait impl by a method
260 pub(crate) extern "C" fn ForwardTlvs_clone_void(this_ptr: *const c_void) -> *mut c_void {
261         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeForwardTlvs)).clone() })) as *mut c_void
262 }
263 #[no_mangle]
264 /// Creates a copy of the ForwardTlvs
265 pub extern "C" fn ForwardTlvs_clone(orig: &ForwardTlvs) -> ForwardTlvs {
266         orig.clone()
267 }
268
269 use lightning::blinded_path::payment::ReceiveTlvs as nativeReceiveTlvsImport;
270 pub(crate) type nativeReceiveTlvs = nativeReceiveTlvsImport;
271
272 /// Data to construct a [`BlindedHop`] for receiving a payment. This payload is custom to LDK and
273 /// may not be valid if received by another lightning implementation.
274 #[must_use]
275 #[repr(C)]
276 pub struct ReceiveTlvs {
277         /// A pointer to the opaque Rust object.
278
279         /// Nearly everywhere, inner must be non-null, however in places where
280         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
281         pub inner: *mut nativeReceiveTlvs,
282         /// Indicates that this is the only struct which contains the same pointer.
283
284         /// Rust functions which take ownership of an object provided via an argument require
285         /// this to be true and invalidate the object pointed to by inner.
286         pub is_owned: bool,
287 }
288
289 impl Drop for ReceiveTlvs {
290         fn drop(&mut self) {
291                 if self.is_owned && !<*mut nativeReceiveTlvs>::is_null(self.inner) {
292                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
293                 }
294         }
295 }
296 /// Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL.
297 #[no_mangle]
298 pub extern "C" fn ReceiveTlvs_free(this_obj: ReceiveTlvs) { }
299 #[allow(unused)]
300 /// Used only if an object of this type is returned as a trait impl by a method
301 pub(crate) extern "C" fn ReceiveTlvs_free_void(this_ptr: *mut c_void) {
302         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReceiveTlvs) };
303 }
304 #[allow(unused)]
305 impl ReceiveTlvs {
306         pub(crate) fn get_native_ref(&self) -> &'static nativeReceiveTlvs {
307                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
308         }
309         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReceiveTlvs {
310                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
311         }
312         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
313         pub(crate) fn take_inner(mut self) -> *mut nativeReceiveTlvs {
314                 assert!(self.is_owned);
315                 let ret = ObjOps::untweak_ptr(self.inner);
316                 self.inner = core::ptr::null_mut();
317                 ret
318         }
319 }
320 /// Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together.
321 #[no_mangle]
322 pub extern "C" fn ReceiveTlvs_get_payment_secret(this_ptr: &ReceiveTlvs) -> *const [u8; 32] {
323         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_secret;
324         &inner_val.0
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_set_payment_secret(this_ptr: &mut ReceiveTlvs, mut val: crate::c_types::ThirtyTwoBytes) {
329         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::PaymentSecret(val.data);
330 }
331 /// Constraints for the receiver of this payment.
332 #[no_mangle]
333 pub extern "C" fn ReceiveTlvs_get_payment_constraints(this_ptr: &ReceiveTlvs) -> crate::lightning::blinded_path::payment::PaymentConstraints {
334         let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_constraints;
335         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 }
336 }
337 /// Constraints for the receiver of this payment.
338 #[no_mangle]
339 pub extern "C" fn ReceiveTlvs_set_payment_constraints(this_ptr: &mut ReceiveTlvs, mut val: crate::lightning::blinded_path::payment::PaymentConstraints) {
340         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_constraints = *unsafe { Box::from_raw(val.take_inner()) };
341 }
342 /// Constructs a new ReceiveTlvs given each field
343 #[must_use]
344 #[no_mangle]
345 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 {
346         ReceiveTlvs { inner: ObjOps::heap_alloc(nativeReceiveTlvs {
347                 payment_secret: ::lightning::ln::PaymentSecret(payment_secret_arg.data),
348                 payment_constraints: *unsafe { Box::from_raw(payment_constraints_arg.take_inner()) },
349         }), is_owned: true }
350 }
351 impl Clone for ReceiveTlvs {
352         fn clone(&self) -> Self {
353                 Self {
354                         inner: if <*mut nativeReceiveTlvs>::is_null(self.inner) { core::ptr::null_mut() } else {
355                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
356                         is_owned: true,
357                 }
358         }
359 }
360 #[allow(unused)]
361 /// Used only if an object of this type is returned as a trait impl by a method
362 pub(crate) extern "C" fn ReceiveTlvs_clone_void(this_ptr: *const c_void) -> *mut c_void {
363         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeReceiveTlvs)).clone() })) as *mut c_void
364 }
365 #[no_mangle]
366 /// Creates a copy of the ReceiveTlvs
367 pub extern "C" fn ReceiveTlvs_clone(orig: &ReceiveTlvs) -> ReceiveTlvs {
368         orig.clone()
369 }
370
371 use lightning::blinded_path::payment::PaymentRelay as nativePaymentRelayImport;
372 pub(crate) type nativePaymentRelay = nativePaymentRelayImport;
373
374 /// Parameters for relaying over a given [`BlindedHop`].
375 ///
376 /// [`BlindedHop`]: crate::blinded_path::BlindedHop
377 #[must_use]
378 #[repr(C)]
379 pub struct PaymentRelay {
380         /// A pointer to the opaque Rust object.
381
382         /// Nearly everywhere, inner must be non-null, however in places where
383         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
384         pub inner: *mut nativePaymentRelay,
385         /// Indicates that this is the only struct which contains the same pointer.
386
387         /// Rust functions which take ownership of an object provided via an argument require
388         /// this to be true and invalidate the object pointed to by inner.
389         pub is_owned: bool,
390 }
391
392 impl Drop for PaymentRelay {
393         fn drop(&mut self) {
394                 if self.is_owned && !<*mut nativePaymentRelay>::is_null(self.inner) {
395                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
396                 }
397         }
398 }
399 /// Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL.
400 #[no_mangle]
401 pub extern "C" fn PaymentRelay_free(this_obj: PaymentRelay) { }
402 #[allow(unused)]
403 /// Used only if an object of this type is returned as a trait impl by a method
404 pub(crate) extern "C" fn PaymentRelay_free_void(this_ptr: *mut c_void) {
405         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePaymentRelay) };
406 }
407 #[allow(unused)]
408 impl PaymentRelay {
409         pub(crate) fn get_native_ref(&self) -> &'static nativePaymentRelay {
410                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
411         }
412         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentRelay {
413                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
414         }
415         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
416         pub(crate) fn take_inner(mut self) -> *mut nativePaymentRelay {
417                 assert!(self.is_owned);
418                 let ret = ObjOps::untweak_ptr(self.inner);
419                 self.inner = core::ptr::null_mut();
420                 ret
421         }
422 }
423 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`].
424 #[no_mangle]
425 pub extern "C" fn PaymentRelay_get_cltv_expiry_delta(this_ptr: &PaymentRelay) -> u16 {
426         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
427         *inner_val
428 }
429 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`].
430 #[no_mangle]
431 pub extern "C" fn PaymentRelay_set_cltv_expiry_delta(this_ptr: &mut PaymentRelay, mut val: u16) {
432         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
433 }
434 /// Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over
435 /// this [`BlindedHop`], (i.e., 10,000 is 1%).
436 #[no_mangle]
437 pub extern "C" fn PaymentRelay_get_fee_proportional_millionths(this_ptr: &PaymentRelay) -> u32 {
438         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
439         *inner_val
440 }
441 /// Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over
442 /// this [`BlindedHop`], (i.e., 10,000 is 1%).
443 #[no_mangle]
444 pub extern "C" fn PaymentRelay_set_fee_proportional_millionths(this_ptr: &mut PaymentRelay, mut val: u32) {
445         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
446 }
447 /// Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`].
448 #[no_mangle]
449 pub extern "C" fn PaymentRelay_get_fee_base_msat(this_ptr: &PaymentRelay) -> u32 {
450         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
451         *inner_val
452 }
453 /// Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`].
454 #[no_mangle]
455 pub extern "C" fn PaymentRelay_set_fee_base_msat(this_ptr: &mut PaymentRelay, mut val: u32) {
456         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
457 }
458 /// Constructs a new PaymentRelay given each field
459 #[must_use]
460 #[no_mangle]
461 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 {
462         PaymentRelay { inner: ObjOps::heap_alloc(nativePaymentRelay {
463                 cltv_expiry_delta: cltv_expiry_delta_arg,
464                 fee_proportional_millionths: fee_proportional_millionths_arg,
465                 fee_base_msat: fee_base_msat_arg,
466         }), is_owned: true }
467 }
468 impl Clone for PaymentRelay {
469         fn clone(&self) -> Self {
470                 Self {
471                         inner: if <*mut nativePaymentRelay>::is_null(self.inner) { core::ptr::null_mut() } else {
472                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
473                         is_owned: true,
474                 }
475         }
476 }
477 #[allow(unused)]
478 /// Used only if an object of this type is returned as a trait impl by a method
479 pub(crate) extern "C" fn PaymentRelay_clone_void(this_ptr: *const c_void) -> *mut c_void {
480         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePaymentRelay)).clone() })) as *mut c_void
481 }
482 #[no_mangle]
483 /// Creates a copy of the PaymentRelay
484 pub extern "C" fn PaymentRelay_clone(orig: &PaymentRelay) -> PaymentRelay {
485         orig.clone()
486 }
487
488 use lightning::blinded_path::payment::PaymentConstraints as nativePaymentConstraintsImport;
489 pub(crate) type nativePaymentConstraints = nativePaymentConstraintsImport;
490
491 /// Constraints for relaying over a given [`BlindedHop`].
492 ///
493 /// [`BlindedHop`]: crate::blinded_path::BlindedHop
494 #[must_use]
495 #[repr(C)]
496 pub struct PaymentConstraints {
497         /// A pointer to the opaque Rust object.
498
499         /// Nearly everywhere, inner must be non-null, however in places where
500         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
501         pub inner: *mut nativePaymentConstraints,
502         /// Indicates that this is the only struct which contains the same pointer.
503
504         /// Rust functions which take ownership of an object provided via an argument require
505         /// this to be true and invalidate the object pointed to by inner.
506         pub is_owned: bool,
507 }
508
509 impl Drop for PaymentConstraints {
510         fn drop(&mut self) {
511                 if self.is_owned && !<*mut nativePaymentConstraints>::is_null(self.inner) {
512                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
513                 }
514         }
515 }
516 /// Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL.
517 #[no_mangle]
518 pub extern "C" fn PaymentConstraints_free(this_obj: PaymentConstraints) { }
519 #[allow(unused)]
520 /// Used only if an object of this type is returned as a trait impl by a method
521 pub(crate) extern "C" fn PaymentConstraints_free_void(this_ptr: *mut c_void) {
522         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePaymentConstraints) };
523 }
524 #[allow(unused)]
525 impl PaymentConstraints {
526         pub(crate) fn get_native_ref(&self) -> &'static nativePaymentConstraints {
527                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
528         }
529         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentConstraints {
530                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
531         }
532         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
533         pub(crate) fn take_inner(mut self) -> *mut nativePaymentConstraints {
534                 assert!(self.is_owned);
535                 let ret = ObjOps::untweak_ptr(self.inner);
536                 self.inner = core::ptr::null_mut();
537                 ret
538         }
539 }
540 /// The maximum total CLTV delta that is acceptable when relaying a payment over this
541 /// [`BlindedHop`].
542 #[no_mangle]
543 pub extern "C" fn PaymentConstraints_get_max_cltv_expiry(this_ptr: &PaymentConstraints) -> u32 {
544         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_cltv_expiry;
545         *inner_val
546 }
547 /// The maximum total CLTV delta that is acceptable when relaying a payment over this
548 /// [`BlindedHop`].
549 #[no_mangle]
550 pub extern "C" fn PaymentConstraints_set_max_cltv_expiry(this_ptr: &mut PaymentConstraints, mut val: u32) {
551         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_cltv_expiry = val;
552 }
553 /// The minimum value, in msat, that may be accepted by the node corresponding to this
554 /// [`BlindedHop`].
555 #[no_mangle]
556 pub extern "C" fn PaymentConstraints_get_htlc_minimum_msat(this_ptr: &PaymentConstraints) -> u64 {
557         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
558         *inner_val
559 }
560 /// The minimum value, in msat, that may be accepted by the node corresponding to this
561 /// [`BlindedHop`].
562 #[no_mangle]
563 pub extern "C" fn PaymentConstraints_set_htlc_minimum_msat(this_ptr: &mut PaymentConstraints, mut val: u64) {
564         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
565 }
566 /// Constructs a new PaymentConstraints given each field
567 #[must_use]
568 #[no_mangle]
569 pub extern "C" fn PaymentConstraints_new(mut max_cltv_expiry_arg: u32, mut htlc_minimum_msat_arg: u64) -> PaymentConstraints {
570         PaymentConstraints { inner: ObjOps::heap_alloc(nativePaymentConstraints {
571                 max_cltv_expiry: max_cltv_expiry_arg,
572                 htlc_minimum_msat: htlc_minimum_msat_arg,
573         }), is_owned: true }
574 }
575 impl Clone for PaymentConstraints {
576         fn clone(&self) -> Self {
577                 Self {
578                         inner: if <*mut nativePaymentConstraints>::is_null(self.inner) { core::ptr::null_mut() } else {
579                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
580                         is_owned: true,
581                 }
582         }
583 }
584 #[allow(unused)]
585 /// Used only if an object of this type is returned as a trait impl by a method
586 pub(crate) extern "C" fn PaymentConstraints_clone_void(this_ptr: *const c_void) -> *mut c_void {
587         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePaymentConstraints)).clone() })) as *mut c_void
588 }
589 #[no_mangle]
590 /// Creates a copy of the PaymentConstraints
591 pub extern "C" fn PaymentConstraints_clone(orig: &PaymentConstraints) -> PaymentConstraints {
592         orig.clone()
593 }
594 #[no_mangle]
595 /// Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read
596 pub extern "C" fn ForwardTlvs_write(obj: &crate::lightning::blinded_path::payment::ForwardTlvs) -> crate::c_types::derived::CVec_u8Z {
597         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
598 }
599 #[no_mangle]
600 pub(crate) extern "C" fn ForwardTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
601         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeForwardTlvs) })
602 }
603 #[no_mangle]
604 /// Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read
605 pub extern "C" fn ReceiveTlvs_write(obj: &crate::lightning::blinded_path::payment::ReceiveTlvs) -> crate::c_types::derived::CVec_u8Z {
606         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
607 }
608 #[no_mangle]
609 pub(crate) extern "C" fn ReceiveTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
610         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReceiveTlvs) })
611 }
612 #[no_mangle]
613 /// Read a ReceiveTlvs from a byte array, created by ReceiveTlvs_write
614 pub extern "C" fn ReceiveTlvs_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReceiveTlvsDecodeErrorZ {
615         let res: Result<lightning::blinded_path::payment::ReceiveTlvs, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
616         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::ReceiveTlvs { 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() };
617         local_res
618 }
619 #[no_mangle]
620 /// Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read
621 pub extern "C" fn PaymentRelay_write(obj: &crate::lightning::blinded_path::payment::PaymentRelay) -> crate::c_types::derived::CVec_u8Z {
622         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
623 }
624 #[no_mangle]
625 pub(crate) extern "C" fn PaymentRelay_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
626         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentRelay) })
627 }
628 #[no_mangle]
629 /// Read a PaymentRelay from a byte array, created by PaymentRelay_write
630 pub extern "C" fn PaymentRelay_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentRelayDecodeErrorZ {
631         let res: Result<lightning::blinded_path::payment::PaymentRelay, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
632         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() };
633         local_res
634 }
635 #[no_mangle]
636 /// Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read
637 pub extern "C" fn PaymentConstraints_write(obj: &crate::lightning::blinded_path::payment::PaymentConstraints) -> crate::c_types::derived::CVec_u8Z {
638         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
639 }
640 #[no_mangle]
641 pub(crate) extern "C" fn PaymentConstraints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
642         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentConstraints) })
643 }
644 #[no_mangle]
645 /// Read a PaymentConstraints from a byte array, created by PaymentConstraints_write
646 pub extern "C" fn PaymentConstraints_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentConstraintsDecodeErrorZ {
647         let res: Result<lightning::blinded_path::payment::PaymentConstraints, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
648         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() };
649         local_res
650 }