Update auto-generated bindings to LDK 0.0.123
[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::TryFrom;
25 //! use lightning::offers::invoice::UnsignedBolt12Invoice;
26 //! use lightning::offers::invoice_request::InvoiceRequest;
27 //! use lightning::offers::refund::Refund;
28 //! use lightning::util::ser::Writeable;
29 //!
30 //! # use lightning::ln::types::PaymentHash;
31 //! # use lightning::offers::invoice::{BlindedPayInfo, ExplicitSigningPubkey, InvoiceBuilder};
32 //! # use lightning::blinded_path::BlindedPath;
33 //! #
34 //! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() }
35 //! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
36 //! #
37 //! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
38 //! let payment_paths = create_payment_paths();
39 //! let payment_hash = create_payment_hash();
40 //! let secp_ctx = Secp256k1::new();
41 //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
42 //! let pubkey = PublicKey::from(keys);
43 //! let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
44 //! let mut buffer = Vec::new();
45 //!
46 //! // Invoice for the \"offer to be paid\" flow.
47 //! # <InvoiceBuilder<ExplicitSigningPubkey>>::from(
48 //! InvoiceRequest::try_from(bytes)?
49 //!
50 //!    .respond_with(payment_paths, payment_hash)?
51 //!
52 //! # )
53 //!     .relative_expiry(3600)
54 //!     .allow_mpp()
55 //!     .fallback_v0_p2wpkh(&wpubkey_hash)
56 //!     .build()?
57 //!     .sign(|message: &UnsignedBolt12Invoice|
58 //!         Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
59 //!     )
60 //!     .expect(\"failed verifying signature\")
61 //!     .write(&mut buffer)
62 //!     .unwrap();
63 //! # Ok(())
64 //! # }
65 //!
66 //! # fn parse_refund(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
67 //! # let payment_paths = create_payment_paths();
68 //! # let payment_hash = create_payment_hash();
69 //! # let secp_ctx = Secp256k1::new();
70 //! # let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
71 //! # let pubkey = PublicKey::from(keys);
72 //! # let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
73 //! # let mut buffer = Vec::new();
74 //!
75 //! // Invoice for the \"offer for money\" flow.
76 //! # <InvoiceBuilder<ExplicitSigningPubkey>>::from(
77 //! \"lnr1qcp4256ypq\"
78 //!     .parse::<Refund>()?
79 //!
80 //!    .respond_with(payment_paths, payment_hash, pubkey)?
81 //!
82 //! # )
83 //!     .relative_expiry(3600)
84 //!     .allow_mpp()
85 //!     .fallback_v0_p2wpkh(&wpubkey_hash)
86 //!     .build()?
87 //!     .sign(|message: &UnsignedBolt12Invoice|
88 //!         Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
89 //!     )
90 //!     .expect(\"failed verifying signature\")
91 //!     .write(&mut buffer)
92 //!     .unwrap();
93 //! # Ok(())
94 //! # }
95 //!
96 //! ```
97
98 use alloc::str::FromStr;
99 use alloc::string::String;
100 use core::ffi::c_void;
101 use core::convert::Infallible;
102 use bitcoin::hashes::Hash;
103 use crate::c_types::*;
104 #[cfg(feature="no-std")]
105 use alloc::{vec::Vec, boxed::Box};
106
107
108 use lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder as nativeInvoiceWithExplicitSigningPubkeyBuilderImport;
109 pub(crate) type nativeInvoiceWithExplicitSigningPubkeyBuilder = nativeInvoiceWithExplicitSigningPubkeyBuilderImport<'static, >;
110
111 /// Builds a [`Bolt12Invoice`] from either:
112 /// - an [`InvoiceRequest`] for the \"offer to be paid\" flow or
113 /// - a [`Refund`] for the \"offer for money\" flow.
114 ///
115 /// See [module-level documentation] for usage.
116 ///
117 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
118 /// [`Refund`]: crate::offers::refund::Refund
119 /// [module-level documentation]: self
120 #[must_use]
121 #[repr(C)]
122 pub struct InvoiceWithExplicitSigningPubkeyBuilder {
123         /// A pointer to the opaque Rust object.
124
125         /// Nearly everywhere, inner must be non-null, however in places where
126         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
127         pub inner: *mut nativeInvoiceWithExplicitSigningPubkeyBuilder,
128         /// Indicates that this is the only struct which contains the same pointer.
129
130         /// Rust functions which take ownership of an object provided via an argument require
131         /// this to be true and invalidate the object pointed to by inner.
132         pub is_owned: bool,
133 }
134
135 impl Drop for InvoiceWithExplicitSigningPubkeyBuilder {
136         fn drop(&mut self) {
137                 if self.is_owned && !<*mut nativeInvoiceWithExplicitSigningPubkeyBuilder>::is_null(self.inner) {
138                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
139                 }
140         }
141 }
142 /// Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL.
143 #[no_mangle]
144 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_free(this_obj: InvoiceWithExplicitSigningPubkeyBuilder) { }
145 #[allow(unused)]
146 /// Used only if an object of this type is returned as a trait impl by a method
147 pub(crate) extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_free_void(this_ptr: *mut c_void) {
148         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceWithExplicitSigningPubkeyBuilder) };
149 }
150 #[allow(unused)]
151 impl InvoiceWithExplicitSigningPubkeyBuilder {
152         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceWithExplicitSigningPubkeyBuilder {
153                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
154         }
155         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceWithExplicitSigningPubkeyBuilder {
156                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
157         }
158         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
159         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceWithExplicitSigningPubkeyBuilder {
160                 assert!(self.is_owned);
161                 let ret = ObjOps::untweak_ptr(self.inner);
162                 self.inner = core::ptr::null_mut();
163                 ret
164         }
165 }
166
167 use lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder as nativeInvoiceWithDerivedSigningPubkeyBuilderImport;
168 pub(crate) type nativeInvoiceWithDerivedSigningPubkeyBuilder = nativeInvoiceWithDerivedSigningPubkeyBuilderImport<'static, >;
169
170 /// Builds a [`Bolt12Invoice`] from either:
171 /// - an [`InvoiceRequest`] for the \"offer to be paid\" flow or
172 /// - a [`Refund`] for the \"offer for money\" flow.
173 ///
174 /// See [module-level documentation] for usage.
175 ///
176 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
177 /// [`Refund`]: crate::offers::refund::Refund
178 /// [module-level documentation]: self
179 #[must_use]
180 #[repr(C)]
181 pub struct InvoiceWithDerivedSigningPubkeyBuilder {
182         /// A pointer to the opaque Rust object.
183
184         /// Nearly everywhere, inner must be non-null, however in places where
185         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
186         pub inner: *mut nativeInvoiceWithDerivedSigningPubkeyBuilder,
187         /// Indicates that this is the only struct which contains the same pointer.
188
189         /// Rust functions which take ownership of an object provided via an argument require
190         /// this to be true and invalidate the object pointed to by inner.
191         pub is_owned: bool,
192 }
193
194 impl Drop for InvoiceWithDerivedSigningPubkeyBuilder {
195         fn drop(&mut self) {
196                 if self.is_owned && !<*mut nativeInvoiceWithDerivedSigningPubkeyBuilder>::is_null(self.inner) {
197                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
198                 }
199         }
200 }
201 /// Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL.
202 #[no_mangle]
203 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_free(this_obj: InvoiceWithDerivedSigningPubkeyBuilder) { }
204 #[allow(unused)]
205 /// Used only if an object of this type is returned as a trait impl by a method
206 pub(crate) extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_free_void(this_ptr: *mut c_void) {
207         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceWithDerivedSigningPubkeyBuilder) };
208 }
209 #[allow(unused)]
210 impl InvoiceWithDerivedSigningPubkeyBuilder {
211         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceWithDerivedSigningPubkeyBuilder {
212                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
213         }
214         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceWithDerivedSigningPubkeyBuilder {
215                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
216         }
217         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
218         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceWithDerivedSigningPubkeyBuilder {
219                 assert!(self.is_owned);
220                 let ret = ObjOps::untweak_ptr(self.inner);
221                 self.inner = core::ptr::null_mut();
222                 ret
223         }
224 }
225 /// Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by
226 /// [`UnsignedBolt12Invoice::sign`].
227 #[must_use]
228 #[no_mangle]
229 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_build(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) -> crate::c_types::derived::CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ {
230         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build();
231         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
232         local_ret
233 }
234
235 /// Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
236 /// Any expiry that has already passed is valid and can be checked for using
237 /// [`Bolt12Invoice::is_expired`].
238 ///
239 /// Successive calls to this method will override the previous setting.
240 #[must_use]
241 #[no_mangle]
242 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, mut relative_expiry_secs: u32) {
243         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).relative_expiry(relative_expiry_secs);
244         () /*ret*/
245 }
246
247 /// Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
248 ///
249 /// Successive calls to this method will add another address. Caller is responsible for not
250 /// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
251 #[must_use]
252 #[no_mangle]
253 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, script_hash: *const [u8; 32]) {
254         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone())));
255         () /*ret*/
256 }
257
258 /// Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
259 ///
260 /// Successive calls to this method will add another address. Caller is responsible for not
261 /// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
262 #[must_use]
263 #[no_mangle]
264 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) {
265         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone())));
266         () /*ret*/
267 }
268
269 /// Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
270 ///
271 /// Successive calls to this method will add another address. Caller is responsible for not
272 /// adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
273 #[must_use]
274 #[no_mangle]
275 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, mut output_key: crate::c_types::TweakedPublicKey) {
276         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v1_p2tr_tweaked(&output_key.into_rust());
277         () /*ret*/
278 }
279
280 /// Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
281 /// disallowed.
282 #[must_use]
283 #[no_mangle]
284 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) {
285         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).allow_mpp();
286         () /*ret*/
287 }
288
289 /// Builds a signed [`Bolt12Invoice`] after checking for valid semantics.
290 #[must_use]
291 #[no_mangle]
292 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) -> crate::c_types::derived::CResult_Bolt12InvoiceBolt12SemanticErrorZ {
293         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build_and_sign(secp256k1::global::SECP256K1);
294         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
295         local_ret
296 }
297
298 /// Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
299 /// Any expiry that has already passed is valid and can be checked for using
300 /// [`Bolt12Invoice::is_expired`].
301 ///
302 /// Successive calls to this method will override the previous setting.
303 #[must_use]
304 #[no_mangle]
305 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, mut relative_expiry_secs: u32) {
306         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).relative_expiry(relative_expiry_secs);
307         () /*ret*/
308 }
309
310 /// Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
311 ///
312 /// Successive calls to this method will add another address. Caller is responsible for not
313 /// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
314 #[must_use]
315 #[no_mangle]
316 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, script_hash: *const [u8; 32]) {
317         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone())));
318         () /*ret*/
319 }
320
321 /// Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
322 ///
323 /// Successive calls to this method will add another address. Caller is responsible for not
324 /// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
325 #[must_use]
326 #[no_mangle]
327 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) {
328         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone())));
329         () /*ret*/
330 }
331
332 /// Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
333 ///
334 /// Successive calls to this method will add another address. Caller is responsible for not
335 /// adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
336 #[must_use]
337 #[no_mangle]
338 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, mut output_key: crate::c_types::TweakedPublicKey) {
339         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v1_p2tr_tweaked(&output_key.into_rust());
340         () /*ret*/
341 }
342
343 /// Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
344 /// disallowed.
345 #[must_use]
346 #[no_mangle]
347 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) {
348         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).allow_mpp();
349         () /*ret*/
350 }
351
352
353 use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport;
354 pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport;
355
356 /// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
357 ///
358 /// # Serialization
359 ///
360 /// This is serialized as a TLV stream, which includes TLV records from the originating message. As
361 /// such, it may include unknown, odd TLV records.
362 #[must_use]
363 #[repr(C)]
364 pub struct UnsignedBolt12Invoice {
365         /// A pointer to the opaque Rust object.
366
367         /// Nearly everywhere, inner must be non-null, however in places where
368         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
369         pub inner: *mut nativeUnsignedBolt12Invoice,
370         /// Indicates that this is the only struct which contains the same pointer.
371
372         /// Rust functions which take ownership of an object provided via an argument require
373         /// this to be true and invalidate the object pointed to by inner.
374         pub is_owned: bool,
375 }
376
377 impl Drop for UnsignedBolt12Invoice {
378         fn drop(&mut self) {
379                 if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) {
380                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
381                 }
382         }
383 }
384 /// Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL.
385 #[no_mangle]
386 pub extern "C" fn UnsignedBolt12Invoice_free(this_obj: UnsignedBolt12Invoice) { }
387 #[allow(unused)]
388 /// Used only if an object of this type is returned as a trait impl by a method
389 pub(crate) extern "C" fn UnsignedBolt12Invoice_free_void(this_ptr: *mut c_void) {
390         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedBolt12Invoice) };
391 }
392 #[allow(unused)]
393 impl UnsignedBolt12Invoice {
394         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedBolt12Invoice {
395                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
396         }
397         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedBolt12Invoice {
398                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
399         }
400         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
401         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedBolt12Invoice {
402                 assert!(self.is_owned);
403                 let ret = ObjOps::untweak_ptr(self.inner);
404                 self.inner = core::ptr::null_mut();
405                 ret
406         }
407 }
408 /// A function for signing an [`UnsignedBolt12Invoice`].
409 #[repr(C)]
410 pub struct SignBolt12InvoiceFn {
411         /// An opaque pointer which is passed to your function implementations as an argument.
412         /// This has no meaning in the LDK, and can be NULL or any other value.
413         pub this_arg: *mut c_void,
414         /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
415         pub sign_invoice: extern "C" fn (this_arg: *const c_void, message: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ,
416         /// Frees any resources associated with this object given its this_arg pointer.
417         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
418         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
419 }
420 unsafe impl Send for SignBolt12InvoiceFn {}
421 unsafe impl Sync for SignBolt12InvoiceFn {}
422 #[allow(unused)]
423 pub(crate) fn SignBolt12InvoiceFn_clone_fields(orig: &SignBolt12InvoiceFn) -> SignBolt12InvoiceFn {
424         SignBolt12InvoiceFn {
425                 this_arg: orig.this_arg,
426                 sign_invoice: Clone::clone(&orig.sign_invoice),
427                 free: Clone::clone(&orig.free),
428         }
429 }
430
431 use lightning::offers::invoice::SignBolt12InvoiceFn as rustSignBolt12InvoiceFn;
432 impl rustSignBolt12InvoiceFn for SignBolt12InvoiceFn {
433         fn sign_invoice(&self, mut message: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result<bitcoin::secp256k1::schnorr::Signature, ()> {
434                 let mut ret = (self.sign_invoice)(self.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) as *mut _) }, is_owned: false });
435                 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
436                 local_ret
437         }
438 }
439
440 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
441 // directly as a Deref trait in higher-level structs:
442 impl core::ops::Deref for SignBolt12InvoiceFn {
443         type Target = Self;
444         fn deref(&self) -> &Self {
445                 self
446         }
447 }
448 impl core::ops::DerefMut for SignBolt12InvoiceFn {
449         fn deref_mut(&mut self) -> &mut Self {
450                 self
451         }
452 }
453 /// Calls the free function if one is set
454 #[no_mangle]
455 pub extern "C" fn SignBolt12InvoiceFn_free(this_ptr: SignBolt12InvoiceFn) { }
456 impl Drop for SignBolt12InvoiceFn {
457         fn drop(&mut self) {
458                 if let Some(f) = self.free {
459                         f(self.this_arg);
460                 }
461         }
462 }
463 /// Returns the [`TaggedHash`] of the invoice to sign.
464 #[must_use]
465 #[no_mangle]
466 pub extern "C" fn UnsignedBolt12Invoice_tagged_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::merkle::TaggedHash {
467         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tagged_hash();
468         crate::lightning::offers::merkle::TaggedHash { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::offers::merkle::TaggedHash<>) as *mut _) }, is_owned: false }
469 }
470
471
472 use lightning::offers::invoice::Bolt12Invoice as nativeBolt12InvoiceImport;
473 pub(crate) type nativeBolt12Invoice = nativeBolt12InvoiceImport;
474
475 /// A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`].
476 ///
477 /// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent
478 /// directly after scanning a refund. It includes all the information needed to pay a recipient.
479 ///
480 /// [`Offer`]: crate::offers::offer::Offer
481 /// [`Refund`]: crate::offers::refund::Refund
482 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
483 #[must_use]
484 #[repr(C)]
485 pub struct Bolt12Invoice {
486         /// A pointer to the opaque Rust object.
487
488         /// Nearly everywhere, inner must be non-null, however in places where
489         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
490         pub inner: *mut nativeBolt12Invoice,
491         /// Indicates that this is the only struct which contains the same pointer.
492
493         /// Rust functions which take ownership of an object provided via an argument require
494         /// this to be true and invalidate the object pointed to by inner.
495         pub is_owned: bool,
496 }
497
498 impl Drop for Bolt12Invoice {
499         fn drop(&mut self) {
500                 if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) {
501                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
502                 }
503         }
504 }
505 /// Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL.
506 #[no_mangle]
507 pub extern "C" fn Bolt12Invoice_free(this_obj: Bolt12Invoice) { }
508 #[allow(unused)]
509 /// Used only if an object of this type is returned as a trait impl by a method
510 pub(crate) extern "C" fn Bolt12Invoice_free_void(this_ptr: *mut c_void) {
511         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12Invoice) };
512 }
513 #[allow(unused)]
514 impl Bolt12Invoice {
515         pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12Invoice {
516                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
517         }
518         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12Invoice {
519                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
520         }
521         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
522         pub(crate) fn take_inner(mut self) -> *mut nativeBolt12Invoice {
523                 assert!(self.is_owned);
524                 let ret = ObjOps::untweak_ptr(self.inner);
525                 self.inner = core::ptr::null_mut();
526                 ret
527         }
528 }
529 impl Clone for Bolt12Invoice {
530         fn clone(&self) -> Self {
531                 Self {
532                         inner: if <*mut nativeBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
533                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
534                         is_owned: true,
535                 }
536         }
537 }
538 #[allow(unused)]
539 /// Used only if an object of this type is returned as a trait impl by a method
540 pub(crate) extern "C" fn Bolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
541         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12Invoice)).clone() })) as *mut c_void
542 }
543 #[no_mangle]
544 /// Creates a copy of the Bolt12Invoice
545 pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice {
546         orig.clone()
547 }
548 /// Get a string which allows debug introspection of a Bolt12Invoice object
549 pub extern "C" fn Bolt12Invoice_debug_str_void(o: *const c_void) -> Str {
550         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::Bolt12Invoice }).into()}
551 /// The chains that may be used when paying a requested invoice.
552 ///
553 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
554 ///
555 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
556 #[must_use]
557 #[no_mangle]
558 pub extern "C" fn UnsignedBolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
559         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
560         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_ret_0.into() }) };
561         local_ret
562 }
563
564 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
565 /// invoice originated from an offer.
566 ///
567 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
568 ///
569 /// [`offer_chains`]: Self::offer_chains
570 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
571 #[must_use]
572 #[no_mangle]
573 pub extern "C" fn UnsignedBolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
574         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
575         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
576 }
577
578 /// Opaque bytes set by the originating [`Offer`].
579 ///
580 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
581 /// if the [`Offer`] did not set it.
582 ///
583 /// [`Offer`]: crate::offers::offer::Offer
584 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
585 #[must_use]
586 #[no_mangle]
587 pub extern "C" fn UnsignedBolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
588         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
589         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) };
590         local_ret
591 }
592
593 /// The minimum amount required for a successful payment of a single item.
594 ///
595 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
596 /// the [`Offer`] did not set it.
597 ///
598 /// [`Offer`]: crate::offers::offer::Offer
599 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
600 #[must_use]
601 #[no_mangle]
602 pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_AmountZ {
603         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
604         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) };
605         local_ret
606 }
607
608 /// Features pertaining to the originating [`Offer`].
609 ///
610 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
611 /// [`Refund`].
612 ///
613 /// [`Offer`]: crate::offers::offer::Offer
614 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
615 ///
616 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
617 #[must_use]
618 #[no_mangle]
619 pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
620         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
621         let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false };
622         local_ret
623 }
624
625 /// A complete description of the purpose of the originating offer or refund.
626 ///
627 /// From [`Offer::description`] or [`Refund::description`].
628 ///
629 /// [`Offer::description`]: crate::offers::offer::Offer::description
630 ///
631 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
632 #[must_use]
633 #[no_mangle]
634 pub extern "C" fn UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
635         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
636         let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
637         local_ret
638 }
639
640 /// Duration since the Unix epoch when an invoice should no longer be requested.
641 ///
642 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
643 ///
644 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
645 #[must_use]
646 #[no_mangle]
647 pub extern "C" fn UnsignedBolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
648         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
649         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap().as_secs() }) };
650         local_ret
651 }
652
653 /// The issuer of the offer or refund.
654 ///
655 /// From [`Offer::issuer`] or [`Refund::issuer`].
656 ///
657 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
658 ///
659 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
660 #[must_use]
661 #[no_mangle]
662 pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
663         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
664         let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
665         local_ret
666 }
667
668 /// Paths to the recipient originating from publicly reachable nodes.
669 ///
670 /// From [`Offer::paths`] or [`Refund::paths`].
671 ///
672 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
673 #[must_use]
674 #[no_mangle]
675 pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
676         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
677         let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
678         local_ret.into()
679 }
680
681 /// The quantity of items supported.
682 ///
683 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
684 /// [`Refund`].
685 ///
686 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
687 #[must_use]
688 #[no_mangle]
689 pub extern "C" fn UnsignedBolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_QuantityZ {
690         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
691         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_QuantityZ::None } else { crate::c_types::derived::COption_QuantityZ::Some( { crate::lightning::offers::offer::Quantity::native_into(ret.unwrap()) }) };
692         local_ret
693 }
694
695 /// An unpredictable series of bytes from the payer.
696 ///
697 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
698 #[must_use]
699 #[no_mangle]
700 pub extern "C" fn UnsignedBolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::u8slice {
701         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
702         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
703         local_ret
704 }
705
706 /// Features pertaining to requesting an invoice.
707 ///
708 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
709 #[must_use]
710 #[no_mangle]
711 pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
712         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
713         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
714 }
715
716 /// The quantity of items requested or refunded for.
717 ///
718 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
719 #[must_use]
720 #[no_mangle]
721 pub extern "C" fn UnsignedBolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
722         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
723         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
724         local_ret
725 }
726
727 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
728 /// refund in case there are no [`message_paths`].
729 ///
730 /// [`message_paths`]: Self::message_paths
731 #[must_use]
732 #[no_mangle]
733 pub extern "C" fn UnsignedBolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
734         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
735         crate::c_types::PublicKey::from_rust(&ret)
736 }
737
738 /// A payer-provided note reflected back in the invoice.
739 ///
740 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
741 ///
742 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
743 #[must_use]
744 #[no_mangle]
745 pub extern "C" fn UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
746         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
747         let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
748         local_ret
749 }
750
751 /// Duration since the Unix epoch when the invoice was created.
752 #[must_use]
753 #[no_mangle]
754 pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
755         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
756         ret.as_secs()
757 }
758
759 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
760 /// should no longer be paid.
761 #[must_use]
762 #[no_mangle]
763 pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
764         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
765         ret.as_secs()
766 }
767
768 /// Whether the invoice has expired.
769 #[must_use]
770 #[no_mangle]
771 pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool {
772         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
773         ret
774 }
775
776 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
777 #[must_use]
778 #[no_mangle]
779 pub extern "C" fn UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
780         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
781         crate::c_types::ThirtyTwoBytes { data: ret.0 }
782 }
783
784 /// The minimum amount required for a successful payment of the invoice.
785 #[must_use]
786 #[no_mangle]
787 pub extern "C" fn UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
788         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
789         ret
790 }
791
792 /// Features pertaining to paying an invoice.
793 #[must_use]
794 #[no_mangle]
795 pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
796         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
797         crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
798 }
799
800 /// The public key corresponding to the key used to sign the invoice.
801 #[must_use]
802 #[no_mangle]
803 pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
804         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
805         crate::c_types::PublicKey::from_rust(&ret)
806 }
807
808 /// The chains that may be used when paying a requested invoice.
809 ///
810 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
811 ///
812 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
813 #[must_use]
814 #[no_mangle]
815 pub extern "C" fn Bolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
816         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
817         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_ret_0.into() }) };
818         local_ret
819 }
820
821 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
822 /// invoice originated from an offer.
823 ///
824 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
825 ///
826 /// [`offer_chains`]: Self::offer_chains
827 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
828 #[must_use]
829 #[no_mangle]
830 pub extern "C" fn Bolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
831         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
832         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
833 }
834
835 /// Opaque bytes set by the originating [`Offer`].
836 ///
837 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
838 /// if the [`Offer`] did not set it.
839 ///
840 /// [`Offer`]: crate::offers::offer::Offer
841 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
842 #[must_use]
843 #[no_mangle]
844 pub extern "C" fn Bolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
845         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
846         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) };
847         local_ret
848 }
849
850 /// The minimum amount required for a successful payment of a single item.
851 ///
852 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
853 /// the [`Offer`] did not set it.
854 ///
855 /// [`Offer`]: crate::offers::offer::Offer
856 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
857 #[must_use]
858 #[no_mangle]
859 pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_AmountZ {
860         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
861         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) };
862         local_ret
863 }
864
865 /// Features pertaining to the originating [`Offer`].
866 ///
867 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
868 /// [`Refund`].
869 ///
870 /// [`Offer`]: crate::offers::offer::Offer
871 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
872 ///
873 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
874 #[must_use]
875 #[no_mangle]
876 pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
877         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
878         let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false };
879         local_ret
880 }
881
882 /// A complete description of the purpose of the originating offer or refund.
883 ///
884 /// From [`Offer::description`] or [`Refund::description`].
885 ///
886 /// [`Offer::description`]: crate::offers::offer::Offer::description
887 ///
888 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
889 #[must_use]
890 #[no_mangle]
891 pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
892         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
893         let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
894         local_ret
895 }
896
897 /// Duration since the Unix epoch when an invoice should no longer be requested.
898 ///
899 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
900 ///
901 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
902 #[must_use]
903 #[no_mangle]
904 pub extern "C" fn Bolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
905         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
906         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap().as_secs() }) };
907         local_ret
908 }
909
910 /// The issuer of the offer or refund.
911 ///
912 /// From [`Offer::issuer`] or [`Refund::issuer`].
913 ///
914 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
915 ///
916 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
917 #[must_use]
918 #[no_mangle]
919 pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
920         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
921         let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
922         local_ret
923 }
924
925 /// Paths to the recipient originating from publicly reachable nodes.
926 ///
927 /// From [`Offer::paths`] or [`Refund::paths`].
928 ///
929 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
930 #[must_use]
931 #[no_mangle]
932 pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
933         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
934         let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
935         local_ret.into()
936 }
937
938 /// The quantity of items supported.
939 ///
940 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
941 /// [`Refund`].
942 ///
943 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
944 #[must_use]
945 #[no_mangle]
946 pub extern "C" fn Bolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_QuantityZ {
947         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
948         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_QuantityZ::None } else { crate::c_types::derived::COption_QuantityZ::Some( { crate::lightning::offers::offer::Quantity::native_into(ret.unwrap()) }) };
949         local_ret
950 }
951
952 /// An unpredictable series of bytes from the payer.
953 ///
954 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
955 #[must_use]
956 #[no_mangle]
957 pub extern "C" fn Bolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::u8slice {
958         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
959         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
960         local_ret
961 }
962
963 /// Features pertaining to requesting an invoice.
964 ///
965 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
966 #[must_use]
967 #[no_mangle]
968 pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
969         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
970         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
971 }
972
973 /// The quantity of items requested or refunded for.
974 ///
975 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
976 #[must_use]
977 #[no_mangle]
978 pub extern "C" fn Bolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
979         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
980         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
981         local_ret
982 }
983
984 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
985 /// refund in case there are no [`message_paths`].
986 ///
987 /// [`message_paths`]: Self::message_paths
988 #[must_use]
989 #[no_mangle]
990 pub extern "C" fn Bolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
991         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
992         crate::c_types::PublicKey::from_rust(&ret)
993 }
994
995 /// A payer-provided note reflected back in the invoice.
996 ///
997 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
998 ///
999 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1000 #[must_use]
1001 #[no_mangle]
1002 pub extern "C" fn Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
1003         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
1004         let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
1005         local_ret
1006 }
1007
1008 /// Duration since the Unix epoch when the invoice was created.
1009 #[must_use]
1010 #[no_mangle]
1011 pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
1012         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
1013         ret.as_secs()
1014 }
1015
1016 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
1017 /// should no longer be paid.
1018 #[must_use]
1019 #[no_mangle]
1020 pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
1021         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
1022         ret.as_secs()
1023 }
1024
1025 /// Whether the invoice has expired.
1026 #[must_use]
1027 #[no_mangle]
1028 pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool {
1029         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
1030         ret
1031 }
1032
1033 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
1034 #[must_use]
1035 #[no_mangle]
1036 pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
1037         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
1038         crate::c_types::ThirtyTwoBytes { data: ret.0 }
1039 }
1040
1041 /// The minimum amount required for a successful payment of the invoice.
1042 #[must_use]
1043 #[no_mangle]
1044 pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
1045         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
1046         ret
1047 }
1048
1049 /// Features pertaining to paying an invoice.
1050 #[must_use]
1051 #[no_mangle]
1052 pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
1053         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
1054         crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
1055 }
1056
1057 /// The public key corresponding to the key used to sign the invoice.
1058 #[must_use]
1059 #[no_mangle]
1060 pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
1061         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
1062         crate::c_types::PublicKey::from_rust(&ret)
1063 }
1064
1065 /// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
1066 #[must_use]
1067 #[no_mangle]
1068 pub extern "C" fn Bolt12Invoice_signature(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::SchnorrSignature {
1069         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
1070         crate::c_types::SchnorrSignature::from_rust(&ret)
1071 }
1072
1073 /// Hash that was used for signing the invoice.
1074 #[must_use]
1075 #[no_mangle]
1076 pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
1077         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
1078         crate::c_types::ThirtyTwoBytes { data: ret }
1079 }
1080
1081 /// Verifies that the invoice was for a request or refund created using the given key. Returns
1082 /// the associated [`PaymentId`] to use when sending the payment.
1083 #[must_use]
1084 #[no_mangle]
1085 pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ {
1086         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1);
1087         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1088         local_ret
1089 }
1090
1091 /// Generates a non-cryptographic 64-bit hash of the Bolt12Invoice.
1092 #[no_mangle]
1093 pub extern "C" fn Bolt12Invoice_hash(o: &Bolt12Invoice) -> u64 {
1094         if o.inner.is_null() { return 0; }
1095         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1096         #[allow(deprecated)]
1097         let mut hasher = core::hash::SipHasher::new();
1098         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1099         core::hash::Hasher::finish(&hasher)
1100 }
1101 #[no_mangle]
1102 /// Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read
1103 pub extern "C" fn UnsignedBolt12Invoice_write(obj: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
1104         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1105 }
1106 #[allow(unused)]
1107 pub(crate) extern "C" fn UnsignedBolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1108         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedBolt12Invoice) })
1109 }
1110 #[no_mangle]
1111 /// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
1112 pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
1113         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1114 }
1115 #[allow(unused)]
1116 pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1117         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) })
1118 }
1119
1120 use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport;
1121 pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport;
1122
1123 /// Information needed to route a payment across a [`BlindedPath`].
1124 #[must_use]
1125 #[repr(C)]
1126 pub struct BlindedPayInfo {
1127         /// A pointer to the opaque Rust object.
1128
1129         /// Nearly everywhere, inner must be non-null, however in places where
1130         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1131         pub inner: *mut nativeBlindedPayInfo,
1132         /// Indicates that this is the only struct which contains the same pointer.
1133
1134         /// Rust functions which take ownership of an object provided via an argument require
1135         /// this to be true and invalidate the object pointed to by inner.
1136         pub is_owned: bool,
1137 }
1138
1139 impl Drop for BlindedPayInfo {
1140         fn drop(&mut self) {
1141                 if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) {
1142                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1143                 }
1144         }
1145 }
1146 /// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL.
1147 #[no_mangle]
1148 pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { }
1149 #[allow(unused)]
1150 /// Used only if an object of this type is returned as a trait impl by a method
1151 pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) {
1152         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) };
1153 }
1154 #[allow(unused)]
1155 impl BlindedPayInfo {
1156         pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo {
1157                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1158         }
1159         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo {
1160                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1161         }
1162         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1163         pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo {
1164                 assert!(self.is_owned);
1165                 let ret = ObjOps::untweak_ptr(self.inner);
1166                 self.inner = core::ptr::null_mut();
1167                 ret
1168         }
1169 }
1170 /// Base fee charged (in millisatoshi) for the entire blinded path.
1171 #[no_mangle]
1172 pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 {
1173         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
1174         *inner_val
1175 }
1176 /// Base fee charged (in millisatoshi) for the entire blinded path.
1177 #[no_mangle]
1178 pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) {
1179         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
1180 }
1181 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
1182 /// (i.e., 10,000 is 1%).
1183 #[no_mangle]
1184 pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 {
1185         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
1186         *inner_val
1187 }
1188 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
1189 /// (i.e., 10,000 is 1%).
1190 #[no_mangle]
1191 pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) {
1192         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
1193 }
1194 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
1195 /// path.
1196 #[no_mangle]
1197 pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 {
1198         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
1199         *inner_val
1200 }
1201 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
1202 /// path.
1203 #[no_mangle]
1204 pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) {
1205         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
1206 }
1207 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1208 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1209 /// seen by the recipient.
1210 #[no_mangle]
1211 pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 {
1212         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1213         *inner_val
1214 }
1215 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1216 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1217 /// seen by the recipient.
1218 #[no_mangle]
1219 pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
1220         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1221 }
1222 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1223 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1224 /// seen by the recipient.
1225 #[no_mangle]
1226 pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 {
1227         let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
1228         *inner_val
1229 }
1230 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1231 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1232 /// seen by the recipient.
1233 #[no_mangle]
1234 pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
1235         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
1236 }
1237 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
1238 /// onion payload.
1239 #[no_mangle]
1240 pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures {
1241         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
1242         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 }
1243 }
1244 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
1245 /// onion payload.
1246 #[no_mangle]
1247 pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
1248         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
1249 }
1250 /// Constructs a new BlindedPayInfo given each field
1251 #[must_use]
1252 #[no_mangle]
1253 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 {
1254         BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo {
1255                 fee_base_msat: fee_base_msat_arg,
1256                 fee_proportional_millionths: fee_proportional_millionths_arg,
1257                 cltv_expiry_delta: cltv_expiry_delta_arg,
1258                 htlc_minimum_msat: htlc_minimum_msat_arg,
1259                 htlc_maximum_msat: htlc_maximum_msat_arg,
1260                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1261         }), is_owned: true }
1262 }
1263 impl Clone for BlindedPayInfo {
1264         fn clone(&self) -> Self {
1265                 Self {
1266                         inner: if <*mut nativeBlindedPayInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1267                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1268                         is_owned: true,
1269                 }
1270         }
1271 }
1272 #[allow(unused)]
1273 /// Used only if an object of this type is returned as a trait impl by a method
1274 pub(crate) extern "C" fn BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1275         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void
1276 }
1277 #[no_mangle]
1278 /// Creates a copy of the BlindedPayInfo
1279 pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo {
1280         orig.clone()
1281 }
1282 /// Get a string which allows debug introspection of a BlindedPayInfo object
1283 pub extern "C" fn BlindedPayInfo_debug_str_void(o: *const c_void) -> Str {
1284         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::BlindedPayInfo }).into()}
1285 /// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo.
1286 #[no_mangle]
1287 pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 {
1288         if o.inner.is_null() { return 0; }
1289         // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1290         #[allow(deprecated)]
1291         let mut hasher = core::hash::SipHasher::new();
1292         core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1293         core::hash::Hasher::finish(&hasher)
1294 }
1295 /// Checks if two BlindedPayInfos contain equal inner contents.
1296 /// This ignores pointers and is_owned flags and looks at the values in fields.
1297 /// Two objects with NULL inner values will be considered "equal" here.
1298 #[no_mangle]
1299 pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool {
1300         if a.inner == b.inner { return true; }
1301         if a.inner.is_null() || b.inner.is_null() { return false; }
1302         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1303 }
1304 #[no_mangle]
1305 /// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read
1306 pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z {
1307         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1308 }
1309 #[allow(unused)]
1310 pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1311         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) })
1312 }
1313 #[no_mangle]
1314 /// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write
1315 pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ {
1316         let res: Result<lightning::offers::invoice::BlindedPayInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1317         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() };
1318         local_res
1319 }