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 core::convert::Infallible;
28 //! use lightning::ln::features::OfferFeatures;
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 //! \"lno1qcp4256ypq\"
39 //! .parse::<Offer>()?
40 //! .request_invoice(vec![42; 64], pubkey)?
41 //! .chain(Network::Testnet)?
42 //! .amount_msats(1000)?
44 //! .payer_note(\"foo\".to_string())
46 //! .sign::<_, Infallible>(
47 //! |message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
49 //! .expect(\"failed verifying signature\")
50 //! .write(&mut buffer)
56 use alloc::str::FromStr;
57 use alloc::string::String;
58 use core::ffi::c_void;
59 use core::convert::Infallible;
60 use bitcoin::hashes::Hash;
61 use crate::c_types::*;
62 #[cfg(feature="no-std")]
63 use alloc::{vec::Vec, boxed::Box};
66 use lightning::offers::invoice_request::UnsignedInvoiceRequest as nativeUnsignedInvoiceRequestImport;
67 pub(crate) type nativeUnsignedInvoiceRequest = nativeUnsignedInvoiceRequestImport;
69 /// A semantically valid [`InvoiceRequest`] that hasn't been signed.
73 /// This is serialized as a TLV stream, which includes TLV records from the originating message. As
74 /// such, it may include unknown, odd TLV records.
77 pub struct UnsignedInvoiceRequest {
78 /// A pointer to the opaque Rust object.
80 /// Nearly everywhere, inner must be non-null, however in places where
81 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
82 pub inner: *mut nativeUnsignedInvoiceRequest,
83 /// Indicates that this is the only struct which contains the same pointer.
85 /// Rust functions which take ownership of an object provided via an argument require
86 /// this to be true and invalidate the object pointed to by inner.
90 impl Drop for UnsignedInvoiceRequest {
92 if self.is_owned && !<*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) {
93 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
97 /// Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL.
99 pub extern "C" fn UnsignedInvoiceRequest_free(this_obj: UnsignedInvoiceRequest) { }
101 /// Used only if an object of this type is returned as a trait impl by a method
102 pub(crate) extern "C" fn UnsignedInvoiceRequest_free_void(this_ptr: *mut c_void) {
103 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedInvoiceRequest) };
106 impl UnsignedInvoiceRequest {
107 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedInvoiceRequest {
108 unsafe { &*ObjOps::untweak_ptr(self.inner) }
110 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedInvoiceRequest {
111 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
113 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
114 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedInvoiceRequest {
115 assert!(self.is_owned);
116 let ret = ObjOps::untweak_ptr(self.inner);
117 self.inner = core::ptr::null_mut();
121 /// Returns the [`TaggedHash`] of the invoice to sign.
124 pub extern "C" fn UnsignedInvoiceRequest_tagged_hash(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::merkle::TaggedHash {
125 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tagged_hash();
126 crate::lightning::offers::merkle::TaggedHash { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::offers::merkle::TaggedHash<>) as *mut _) }, is_owned: false }
130 use lightning::offers::invoice_request::InvoiceRequest as nativeInvoiceRequestImport;
131 pub(crate) type nativeInvoiceRequest = nativeInvoiceRequestImport;
133 /// An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
135 /// An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
136 /// specifies these such that its recipient can send an invoice for payment.
138 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
139 /// [`Offer`]: crate::offers::offer::Offer
142 pub struct InvoiceRequest {
143 /// A pointer to the opaque Rust object.
145 /// Nearly everywhere, inner must be non-null, however in places where
146 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
147 pub inner: *mut nativeInvoiceRequest,
148 /// Indicates that this is the only struct which contains the same pointer.
150 /// Rust functions which take ownership of an object provided via an argument require
151 /// this to be true and invalidate the object pointed to by inner.
155 impl Drop for InvoiceRequest {
157 if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) {
158 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
162 /// Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL.
164 pub extern "C" fn InvoiceRequest_free(this_obj: InvoiceRequest) { }
166 /// Used only if an object of this type is returned as a trait impl by a method
167 pub(crate) extern "C" fn InvoiceRequest_free_void(this_ptr: *mut c_void) {
168 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequest) };
171 impl InvoiceRequest {
172 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequest {
173 unsafe { &*ObjOps::untweak_ptr(self.inner) }
175 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequest {
176 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
178 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
179 pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequest {
180 assert!(self.is_owned);
181 let ret = ObjOps::untweak_ptr(self.inner);
182 self.inner = core::ptr::null_mut();
186 impl Clone for InvoiceRequest {
187 fn clone(&self) -> Self {
189 inner: if <*mut nativeInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
190 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
196 /// Used only if an object of this type is returned as a trait impl by a method
197 pub(crate) extern "C" fn InvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
198 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequest)).clone() })) as *mut c_void
201 /// Creates a copy of the InvoiceRequest
202 pub extern "C" fn InvoiceRequest_clone(orig: &InvoiceRequest) -> InvoiceRequest {
206 use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport;
207 pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport;
209 /// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different
210 /// ways to respond depending on whether the signing keys were derived.
213 pub struct VerifiedInvoiceRequest {
214 /// A pointer to the opaque Rust object.
216 /// Nearly everywhere, inner must be non-null, however in places where
217 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
218 pub inner: *mut nativeVerifiedInvoiceRequest,
219 /// Indicates that this is the only struct which contains the same pointer.
221 /// Rust functions which take ownership of an object provided via an argument require
222 /// this to be true and invalidate the object pointed to by inner.
226 impl Drop for VerifiedInvoiceRequest {
228 if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) {
229 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
233 /// Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL.
235 pub extern "C" fn VerifiedInvoiceRequest_free(this_obj: VerifiedInvoiceRequest) { }
237 /// Used only if an object of this type is returned as a trait impl by a method
238 pub(crate) extern "C" fn VerifiedInvoiceRequest_free_void(this_ptr: *mut c_void) {
239 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeVerifiedInvoiceRequest) };
242 impl VerifiedInvoiceRequest {
243 pub(crate) fn get_native_ref(&self) -> &'static nativeVerifiedInvoiceRequest {
244 unsafe { &*ObjOps::untweak_ptr(self.inner) }
246 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeVerifiedInvoiceRequest {
247 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
249 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
250 pub(crate) fn take_inner(mut self) -> *mut nativeVerifiedInvoiceRequest {
251 assert!(self.is_owned);
252 let ret = ObjOps::untweak_ptr(self.inner);
253 self.inner = core::ptr::null_mut();
257 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
259 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
260 /// [`respond_with`].
262 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
263 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
264 /// [`respond_with`]: Self::respond_with
266 pub extern "C" fn VerifiedInvoiceRequest_get_keys(this_ptr: &VerifiedInvoiceRequest) -> crate::c_types::derived::COption_SecretKeyZ {
267 let mut inner_val = &mut this_ptr.get_native_mut_ref().keys;
268 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()) }) };
271 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
273 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
274 /// [`respond_with`].
276 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
277 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
278 /// [`respond_with`]: Self::respond_with
280 pub extern "C" fn VerifiedInvoiceRequest_set_keys(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::c_types::derived::COption_SecretKeyZ) {
281 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()) }})} };
282 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys = local_val;
284 impl Clone for VerifiedInvoiceRequest {
285 fn clone(&self) -> Self {
287 inner: if <*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
288 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
294 /// Used only if an object of this type is returned as a trait impl by a method
295 pub(crate) extern "C" fn VerifiedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
296 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeVerifiedInvoiceRequest)).clone() })) as *mut c_void
299 /// Creates a copy of the VerifiedInvoiceRequest
300 pub extern "C" fn VerifiedInvoiceRequest_clone(orig: &VerifiedInvoiceRequest) -> VerifiedInvoiceRequest {
303 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
304 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
305 /// for the selected chain.
308 pub extern "C" fn UnsignedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
309 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
310 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); };
314 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
315 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
318 pub extern "C" fn UnsignedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
319 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
320 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() }) };
324 /// The minimum amount required for a successful payment of a single item.
326 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
329 pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Amount {
330 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
331 let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false };
335 /// A complete description of the purpose of the payment. Intended to be displayed to the user
336 /// but with the caveat that it has not been verified in any way.
339 pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
340 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
341 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
344 /// Features pertaining to the offer.
347 pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
348 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
349 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
352 /// Duration since the Unix epoch when an invoice should no longer be requested.
354 /// If `None`, the offer does not expire.
357 pub extern "C" fn UnsignedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
358 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
359 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() }) };
363 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
364 /// displayed to the user but with the caveat that it has not been verified in any way.
366 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
369 pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
370 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
371 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 };
375 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
376 /// recipient privacy by obfuscating its node id.
379 pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
380 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
381 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 } }); };
385 /// The quantity of items supported.
388 pub extern "C" fn UnsignedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
389 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
390 crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true }
393 /// The public key used by the recipient to sign invoices.
396 pub extern "C" fn UnsignedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
397 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
398 crate::c_types::PublicKey::from_rust(&ret)
401 /// An unpredictable series of bytes, typically containing information about the derivation of
404 /// [`payer_id`]: Self::payer_id
407 pub extern "C" fn UnsignedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::u8slice {
408 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
409 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
413 /// A chain from [`Offer::chains`] that the offer is valid for.
416 pub extern "C" fn UnsignedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
417 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
418 crate::c_types::ThirtyTwoBytes { data: ret.to_bytes() }
421 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
422 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
424 /// [`chain`]: Self::chain
427 pub extern "C" fn UnsignedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
428 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
429 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() }) };
433 /// Features pertaining to requesting an invoice.
436 pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
437 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
438 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
441 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
444 pub extern "C" fn UnsignedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
445 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
446 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() }) };
450 /// A possibly transient pubkey used to sign the invoice request.
453 pub extern "C" fn UnsignedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
454 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
455 crate::c_types::PublicKey::from_rust(&ret)
458 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
461 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
464 pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
465 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
466 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 };
470 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
471 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
472 /// for the selected chain.
475 pub extern "C" fn InvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
476 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
477 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); };
481 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
482 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
485 pub extern "C" fn InvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
486 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
487 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() }) };
491 /// The minimum amount required for a successful payment of a single item.
493 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
496 pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Amount {
497 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
498 let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false };
502 /// A complete description of the purpose of the payment. Intended to be displayed to the user
503 /// but with the caveat that it has not been verified in any way.
506 pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
507 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
508 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
511 /// Features pertaining to the offer.
514 pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
515 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
516 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
519 /// Duration since the Unix epoch when an invoice should no longer be requested.
521 /// If `None`, the offer does not expire.
524 pub extern "C" fn InvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
525 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
526 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() }) };
530 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
531 /// displayed to the user but with the caveat that it has not been verified in any way.
533 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
536 pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
537 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
538 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 };
542 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
543 /// recipient privacy by obfuscating its node id.
546 pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
547 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
548 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 } }); };
552 /// The quantity of items supported.
555 pub extern "C" fn InvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Quantity {
556 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
557 crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true }
560 /// The public key used by the recipient to sign invoices.
563 pub extern "C" fn InvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
564 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
565 crate::c_types::PublicKey::from_rust(&ret)
568 /// An unpredictable series of bytes, typically containing information about the derivation of
571 /// [`payer_id`]: Self::payer_id
574 pub extern "C" fn InvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::u8slice {
575 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
576 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
580 /// A chain from [`Offer::chains`] that the offer is valid for.
583 pub extern "C" fn InvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
584 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
585 crate::c_types::ThirtyTwoBytes { data: ret.to_bytes() }
588 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
589 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
591 /// [`chain`]: Self::chain
594 pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
595 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
596 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() }) };
600 /// Features pertaining to requesting an invoice.
603 pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
604 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
605 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
608 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
611 pub extern "C" fn InvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
612 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
613 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() }) };
617 /// A possibly transient pubkey used to sign the invoice request.
620 pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
621 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
622 crate::c_types::PublicKey::from_rust(&ret)
625 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
628 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
631 pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
632 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
633 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
637 /// Signature of the invoice request using [`payer_id`].
639 /// [`payer_id`]: Self::payer_id
642 pub extern "C" fn InvoiceRequest_signature(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::SchnorrSignature {
643 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
644 crate::c_types::SchnorrSignature::from_rust(&ret)
647 /// Verifies that the request was for an offer created using the given key. Returns the verified
648 /// request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
649 /// if they could be extracted from the metadata.
651 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
654 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 {
655 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify(key.get_native_ref(), secp256k1::global::SECP256K1);
656 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() };
660 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
661 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
662 /// for the selected chain.
665 pub extern "C" fn VerifiedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
666 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
667 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); };
671 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
672 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
675 pub extern "C" fn VerifiedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
676 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
677 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() }) };
681 /// The minimum amount required for a successful payment of a single item.
683 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
686 pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Amount {
687 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
688 let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false };
692 /// A complete description of the purpose of the payment. Intended to be displayed to the user
693 /// but with the caveat that it has not been verified in any way.
696 pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
697 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
698 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
701 /// Features pertaining to the offer.
704 pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
705 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
706 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
709 /// Duration since the Unix epoch when an invoice should no longer be requested.
711 /// If `None`, the offer does not expire.
714 pub extern "C" fn VerifiedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
715 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
716 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() }) };
720 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
721 /// displayed to the user but with the caveat that it has not been verified in any way.
723 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
726 pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
727 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
728 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 };
732 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
733 /// recipient privacy by obfuscating its node id.
736 pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
737 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
738 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 } }); };
742 /// The quantity of items supported.
745 pub extern "C" fn VerifiedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
746 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
747 crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true }
750 /// The public key used by the recipient to sign invoices.
753 pub extern "C" fn VerifiedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
754 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
755 crate::c_types::PublicKey::from_rust(&ret)
758 /// An unpredictable series of bytes, typically containing information about the derivation of
761 /// [`payer_id`]: Self::payer_id
764 pub extern "C" fn VerifiedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::u8slice {
765 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
766 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
770 /// A chain from [`Offer::chains`] that the offer is valid for.
773 pub extern "C" fn VerifiedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
774 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
775 crate::c_types::ThirtyTwoBytes { data: ret.to_bytes() }
778 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
779 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
781 /// [`chain`]: Self::chain
784 pub extern "C" fn VerifiedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
785 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
786 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() }) };
790 /// Features pertaining to requesting an invoice.
793 pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
794 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
795 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
798 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
801 pub extern "C" fn VerifiedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
802 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
803 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() }) };
807 /// A possibly transient pubkey used to sign the invoice request.
810 pub extern "C" fn VerifiedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
811 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
812 crate::c_types::PublicKey::from_rust(&ret)
815 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
818 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
821 pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
822 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
823 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 };
828 /// Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
829 pub extern "C" fn UnsignedInvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
830 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
833 pub(crate) extern "C" fn UnsignedInvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
834 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedInvoiceRequest) })
837 /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
838 pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
839 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
842 pub(crate) extern "C" fn InvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
843 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequest) })