Pin compiler_builtins to 0.1.109 when building std
[ldk-c-bindings] / lightning-c-bindings / src / lightning / offers / invoice_request.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_request` messages.
10 //!
11 //! An [`InvoiceRequest`] can be built from a parsed [`Offer`] as an \"offer to be paid\". It is
12 //! typically constructed by a customer and sent to the merchant who had published the corresponding
13 //! offer. The recipient of the request responds with a [`Bolt12Invoice`].
14 //!
15 //! For an \"offer for money\" (e.g., refund, ATM withdrawal), where an offer doesn't exist as a
16 //! precursor, see [`Refund`].
17 //!
18 //! [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
19 //! [`Refund`]: crate::offers::refund::Refund
20 //!
21 //! ```
22 //! extern crate bitcoin;
23 //! extern crate lightning;
24 //!
25 //! use bitcoin::network::constants::Network;
26 //! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
27 //! use lightning::ln::features::OfferFeatures;
28 //! use lightning::offers::invoice_request::UnsignedInvoiceRequest;
29 //! use lightning::offers::offer::Offer;
30 //! use lightning::util::ser::Writeable;
31 //!
32 //! # fn parse() -> Result<(), lightning::offers::parse::Bolt12ParseError> {
33 //! let secp_ctx = Secp256k1::new();
34 //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
35 //! let pubkey = PublicKey::from(keys);
36 //! let mut buffer = Vec::new();
37 //!
38 //! # use lightning::offers::invoice_request::{ExplicitPayerId, InvoiceRequestBuilder};
39 //! # <InvoiceRequestBuilder<ExplicitPayerId, _>>::from(
40 //! \"lno1qcp4256ypq\"
41 //!     .parse::<Offer>()?
42 //!     .request_invoice(vec![42; 64], pubkey)?
43 //! # )
44 //!     .chain(Network::Testnet)?
45 //!     .amount_msats(1000)?
46 //!     .quantity(5)?
47 //!     .payer_note(\"foo\".to_string())
48 //!     .build()?
49 //!     .sign(|message: &UnsignedInvoiceRequest|
50 //!         Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
51 //!     )
52 //!     .expect(\"failed verifying signature\")
53 //!     .write(&mut buffer)
54 //!     .unwrap();
55 //! # Ok(())
56 //! # }
57 //! ```
58
59 use alloc::str::FromStr;
60 use alloc::string::String;
61 use core::ffi::c_void;
62 use core::convert::Infallible;
63 use bitcoin::hashes::Hash;
64 use crate::c_types::*;
65 #[cfg(feature="no-std")]
66 use alloc::{vec::Vec, boxed::Box};
67
68
69 use lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder as nativeInvoiceRequestWithExplicitPayerIdBuilderImport;
70 pub(crate) type nativeInvoiceRequestWithExplicitPayerIdBuilder = nativeInvoiceRequestWithExplicitPayerIdBuilderImport<'static, 'static, >;
71
72 /// Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow.
73 ///
74 /// See [module-level documentation] for usage.
75 ///
76 /// [module-level documentation]: self
77 #[must_use]
78 #[repr(C)]
79 pub struct InvoiceRequestWithExplicitPayerIdBuilder {
80         /// A pointer to the opaque Rust object.
81
82         /// Nearly everywhere, inner must be non-null, however in places where
83         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
84         pub inner: *mut nativeInvoiceRequestWithExplicitPayerIdBuilder,
85         /// Indicates that this is the only struct which contains the same pointer.
86
87         /// Rust functions which take ownership of an object provided via an argument require
88         /// this to be true and invalidate the object pointed to by inner.
89         pub is_owned: bool,
90 }
91
92 impl Drop for InvoiceRequestWithExplicitPayerIdBuilder {
93         fn drop(&mut self) {
94                 if self.is_owned && !<*mut nativeInvoiceRequestWithExplicitPayerIdBuilder>::is_null(self.inner) {
95                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
96                 }
97         }
98 }
99 /// Frees any resources used by the InvoiceRequestWithExplicitPayerIdBuilder, if is_owned is set and inner is non-NULL.
100 #[no_mangle]
101 pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_free(this_obj: InvoiceRequestWithExplicitPayerIdBuilder) { }
102 #[allow(unused)]
103 /// Used only if an object of this type is returned as a trait impl by a method
104 pub(crate) extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_free_void(this_ptr: *mut c_void) {
105         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestWithExplicitPayerIdBuilder) };
106 }
107 #[allow(unused)]
108 impl InvoiceRequestWithExplicitPayerIdBuilder {
109         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestWithExplicitPayerIdBuilder {
110                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
111         }
112         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestWithExplicitPayerIdBuilder {
113                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
114         }
115         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
116         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestWithExplicitPayerIdBuilder {
117                 assert!(self.is_owned);
118                 let ret = ObjOps::untweak_ptr(self.inner);
119                 self.inner = core::ptr::null_mut();
120                 ret
121         }
122 }
123
124 use lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder as nativeInvoiceRequestWithDerivedPayerIdBuilderImport;
125 pub(crate) type nativeInvoiceRequestWithDerivedPayerIdBuilder = nativeInvoiceRequestWithDerivedPayerIdBuilderImport<'static, 'static, >;
126
127 /// Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow.
128 ///
129 /// See [module-level documentation] for usage.
130 ///
131 /// [module-level documentation]: self
132 #[must_use]
133 #[repr(C)]
134 pub struct InvoiceRequestWithDerivedPayerIdBuilder {
135         /// A pointer to the opaque Rust object.
136
137         /// Nearly everywhere, inner must be non-null, however in places where
138         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
139         pub inner: *mut nativeInvoiceRequestWithDerivedPayerIdBuilder,
140         /// Indicates that this is the only struct which contains the same pointer.
141
142         /// Rust functions which take ownership of an object provided via an argument require
143         /// this to be true and invalidate the object pointed to by inner.
144         pub is_owned: bool,
145 }
146
147 impl Drop for InvoiceRequestWithDerivedPayerIdBuilder {
148         fn drop(&mut self) {
149                 if self.is_owned && !<*mut nativeInvoiceRequestWithDerivedPayerIdBuilder>::is_null(self.inner) {
150                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
151                 }
152         }
153 }
154 /// Frees any resources used by the InvoiceRequestWithDerivedPayerIdBuilder, if is_owned is set and inner is non-NULL.
155 #[no_mangle]
156 pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_free(this_obj: InvoiceRequestWithDerivedPayerIdBuilder) { }
157 #[allow(unused)]
158 /// Used only if an object of this type is returned as a trait impl by a method
159 pub(crate) extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_free_void(this_ptr: *mut c_void) {
160         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestWithDerivedPayerIdBuilder) };
161 }
162 #[allow(unused)]
163 impl InvoiceRequestWithDerivedPayerIdBuilder {
164         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestWithDerivedPayerIdBuilder {
165                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
166         }
167         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestWithDerivedPayerIdBuilder {
168                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
169         }
170         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
171         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestWithDerivedPayerIdBuilder {
172                 assert!(self.is_owned);
173                 let ret = ObjOps::untweak_ptr(self.inner);
174                 self.inner = core::ptr::null_mut();
175                 ret
176         }
177 }
178 /// Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed
179 /// by [`UnsignedInvoiceRequest::sign`].
180 #[must_use]
181 #[no_mangle]
182 pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_build(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder) -> crate::c_types::derived::CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ {
183         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build();
184         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { 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() };
185         local_ret
186 }
187
188 /// Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not
189 /// called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported
190 /// by the offer.
191 ///
192 /// Successive calls to this method will override the previous setting.
193 #[must_use]
194 #[no_mangle]
195 pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_chain(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut network: crate::bitcoin::network::Network) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
196         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).chain(network.into_bitcoin());
197         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
198         local_ret
199 }
200
201 /// Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is
202 /// not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]).
203 ///
204 /// Successive calls to this method will override the previous setting.
205 ///
206 /// [`quantity`]: Self::quantity
207 #[must_use]
208 #[no_mangle]
209 pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_amount_msats(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut amount_msats: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
210         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).amount_msats(amount_msats);
211         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
212         local_ret
213 }
214
215 /// Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity`
216 /// does not conform to [`Offer::is_valid_quantity`].
217 ///
218 /// Successive calls to this method will override the previous setting.
219 #[must_use]
220 #[no_mangle]
221 pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_quantity(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut quantity: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
222         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).quantity(quantity);
223         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
224         local_ret
225 }
226
227 /// Sets the [`InvoiceRequest::payer_note`].
228 ///
229 /// Successive calls to this method will override the previous setting.
230 #[must_use]
231 #[no_mangle]
232 pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_payer_note(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut payer_note: crate::c_types::Str) {
233         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).payer_note(payer_note.into_string());
234         () /*ret*/
235 }
236
237 /// Builds a signed [`InvoiceRequest`] after checking for valid semantics.
238 #[must_use]
239 #[no_mangle]
240 pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_build_and_sign(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder) -> crate::c_types::derived::CResult_InvoiceRequestBolt12SemanticErrorZ {
241         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build_and_sign();
242         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequest { 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() };
243         local_ret
244 }
245
246 /// Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not
247 /// called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported
248 /// by the offer.
249 ///
250 /// Successive calls to this method will override the previous setting.
251 #[must_use]
252 #[no_mangle]
253 pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_chain(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut network: crate::bitcoin::network::Network) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
254         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).chain(network.into_bitcoin());
255         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
256         local_ret
257 }
258
259 /// Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is
260 /// not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]).
261 ///
262 /// Successive calls to this method will override the previous setting.
263 ///
264 /// [`quantity`]: Self::quantity
265 #[must_use]
266 #[no_mangle]
267 pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_amount_msats(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut amount_msats: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
268         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).amount_msats(amount_msats);
269         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
270         local_ret
271 }
272
273 /// Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity`
274 /// does not conform to [`Offer::is_valid_quantity`].
275 ///
276 /// Successive calls to this method will override the previous setting.
277 #[must_use]
278 #[no_mangle]
279 pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_quantity(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut quantity: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
280         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).quantity(quantity);
281         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
282         local_ret
283 }
284
285 /// Sets the [`InvoiceRequest::payer_note`].
286 ///
287 /// Successive calls to this method will override the previous setting.
288 #[must_use]
289 #[no_mangle]
290 pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_payer_note(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut payer_note: crate::c_types::Str) {
291         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).payer_note(payer_note.into_string());
292         () /*ret*/
293 }
294
295
296 use lightning::offers::invoice_request::UnsignedInvoiceRequest as nativeUnsignedInvoiceRequestImport;
297 pub(crate) type nativeUnsignedInvoiceRequest = nativeUnsignedInvoiceRequestImport;
298
299 /// A semantically valid [`InvoiceRequest`] that hasn't been signed.
300 ///
301 /// # Serialization
302 ///
303 /// This is serialized as a TLV stream, which includes TLV records from the originating message. As
304 /// such, it may include unknown, odd TLV records.
305 #[must_use]
306 #[repr(C)]
307 pub struct UnsignedInvoiceRequest {
308         /// A pointer to the opaque Rust object.
309
310         /// Nearly everywhere, inner must be non-null, however in places where
311         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
312         pub inner: *mut nativeUnsignedInvoiceRequest,
313         /// Indicates that this is the only struct which contains the same pointer.
314
315         /// Rust functions which take ownership of an object provided via an argument require
316         /// this to be true and invalidate the object pointed to by inner.
317         pub is_owned: bool,
318 }
319
320 impl Drop for UnsignedInvoiceRequest {
321         fn drop(&mut self) {
322                 if self.is_owned && !<*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) {
323                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
324                 }
325         }
326 }
327 /// Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL.
328 #[no_mangle]
329 pub extern "C" fn UnsignedInvoiceRequest_free(this_obj: UnsignedInvoiceRequest) { }
330 #[allow(unused)]
331 /// Used only if an object of this type is returned as a trait impl by a method
332 pub(crate) extern "C" fn UnsignedInvoiceRequest_free_void(this_ptr: *mut c_void) {
333         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedInvoiceRequest) };
334 }
335 #[allow(unused)]
336 impl UnsignedInvoiceRequest {
337         pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedInvoiceRequest {
338                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
339         }
340         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedInvoiceRequest {
341                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
342         }
343         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
344         pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedInvoiceRequest {
345                 assert!(self.is_owned);
346                 let ret = ObjOps::untweak_ptr(self.inner);
347                 self.inner = core::ptr::null_mut();
348                 ret
349         }
350 }
351 impl Clone for UnsignedInvoiceRequest {
352         fn clone(&self) -> Self {
353                 Self {
354                         inner: if <*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
355                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
356                         is_owned: true,
357                 }
358         }
359 }
360 #[allow(unused)]
361 /// Used only if an object of this type is returned as a trait impl by a method
362 pub(crate) extern "C" fn UnsignedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
363         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedInvoiceRequest)).clone() })) as *mut c_void
364 }
365 #[no_mangle]
366 /// Creates a copy of the UnsignedInvoiceRequest
367 pub extern "C" fn UnsignedInvoiceRequest_clone(orig: &UnsignedInvoiceRequest) -> UnsignedInvoiceRequest {
368         orig.clone()
369 }
370 /// A function for signing an [`UnsignedInvoiceRequest`].
371 #[repr(C)]
372 pub struct SignInvoiceRequestFn {
373         /// An opaque pointer which is passed to your function implementations as an argument.
374         /// This has no meaning in the LDK, and can be NULL or any other value.
375         pub this_arg: *mut c_void,
376         /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
377         pub sign_invoice_request: extern "C" fn (this_arg: *const c_void, message: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ,
378         /// Frees any resources associated with this object given its this_arg pointer.
379         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
380         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
381 }
382 unsafe impl Send for SignInvoiceRequestFn {}
383 unsafe impl Sync for SignInvoiceRequestFn {}
384 #[allow(unused)]
385 pub(crate) fn SignInvoiceRequestFn_clone_fields(orig: &SignInvoiceRequestFn) -> SignInvoiceRequestFn {
386         SignInvoiceRequestFn {
387                 this_arg: orig.this_arg,
388                 sign_invoice_request: Clone::clone(&orig.sign_invoice_request),
389                 free: Clone::clone(&orig.free),
390         }
391 }
392
393 use lightning::offers::invoice_request::SignInvoiceRequestFn as rustSignInvoiceRequestFn;
394 impl rustSignInvoiceRequestFn for SignInvoiceRequestFn {
395         fn sign_invoice_request(&self, mut message: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result<bitcoin::secp256k1::schnorr::Signature, ()> {
396                 let mut ret = (self.sign_invoice_request)(self.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) as *mut _) }, is_owned: false });
397                 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)) })*/ })};
398                 local_ret
399         }
400 }
401
402 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
403 // directly as a Deref trait in higher-level structs:
404 impl core::ops::Deref for SignInvoiceRequestFn {
405         type Target = Self;
406         fn deref(&self) -> &Self {
407                 self
408         }
409 }
410 impl core::ops::DerefMut for SignInvoiceRequestFn {
411         fn deref_mut(&mut self) -> &mut Self {
412                 self
413         }
414 }
415 /// Calls the free function if one is set
416 #[no_mangle]
417 pub extern "C" fn SignInvoiceRequestFn_free(this_ptr: SignInvoiceRequestFn) { }
418 impl Drop for SignInvoiceRequestFn {
419         fn drop(&mut self) {
420                 if let Some(f) = self.free {
421                         f(self.this_arg);
422                 }
423         }
424 }
425 /// Returns the [`TaggedHash`] of the invoice to sign.
426 #[must_use]
427 #[no_mangle]
428 pub extern "C" fn UnsignedInvoiceRequest_tagged_hash(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::merkle::TaggedHash {
429         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tagged_hash();
430         crate::lightning::offers::merkle::TaggedHash { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::offers::merkle::TaggedHash<>) as *mut _) }, is_owned: false }
431 }
432
433
434 use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport;
435 pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport;
436
437 /// An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
438 ///
439 /// An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
440 /// specifies these such that its recipient can send an invoice for payment.
441 ///
442 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
443 /// [`Offer`]: crate::offers::offer::Offer
444 #[must_use]
445 #[repr(C)]
446 pub struct InvoiceRequest {
447         /// A pointer to the opaque Rust object.
448
449         /// Nearly everywhere, inner must be non-null, however in places where
450         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
451         pub inner: *mut nativeInvoiceRequest,
452         /// Indicates that this is the only struct which contains the same pointer.
453
454         /// Rust functions which take ownership of an object provided via an argument require
455         /// this to be true and invalidate the object pointed to by inner.
456         pub is_owned: bool,
457 }
458
459 impl Drop for InvoiceRequest {
460         fn drop(&mut self) {
461                 if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) {
462                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
463                 }
464         }
465 }
466 /// Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL.
467 #[no_mangle]
468 pub extern "C" fn InvoiceRequest_free(this_obj: InvoiceRequest) { }
469 #[allow(unused)]
470 /// Used only if an object of this type is returned as a trait impl by a method
471 pub(crate) extern "C" fn InvoiceRequest_free_void(this_ptr: *mut c_void) {
472         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequest) };
473 }
474 #[allow(unused)]
475 impl InvoiceRequest {
476         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequest {
477                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
478         }
479         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequest {
480                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
481         }
482         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
483         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequest {
484                 assert!(self.is_owned);
485                 let ret = ObjOps::untweak_ptr(self.inner);
486                 self.inner = core::ptr::null_mut();
487                 ret
488         }
489 }
490 impl Clone for InvoiceRequest {
491         fn clone(&self) -> Self {
492                 Self {
493                         inner: if <*mut nativeInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
494                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
495                         is_owned: true,
496                 }
497         }
498 }
499 #[allow(unused)]
500 /// Used only if an object of this type is returned as a trait impl by a method
501 pub(crate) extern "C" fn InvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
502         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequest)).clone() })) as *mut c_void
503 }
504 #[no_mangle]
505 /// Creates a copy of the InvoiceRequest
506 pub extern "C" fn InvoiceRequest_clone(orig: &InvoiceRequest) -> InvoiceRequest {
507         orig.clone()
508 }
509 /// Get a string which allows debug introspection of a InvoiceRequest object
510 pub extern "C" fn InvoiceRequest_debug_str_void(o: *const c_void) -> Str {
511         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequest }).into()}
512
513 use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport;
514 pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport;
515
516 /// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different
517 /// ways to respond depending on whether the signing keys were derived.
518 #[must_use]
519 #[repr(C)]
520 pub struct VerifiedInvoiceRequest {
521         /// A pointer to the opaque Rust object.
522
523         /// Nearly everywhere, inner must be non-null, however in places where
524         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
525         pub inner: *mut nativeVerifiedInvoiceRequest,
526         /// Indicates that this is the only struct which contains the same pointer.
527
528         /// Rust functions which take ownership of an object provided via an argument require
529         /// this to be true and invalidate the object pointed to by inner.
530         pub is_owned: bool,
531 }
532
533 impl Drop for VerifiedInvoiceRequest {
534         fn drop(&mut self) {
535                 if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) {
536                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
537                 }
538         }
539 }
540 /// Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL.
541 #[no_mangle]
542 pub extern "C" fn VerifiedInvoiceRequest_free(this_obj: VerifiedInvoiceRequest) { }
543 #[allow(unused)]
544 /// Used only if an object of this type is returned as a trait impl by a method
545 pub(crate) extern "C" fn VerifiedInvoiceRequest_free_void(this_ptr: *mut c_void) {
546         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeVerifiedInvoiceRequest) };
547 }
548 #[allow(unused)]
549 impl VerifiedInvoiceRequest {
550         pub(crate) fn get_native_ref(&self) -> &'static nativeVerifiedInvoiceRequest {
551                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
552         }
553         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeVerifiedInvoiceRequest {
554                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
555         }
556         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
557         pub(crate) fn take_inner(mut self) -> *mut nativeVerifiedInvoiceRequest {
558                 assert!(self.is_owned);
559                 let ret = ObjOps::untweak_ptr(self.inner);
560                 self.inner = core::ptr::null_mut();
561                 ret
562         }
563 }
564 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
565 #[no_mangle]
566 pub extern "C" fn VerifiedInvoiceRequest_get_offer_id(this_ptr: &VerifiedInvoiceRequest) -> crate::lightning::offers::offer::OfferId {
567         let mut inner_val = &mut this_ptr.get_native_mut_ref().offer_id;
568         crate::lightning::offers::offer::OfferId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::offers::offer::OfferId<>) as *mut _) }, is_owned: false }
569 }
570 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
571 #[no_mangle]
572 pub extern "C" fn VerifiedInvoiceRequest_set_offer_id(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::lightning::offers::offer::OfferId) {
573         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.offer_id = *unsafe { Box::from_raw(val.take_inner()) };
574 }
575 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
576 ///
577 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
578 /// [`respond_with`].
579 ///
580 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
581 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
582 /// [`respond_with`]: Self::respond_with
583 #[no_mangle]
584 pub extern "C" fn VerifiedInvoiceRequest_get_keys(this_ptr: &VerifiedInvoiceRequest) -> crate::c_types::derived::COption_SecretKeyZ {
585         let mut inner_val = &mut this_ptr.get_native_mut_ref().keys;
586         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SecretKeyZ::None } else { crate::c_types::derived::COption_SecretKeyZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::SecretKey::from_rust((*inner_val.as_ref().unwrap()).clone().secret_key()) }) };
587         local_inner_val
588 }
589 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
590 ///
591 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
592 /// [`respond_with`].
593 ///
594 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
595 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
596 /// [`respond_with`]: Self::respond_with
597 #[no_mangle]
598 pub extern "C" fn VerifiedInvoiceRequest_set_keys(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::c_types::derived::COption_SecretKeyZ) {
599         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::secp256k1::KeyPair::from_secret_key(&secp256k1::global::SECP256K1, &{ val_opt.take() }.into_rust()) }})} };
600         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys = local_val;
601 }
602 impl Clone for VerifiedInvoiceRequest {
603         fn clone(&self) -> Self {
604                 Self {
605                         inner: if <*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
606                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
607                         is_owned: true,
608                 }
609         }
610 }
611 #[allow(unused)]
612 /// Used only if an object of this type is returned as a trait impl by a method
613 pub(crate) extern "C" fn VerifiedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
614         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeVerifiedInvoiceRequest)).clone() })) as *mut c_void
615 }
616 #[no_mangle]
617 /// Creates a copy of the VerifiedInvoiceRequest
618 pub extern "C" fn VerifiedInvoiceRequest_clone(orig: &VerifiedInvoiceRequest) -> VerifiedInvoiceRequest {
619         orig.clone()
620 }
621 /// Get a string which allows debug introspection of a VerifiedInvoiceRequest object
622 pub extern "C" fn VerifiedInvoiceRequest_debug_str_void(o: *const c_void) -> Str {
623         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::VerifiedInvoiceRequest }).into()}
624 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
625 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
626 /// for the selected chain.
627 #[must_use]
628 #[no_mangle]
629 pub extern "C" fn UnsignedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
630         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
631         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
632         local_ret.into()
633 }
634
635 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
636 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
637 #[must_use]
638 #[no_mangle]
639 pub extern "C" fn UnsignedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
640         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
641         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() }) };
642         local_ret
643 }
644
645 /// The minimum amount required for a successful payment of a single item.
646 #[must_use]
647 #[no_mangle]
648 pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
649         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
650         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()) }) };
651         local_ret
652 }
653
654 /// A complete description of the purpose of the payment. Intended to be displayed to the user
655 /// but with the caveat that it has not been verified in any way.
656 ///
657 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
658 #[must_use]
659 #[no_mangle]
660 pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
661         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
662         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 };
663         local_ret
664 }
665
666 /// Features pertaining to the offer.
667 #[must_use]
668 #[no_mangle]
669 pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
670         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
671         crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
672 }
673
674 /// Duration since the Unix epoch when an invoice should no longer be requested.
675 ///
676 /// If `None`, the offer does not expire.
677 #[must_use]
678 #[no_mangle]
679 pub extern "C" fn UnsignedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
680         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
681         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() }) };
682         local_ret
683 }
684
685 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
686 /// displayed to the user but with the caveat that it has not been verified in any way.
687 ///
688 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
689 #[must_use]
690 #[no_mangle]
691 pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
692         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
693         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 };
694         local_ret
695 }
696
697 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
698 /// recipient privacy by obfuscating its node id.
699 #[must_use]
700 #[no_mangle]
701 pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
702         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
703         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 } }); };
704         local_ret.into()
705 }
706
707 /// The quantity of items supported.
708 #[must_use]
709 #[no_mangle]
710 pub extern "C" fn UnsignedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
711         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
712         crate::lightning::offers::offer::Quantity::native_into(ret)
713 }
714
715 /// The public key used by the recipient to sign invoices.
716 ///
717 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
718 #[must_use]
719 #[no_mangle]
720 pub extern "C" fn UnsignedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
721         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
722         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
723         local_ret
724 }
725
726 /// An unpredictable series of bytes, typically containing information about the derivation of
727 /// [`payer_id`].
728 ///
729 /// [`payer_id`]: Self::payer_id
730 #[must_use]
731 #[no_mangle]
732 pub extern "C" fn UnsignedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::u8slice {
733         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
734         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
735         local_ret
736 }
737
738 /// A chain from [`Offer::chains`] that the offer is valid for.
739 #[must_use]
740 #[no_mangle]
741 pub extern "C" fn UnsignedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
742         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
743         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
744 }
745
746 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
747 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
748 ///
749 /// [`chain`]: Self::chain
750 #[must_use]
751 #[no_mangle]
752 pub extern "C" fn UnsignedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
753         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
754         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() }) };
755         local_ret
756 }
757
758 /// Features pertaining to requesting an invoice.
759 #[must_use]
760 #[no_mangle]
761 pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
762         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
763         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
764 }
765
766 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
767 #[must_use]
768 #[no_mangle]
769 pub extern "C" fn UnsignedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
770         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
771         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() }) };
772         local_ret
773 }
774
775 /// A possibly transient pubkey used to sign the invoice request.
776 #[must_use]
777 #[no_mangle]
778 pub extern "C" fn UnsignedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
779         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
780         crate::c_types::PublicKey::from_rust(&ret)
781 }
782
783 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
784 /// response.
785 ///
786 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
787 #[must_use]
788 #[no_mangle]
789 pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
790         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
791         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 };
792         local_ret
793 }
794
795 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
796 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
797 /// for the selected chain.
798 #[must_use]
799 #[no_mangle]
800 pub extern "C" fn InvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
801         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
802         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
803         local_ret.into()
804 }
805
806 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
807 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
808 #[must_use]
809 #[no_mangle]
810 pub extern "C" fn InvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
811         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
812         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() }) };
813         local_ret
814 }
815
816 /// The minimum amount required for a successful payment of a single item.
817 #[must_use]
818 #[no_mangle]
819 pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
820         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
821         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()) }) };
822         local_ret
823 }
824
825 /// A complete description of the purpose of the payment. Intended to be displayed to the user
826 /// but with the caveat that it has not been verified in any way.
827 ///
828 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
829 #[must_use]
830 #[no_mangle]
831 pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
832         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
833         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 };
834         local_ret
835 }
836
837 /// Features pertaining to the offer.
838 #[must_use]
839 #[no_mangle]
840 pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
841         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
842         crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
843 }
844
845 /// Duration since the Unix epoch when an invoice should no longer be requested.
846 ///
847 /// If `None`, the offer does not expire.
848 #[must_use]
849 #[no_mangle]
850 pub extern "C" fn InvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
851         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
852         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() }) };
853         local_ret
854 }
855
856 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
857 /// displayed to the user but with the caveat that it has not been verified in any way.
858 ///
859 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
860 #[must_use]
861 #[no_mangle]
862 pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
863         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
864         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 };
865         local_ret
866 }
867
868 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
869 /// recipient privacy by obfuscating its node id.
870 #[must_use]
871 #[no_mangle]
872 pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
873         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
874         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 } }); };
875         local_ret.into()
876 }
877
878 /// The quantity of items supported.
879 #[must_use]
880 #[no_mangle]
881 pub extern "C" fn InvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Quantity {
882         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
883         crate::lightning::offers::offer::Quantity::native_into(ret)
884 }
885
886 /// The public key used by the recipient to sign invoices.
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 InvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
892         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
893         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
894         local_ret
895 }
896
897 /// An unpredictable series of bytes, typically containing information about the derivation of
898 /// [`payer_id`].
899 ///
900 /// [`payer_id`]: Self::payer_id
901 #[must_use]
902 #[no_mangle]
903 pub extern "C" fn InvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::u8slice {
904         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
905         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
906         local_ret
907 }
908
909 /// A chain from [`Offer::chains`] that the offer is valid for.
910 #[must_use]
911 #[no_mangle]
912 pub extern "C" fn InvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
913         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
914         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
915 }
916
917 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
918 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
919 ///
920 /// [`chain`]: Self::chain
921 #[must_use]
922 #[no_mangle]
923 pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
924         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
925         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() }) };
926         local_ret
927 }
928
929 /// Features pertaining to requesting an invoice.
930 #[must_use]
931 #[no_mangle]
932 pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
933         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
934         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
935 }
936
937 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
938 #[must_use]
939 #[no_mangle]
940 pub extern "C" fn InvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
941         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
942         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() }) };
943         local_ret
944 }
945
946 /// A possibly transient pubkey used to sign the invoice request.
947 #[must_use]
948 #[no_mangle]
949 pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
950         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
951         crate::c_types::PublicKey::from_rust(&ret)
952 }
953
954 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
955 /// response.
956 ///
957 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
958 #[must_use]
959 #[no_mangle]
960 pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
961         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
962         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 };
963         local_ret
964 }
965
966 /// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
967 /// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
968 ///
969 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
970 /// creation time is used for the `created_at` parameter.
971 ///
972 /// [`Duration`]: core::time::Duration
973 #[must_use]
974 #[no_mangle]
975 pub extern "C" fn InvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
976         let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
977         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
978         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { 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() };
979         local_ret
980 }
981
982 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
983 ///
984 /// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
985 /// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
986 /// where [`std::time::SystemTime`] is not available.
987 ///
988 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
989 /// for the invoice.
990 ///
991 /// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
992 /// must contain one or more elements ordered from most-preferred to least-preferred, if there's
993 /// a preference. Note, however, that any privacy is lost if a public node id was used for
994 /// [`Offer::signing_pubkey`].
995 ///
996 /// Errors if the request contains unknown required features.
997 ///
998 /// # Note
999 ///
1000 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
1001 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
1002 ///
1003 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
1004 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
1005 #[must_use]
1006 #[no_mangle]
1007 pub extern "C" fn InvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
1008         let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1009         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at));
1010         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { 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() };
1011         local_ret
1012 }
1013
1014 /// Verifies that the request was for an offer created using the given key. Returns the verified
1015 /// request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
1016 /// if they could be extracted from the metadata.
1017 ///
1018 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1019 #[must_use]
1020 #[no_mangle]
1021 pub extern "C" fn InvoiceRequest_verify(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ {
1022         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify(key.get_native_ref(), secp256k1::global::SECP256K1);
1023         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::VerifiedInvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1024         local_ret
1025 }
1026
1027 /// Signature of the invoice request using [`payer_id`].
1028 ///
1029 /// [`payer_id`]: Self::payer_id
1030 #[must_use]
1031 #[no_mangle]
1032 pub extern "C" fn InvoiceRequest_signature(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::SchnorrSignature {
1033         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
1034         crate::c_types::SchnorrSignature::from_rust(&ret)
1035 }
1036
1037 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
1038 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
1039 /// for the selected chain.
1040 #[must_use]
1041 #[no_mangle]
1042 pub extern "C" fn VerifiedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
1043         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
1044         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
1045         local_ret.into()
1046 }
1047
1048 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
1049 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
1050 #[must_use]
1051 #[no_mangle]
1052 pub extern "C" fn VerifiedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
1053         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
1054         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() }) };
1055         local_ret
1056 }
1057
1058 /// The minimum amount required for a successful payment of a single item.
1059 #[must_use]
1060 #[no_mangle]
1061 pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
1062         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
1063         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()) }) };
1064         local_ret
1065 }
1066
1067 /// A complete description of the purpose of the payment. Intended to be displayed to the user
1068 /// but with the caveat that it has not been verified in any way.
1069 ///
1070 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1071 #[must_use]
1072 #[no_mangle]
1073 pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1074         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
1075         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 };
1076         local_ret
1077 }
1078
1079 /// Features pertaining to the offer.
1080 #[must_use]
1081 #[no_mangle]
1082 pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
1083         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
1084         crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
1085 }
1086
1087 /// Duration since the Unix epoch when an invoice should no longer be requested.
1088 ///
1089 /// If `None`, the offer does not expire.
1090 #[must_use]
1091 #[no_mangle]
1092 pub extern "C" fn VerifiedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1093         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
1094         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() }) };
1095         local_ret
1096 }
1097
1098 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
1099 /// displayed to the user but with the caveat that it has not been verified in any way.
1100 ///
1101 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1102 #[must_use]
1103 #[no_mangle]
1104 pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1105         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
1106         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 };
1107         local_ret
1108 }
1109
1110 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
1111 /// recipient privacy by obfuscating its node id.
1112 #[must_use]
1113 #[no_mangle]
1114 pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
1115         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
1116         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 } }); };
1117         local_ret.into()
1118 }
1119
1120 /// The quantity of items supported.
1121 #[must_use]
1122 #[no_mangle]
1123 pub extern "C" fn VerifiedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
1124         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
1125         crate::lightning::offers::offer::Quantity::native_into(ret)
1126 }
1127
1128 /// The public key used by the recipient to sign invoices.
1129 ///
1130 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1131 #[must_use]
1132 #[no_mangle]
1133 pub extern "C" fn VerifiedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
1134         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
1135         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
1136         local_ret
1137 }
1138
1139 /// An unpredictable series of bytes, typically containing information about the derivation of
1140 /// [`payer_id`].
1141 ///
1142 /// [`payer_id`]: Self::payer_id
1143 #[must_use]
1144 #[no_mangle]
1145 pub extern "C" fn VerifiedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::u8slice {
1146         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
1147         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
1148         local_ret
1149 }
1150
1151 /// A chain from [`Offer::chains`] that the offer is valid for.
1152 #[must_use]
1153 #[no_mangle]
1154 pub extern "C" fn VerifiedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
1155         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
1156         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
1157 }
1158
1159 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
1160 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
1161 ///
1162 /// [`chain`]: Self::chain
1163 #[must_use]
1164 #[no_mangle]
1165 pub extern "C" fn VerifiedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1166         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
1167         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() }) };
1168         local_ret
1169 }
1170
1171 /// Features pertaining to requesting an invoice.
1172 #[must_use]
1173 #[no_mangle]
1174 pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
1175         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
1176         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
1177 }
1178
1179 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1180 #[must_use]
1181 #[no_mangle]
1182 pub extern "C" fn VerifiedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1183         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
1184         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() }) };
1185         local_ret
1186 }
1187
1188 /// A possibly transient pubkey used to sign the invoice request.
1189 #[must_use]
1190 #[no_mangle]
1191 pub extern "C" fn VerifiedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
1192         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
1193         crate::c_types::PublicKey::from_rust(&ret)
1194 }
1195
1196 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1197 /// response.
1198 ///
1199 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1200 #[must_use]
1201 #[no_mangle]
1202 pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1203         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
1204         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 };
1205         local_ret
1206 }
1207
1208 /// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
1209 /// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
1210 ///
1211 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
1212 /// creation time is used for the `created_at` parameter.
1213 ///
1214 /// [`Duration`]: core::time::Duration
1215 #[must_use]
1216 #[no_mangle]
1217 pub extern "C" fn VerifiedInvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
1218         let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1219         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
1220         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { 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() };
1221         local_ret
1222 }
1223
1224 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
1225 ///
1226 /// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
1227 /// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
1228 /// where [`std::time::SystemTime`] is not available.
1229 ///
1230 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
1231 /// for the invoice.
1232 ///
1233 /// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
1234 /// must contain one or more elements ordered from most-preferred to least-preferred, if there's
1235 /// a preference. Note, however, that any privacy is lost if a public node id was used for
1236 /// [`Offer::signing_pubkey`].
1237 ///
1238 /// Errors if the request contains unknown required features.
1239 ///
1240 /// # Note
1241 ///
1242 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
1243 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
1244 ///
1245 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
1246 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
1247 #[must_use]
1248 #[no_mangle]
1249 pub extern "C" fn VerifiedInvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
1250         let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1251         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at));
1252         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { 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() };
1253         local_ret
1254 }
1255
1256 /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
1257 /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
1258 /// the same [`ExpandedKey`] as the one used to create the offer.
1259 ///
1260 /// See [`InvoiceRequest::respond_with`] for further details.
1261 ///
1262 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1263 #[must_use]
1264 #[no_mangle]
1265 pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ {
1266         let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1267         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
1268         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { 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() };
1269         local_ret
1270 }
1271
1272 /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
1273 /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
1274 /// the same [`ExpandedKey`] as the one used to create the offer.
1275 ///
1276 /// See [`InvoiceRequest::respond_with_no_std`] for further details.
1277 ///
1278 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1279 #[must_use]
1280 #[no_mangle]
1281 pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ {
1282         let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1283         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at));
1284         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { 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() };
1285         local_ret
1286 }
1287
1288 #[no_mangle]
1289 /// Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
1290 pub extern "C" fn UnsignedInvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
1291         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1292 }
1293 #[allow(unused)]
1294 pub(crate) extern "C" fn UnsignedInvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1295         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedInvoiceRequest) })
1296 }
1297 #[no_mangle]
1298 /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
1299 pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
1300         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1301 }
1302 #[allow(unused)]
1303 pub(crate) extern "C" fn InvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1304         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequest) })
1305 }
1306
1307 use lightning::offers::invoice_request::InvoiceRequestFields as nativeInvoiceRequestFieldsImport;
1308 pub(crate) type nativeInvoiceRequestFields = nativeInvoiceRequestFieldsImport;
1309
1310 /// Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`].
1311 ///
1312 /// [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
1313 #[must_use]
1314 #[repr(C)]
1315 pub struct InvoiceRequestFields {
1316         /// A pointer to the opaque Rust object.
1317
1318         /// Nearly everywhere, inner must be non-null, however in places where
1319         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1320         pub inner: *mut nativeInvoiceRequestFields,
1321         /// Indicates that this is the only struct which contains the same pointer.
1322
1323         /// Rust functions which take ownership of an object provided via an argument require
1324         /// this to be true and invalidate the object pointed to by inner.
1325         pub is_owned: bool,
1326 }
1327
1328 impl Drop for InvoiceRequestFields {
1329         fn drop(&mut self) {
1330                 if self.is_owned && !<*mut nativeInvoiceRequestFields>::is_null(self.inner) {
1331                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1332                 }
1333         }
1334 }
1335 /// Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL.
1336 #[no_mangle]
1337 pub extern "C" fn InvoiceRequestFields_free(this_obj: InvoiceRequestFields) { }
1338 #[allow(unused)]
1339 /// Used only if an object of this type is returned as a trait impl by a method
1340 pub(crate) extern "C" fn InvoiceRequestFields_free_void(this_ptr: *mut c_void) {
1341         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFields) };
1342 }
1343 #[allow(unused)]
1344 impl InvoiceRequestFields {
1345         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFields {
1346                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1347         }
1348         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFields {
1349                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1350         }
1351         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1352         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestFields {
1353                 assert!(self.is_owned);
1354                 let ret = ObjOps::untweak_ptr(self.inner);
1355                 self.inner = core::ptr::null_mut();
1356                 ret
1357         }
1358 }
1359 /// A possibly transient pubkey used to sign the invoice request.
1360 #[no_mangle]
1361 pub extern "C" fn InvoiceRequestFields_get_payer_id(this_ptr: &InvoiceRequestFields) -> crate::c_types::PublicKey {
1362         let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_id;
1363         crate::c_types::PublicKey::from_rust(&inner_val)
1364 }
1365 /// A possibly transient pubkey used to sign the invoice request.
1366 #[no_mangle]
1367 pub extern "C" fn InvoiceRequestFields_set_payer_id(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::PublicKey) {
1368         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_id = val.into_rust();
1369 }
1370 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1371 #[no_mangle]
1372 pub extern "C" fn InvoiceRequestFields_get_quantity(this_ptr: &InvoiceRequestFields) -> crate::c_types::derived::COption_u64Z {
1373         let mut inner_val = &mut this_ptr.get_native_mut_ref().quantity;
1374         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1375         local_inner_val
1376 }
1377 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1378 #[no_mangle]
1379 pub extern "C" fn InvoiceRequestFields_set_quantity(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::derived::COption_u64Z) {
1380         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1381         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.quantity = local_val;
1382 }
1383 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1384 /// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
1385 ///
1386 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1387 #[no_mangle]
1388 pub extern "C" fn InvoiceRequestFields_get_payer_note_truncated(this_ptr: &InvoiceRequestFields) -> crate::lightning::util::string::UntrustedString {
1389         let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_note_truncated;
1390         let mut local_inner_val = crate::lightning::util::string::UntrustedString { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::util::string::UntrustedString<>) as *mut _ }, is_owned: false };
1391         local_inner_val
1392 }
1393 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1394 /// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
1395 ///
1396 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1397 #[no_mangle]
1398 pub extern "C" fn InvoiceRequestFields_set_payer_note_truncated(this_ptr: &mut InvoiceRequestFields, mut val: crate::lightning::util::string::UntrustedString) {
1399         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1400         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_note_truncated = local_val;
1401 }
1402 /// Constructs a new InvoiceRequestFields given each field
1403 ///
1404 /// Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1405 #[must_use]
1406 #[no_mangle]
1407 pub extern "C" fn InvoiceRequestFields_new(mut payer_id_arg: crate::c_types::PublicKey, mut quantity_arg: crate::c_types::derived::COption_u64Z, mut payer_note_truncated_arg: crate::lightning::util::string::UntrustedString) -> InvoiceRequestFields {
1408         let mut local_quantity_arg = if quantity_arg.is_some() { Some( { quantity_arg.take() }) } else { None };
1409         let mut local_payer_note_truncated_arg = if payer_note_truncated_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payer_note_truncated_arg.take_inner()) } }) };
1410         InvoiceRequestFields { inner: ObjOps::heap_alloc(nativeInvoiceRequestFields {
1411                 payer_id: payer_id_arg.into_rust(),
1412                 quantity: local_quantity_arg,
1413                 payer_note_truncated: local_payer_note_truncated_arg,
1414         }), is_owned: true }
1415 }
1416 impl Clone for InvoiceRequestFields {
1417         fn clone(&self) -> Self {
1418                 Self {
1419                         inner: if <*mut nativeInvoiceRequestFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1420                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1421                         is_owned: true,
1422                 }
1423         }
1424 }
1425 #[allow(unused)]
1426 /// Used only if an object of this type is returned as a trait impl by a method
1427 pub(crate) extern "C" fn InvoiceRequestFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1428         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFields)).clone() })) as *mut c_void
1429 }
1430 #[no_mangle]
1431 /// Creates a copy of the InvoiceRequestFields
1432 pub extern "C" fn InvoiceRequestFields_clone(orig: &InvoiceRequestFields) -> InvoiceRequestFields {
1433         orig.clone()
1434 }
1435 /// Get a string which allows debug introspection of a InvoiceRequestFields object
1436 pub extern "C" fn InvoiceRequestFields_debug_str_void(o: *const c_void) -> Str {
1437         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequestFields }).into()}
1438 /// Checks if two InvoiceRequestFieldss contain equal inner contents.
1439 /// This ignores pointers and is_owned flags and looks at the values in fields.
1440 /// Two objects with NULL inner values will be considered "equal" here.
1441 #[no_mangle]
1442 pub extern "C" fn InvoiceRequestFields_eq(a: &InvoiceRequestFields, b: &InvoiceRequestFields) -> bool {
1443         if a.inner == b.inner { return true; }
1444         if a.inner.is_null() || b.inner.is_null() { return false; }
1445         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1446 }
1447 /// The maximum number of characters included in [`InvoiceRequestFields::payer_note_truncated`].
1448
1449 #[no_mangle]
1450 pub static PAYER_NOTE_LIMIT: usize = lightning::offers::invoice_request::PAYER_NOTE_LIMIT;
1451 #[no_mangle]
1452 /// Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read
1453 pub extern "C" fn InvoiceRequestFields_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequestFields) -> crate::c_types::derived::CVec_u8Z {
1454         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1455 }
1456 #[allow(unused)]
1457 pub(crate) extern "C" fn InvoiceRequestFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1458         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequestFields) })
1459 }
1460 #[no_mangle]
1461 /// Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write
1462 pub extern "C" fn InvoiceRequestFields_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceRequestFieldsDecodeErrorZ {
1463         let res: Result<lightning::offers::invoice_request::InvoiceRequestFields, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1464         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestFields { 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() };
1465         local_res
1466 }