1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
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.
9 //! Data structures and encoding for `invoice_request` messages.
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`].
15 //! For an \"offer for money\" (e.g., refund, ATM withdrawal), where an offer doesn't exist as a
16 //! precursor, see [`Refund`].
18 //! [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
19 //! [`Refund`]: crate::offers::refund::Refund
22 //! extern crate bitcoin;
23 //! extern crate lightning;
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;
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();
38 //! # use lightning::offers::invoice_request::{ExplicitPayerId, InvoiceRequestBuilder};
39 //! # <InvoiceRequestBuilder<ExplicitPayerId, _>>::from(
40 //! \"lno1qcp4256ypq\"
41 //! .parse::<Offer>()?
42 //! .request_invoice(vec![42; 64], pubkey)?
44 //! .chain(Network::Testnet)?
45 //! .amount_msats(1000)?
47 //! .payer_note(\"foo\".to_string())
49 //! .sign(|message: &UnsignedInvoiceRequest|
50 //! Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
52 //! .expect(\"failed verifying signature\")
53 //! .write(&mut buffer)
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};
69 use lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder as nativeInvoiceRequestWithExplicitPayerIdBuilderImport;
70 pub(crate) type nativeInvoiceRequestWithExplicitPayerIdBuilder = nativeInvoiceRequestWithExplicitPayerIdBuilderImport<'static, 'static, >;
72 /// Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow.
74 /// See [module-level documentation] for usage.
76 /// [module-level documentation]: self
79 pub struct InvoiceRequestWithExplicitPayerIdBuilder {
80 /// A pointer to the opaque Rust object.
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.
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.
92 impl Drop for InvoiceRequestWithExplicitPayerIdBuilder {
94 if self.is_owned && !<*mut nativeInvoiceRequestWithExplicitPayerIdBuilder>::is_null(self.inner) {
95 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
99 /// Frees any resources used by the InvoiceRequestWithExplicitPayerIdBuilder, if is_owned is set and inner is non-NULL.
101 pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_free(this_obj: InvoiceRequestWithExplicitPayerIdBuilder) { }
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) };
108 impl InvoiceRequestWithExplicitPayerIdBuilder {
109 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestWithExplicitPayerIdBuilder {
110 unsafe { &*ObjOps::untweak_ptr(self.inner) }
112 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestWithExplicitPayerIdBuilder {
113 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
124 use lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder as nativeInvoiceRequestWithDerivedPayerIdBuilderImport;
125 pub(crate) type nativeInvoiceRequestWithDerivedPayerIdBuilder = nativeInvoiceRequestWithDerivedPayerIdBuilderImport<'static, 'static, >;
127 /// Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow.
129 /// See [module-level documentation] for usage.
131 /// [module-level documentation]: self
134 pub struct InvoiceRequestWithDerivedPayerIdBuilder {
135 /// A pointer to the opaque Rust object.
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.
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.
147 impl Drop for InvoiceRequestWithDerivedPayerIdBuilder {
149 if self.is_owned && !<*mut nativeInvoiceRequestWithDerivedPayerIdBuilder>::is_null(self.inner) {
150 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
154 /// Frees any resources used by the InvoiceRequestWithDerivedPayerIdBuilder, if is_owned is set and inner is non-NULL.
156 pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_free(this_obj: InvoiceRequestWithDerivedPayerIdBuilder) { }
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) };
163 impl InvoiceRequestWithDerivedPayerIdBuilder {
164 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestWithDerivedPayerIdBuilder {
165 unsafe { &*ObjOps::untweak_ptr(self.inner) }
167 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestWithDerivedPayerIdBuilder {
168 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
178 /// Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed
179 /// by [`UnsignedInvoiceRequest::sign`].
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() };
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
192 /// Successive calls to this method will override the previous setting.
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() };
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`]).
204 /// Successive calls to this method will override the previous setting.
206 /// [`quantity`]: Self::quantity
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() };
215 /// Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity`
216 /// does not conform to [`Offer::is_valid_quantity`].
218 /// Successive calls to this method will override the previous setting.
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() };
227 /// Sets the [`InvoiceRequest::payer_note`].
229 /// Successive calls to this method will override the previous setting.
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());
237 /// Builds a signed [`InvoiceRequest`] after checking for valid semantics.
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() };
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
250 /// Successive calls to this method will override the previous setting.
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() };
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`]).
262 /// Successive calls to this method will override the previous setting.
264 /// [`quantity`]: Self::quantity
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() };
273 /// Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity`
274 /// does not conform to [`Offer::is_valid_quantity`].
276 /// Successive calls to this method will override the previous setting.
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() };
285 /// Sets the [`InvoiceRequest::payer_note`].
287 /// Successive calls to this method will override the previous setting.
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());
296 use lightning::offers::invoice_request::UnsignedInvoiceRequest as nativeUnsignedInvoiceRequestImport;
297 pub(crate) type nativeUnsignedInvoiceRequest = nativeUnsignedInvoiceRequestImport;
299 /// A semantically valid [`InvoiceRequest`] that hasn't been signed.
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.
307 pub struct UnsignedInvoiceRequest {
308 /// A pointer to the opaque Rust object.
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.
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.
320 impl Drop for UnsignedInvoiceRequest {
322 if self.is_owned && !<*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) {
323 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
327 /// Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL.
329 pub extern "C" fn UnsignedInvoiceRequest_free(this_obj: UnsignedInvoiceRequest) { }
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) };
336 impl UnsignedInvoiceRequest {
337 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedInvoiceRequest {
338 unsafe { &*ObjOps::untweak_ptr(self.inner) }
340 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedInvoiceRequest {
341 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
351 impl Clone for UnsignedInvoiceRequest {
352 fn clone(&self) -> Self {
354 inner: if <*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
355 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
361 /// Used only if an object of this type is returned as a trait impl by a method
362 pub(crate) extern "C" fn UnsignedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
363 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedInvoiceRequest)).clone() })) as *mut c_void
366 /// Creates a copy of the UnsignedInvoiceRequest
367 pub extern "C" fn UnsignedInvoiceRequest_clone(orig: &UnsignedInvoiceRequest) -> UnsignedInvoiceRequest {
370 /// A function for signing an [`UnsignedInvoiceRequest`].
372 pub struct SignInvoiceRequestFn {
373 /// An opaque pointer which is passed to your function implementations as an argument.
374 /// This has no meaning in the LDK, and can be NULL or any other value.
375 pub this_arg: *mut c_void,
376 /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
377 pub sign_invoice_request: extern "C" fn (this_arg: *const c_void, message: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ,
378 /// Frees any resources associated with this object given its this_arg pointer.
379 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
380 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
382 unsafe impl Send for SignInvoiceRequestFn {}
383 unsafe impl Sync for SignInvoiceRequestFn {}
385 pub(crate) fn SignInvoiceRequestFn_clone_fields(orig: &SignInvoiceRequestFn) -> SignInvoiceRequestFn {
386 SignInvoiceRequestFn {
387 this_arg: orig.this_arg,
388 sign_invoice_request: Clone::clone(&orig.sign_invoice_request),
389 free: Clone::clone(&orig.free),
393 use lightning::offers::invoice_request::SignInvoiceRequestFn as rustSignInvoiceRequestFn;
394 impl rustSignInvoiceRequestFn for SignInvoiceRequestFn {
395 fn sign_invoice_request(&self, mut message: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result<bitcoin::secp256k1::schnorr::Signature, ()> {
396 let mut ret = (self.sign_invoice_request)(self.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) as *mut _) }, is_owned: false });
397 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
402 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
403 // directly as a Deref trait in higher-level structs:
404 impl core::ops::Deref for SignInvoiceRequestFn {
406 fn deref(&self) -> &Self {
410 impl core::ops::DerefMut for SignInvoiceRequestFn {
411 fn deref_mut(&mut self) -> &mut Self {
415 /// Calls the free function if one is set
417 pub extern "C" fn SignInvoiceRequestFn_free(this_ptr: SignInvoiceRequestFn) { }
418 impl Drop for SignInvoiceRequestFn {
420 if let Some(f) = self.free {
425 /// Returns the [`TaggedHash`] of the invoice to sign.
428 pub extern "C" fn UnsignedInvoiceRequest_tagged_hash(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::merkle::TaggedHash {
429 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tagged_hash();
430 crate::lightning::offers::merkle::TaggedHash { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::offers::merkle::TaggedHash<>) as *mut _) }, is_owned: false }
434 use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport;
435 pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport;
437 /// An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
439 /// An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
440 /// specifies these such that its recipient can send an invoice for payment.
442 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
443 /// [`Offer`]: crate::offers::offer::Offer
446 pub struct InvoiceRequest {
447 /// A pointer to the opaque Rust object.
449 /// Nearly everywhere, inner must be non-null, however in places where
450 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
451 pub inner: *mut nativeInvoiceRequest,
452 /// Indicates that this is the only struct which contains the same pointer.
454 /// Rust functions which take ownership of an object provided via an argument require
455 /// this to be true and invalidate the object pointed to by inner.
459 impl Drop for InvoiceRequest {
461 if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) {
462 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
466 /// Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL.
468 pub extern "C" fn InvoiceRequest_free(this_obj: InvoiceRequest) { }
470 /// Used only if an object of this type is returned as a trait impl by a method
471 pub(crate) extern "C" fn InvoiceRequest_free_void(this_ptr: *mut c_void) {
472 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequest) };
475 impl InvoiceRequest {
476 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequest {
477 unsafe { &*ObjOps::untweak_ptr(self.inner) }
479 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequest {
480 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
482 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
483 pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequest {
484 assert!(self.is_owned);
485 let ret = ObjOps::untweak_ptr(self.inner);
486 self.inner = core::ptr::null_mut();
490 impl Clone for InvoiceRequest {
491 fn clone(&self) -> Self {
493 inner: if <*mut nativeInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
494 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
500 /// Used only if an object of this type is returned as a trait impl by a method
501 pub(crate) extern "C" fn InvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
502 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequest)).clone() })) as *mut c_void
505 /// Creates a copy of the InvoiceRequest
506 pub extern "C" fn InvoiceRequest_clone(orig: &InvoiceRequest) -> InvoiceRequest {
509 /// Get a string which allows debug introspection of a InvoiceRequest object
510 pub extern "C" fn InvoiceRequest_debug_str_void(o: *const c_void) -> Str {
511 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequest }).into()}
513 use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport;
514 pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport;
516 /// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different
517 /// ways to respond depending on whether the signing keys were derived.
520 pub struct VerifiedInvoiceRequest {
521 /// A pointer to the opaque Rust object.
523 /// Nearly everywhere, inner must be non-null, however in places where
524 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
525 pub inner: *mut nativeVerifiedInvoiceRequest,
526 /// Indicates that this is the only struct which contains the same pointer.
528 /// Rust functions which take ownership of an object provided via an argument require
529 /// this to be true and invalidate the object pointed to by inner.
533 impl Drop for VerifiedInvoiceRequest {
535 if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) {
536 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
540 /// Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL.
542 pub extern "C" fn VerifiedInvoiceRequest_free(this_obj: VerifiedInvoiceRequest) { }
544 /// Used only if an object of this type is returned as a trait impl by a method
545 pub(crate) extern "C" fn VerifiedInvoiceRequest_free_void(this_ptr: *mut c_void) {
546 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeVerifiedInvoiceRequest) };
549 impl VerifiedInvoiceRequest {
550 pub(crate) fn get_native_ref(&self) -> &'static nativeVerifiedInvoiceRequest {
551 unsafe { &*ObjOps::untweak_ptr(self.inner) }
553 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeVerifiedInvoiceRequest {
554 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
556 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
557 pub(crate) fn take_inner(mut self) -> *mut nativeVerifiedInvoiceRequest {
558 assert!(self.is_owned);
559 let ret = ObjOps::untweak_ptr(self.inner);
560 self.inner = core::ptr::null_mut();
564 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
566 pub extern "C" fn VerifiedInvoiceRequest_get_offer_id(this_ptr: &VerifiedInvoiceRequest) -> crate::lightning::offers::offer::OfferId {
567 let mut inner_val = &mut this_ptr.get_native_mut_ref().offer_id;
568 crate::lightning::offers::offer::OfferId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::offers::offer::OfferId<>) as *mut _) }, is_owned: false }
570 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
572 pub extern "C" fn VerifiedInvoiceRequest_set_offer_id(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::lightning::offers::offer::OfferId) {
573 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.offer_id = *unsafe { Box::from_raw(val.take_inner()) };
575 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
577 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
578 /// [`respond_with`].
580 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
581 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
582 /// [`respond_with`]: Self::respond_with
584 pub extern "C" fn VerifiedInvoiceRequest_get_keys(this_ptr: &VerifiedInvoiceRequest) -> crate::c_types::derived::COption_SecretKeyZ {
585 let mut inner_val = &mut this_ptr.get_native_mut_ref().keys;
586 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SecretKeyZ::None } else { crate::c_types::derived::COption_SecretKeyZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::c_types::SecretKey::from_rust((*inner_val.as_ref().unwrap()).clone().secret_key()) }) };
589 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
591 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
592 /// [`respond_with`].
594 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
595 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
596 /// [`respond_with`]: Self::respond_with
598 pub extern "C" fn VerifiedInvoiceRequest_set_keys(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::c_types::derived::COption_SecretKeyZ) {
599 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::secp256k1::KeyPair::from_secret_key(&secp256k1::global::SECP256K1, &{ val_opt.take() }.into_rust()) }})} };
600 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys = local_val;
602 impl Clone for VerifiedInvoiceRequest {
603 fn clone(&self) -> Self {
605 inner: if <*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
606 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
612 /// Used only if an object of this type is returned as a trait impl by a method
613 pub(crate) extern "C" fn VerifiedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
614 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeVerifiedInvoiceRequest)).clone() })) as *mut c_void
617 /// Creates a copy of the VerifiedInvoiceRequest
618 pub extern "C" fn VerifiedInvoiceRequest_clone(orig: &VerifiedInvoiceRequest) -> VerifiedInvoiceRequest {
621 /// Get a string which allows debug introspection of a VerifiedInvoiceRequest object
622 pub extern "C" fn VerifiedInvoiceRequest_debug_str_void(o: *const c_void) -> Str {
623 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::VerifiedInvoiceRequest }).into()}
624 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
625 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
626 /// for the selected chain.
629 pub extern "C" fn UnsignedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
630 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
631 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
635 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
636 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
639 pub extern "C" fn UnsignedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
640 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
641 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) };
645 /// The minimum amount required for a successful payment of a single item.
648 pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
649 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
650 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) };
654 /// A complete description of the purpose of the payment. Intended to be displayed to the user
655 /// but with the caveat that it has not been verified in any way.
657 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
660 pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
661 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
662 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
666 /// Features pertaining to the offer.
669 pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
670 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
671 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
674 /// Duration since the Unix epoch when an invoice should no longer be requested.
676 /// If `None`, the offer does not expire.
679 pub extern "C" fn UnsignedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
680 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
681 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap().as_secs() }) };
685 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
686 /// displayed to the user but with the caveat that it has not been verified in any way.
688 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
691 pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
692 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
693 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
697 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
698 /// recipient privacy by obfuscating its node id.
701 pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
702 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
703 let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
707 /// The quantity of items supported.
710 pub extern "C" fn UnsignedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
711 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
712 crate::lightning::offers::offer::Quantity::native_into(ret)
715 /// The public key used by the recipient to sign invoices.
717 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
720 pub extern "C" fn UnsignedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
721 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
722 let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
726 /// An unpredictable series of bytes, typically containing information about the derivation of
729 /// [`payer_id`]: Self::payer_id
732 pub extern "C" fn UnsignedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::u8slice {
733 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
734 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
738 /// A chain from [`Offer::chains`] that the offer is valid for.
741 pub extern "C" fn UnsignedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
742 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
743 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
746 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
747 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
749 /// [`chain`]: Self::chain
752 pub extern "C" fn UnsignedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
753 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
754 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
758 /// Features pertaining to requesting an invoice.
761 pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
762 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
763 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
766 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
769 pub extern "C" fn UnsignedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
770 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
771 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
775 /// A possibly transient pubkey used to sign the invoice request.
778 pub extern "C" fn UnsignedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
779 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
780 crate::c_types::PublicKey::from_rust(&ret)
783 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
786 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
789 pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
790 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
791 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
795 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
796 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
797 /// for the selected chain.
800 pub extern "C" fn InvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
801 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
802 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
806 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
807 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
810 pub extern "C" fn InvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
811 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
812 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) };
816 /// The minimum amount required for a successful payment of a single item.
819 pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
820 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
821 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) };
825 /// A complete description of the purpose of the payment. Intended to be displayed to the user
826 /// but with the caveat that it has not been verified in any way.
828 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
831 pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
832 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
833 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
837 /// Features pertaining to the offer.
840 pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
841 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
842 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
845 /// Duration since the Unix epoch when an invoice should no longer be requested.
847 /// If `None`, the offer does not expire.
850 pub extern "C" fn InvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
851 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
852 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap().as_secs() }) };
856 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
857 /// displayed to the user but with the caveat that it has not been verified in any way.
859 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
862 pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
863 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
864 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
868 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
869 /// recipient privacy by obfuscating its node id.
872 pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
873 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
874 let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
878 /// The quantity of items supported.
881 pub extern "C" fn InvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Quantity {
882 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
883 crate::lightning::offers::offer::Quantity::native_into(ret)
886 /// The public key used by the recipient to sign invoices.
888 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
891 pub extern "C" fn InvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
892 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
893 let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
897 /// An unpredictable series of bytes, typically containing information about the derivation of
900 /// [`payer_id`]: Self::payer_id
903 pub extern "C" fn InvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::u8slice {
904 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
905 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
909 /// A chain from [`Offer::chains`] that the offer is valid for.
912 pub extern "C" fn InvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
913 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
914 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
917 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
918 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
920 /// [`chain`]: Self::chain
923 pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
924 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
925 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
929 /// Features pertaining to requesting an invoice.
932 pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
933 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
934 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
937 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
940 pub extern "C" fn InvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
941 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
942 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
946 /// A possibly transient pubkey used to sign the invoice request.
949 pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
950 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
951 crate::c_types::PublicKey::from_rust(&ret)
954 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
957 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
960 pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
961 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
962 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
966 /// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
967 /// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
969 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
970 /// creation time is used for the `created_at` parameter.
972 /// [`Duration`]: core::time::Duration
975 pub extern "C" fn InvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
976 let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
977 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
978 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
982 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
984 /// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
985 /// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
986 /// where [`std::time::SystemTime`] is not available.
988 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
991 /// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
992 /// must contain one or more elements ordered from most-preferred to least-preferred, if there's
993 /// a preference. Note, however, that any privacy is lost if a public node id was used for
994 /// [`Offer::signing_pubkey`].
996 /// Errors if the request contains unknown required features.
1000 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
1001 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
1003 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
1004 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
1007 pub extern "C" fn InvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
1008 let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1009 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at));
1010 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
1014 /// Verifies that the request was for an offer created using the given key. Returns the verified
1015 /// request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
1016 /// if they could be extracted from the metadata.
1018 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1021 pub extern "C" fn InvoiceRequest_verify(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ {
1022 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify(key.get_native_ref(), secp256k1::global::SECP256K1);
1023 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::VerifiedInvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
1027 /// Signature of the invoice request using [`payer_id`].
1029 /// [`payer_id`]: Self::payer_id
1032 pub extern "C" fn InvoiceRequest_signature(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::SchnorrSignature {
1033 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
1034 crate::c_types::SchnorrSignature::from_rust(&ret)
1037 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
1038 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
1039 /// for the selected chain.
1042 pub extern "C" fn VerifiedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
1043 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
1044 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
1048 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
1049 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
1052 pub extern "C" fn VerifiedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
1053 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
1054 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { let mut local_ret_0 = Vec::new(); for mut item in (*ret.as_ref().unwrap()).clone().drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }) };
1058 /// The minimum amount required for a successful payment of a single item.
1061 pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ {
1062 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
1063 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) };
1067 /// A complete description of the purpose of the payment. Intended to be displayed to the user
1068 /// but with the caveat that it has not been verified in any way.
1070 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1073 pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1074 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
1075 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
1079 /// Features pertaining to the offer.
1082 pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
1083 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
1084 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
1087 /// Duration since the Unix epoch when an invoice should no longer be requested.
1089 /// If `None`, the offer does not expire.
1092 pub extern "C" fn VerifiedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1093 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
1094 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap().as_secs() }) };
1098 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
1099 /// displayed to the user but with the caveat that it has not been verified in any way.
1101 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1104 pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1105 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
1106 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
1110 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
1111 /// recipient privacy by obfuscating its node id.
1114 pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
1115 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
1116 let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
1120 /// The quantity of items supported.
1123 pub extern "C" fn VerifiedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
1124 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
1125 crate::lightning::offers::offer::Quantity::native_into(ret)
1128 /// The public key used by the recipient to sign invoices.
1130 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1133 pub extern "C" fn VerifiedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
1134 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
1135 let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } };
1139 /// An unpredictable series of bytes, typically containing information about the derivation of
1142 /// [`payer_id`]: Self::payer_id
1145 pub extern "C" fn VerifiedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::u8slice {
1146 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
1147 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
1151 /// A chain from [`Offer::chains`] that the offer is valid for.
1154 pub extern "C" fn VerifiedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
1155 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
1156 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
1159 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
1160 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
1162 /// [`chain`]: Self::chain
1165 pub extern "C" fn VerifiedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1166 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
1167 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
1171 /// Features pertaining to requesting an invoice.
1174 pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
1175 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
1176 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
1179 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1182 pub extern "C" fn VerifiedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
1183 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
1184 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
1188 /// A possibly transient pubkey used to sign the invoice request.
1191 pub extern "C" fn VerifiedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
1192 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
1193 crate::c_types::PublicKey::from_rust(&ret)
1196 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1199 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1202 pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
1203 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
1204 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
1208 /// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
1209 /// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
1211 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
1212 /// creation time is used for the `created_at` parameter.
1214 /// [`Duration`]: core::time::Duration
1217 pub extern "C" fn VerifiedInvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
1218 let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1219 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
1220 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
1224 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
1226 /// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
1227 /// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
1228 /// where [`std::time::SystemTime`] is not available.
1230 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
1231 /// for the invoice.
1233 /// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
1234 /// must contain one or more elements ordered from most-preferred to least-preferred, if there's
1235 /// a preference. Note, however, that any privacy is lost if a public node id was used for
1236 /// [`Offer::signing_pubkey`].
1238 /// Errors if the request contains unknown required features.
1242 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
1243 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
1245 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
1246 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
1249 pub extern "C" fn VerifiedInvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ {
1250 let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1251 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at));
1252 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
1256 /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
1257 /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
1258 /// the same [`ExpandedKey`] as the one used to create the offer.
1260 /// See [`InvoiceRequest::respond_with`] for further details.
1262 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1265 pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ {
1266 let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1267 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data));
1268 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
1272 /// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
1273 /// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
1274 /// the same [`ExpandedKey`] as the one used to create the offer.
1276 /// See [`InvoiceRequest::respond_with_no_std`] for further details.
1278 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1281 pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ {
1282 let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { let (mut orig_payment_paths_0_0, mut orig_payment_paths_0_1) = item.to_rust(); let mut local_payment_paths_0 = (*unsafe { Box::from_raw(orig_payment_paths_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_payment_paths_0_1.take_inner()) }); local_payment_paths_0 }); };
1283 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at));
1284 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
1289 /// Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
1290 pub extern "C" fn UnsignedInvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
1291 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1294 pub(crate) extern "C" fn UnsignedInvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1295 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedInvoiceRequest) })
1298 /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
1299 pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
1300 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1303 pub(crate) extern "C" fn InvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1304 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequest) })
1307 use lightning::offers::invoice_request::InvoiceRequestFields as nativeInvoiceRequestFieldsImport;
1308 pub(crate) type nativeInvoiceRequestFields = nativeInvoiceRequestFieldsImport;
1310 /// Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`].
1312 /// [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
1315 pub struct InvoiceRequestFields {
1316 /// A pointer to the opaque Rust object.
1318 /// Nearly everywhere, inner must be non-null, however in places where
1319 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1320 pub inner: *mut nativeInvoiceRequestFields,
1321 /// Indicates that this is the only struct which contains the same pointer.
1323 /// Rust functions which take ownership of an object provided via an argument require
1324 /// this to be true and invalidate the object pointed to by inner.
1328 impl Drop for InvoiceRequestFields {
1329 fn drop(&mut self) {
1330 if self.is_owned && !<*mut nativeInvoiceRequestFields>::is_null(self.inner) {
1331 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1335 /// Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL.
1337 pub extern "C" fn InvoiceRequestFields_free(this_obj: InvoiceRequestFields) { }
1339 /// Used only if an object of this type is returned as a trait impl by a method
1340 pub(crate) extern "C" fn InvoiceRequestFields_free_void(this_ptr: *mut c_void) {
1341 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFields) };
1344 impl InvoiceRequestFields {
1345 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFields {
1346 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1348 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFields {
1349 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1351 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1352 pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestFields {
1353 assert!(self.is_owned);
1354 let ret = ObjOps::untweak_ptr(self.inner);
1355 self.inner = core::ptr::null_mut();
1359 /// A possibly transient pubkey used to sign the invoice request.
1361 pub extern "C" fn InvoiceRequestFields_get_payer_id(this_ptr: &InvoiceRequestFields) -> crate::c_types::PublicKey {
1362 let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_id;
1363 crate::c_types::PublicKey::from_rust(&inner_val)
1365 /// A possibly transient pubkey used to sign the invoice request.
1367 pub extern "C" fn InvoiceRequestFields_set_payer_id(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::PublicKey) {
1368 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_id = val.into_rust();
1370 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1372 pub extern "C" fn InvoiceRequestFields_get_quantity(this_ptr: &InvoiceRequestFields) -> crate::c_types::derived::COption_u64Z {
1373 let mut inner_val = &mut this_ptr.get_native_mut_ref().quantity;
1374 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1377 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
1379 pub extern "C" fn InvoiceRequestFields_set_quantity(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::derived::COption_u64Z) {
1380 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1381 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.quantity = local_val;
1383 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1384 /// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
1386 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1388 pub extern "C" fn InvoiceRequestFields_get_payer_note_truncated(this_ptr: &InvoiceRequestFields) -> crate::lightning::util::string::UntrustedString {
1389 let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_note_truncated;
1390 let mut local_inner_val = crate::lightning::util::string::UntrustedString { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::util::string::UntrustedString<>) as *mut _ }, is_owned: false };
1393 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1394 /// response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
1396 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1398 pub extern "C" fn InvoiceRequestFields_set_payer_note_truncated(this_ptr: &mut InvoiceRequestFields, mut val: crate::lightning::util::string::UntrustedString) {
1399 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1400 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_note_truncated = local_val;
1402 /// Constructs a new InvoiceRequestFields given each field
1404 /// Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1407 pub extern "C" fn InvoiceRequestFields_new(mut payer_id_arg: crate::c_types::PublicKey, mut quantity_arg: crate::c_types::derived::COption_u64Z, mut payer_note_truncated_arg: crate::lightning::util::string::UntrustedString) -> InvoiceRequestFields {
1408 let mut local_quantity_arg = if quantity_arg.is_some() { Some( { quantity_arg.take() }) } else { None };
1409 let mut local_payer_note_truncated_arg = if payer_note_truncated_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payer_note_truncated_arg.take_inner()) } }) };
1410 InvoiceRequestFields { inner: ObjOps::heap_alloc(nativeInvoiceRequestFields {
1411 payer_id: payer_id_arg.into_rust(),
1412 quantity: local_quantity_arg,
1413 payer_note_truncated: local_payer_note_truncated_arg,
1414 }), is_owned: true }
1416 impl Clone for InvoiceRequestFields {
1417 fn clone(&self) -> Self {
1419 inner: if <*mut nativeInvoiceRequestFields>::is_null(self.inner) { core::ptr::null_mut() } else {
1420 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1426 /// Used only if an object of this type is returned as a trait impl by a method
1427 pub(crate) extern "C" fn InvoiceRequestFields_clone_void(this_ptr: *const c_void) -> *mut c_void {
1428 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFields)).clone() })) as *mut c_void
1431 /// Creates a copy of the InvoiceRequestFields
1432 pub extern "C" fn InvoiceRequestFields_clone(orig: &InvoiceRequestFields) -> InvoiceRequestFields {
1435 /// Get a string which allows debug introspection of a InvoiceRequestFields object
1436 pub extern "C" fn InvoiceRequestFields_debug_str_void(o: *const c_void) -> Str {
1437 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequestFields }).into()}
1438 /// Checks if two InvoiceRequestFieldss contain equal inner contents.
1439 /// This ignores pointers and is_owned flags and looks at the values in fields.
1440 /// Two objects with NULL inner values will be considered "equal" here.
1442 pub extern "C" fn InvoiceRequestFields_eq(a: &InvoiceRequestFields, b: &InvoiceRequestFields) -> bool {
1443 if a.inner == b.inner { return true; }
1444 if a.inner.is_null() || b.inner.is_null() { return false; }
1445 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1447 /// The maximum number of characters included in [`InvoiceRequestFields::payer_note_truncated`].
1450 pub static PAYER_NOTE_LIMIT: usize = lightning::offers::invoice_request::PAYER_NOTE_LIMIT;
1452 /// Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read
1453 pub extern "C" fn InvoiceRequestFields_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequestFields) -> crate::c_types::derived::CVec_u8Z {
1454 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1457 pub(crate) extern "C" fn InvoiceRequestFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1458 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequestFields) })
1461 /// Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write
1462 pub extern "C" fn InvoiceRequestFields_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceRequestFieldsDecodeErrorZ {
1463 let res: Result<lightning::offers::invoice_request::InvoiceRequestFields, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1464 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestFields { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };