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 /// A function for signing an [`UnsignedInvoiceRequest`].
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)>,
363 unsafe impl Send for SignInvoiceRequestFn {}
364 unsafe impl Sync for SignInvoiceRequestFn {}
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),
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)) })*/ })};
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 {
387 fn deref(&self) -> &Self {
391 impl core::ops::DerefMut for SignInvoiceRequestFn {
392 fn deref_mut(&mut self) -> &mut Self {
396 /// Calls the free function if one is set
398 pub extern "C" fn SignInvoiceRequestFn_free(this_ptr: SignInvoiceRequestFn) { }
399 impl Drop for SignInvoiceRequestFn {
401 if let Some(f) = self.free {
406 /// Returns the [`TaggedHash`] of the invoice to sign.
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 }
415 use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport;
416 pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport;
418 /// An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
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.
423 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
424 /// [`Offer`]: crate::offers::offer::Offer
427 pub struct InvoiceRequest {
428 /// A pointer to the opaque Rust object.
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.
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.
440 impl Drop for InvoiceRequest {
442 if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) {
443 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
447 /// Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL.
449 pub extern "C" fn InvoiceRequest_free(this_obj: InvoiceRequest) { }
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) };
456 impl InvoiceRequest {
457 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequest {
458 unsafe { &*ObjOps::untweak_ptr(self.inner) }
460 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequest {
461 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
471 impl Clone for InvoiceRequest {
472 fn clone(&self) -> 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()) },
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
486 /// Creates a copy of the InvoiceRequest
487 pub extern "C" fn InvoiceRequest_clone(orig: &InvoiceRequest) -> InvoiceRequest {
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()}
494 use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport;
495 pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport;
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.
501 pub struct VerifiedInvoiceRequest {
502 /// A pointer to the opaque Rust object.
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.
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.
514 impl Drop for VerifiedInvoiceRequest {
516 if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) {
517 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
521 /// Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL.
523 pub extern "C" fn VerifiedInvoiceRequest_free(this_obj: VerifiedInvoiceRequest) { }
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) };
530 impl VerifiedInvoiceRequest {
531 pub(crate) fn get_native_ref(&self) -> &'static nativeVerifiedInvoiceRequest {
532 unsafe { &*ObjOps::untweak_ptr(self.inner) }
534 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeVerifiedInvoiceRequest {
535 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
545 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
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 }
551 /// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
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()) };
556 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
558 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
559 /// [`respond_with`].
561 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
562 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
563 /// [`respond_with`]: Self::respond_with
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()) }) };
570 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
572 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
573 /// [`respond_with`].
575 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
576 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
577 /// [`respond_with`]: Self::respond_with
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;
583 impl Clone for VerifiedInvoiceRequest {
584 fn clone(&self) -> 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()) },
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
598 /// Creates a copy of the VerifiedInvoiceRequest
599 pub extern "C" fn VerifiedInvoiceRequest_clone(orig: &VerifiedInvoiceRequest) -> VerifiedInvoiceRequest {
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.
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() } }); };
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`.
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() }) };
626 /// The minimum amount required for a successful payment of a single item.
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()) }) };
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.
638 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
647 /// Features pertaining to the offer.
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 }
655 /// Duration since the Unix epoch when an invoice should no longer be requested.
657 /// If `None`, the offer does not expire.
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() }) };
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.
669 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
678 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
679 /// recipient privacy by obfuscating its node id.
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 } }); };
688 /// The quantity of items supported.
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)
696 /// The public key used by the recipient to sign invoices.
698 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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())) } };
707 /// An unpredictable series of bytes, typically containing information about the derivation of
710 /// [`payer_id`]: Self::payer_id
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);
719 /// A chain from [`Offer::chains`] that the offer is valid for.
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() }
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.
730 /// [`chain`]: Self::chain
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() }) };
739 /// Features pertaining to requesting an invoice.
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 }
747 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
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() }) };
756 /// A possibly transient pubkey used to sign the invoice request.
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)
764 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
767 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
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.
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() } }); };
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`.
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() }) };
797 /// The minimum amount required for a successful payment of a single item.
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()) }) };
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.
809 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
818 /// Features pertaining to the offer.
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 }
826 /// Duration since the Unix epoch when an invoice should no longer be requested.
828 /// If `None`, the offer does not expire.
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() }) };
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.
840 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
849 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
850 /// recipient privacy by obfuscating its node id.
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 } }); };
859 /// The quantity of items supported.
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)
867 /// The public key used by the recipient to sign invoices.
869 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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())) } };
878 /// An unpredictable series of bytes, typically containing information about the derivation of
881 /// [`payer_id`]: Self::payer_id
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);
890 /// A chain from [`Offer::chains`] that the offer is valid for.
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() }
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.
901 /// [`chain`]: Self::chain
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() }) };
910 /// Features pertaining to requesting an invoice.
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 }
918 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
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() }) };
927 /// A possibly transient pubkey used to sign the invoice request.
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)
935 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
938 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
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.
950 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
951 /// creation time is used for the `created_at` parameter.
953 /// [`Duration`]: core::time::Duration
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() };
963 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
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.
969 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
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`].
977 /// Errors if the request contains unknown required features.
981 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
982 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
984 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
985 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
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() };
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.
999 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
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() };
1008 /// Signature of the invoice request using [`payer_id`].
1010 /// [`payer_id`]: Self::payer_id
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)
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.
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() } }); };
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`.
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() }) };
1039 /// The minimum amount required for a successful payment of a single item.
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()) }) };
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.
1051 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
1060 /// Features pertaining to the offer.
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 }
1068 /// Duration since the Unix epoch when an invoice should no longer be requested.
1070 /// If `None`, the offer does not expire.
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() }) };
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.
1082 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
1091 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
1092 /// recipient privacy by obfuscating its node id.
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 } }); };
1101 /// The quantity of items supported.
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)
1109 /// The public key used by the recipient to sign invoices.
1111 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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())) } };
1120 /// An unpredictable series of bytes, typically containing information about the derivation of
1123 /// [`payer_id`]: Self::payer_id
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);
1132 /// A chain from [`Offer::chains`] that the offer is valid for.
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() }
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.
1143 /// [`chain`]: Self::chain
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() }) };
1152 /// Features pertaining to requesting an invoice.
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 }
1160 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
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() }) };
1169 /// A possibly transient pubkey used to sign the invoice request.
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)
1177 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
1180 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
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.
1192 /// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
1193 /// creation time is used for the `created_at` parameter.
1195 /// [`Duration`]: core::time::Duration
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() };
1205 /// Creates an [`InvoiceBuilder`] for the request with the given required fields.
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.
1211 /// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
1212 /// for the invoice.
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`].
1219 /// Errors if the request contains unknown required features.
1223 /// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
1224 /// then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
1226 /// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
1227 /// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
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() };
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.
1241 /// See [`InvoiceRequest::respond_with`] for further details.
1243 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
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() };
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.
1257 /// See [`InvoiceRequest::respond_with_no_std`] for further details.
1259 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
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() };
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())
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) })
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())
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) })
1288 use lightning::offers::invoice_request::InvoiceRequestFields as nativeInvoiceRequestFieldsImport;
1289 pub(crate) type nativeInvoiceRequestFields = nativeInvoiceRequestFieldsImport;
1291 /// Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`].
1293 /// [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
1296 pub struct InvoiceRequestFields {
1297 /// A pointer to the opaque Rust object.
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.
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.
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)) };
1316 /// Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL.
1318 pub extern "C" fn InvoiceRequestFields_free(this_obj: InvoiceRequestFields) { }
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) };
1325 impl InvoiceRequestFields {
1326 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFields {
1327 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1329 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFields {
1330 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
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();
1340 /// A possibly transient pubkey used to sign the invoice request.
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)
1346 /// A possibly transient pubkey used to sign the invoice request.
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();
1351 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
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() }) };
1358 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
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;
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.
1367 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 };
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.
1377 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
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;
1383 /// Constructs a new InvoiceRequestFields given each field
1385 /// Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
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 }
1397 impl Clone for InvoiceRequestFields {
1398 fn clone(&self) -> 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()) },
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
1412 /// Creates a copy of the InvoiceRequestFields
1413 pub extern "C" fn InvoiceRequestFields_clone(orig: &InvoiceRequestFields) -> InvoiceRequestFields {
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.
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 }
1428 /// The maximum number of characters included in [`InvoiceRequestFields::payer_note_truncated`].
1431 pub static PAYER_NOTE_LIMIT: usize = lightning::offers::invoice_request::PAYER_NOTE_LIMIT;
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())
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) })
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() };