Update auto-generated bindings to LDK 0.0.116
[ldk-c-bindings] / lightning-c-bindings / src / lightning / offers / invoice.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 encoding for `invoice` messages.
10 //!
11 //! A [`Bolt12Invoice`] can be built from a parsed [`InvoiceRequest`] for the \"offer to be paid\"
12 //! flow or from a [`Refund`] as an \"offer for money\" flow. The expected recipient of the payment
13 //! then sends the invoice to the intended payer, who will then pay it.
14 //!
15 //! The payment recipient must include a [`PaymentHash`], so as to reveal the preimage upon payment
16 //! receipt, and one or more [`BlindedPath`]s for the payer to use when sending the payment.
17 //!
18 //! ```
19 //! extern crate bitcoin;
20 //! extern crate lightning;
21 //!
22 //! use bitcoin::hashes::Hash;
23 //! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
24 //! use core::convert::{Infallible, TryFrom};
25 //! use lightning::offers::invoice_request::InvoiceRequest;
26 //! use lightning::offers::refund::Refund;
27 //! use lightning::util::ser::Writeable;
28 //!
29 //! # use lightning::ln::PaymentHash;
30 //! # use lightning::offers::invoice::BlindedPayInfo;
31 //! # use lightning::blinded_path::BlindedPath;
32 //! #
33 //! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() }
34 //! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
35 //! #
36 //! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
37 //! let payment_paths = create_payment_paths();
38 //! let payment_hash = create_payment_hash();
39 //! let secp_ctx = Secp256k1::new();
40 //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
41 //! let pubkey = PublicKey::from(keys);
42 //! let wpubkey_hash = bitcoin::util::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
43 //! let mut buffer = Vec::new();
44 //!
45 //! // Invoice for the \"offer to be paid\" flow.
46 //! InvoiceRequest::try_from(bytes)?
47 //!
48 //!    .respond_with(payment_paths, payment_hash)?
49 //!
50 //!     .relative_expiry(3600)
51 //!     .allow_mpp()
52 //!     .fallback_v0_p2wpkh(&wpubkey_hash)
53 //!     .build()?
54 //!     .sign::<_, Infallible>(|digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys)))
55 //!     .expect(\"failed verifying signature\")
56 //!     .write(&mut buffer)
57 //!     .unwrap();
58 //! # Ok(())
59 //! # }
60 //!
61 //! # fn parse_refund(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
62 //! # let payment_paths = create_payment_paths();
63 //! # let payment_hash = create_payment_hash();
64 //! # let secp_ctx = Secp256k1::new();
65 //! # let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
66 //! # let pubkey = PublicKey::from(keys);
67 //! # let wpubkey_hash = bitcoin::util::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
68 //! # let mut buffer = Vec::new();
69 //!
70 //! // Invoice for the \"offer for money\" flow.
71 //! \"lnr1qcp4256ypq\"
72 //!     .parse::<Refund>()?
73 //!
74 //!    .respond_with(payment_paths, payment_hash, pubkey)?
75 //!
76 //!     .relative_expiry(3600)
77 //!     .allow_mpp()
78 //!     .fallback_v0_p2wpkh(&wpubkey_hash)
79 //!     .build()?
80 //!     .sign::<_, Infallible>(|digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys)))
81 //!     .expect(\"failed verifying signature\")
82 //!     .write(&mut buffer)
83 //!     .unwrap();
84 //! # Ok(())
85 //! # }
86 //!
87 //! ```
88
89 use alloc::str::FromStr;
90 use core::ffi::c_void;
91 use core::convert::Infallible;
92 use bitcoin::hashes::Hash;
93 use crate::c_types::*;
94 #[cfg(feature="no-std")]
95 use alloc::{vec::Vec, boxed::Box};
96
97
98 use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport;
99 pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport<'static>;
100
101 /// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
102 #[must_use]
103 #[repr(C)]
104 pub struct UnsignedBolt12Invoice {
105         /// A pointer to the opaque Rust object.
106
107         /// Nearly everywhere, inner must be non-null, however in places where
108         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
109         pub inner: *mut nativeUnsignedBolt12Invoice,
110         /// Indicates that this is the only struct which contains the same pointer.
111
112         /// Rust functions which take ownership of an object provided via an argument require
113         /// this to be true and invalidate the object pointed to by inner.
114         pub is_owned: bool,
115 }
116
117 impl Drop for UnsignedBolt12Invoice {
118         fn drop(&mut self) {
119                 if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) {
120                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
121                 }
122         }
123 }
124 /// Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL.
125 #[no_mangle]
126 pub extern "C" fn UnsignedBolt12Invoice_free(this_obj: UnsignedBolt12Invoice) { }
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 UnsignedBolt12Invoice_free_void(this_ptr: *mut c_void) {
130         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedBolt12Invoice) };
131 }
132 #[allow(unused)]
133 impl UnsignedBolt12Invoice {
134         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedBolt12Invoice {
135                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
136         }
137         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedBolt12Invoice {
138                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
139         }
140         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
141         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedBolt12Invoice {
142                 assert!(self.is_owned);
143                 let ret = ObjOps::untweak_ptr(self.inner);
144                 self.inner = core::ptr::null_mut();
145                 ret
146         }
147 }
148 /// The public key corresponding to the key needed to sign the invoice.
149 #[must_use]
150 #[no_mangle]
151 pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
152         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
153         crate::c_types::PublicKey::from_rust(&ret)
154 }
155
156
157 use lightning::offers::invoice::Bolt12Invoice as nativeBolt12InvoiceImport;
158 pub(crate) type nativeBolt12Invoice = nativeBolt12InvoiceImport;
159
160 /// A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`].
161 ///
162 /// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent
163 /// directly after scanning a refund. It includes all the information needed to pay a recipient.
164 ///
165 /// [`Offer`]: crate::offers::offer::Offer
166 /// [`Refund`]: crate::offers::refund::Refund
167 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
168 #[must_use]
169 #[repr(C)]
170 pub struct Bolt12Invoice {
171         /// A pointer to the opaque Rust object.
172
173         /// Nearly everywhere, inner must be non-null, however in places where
174         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
175         pub inner: *mut nativeBolt12Invoice,
176         /// Indicates that this is the only struct which contains the same pointer.
177
178         /// Rust functions which take ownership of an object provided via an argument require
179         /// this to be true and invalidate the object pointed to by inner.
180         pub is_owned: bool,
181 }
182
183 impl Drop for Bolt12Invoice {
184         fn drop(&mut self) {
185                 if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) {
186                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
187                 }
188         }
189 }
190 /// Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL.
191 #[no_mangle]
192 pub extern "C" fn Bolt12Invoice_free(this_obj: Bolt12Invoice) { }
193 #[allow(unused)]
194 /// Used only if an object of this type is returned as a trait impl by a method
195 pub(crate) extern "C" fn Bolt12Invoice_free_void(this_ptr: *mut c_void) {
196         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12Invoice) };
197 }
198 #[allow(unused)]
199 impl Bolt12Invoice {
200         pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12Invoice {
201                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
202         }
203         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12Invoice {
204                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
205         }
206         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
207         pub(crate) fn take_inner(mut self) -> *mut nativeBolt12Invoice {
208                 assert!(self.is_owned);
209                 let ret = ObjOps::untweak_ptr(self.inner);
210                 self.inner = core::ptr::null_mut();
211                 ret
212         }
213 }
214 impl Clone for Bolt12Invoice {
215         fn clone(&self) -> Self {
216                 Self {
217                         inner: if <*mut nativeBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
218                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
219                         is_owned: true,
220                 }
221         }
222 }
223 #[allow(unused)]
224 /// Used only if an object of this type is returned as a trait impl by a method
225 pub(crate) extern "C" fn Bolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
226         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt12Invoice)).clone() })) as *mut c_void
227 }
228 #[no_mangle]
229 /// Creates a copy of the Bolt12Invoice
230 pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice {
231         orig.clone()
232 }
233 /// A complete description of the purpose of the originating offer or refund. Intended to be
234 /// displayed to the user but with the caveat that it has not been verified in any way.
235 #[must_use]
236 #[no_mangle]
237 pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
238         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
239         crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
240 }
241
242 /// Duration since the Unix epoch when the invoice was created.
243 #[must_use]
244 #[no_mangle]
245 pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
246         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
247         ret.as_secs()
248 }
249
250 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
251 /// should no longer be paid.
252 #[must_use]
253 #[no_mangle]
254 pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
255         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
256         ret.as_secs()
257 }
258
259 /// Whether the invoice has expired.
260 #[must_use]
261 #[no_mangle]
262 pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool {
263         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
264         ret
265 }
266
267 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
268 #[must_use]
269 #[no_mangle]
270 pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
271         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
272         crate::c_types::ThirtyTwoBytes { data: ret.0 }
273 }
274
275 /// The minimum amount required for a successful payment of the invoice.
276 #[must_use]
277 #[no_mangle]
278 pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
279         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
280         ret
281 }
282
283 /// Features pertaining to paying an invoice.
284 #[must_use]
285 #[no_mangle]
286 pub extern "C" fn Bolt12Invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
287         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
288         crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
289 }
290
291 /// The public key corresponding to the key used to sign the invoice.
292 #[must_use]
293 #[no_mangle]
294 pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
295         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
296         crate::c_types::PublicKey::from_rust(&ret)
297 }
298
299 /// Hash that was used for signing the invoice.
300 #[must_use]
301 #[no_mangle]
302 pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
303         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
304         crate::c_types::ThirtyTwoBytes { data: ret }
305 }
306
307 /// Verifies that the invoice was for a request or refund created using the given key.
308 #[must_use]
309 #[no_mangle]
310 pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> bool {
311         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1);
312         ret
313 }
314
315 #[no_mangle]
316 /// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
317 pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
318         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
319 }
320 #[no_mangle]
321 pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
322         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) })
323 }
324
325 use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport;
326 pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport;
327
328 /// Information needed to route a payment across a [`BlindedPath`].
329 #[must_use]
330 #[repr(C)]
331 pub struct BlindedPayInfo {
332         /// A pointer to the opaque Rust object.
333
334         /// Nearly everywhere, inner must be non-null, however in places where
335         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
336         pub inner: *mut nativeBlindedPayInfo,
337         /// Indicates that this is the only struct which contains the same pointer.
338
339         /// Rust functions which take ownership of an object provided via an argument require
340         /// this to be true and invalidate the object pointed to by inner.
341         pub is_owned: bool,
342 }
343
344 impl Drop for BlindedPayInfo {
345         fn drop(&mut self) {
346                 if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) {
347                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
348                 }
349         }
350 }
351 /// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL.
352 #[no_mangle]
353 pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { }
354 #[allow(unused)]
355 /// Used only if an object of this type is returned as a trait impl by a method
356 pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) {
357         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) };
358 }
359 #[allow(unused)]
360 impl BlindedPayInfo {
361         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo {
362                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
363         }
364         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo {
365                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
366         }
367         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
368         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo {
369                 assert!(self.is_owned);
370                 let ret = ObjOps::untweak_ptr(self.inner);
371                 self.inner = core::ptr::null_mut();
372                 ret
373         }
374 }
375 /// Base fee charged (in millisatoshi) for the entire blinded path.
376 #[no_mangle]
377 pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 {
378         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
379         *inner_val
380 }
381 /// Base fee charged (in millisatoshi) for the entire blinded path.
382 #[no_mangle]
383 pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) {
384         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
385 }
386 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
387 /// (i.e., 10,000 is 1%).
388 #[no_mangle]
389 pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 {
390         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
391         *inner_val
392 }
393 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
394 /// (i.e., 10,000 is 1%).
395 #[no_mangle]
396 pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) {
397         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
398 }
399 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
400 /// path.
401 #[no_mangle]
402 pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 {
403         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
404         *inner_val
405 }
406 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
407 /// path.
408 #[no_mangle]
409 pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) {
410         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
411 }
412 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
413 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
414 /// seen by the recipient.
415 #[no_mangle]
416 pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 {
417         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
418         *inner_val
419 }
420 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
421 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
422 /// seen by the recipient.
423 #[no_mangle]
424 pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
425         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
426 }
427 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
428 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
429 /// seen by the recipient.
430 #[no_mangle]
431 pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 {
432         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
433         *inner_val
434 }
435 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
436 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
437 /// seen by the recipient.
438 #[no_mangle]
439 pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
440         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
441 }
442 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
443 /// onion payload.
444 #[no_mangle]
445 pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures {
446         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
447         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 }
448 }
449 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
450 /// onion payload.
451 #[no_mangle]
452 pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
453         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
454 }
455 /// Constructs a new BlindedPayInfo given each field
456 #[must_use]
457 #[no_mangle]
458 pub extern "C" fn BlindedPayInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut features_arg: crate::lightning::ln::features::BlindedHopFeatures) -> BlindedPayInfo {
459         BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo {
460                 fee_base_msat: fee_base_msat_arg,
461                 fee_proportional_millionths: fee_proportional_millionths_arg,
462                 cltv_expiry_delta: cltv_expiry_delta_arg,
463                 htlc_minimum_msat: htlc_minimum_msat_arg,
464                 htlc_maximum_msat: htlc_maximum_msat_arg,
465                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
466         }), is_owned: true }
467 }
468 impl Clone for BlindedPayInfo {
469         fn clone(&self) -> Self {
470                 Self {
471                         inner: if <*mut nativeBlindedPayInfo>::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 BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
480         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBlindedPayInfo)).clone() })) as *mut c_void
481 }
482 #[no_mangle]
483 /// Creates a copy of the BlindedPayInfo
484 pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo {
485         orig.clone()
486 }
487 /// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo.
488 #[no_mangle]
489 pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 {
490         if o.inner.is_null() { return 0; }
491         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
492         #[allow(deprecated)]
493         let mut hasher = core::hash::SipHasher::new();
494         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
495         core::hash::Hasher::finish(&hasher)
496 }
497 /// Checks if two BlindedPayInfos contain equal inner contents.
498 /// This ignores pointers and is_owned flags and looks at the values in fields.
499 /// Two objects with NULL inner values will be considered "equal" here.
500 #[no_mangle]
501 pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool {
502         if a.inner == b.inner { return true; }
503         if a.inner.is_null() || b.inner.is_null() { return false; }
504         if a.get_native_ref() == b.get_native_ref() { true } else { false }
505 }
506 #[no_mangle]
507 /// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read
508 pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z {
509         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
510 }
511 #[no_mangle]
512 pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
513         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) })
514 }
515 #[no_mangle]
516 /// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write
517 pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ {
518         let res: Result<lightning::offers::invoice::BlindedPayInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
519         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::BlindedPayInfo { 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() };
520         local_res
521 }