]> git.bitcoin.ninja Git - ldk-c-bindings/blob - lightning-c-bindings/src/lightning/offers/invoice_request.rs
Update auto-generated bindings to LDK 0.0.123
[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 /// A function for signing an [`UnsignedInvoiceRequest`].
352 #[repr(C)]
353 pub struct SignInvoiceRequestFn {
354         /// An opaque pointer which is passed to your function implementations as an argument.
355         /// This has no meaning in the LDK, and can be NULL or any other value.
356         pub this_arg: *mut c_void,
357         /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
358         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,
359         /// Frees any resources associated with this object given its this_arg pointer.
360         /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
361         pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
362 }
363 unsafe impl Send for SignInvoiceRequestFn {}
364 unsafe impl Sync for SignInvoiceRequestFn {}
365 #[allow(unused)]
366 pub(crate) fn SignInvoiceRequestFn_clone_fields(orig: &SignInvoiceRequestFn) -> SignInvoiceRequestFn {
367         SignInvoiceRequestFn {
368                 this_arg: orig.this_arg,
369                 sign_invoice_request: Clone::clone(&orig.sign_invoice_request),
370                 free: Clone::clone(&orig.free),
371         }
372 }
373
374 use lightning::offers::invoice_request::SignInvoiceRequestFn as rustSignInvoiceRequestFn;
375 impl rustSignInvoiceRequestFn for SignInvoiceRequestFn {
376         fn sign_invoice_request(&self, mut message: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result<bitcoin::secp256k1::schnorr::Signature, ()> {
377                 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 });
378                 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)) })*/ })};
379                 local_ret
380         }
381 }
382
383 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
384 // directly as a Deref trait in higher-level structs:
385 impl core::ops::Deref for SignInvoiceRequestFn {
386         type Target = Self;
387         fn deref(&self) -> &Self {
388                 self
389         }
390 }
391 impl core::ops::DerefMut for SignInvoiceRequestFn {
392         fn deref_mut(&mut self) -> &mut Self {
393                 self
394         }
395 }
396 /// Calls the free function if one is set
397 #[no_mangle]
398 pub extern "C" fn SignInvoiceRequestFn_free(this_ptr: SignInvoiceRequestFn) { }
399 impl Drop for SignInvoiceRequestFn {
400         fn drop(&mut self) {
401                 if let Some(f) = self.free {
402                         f(self.this_arg);
403                 }
404         }
405 }
406 /// Returns the [`TaggedHash`] of the invoice to sign.
407 #[must_use]
408 #[no_mangle]
409 pub extern "C" fn UnsignedInvoiceRequest_tagged_hash(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::merkle::TaggedHash {
410         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tagged_hash();
411         crate::lightning::offers::merkle::TaggedHash { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::offers::merkle::TaggedHash<>) as *mut _) }, is_owned: false }
412 }
413
414
415 use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport;
416 pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport;
417
418 /// An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
419 ///
420 /// An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
421 /// specifies these such that its recipient can send an invoice for payment.
422 ///
423 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
424 /// [`Offer`]: crate::offers::offer::Offer
425 #[must_use]
426 #[repr(C)]
427 pub struct InvoiceRequest {
428         /// A pointer to the opaque Rust object.
429
430         /// Nearly everywhere, inner must be non-null, however in places where
431         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
432         pub inner: *mut nativeInvoiceRequest,
433         /// Indicates that this is the only struct which contains the same pointer.
434
435         /// Rust functions which take ownership of an object provided via an argument require
436         /// this to be true and invalidate the object pointed to by inner.
437         pub is_owned: bool,
438 }
439
440 impl Drop for InvoiceRequest {
441         fn drop(&mut self) {
442                 if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) {
443                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
444                 }
445         }
446 }
447 /// Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL.
448 #[no_mangle]
449 pub extern "C" fn InvoiceRequest_free(this_obj: InvoiceRequest) { }
450 #[allow(unused)]
451 /// Used only if an object of this type is returned as a trait impl by a method
452 pub(crate) extern "C" fn InvoiceRequest_free_void(this_ptr: *mut c_void) {
453         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequest) };
454 }
455 #[allow(unused)]
456 impl InvoiceRequest {
457         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequest {
458                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
459         }
460         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequest {
461                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
462         }
463         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
464         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequest {
465                 assert!(self.is_owned);
466                 let ret = ObjOps::untweak_ptr(self.inner);
467                 self.inner = core::ptr::null_mut();
468                 ret
469         }
470 }
471 impl Clone for InvoiceRequest {
472         fn clone(&self) -> Self {
473                 Self {
474                         inner: if <*mut nativeInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
475                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
476                         is_owned: true,
477                 }
478         }
479 }
480 #[allow(unused)]
481 /// Used only if an object of this type is returned as a trait impl by a method
482 pub(crate) extern "C" fn InvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
483         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequest)).clone() })) as *mut c_void
484 }
485 #[no_mangle]
486 /// Creates a copy of the InvoiceRequest
487 pub extern "C" fn InvoiceRequest_clone(orig: &InvoiceRequest) -> InvoiceRequest {
488         orig.clone()
489 }
490 /// Get a string which allows debug introspection of a InvoiceRequest object
491 pub extern "C" fn InvoiceRequest_debug_str_void(o: *const c_void) -> Str {
492         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequest }).into()}
493
494 use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport;
495 pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport;
496
497 /// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different
498 /// ways to respond depending on whether the signing keys were derived.
499 #[must_use]
500 #[repr(C)]
501 pub struct VerifiedInvoiceRequest {
502         /// A pointer to the opaque Rust object.
503
504         /// Nearly everywhere, inner must be non-null, however in places where
505         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
506         pub inner: *mut nativeVerifiedInvoiceRequest,
507         /// Indicates that this is the only struct which contains the same pointer.
508
509         /// Rust functions which take ownership of an object provided via an argument require
510         /// this to be true and invalidate the object pointed to by inner.
511         pub is_owned: bool,
512 }
513
514 impl Drop for VerifiedInvoiceRequest {
515         fn drop(&mut self) {
516                 if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) {
517                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
518                 }
519         }
520 }
521 /// Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL.
522 #[no_mangle]
523 pub extern "C" fn VerifiedInvoiceRequest_free(this_obj: VerifiedInvoiceRequest) { }
524 #[allow(unused)]
525 /// Used only if an object of this type is returned as a trait impl by a method
526 pub(crate) extern "C" fn VerifiedInvoiceRequest_free_void(this_ptr: *mut c_void) {
527         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeVerifiedInvoiceRequest) };
528 }
529 #[allow(unused)]
530 impl VerifiedInvoiceRequest {
531         pub(crate) fn get_native_ref(&self) -> &'static nativeVerifiedInvoiceRequest {
532                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
533         }
534         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeVerifiedInvoiceRequest {
535                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
536         }
537         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
538         pub(crate) fn take_inner(mut self) -> *mut nativeVerifiedInvoiceRequest {
539                 assert!(self.is_owned);
540                 let ret = ObjOps::untweak_ptr(self.inner);
541                 self.inner = core::ptr::null_mut();
542                 ret
543         }
544 }
545 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
546 #[no_mangle]
547 pub extern "C" fn VerifiedInvoiceRequest_get_offer_id(this_ptr: &VerifiedInvoiceRequest) -> crate::lightning::offers::offer::OfferId {
548         let mut inner_val = &mut this_ptr.get_native_mut_ref().offer_id;
549         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 }
550 }
551 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
552 #[no_mangle]
553 pub extern "C" fn VerifiedInvoiceRequest_set_offer_id(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::lightning::offers::offer::OfferId) {
554         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.offer_id = *unsafe { Box::from_raw(val.take_inner()) };
555 }
556 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
557 ///
558 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
559 /// [`respond_with`].
560 ///
561 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
562 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
563 /// [`respond_with`]: Self::respond_with
564 #[no_mangle]
565 pub extern "C" fn VerifiedInvoiceRequest_get_keys(this_ptr: &VerifiedInvoiceRequest) -> crate::c_types::derived::COption_SecretKeyZ {
566         let mut inner_val = &mut this_ptr.get_native_mut_ref().keys;
567         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()) }) };
568         local_inner_val
569 }
570 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
571 ///
572 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
573 /// [`respond_with`].
574 ///
575 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
576 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
577 /// [`respond_with`]: Self::respond_with
578 #[no_mangle]
579 pub extern "C" fn VerifiedInvoiceRequest_set_keys(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::c_types::derived::COption_SecretKeyZ) {
580         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()) }})} };
581         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys = local_val;
582 }
583 impl Clone for VerifiedInvoiceRequest {
584         fn clone(&self) -> Self {
585                 Self {
586                         inner: if <*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
587                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
588                         is_owned: true,
589                 }
590         }
591 }
592 #[allow(unused)]
593 /// Used only if an object of this type is returned as a trait impl by a method
594 pub(crate) extern "C" fn VerifiedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
595         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeVerifiedInvoiceRequest)).clone() })) as *mut c_void
596 }
597 #[no_mangle]
598 /// Creates a copy of the VerifiedInvoiceRequest
599 pub extern "C" fn VerifiedInvoiceRequest_clone(orig: &VerifiedInvoiceRequest) -> VerifiedInvoiceRequest {
600         orig.clone()
601 }
602 /// Get a string which allows debug introspection of a VerifiedInvoiceRequest object
603 pub extern "C" fn VerifiedInvoiceRequest_debug_str_void(o: *const c_void) -> Str {
604         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::VerifiedInvoiceRequest }).into()}
605 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
606 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
607 /// for the selected chain.
608 #[must_use]
609 #[no_mangle]
610 pub extern "C" fn UnsignedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
611         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
612         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
613         local_ret.into()
614 }
615
616 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
617 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
618 #[must_use]
619 #[no_mangle]
620 pub extern "C" fn UnsignedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
621         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
622         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() }) };
623         local_ret
624 }
625
626 /// The minimum amount required for a successful payment of a single item.
627 #[must_use]
628 #[no_mangle]
629 pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
630         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
631         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()) }) };
632         local_ret
633 }
634
635 /// A complete description of the purpose of the payment. Intended to be displayed to the user
636 /// but with the caveat that it has not been verified in any way.
637 ///
638 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
639 #[must_use]
640 #[no_mangle]
641 pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
642         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
643         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 };
644         local_ret
645 }
646
647 /// Features pertaining to the offer.
648 #[must_use]
649 #[no_mangle]
650 pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
651         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
652         crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
653 }
654
655 /// Duration since the Unix epoch when an invoice should no longer be requested.
656 ///
657 /// If `None`, the offer does not expire.
658 #[must_use]
659 #[no_mangle]
660 pub extern "C" fn UnsignedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
661         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
662         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() }) };
663         local_ret
664 }
665
666 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
667 /// displayed to the user but with the caveat that it has not been verified in any way.
668 ///
669 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
670 #[must_use]
671 #[no_mangle]
672 pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
673         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
674         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 };
675         local_ret
676 }
677
678 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
679 /// recipient privacy by obfuscating its node id.
680 #[must_use]
681 #[no_mangle]
682 pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
683         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
684         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 } }); };
685         local_ret.into()
686 }
687
688 /// The quantity of items supported.
689 #[must_use]
690 #[no_mangle]
691 pub extern "C" fn UnsignedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
692         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
693         crate::lightning::offers::offer::Quantity::native_into(ret)
694 }
695
696 /// The public key used by the recipient to sign invoices.
697 ///
698 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
699 #[must_use]
700 #[no_mangle]
701 pub extern "C" fn UnsignedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
702         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
703         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
704         local_ret
705 }
706
707 /// An unpredictable series of bytes, typically containing information about the derivation of
708 /// [`payer_id`].
709 ///
710 /// [`payer_id`]: Self::payer_id
711 #[must_use]
712 #[no_mangle]
713 pub extern "C" fn UnsignedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::u8slice {
714         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
715         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
716         local_ret
717 }
718
719 /// A chain from [`Offer::chains`] that the offer is valid for.
720 #[must_use]
721 #[no_mangle]
722 pub extern "C" fn UnsignedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
723         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
724         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
725 }
726
727 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
728 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
729 ///
730 /// [`chain`]: Self::chain
731 #[must_use]
732 #[no_mangle]
733 pub extern "C" fn UnsignedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
734         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
735         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() }) };
736         local_ret
737 }
738
739 /// Features pertaining to requesting an invoice.
740 #[must_use]
741 #[no_mangle]
742 pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
743         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
744         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
745 }
746
747 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
748 #[must_use]
749 #[no_mangle]
750 pub extern "C" fn UnsignedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
751         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
752         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() }) };
753         local_ret
754 }
755
756 /// A possibly transient pubkey used to sign the invoice request.
757 #[must_use]
758 #[no_mangle]
759 pub extern "C" fn UnsignedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
760         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
761         crate::c_types::PublicKey::from_rust(&ret)
762 }
763
764 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
765 /// response.
766 ///
767 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
768 #[must_use]
769 #[no_mangle]
770 pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
771         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
772         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 };
773         local_ret
774 }
775
776 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
777 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
778 /// for the selected chain.
779 #[must_use]
780 #[no_mangle]
781 pub extern "C" fn InvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
782         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
783         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
784         local_ret.into()
785 }
786
787 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
788 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
789 #[must_use]
790 #[no_mangle]
791 pub extern "C" fn InvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
792         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
793         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() }) };
794         local_ret
795 }
796
797 /// The minimum amount required for a successful payment of a single item.
798 #[must_use]
799 #[no_mangle]
800 pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
801         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
802         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()) }) };
803         local_ret
804 }
805
806 /// A complete description of the purpose of the payment. Intended to be displayed to the user
807 /// but with the caveat that it has not been verified in any way.
808 ///
809 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
810 #[must_use]
811 #[no_mangle]
812 pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
813         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
814         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 };
815         local_ret
816 }
817
818 /// Features pertaining to the offer.
819 #[must_use]
820 #[no_mangle]
821 pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
822         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
823         crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
824 }
825
826 /// Duration since the Unix epoch when an invoice should no longer be requested.
827 ///
828 /// If `None`, the offer does not expire.
829 #[must_use]
830 #[no_mangle]
831 pub extern "C" fn InvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
832         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
833         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() }) };
834         local_ret
835 }
836
837 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
838 /// displayed to the user but with the caveat that it has not been verified in any way.
839 ///
840 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
841 #[must_use]
842 #[no_mangle]
843 pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
844         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
845         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 };
846         local_ret
847 }
848
849 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
850 /// recipient privacy by obfuscating its node id.
851 #[must_use]
852 #[no_mangle]
853 pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
854         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
855         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 } }); };
856         local_ret.into()
857 }
858
859 /// The quantity of items supported.
860 #[must_use]
861 #[no_mangle]
862 pub extern "C" fn InvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Quantity {
863         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
864         crate::lightning::offers::offer::Quantity::native_into(ret)
865 }
866
867 /// The public key used by the recipient to sign invoices.
868 ///
869 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
870 #[must_use]
871 #[no_mangle]
872 pub extern "C" fn InvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
873         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
874         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
875         local_ret
876 }
877
878 /// An unpredictable series of bytes, typically containing information about the derivation of
879 /// [`payer_id`].
880 ///
881 /// [`payer_id`]: Self::payer_id
882 #[must_use]
883 #[no_mangle]
884 pub extern "C" fn InvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::u8slice {
885         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
886         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
887         local_ret
888 }
889
890 /// A chain from [`Offer::chains`] that the offer is valid for.
891 #[must_use]
892 #[no_mangle]
893 pub extern "C" fn InvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
894         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
895         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
896 }
897
898 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
899 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
900 ///
901 /// [`chain`]: Self::chain
902 #[must_use]
903 #[no_mangle]
904 pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
905         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
906         let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
907         local_ret
908 }
909
910 /// Features pertaining to requesting an invoice.
911 #[must_use]
912 #[no_mangle]
913 pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
914         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
915         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
916 }
917
918 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
919 #[must_use]
920 #[no_mangle]
921 pub extern "C" fn InvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
922         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
923         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() }) };
924         local_ret
925 }
926
927 /// A possibly transient pubkey used to sign the invoice request.
928 #[must_use]
929 #[no_mangle]
930 pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
931         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
932         crate::c_types::PublicKey::from_rust(&ret)
933 }
934
935 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
936 /// response.
937 ///
938 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
939 #[must_use]
940 #[no_mangle]
941 pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
942         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
943         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 };
944         local_ret
945 }
946
947 /// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
948 /// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
949 ///
950 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
951 /// creation time is used for the `created_at` parameter.
952 ///
953 /// [`Duration`]: core::time::Duration
954 #[must_use]
955 #[no_mangle]
956 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 {
957         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 }); };
958         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
959         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() };
960         local_ret
961 }
962
963 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
964 ///
965 /// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
966 /// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
967 /// where [`std::time::SystemTime`] is not available.
968 ///
969 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
970 /// for the invoice.
971 ///
972 /// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
973 /// must contain one or more elements ordered from most-preferred to least-preferred, if there's
974 /// a preference. Note, however, that any privacy is lost if a public node id was used for
975 /// [`Offer::signing_pubkey`].
976 ///
977 /// Errors if the request contains unknown required features.
978 ///
979 /// # Note
980 ///
981 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
982 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
983 ///
984 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
985 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
986 #[must_use]
987 #[no_mangle]
988 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 {
989         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 }); };
990         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));
991         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() };
992         local_ret
993 }
994
995 /// Verifies that the request was for an offer created using the given key. Returns the verified
996 /// request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
997 /// if they could be extracted from the metadata.
998 ///
999 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1000 #[must_use]
1001 #[no_mangle]
1002 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 {
1003         let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify(key.get_native_ref(), secp256k1::global::SECP256K1);
1004         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() };
1005         local_ret
1006 }
1007
1008 /// Signature of the invoice request using [`payer_id`].
1009 ///
1010 /// [`payer_id`]: Self::payer_id
1011 #[must_use]
1012 #[no_mangle]
1013 pub extern "C" fn InvoiceRequest_signature(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::SchnorrSignature {
1014         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
1015         crate::c_types::SchnorrSignature::from_rust(&ret)
1016 }
1017
1018 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
1019 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
1020 /// for the selected chain.
1021 #[must_use]
1022 #[no_mangle]
1023 pub extern "C" fn VerifiedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
1024         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
1025         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
1026         local_ret.into()
1027 }
1028
1029 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
1030 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
1031 #[must_use]
1032 #[no_mangle]
1033 pub extern "C" fn VerifiedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
1034         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
1035         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() }) };
1036         local_ret
1037 }
1038
1039 /// The minimum amount required for a successful payment of a single item.
1040 #[must_use]
1041 #[no_mangle]
1042 pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
1043         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
1044         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()) }) };
1045         local_ret
1046 }
1047
1048 /// A complete description of the purpose of the payment. Intended to be displayed to the user
1049 /// but with the caveat that it has not been verified in any way.
1050 ///
1051 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1052 #[must_use]
1053 #[no_mangle]
1054 pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1055         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
1056         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 };
1057         local_ret
1058 }
1059
1060 /// Features pertaining to the offer.
1061 #[must_use]
1062 #[no_mangle]
1063 pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
1064         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
1065         crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
1066 }
1067
1068 /// Duration since the Unix epoch when an invoice should no longer be requested.
1069 ///
1070 /// If `None`, the offer does not expire.
1071 #[must_use]
1072 #[no_mangle]
1073 pub extern "C" fn VerifiedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1074         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
1075         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() }) };
1076         local_ret
1077 }
1078
1079 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
1080 /// displayed to the user but with the caveat that it has not been verified in any way.
1081 ///
1082 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1083 #[must_use]
1084 #[no_mangle]
1085 pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1086         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
1087         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 };
1088         local_ret
1089 }
1090
1091 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
1092 /// recipient privacy by obfuscating its node id.
1093 #[must_use]
1094 #[no_mangle]
1095 pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
1096         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
1097         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 } }); };
1098         local_ret.into()
1099 }
1100
1101 /// The quantity of items supported.
1102 #[must_use]
1103 #[no_mangle]
1104 pub extern "C" fn VerifiedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
1105         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
1106         crate::lightning::offers::offer::Quantity::native_into(ret)
1107 }
1108
1109 /// The public key used by the recipient to sign invoices.
1110 ///
1111 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1112 #[must_use]
1113 #[no_mangle]
1114 pub extern "C" fn VerifiedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
1115         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
1116         let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else {  { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
1117         local_ret
1118 }
1119
1120 /// An unpredictable series of bytes, typically containing information about the derivation of
1121 /// [`payer_id`].
1122 ///
1123 /// [`payer_id`]: Self::payer_id
1124 #[must_use]
1125 #[no_mangle]
1126 pub extern "C" fn VerifiedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::u8slice {
1127         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
1128         let mut local_ret = crate::c_types::u8slice::from_slice(ret);
1129         local_ret
1130 }
1131
1132 /// A chain from [`Offer::chains`] that the offer is valid for.
1133 #[must_use]
1134 #[no_mangle]
1135 pub extern "C" fn VerifiedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
1136         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
1137         crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
1138 }
1139
1140 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
1141 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
1142 ///
1143 /// [`chain`]: Self::chain
1144 #[must_use]
1145 #[no_mangle]
1146 pub extern "C" fn VerifiedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1147         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
1148         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() }) };
1149         local_ret
1150 }
1151
1152 /// Features pertaining to requesting an invoice.
1153 #[must_use]
1154 #[no_mangle]
1155 pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
1156         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
1157         crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
1158 }
1159
1160 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1161 #[must_use]
1162 #[no_mangle]
1163 pub extern "C" fn VerifiedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1164         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
1165         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() }) };
1166         local_ret
1167 }
1168
1169 /// A possibly transient pubkey used to sign the invoice request.
1170 #[must_use]
1171 #[no_mangle]
1172 pub extern "C" fn VerifiedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
1173         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
1174         crate::c_types::PublicKey::from_rust(&ret)
1175 }
1176
1177 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1178 /// response.
1179 ///
1180 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1181 #[must_use]
1182 #[no_mangle]
1183 pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1184         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
1185         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 };
1186         local_ret
1187 }
1188
1189 /// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
1190 /// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
1191 ///
1192 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
1193 /// creation time is used for the `created_at` parameter.
1194 ///
1195 /// [`Duration`]: core::time::Duration
1196 #[must_use]
1197 #[no_mangle]
1198 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 {
1199         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 }); };
1200         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
1201         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() };
1202         local_ret
1203 }
1204
1205 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
1206 ///
1207 /// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
1208 /// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
1209 /// where [`std::time::SystemTime`] is not available.
1210 ///
1211 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
1212 /// for the invoice.
1213 ///
1214 /// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
1215 /// must contain one or more elements ordered from most-preferred to least-preferred, if there's
1216 /// a preference. Note, however, that any privacy is lost if a public node id was used for
1217 /// [`Offer::signing_pubkey`].
1218 ///
1219 /// Errors if the request contains unknown required features.
1220 ///
1221 /// # Note
1222 ///
1223 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
1224 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
1225 ///
1226 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
1227 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
1228 #[must_use]
1229 #[no_mangle]
1230 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 {
1231         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 }); };
1232         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));
1233         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() };
1234         local_ret
1235 }
1236
1237 /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
1238 /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
1239 /// the same [`ExpandedKey`] as the one used to create the offer.
1240 ///
1241 /// See [`InvoiceRequest::respond_with`] for further details.
1242 ///
1243 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1244 #[must_use]
1245 #[no_mangle]
1246 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 {
1247         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 }); };
1248         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
1249         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() };
1250         local_ret
1251 }
1252
1253 /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
1254 /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
1255 /// the same [`ExpandedKey`] as the one used to create the offer.
1256 ///
1257 /// See [`InvoiceRequest::respond_with_no_std`] for further details.
1258 ///
1259 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1260 #[must_use]
1261 #[no_mangle]
1262 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 {
1263         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 }); };
1264         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));
1265         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() };
1266         local_ret
1267 }
1268
1269 #[no_mangle]
1270 /// Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
1271 pub extern "C" fn UnsignedInvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
1272         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1273 }
1274 #[allow(unused)]
1275 pub(crate) extern "C" fn UnsignedInvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1276         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedInvoiceRequest) })
1277 }
1278 #[no_mangle]
1279 /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
1280 pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
1281         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1282 }
1283 #[allow(unused)]
1284 pub(crate) extern "C" fn InvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1285         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequest) })
1286 }
1287
1288 use lightning::offers::invoice_request::InvoiceRequestFields as nativeInvoiceRequestFieldsImport;
1289 pub(crate) type nativeInvoiceRequestFields = nativeInvoiceRequestFieldsImport;
1290
1291 /// Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`].
1292 ///
1293 /// [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
1294 #[must_use]
1295 #[repr(C)]
1296 pub struct InvoiceRequestFields {
1297         /// A pointer to the opaque Rust object.
1298
1299         /// Nearly everywhere, inner must be non-null, however in places where
1300         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1301         pub inner: *mut nativeInvoiceRequestFields,
1302         /// Indicates that this is the only struct which contains the same pointer.
1303
1304         /// Rust functions which take ownership of an object provided via an argument require
1305         /// this to be true and invalidate the object pointed to by inner.
1306         pub is_owned: bool,
1307 }
1308
1309 impl Drop for InvoiceRequestFields {
1310         fn drop(&mut self) {
1311                 if self.is_owned && !<*mut nativeInvoiceRequestFields>::is_null(self.inner) {
1312                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1313                 }
1314         }
1315 }
1316 /// Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL.
1317 #[no_mangle]
1318 pub extern "C" fn InvoiceRequestFields_free(this_obj: InvoiceRequestFields) { }
1319 #[allow(unused)]
1320 /// Used only if an object of this type is returned as a trait impl by a method
1321 pub(crate) extern "C" fn InvoiceRequestFields_free_void(this_ptr: *mut c_void) {
1322         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFields) };
1323 }
1324 #[allow(unused)]
1325 impl InvoiceRequestFields {
1326         pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFields {
1327                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1328         }
1329         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFields {
1330                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1331         }
1332         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1333         pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestFields {
1334                 assert!(self.is_owned);
1335                 let ret = ObjOps::untweak_ptr(self.inner);
1336                 self.inner = core::ptr::null_mut();
1337                 ret
1338         }
1339 }
1340 /// A possibly transient pubkey used to sign the invoice request.
1341 #[no_mangle]
1342 pub extern "C" fn InvoiceRequestFields_get_payer_id(this_ptr: &InvoiceRequestFields) -> crate::c_types::PublicKey {
1343         let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_id;
1344         crate::c_types::PublicKey::from_rust(&inner_val)
1345 }
1346 /// A possibly transient pubkey used to sign the invoice request.
1347 #[no_mangle]
1348 pub extern "C" fn InvoiceRequestFields_set_payer_id(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::PublicKey) {
1349         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_id = val.into_rust();
1350 }
1351 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1352 #[no_mangle]
1353 pub extern "C" fn InvoiceRequestFields_get_quantity(this_ptr: &InvoiceRequestFields) -> crate::c_types::derived::COption_u64Z {
1354         let mut inner_val = &mut this_ptr.get_native_mut_ref().quantity;
1355         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() }) };
1356         local_inner_val
1357 }
1358 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1359 #[no_mangle]
1360 pub extern "C" fn InvoiceRequestFields_set_quantity(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::derived::COption_u64Z) {
1361         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1362         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.quantity = local_val;
1363 }
1364 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1365 /// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
1366 ///
1367 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1368 #[no_mangle]
1369 pub extern "C" fn InvoiceRequestFields_get_payer_note_truncated(this_ptr: &InvoiceRequestFields) -> crate::lightning::util::string::UntrustedString {
1370         let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_note_truncated;
1371         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 };
1372         local_inner_val
1373 }
1374 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1375 /// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
1376 ///
1377 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1378 #[no_mangle]
1379 pub extern "C" fn InvoiceRequestFields_set_payer_note_truncated(this_ptr: &mut InvoiceRequestFields, mut val: crate::lightning::util::string::UntrustedString) {
1380         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1381         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_note_truncated = local_val;
1382 }
1383 /// Constructs a new InvoiceRequestFields given each field
1384 ///
1385 /// Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1386 #[must_use]
1387 #[no_mangle]
1388 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 {
1389         let mut local_quantity_arg = if quantity_arg.is_some() { Some( { quantity_arg.take() }) } else { None };
1390         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()) } }) };
1391         InvoiceRequestFields { inner: ObjOps::heap_alloc(nativeInvoiceRequestFields {
1392                 payer_id: payer_id_arg.into_rust(),
1393                 quantity: local_quantity_arg,
1394                 payer_note_truncated: local_payer_note_truncated_arg,
1395         }), is_owned: true }
1396 }
1397 impl Clone for InvoiceRequestFields {
1398         fn clone(&self) -> Self {
1399                 Self {
1400                         inner: if <*mut nativeInvoiceRequestFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1401                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1402                         is_owned: true,
1403                 }
1404         }
1405 }
1406 #[allow(unused)]
1407 /// Used only if an object of this type is returned as a trait impl by a method
1408 pub(crate) extern "C" fn InvoiceRequestFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1409         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFields)).clone() })) as *mut c_void
1410 }
1411 #[no_mangle]
1412 /// Creates a copy of the InvoiceRequestFields
1413 pub extern "C" fn InvoiceRequestFields_clone(orig: &InvoiceRequestFields) -> InvoiceRequestFields {
1414         orig.clone()
1415 }
1416 /// Get a string which allows debug introspection of a InvoiceRequestFields object
1417 pub extern "C" fn InvoiceRequestFields_debug_str_void(o: *const c_void) -> Str {
1418         alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequestFields }).into()}
1419 /// Checks if two InvoiceRequestFieldss contain equal inner contents.
1420 /// This ignores pointers and is_owned flags and looks at the values in fields.
1421 /// Two objects with NULL inner values will be considered "equal" here.
1422 #[no_mangle]
1423 pub extern "C" fn InvoiceRequestFields_eq(a: &InvoiceRequestFields, b: &InvoiceRequestFields) -> bool {
1424         if a.inner == b.inner { return true; }
1425         if a.inner.is_null() || b.inner.is_null() { return false; }
1426         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1427 }
1428 /// The maximum number of characters included in [`InvoiceRequestFields::payer_note_truncated`].
1429
1430 #[no_mangle]
1431 pub static PAYER_NOTE_LIMIT: usize = lightning::offers::invoice_request::PAYER_NOTE_LIMIT;
1432 #[no_mangle]
1433 /// Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read
1434 pub extern "C" fn InvoiceRequestFields_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequestFields) -> crate::c_types::derived::CVec_u8Z {
1435         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1436 }
1437 #[allow(unused)]
1438 pub(crate) extern "C" fn InvoiceRequestFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1439         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequestFields) })
1440 }
1441 #[no_mangle]
1442 /// Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write
1443 pub extern "C" fn InvoiceRequestFields_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceRequestFieldsDecodeErrorZ {
1444         let res: Result<lightning::offers::invoice_request::InvoiceRequestFields, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1445         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() };
1446         local_res
1447 }