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 {
205 /// Get a string which allows debug introspection of a InvoiceRequest object
206 pub extern "C" fn InvoiceRequest_debug_str_void(o: *const c_void) -> Str {
207 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequest }).into()}
209 use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport;
210 pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport;
212 /// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different
213 /// ways to respond depending on whether the signing keys were derived.
216 pub struct VerifiedInvoiceRequest {
217 /// A pointer to the opaque Rust object.
219 /// Nearly everywhere, inner must be non-null, however in places where
220 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
221 pub inner: *mut nativeVerifiedInvoiceRequest,
222 /// Indicates that this is the only struct which contains the same pointer.
224 /// Rust functions which take ownership of an object provided via an argument require
225 /// this to be true and invalidate the object pointed to by inner.
229 impl Drop for VerifiedInvoiceRequest {
231 if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) {
232 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
236 /// Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL.
238 pub extern "C" fn VerifiedInvoiceRequest_free(this_obj: VerifiedInvoiceRequest) { }
240 /// Used only if an object of this type is returned as a trait impl by a method
241 pub(crate) extern "C" fn VerifiedInvoiceRequest_free_void(this_ptr: *mut c_void) {
242 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeVerifiedInvoiceRequest) };
245 impl VerifiedInvoiceRequest {
246 pub(crate) fn get_native_ref(&self) -> &'static nativeVerifiedInvoiceRequest {
247 unsafe { &*ObjOps::untweak_ptr(self.inner) }
249 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeVerifiedInvoiceRequest {
250 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
252 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
253 pub(crate) fn take_inner(mut self) -> *mut nativeVerifiedInvoiceRequest {
254 assert!(self.is_owned);
255 let ret = ObjOps::untweak_ptr(self.inner);
256 self.inner = core::ptr::null_mut();
260 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
262 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
263 /// [`respond_with`].
265 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
266 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
267 /// [`respond_with`]: Self::respond_with
269 pub extern "C" fn VerifiedInvoiceRequest_get_keys(this_ptr: &VerifiedInvoiceRequest) -> crate::c_types::derived::COption_SecretKeyZ {
270 let mut inner_val = &mut this_ptr.get_native_mut_ref().keys;
271 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()) }) };
274 /// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
276 /// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
277 /// [`respond_with`].
279 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
280 /// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
281 /// [`respond_with`]: Self::respond_with
283 pub extern "C" fn VerifiedInvoiceRequest_set_keys(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::c_types::derived::COption_SecretKeyZ) {
284 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()) }})} };
285 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys = local_val;
287 impl Clone for VerifiedInvoiceRequest {
288 fn clone(&self) -> Self {
290 inner: if <*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else {
291 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
297 /// Used only if an object of this type is returned as a trait impl by a method
298 pub(crate) extern "C" fn VerifiedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void {
299 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeVerifiedInvoiceRequest)).clone() })) as *mut c_void
302 /// Creates a copy of the VerifiedInvoiceRequest
303 pub extern "C" fn VerifiedInvoiceRequest_clone(orig: &VerifiedInvoiceRequest) -> VerifiedInvoiceRequest {
306 /// Get a string which allows debug introspection of a VerifiedInvoiceRequest object
307 pub extern "C" fn VerifiedInvoiceRequest_debug_str_void(o: *const c_void) -> Str {
308 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::VerifiedInvoiceRequest }).into()}
309 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
310 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
311 /// for the selected chain.
314 pub extern "C" fn UnsignedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
315 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
316 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
320 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
321 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
324 pub extern "C" fn UnsignedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
325 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
326 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() }) };
330 /// The minimum amount required for a successful payment of a single item.
332 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
335 pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Amount {
336 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
337 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 };
341 /// A complete description of the purpose of the payment. Intended to be displayed to the user
342 /// but with the caveat that it has not been verified in any way.
345 pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
346 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
347 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
350 /// Features pertaining to the offer.
353 pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
354 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
355 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
358 /// Duration since the Unix epoch when an invoice should no longer be requested.
360 /// If `None`, the offer does not expire.
363 pub extern "C" fn UnsignedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
364 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
365 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() }) };
369 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
370 /// displayed to the user but with the caveat that it has not been verified in any way.
372 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
375 pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
376 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
377 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 };
381 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
382 /// recipient privacy by obfuscating its node id.
385 pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
386 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
387 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 } }); };
391 /// The quantity of items supported.
394 pub extern "C" fn UnsignedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
395 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
396 crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true }
399 /// The public key used by the recipient to sign invoices.
402 pub extern "C" fn UnsignedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
403 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
404 crate::c_types::PublicKey::from_rust(&ret)
407 /// An unpredictable series of bytes, typically containing information about the derivation of
410 /// [`payer_id`]: Self::payer_id
413 pub extern "C" fn UnsignedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::u8slice {
414 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
415 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
419 /// A chain from [`Offer::chains`] that the offer is valid for.
422 pub extern "C" fn UnsignedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
423 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
424 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
427 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
428 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
430 /// [`chain`]: Self::chain
433 pub extern "C" fn UnsignedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
434 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
435 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() }) };
439 /// Features pertaining to requesting an invoice.
442 pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
443 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
444 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
447 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
450 pub extern "C" fn UnsignedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
451 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
452 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() }) };
456 /// A possibly transient pubkey used to sign the invoice request.
459 pub extern "C" fn UnsignedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey {
460 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
461 crate::c_types::PublicKey::from_rust(&ret)
464 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
467 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
470 pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
471 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
472 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 };
476 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
477 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
478 /// for the selected chain.
481 pub extern "C" fn InvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
482 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
483 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
487 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
488 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
491 pub extern "C" fn InvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
492 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
493 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() }) };
497 /// The minimum amount required for a successful payment of a single item.
499 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
502 pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Amount {
503 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
504 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 };
508 /// A complete description of the purpose of the payment. Intended to be displayed to the user
509 /// but with the caveat that it has not been verified in any way.
512 pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
513 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
514 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
517 /// Features pertaining to the offer.
520 pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
521 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
522 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
525 /// Duration since the Unix epoch when an invoice should no longer be requested.
527 /// If `None`, the offer does not expire.
530 pub extern "C" fn InvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
531 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
532 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() }) };
536 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
537 /// displayed to the user but with the caveat that it has not been verified in any way.
539 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
542 pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
543 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
544 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 };
548 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
549 /// recipient privacy by obfuscating its node id.
552 pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
553 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
554 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 } }); };
558 /// The quantity of items supported.
561 pub extern "C" fn InvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Quantity {
562 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
563 crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true }
566 /// The public key used by the recipient to sign invoices.
569 pub extern "C" fn InvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
570 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
571 crate::c_types::PublicKey::from_rust(&ret)
574 /// An unpredictable series of bytes, typically containing information about the derivation of
577 /// [`payer_id`]: Self::payer_id
580 pub extern "C" fn InvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::u8slice {
581 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
582 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
586 /// A chain from [`Offer::chains`] that the offer is valid for.
589 pub extern "C" fn InvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
590 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
591 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
594 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
595 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
597 /// [`chain`]: Self::chain
600 pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
601 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
602 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() }) };
606 /// Features pertaining to requesting an invoice.
609 pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
610 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
611 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
614 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
617 pub extern "C" fn InvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_u64Z {
618 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
619 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() }) };
623 /// A possibly transient pubkey used to sign the invoice request.
626 pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey {
627 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
628 crate::c_types::PublicKey::from_rust(&ret)
631 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
634 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
637 pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString {
638 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
639 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 };
643 /// Signature of the invoice request using [`payer_id`].
645 /// [`payer_id`]: Self::payer_id
648 pub extern "C" fn InvoiceRequest_signature(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::SchnorrSignature {
649 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
650 crate::c_types::SchnorrSignature::from_rust(&ret)
653 /// Verifies that the request was for an offer created using the given key. Returns the verified
654 /// request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
655 /// if they could be extracted from the metadata.
657 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
660 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 {
661 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify(key.get_native_ref(), secp256k1::global::SECP256K1);
662 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() };
666 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
667 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
668 /// for the selected chain.
671 pub extern "C" fn VerifiedInvoiceRequest_chains(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
672 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
673 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
677 /// Opaque bytes set by the originator. Useful for authentication and validating fields since it
678 /// is reflected in `invoice_request` messages along with all the other fields from the `offer`.
681 pub extern "C" fn VerifiedInvoiceRequest_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_CVec_u8ZZ {
682 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
683 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() }) };
687 /// The minimum amount required for a successful payment of a single item.
689 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
692 pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Amount {
693 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
694 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 };
698 /// A complete description of the purpose of the payment. Intended to be displayed to the user
699 /// but with the caveat that it has not been verified in any way.
702 pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
703 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
704 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
707 /// Features pertaining to the offer.
710 pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures {
711 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
712 crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false }
715 /// Duration since the Unix epoch when an invoice should no longer be requested.
717 /// If `None`, the offer does not expire.
720 pub extern "C" fn VerifiedInvoiceRequest_absolute_expiry(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
721 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
722 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() }) };
726 /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
727 /// displayed to the user but with the caveat that it has not been verified in any way.
729 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
732 pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
733 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
734 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 };
738 /// Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
739 /// recipient privacy by obfuscating its node id.
742 pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ {
743 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths();
744 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 } }); };
748 /// The quantity of items supported.
751 pub extern "C" fn VerifiedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Quantity {
752 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
753 crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true }
756 /// The public key used by the recipient to sign invoices.
759 pub extern "C" fn VerifiedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
760 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
761 crate::c_types::PublicKey::from_rust(&ret)
764 /// An unpredictable series of bytes, typically containing information about the derivation of
767 /// [`payer_id`]: Self::payer_id
770 pub extern "C" fn VerifiedInvoiceRequest_payer_metadata(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::u8slice {
771 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
772 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
776 /// A chain from [`Offer::chains`] that the offer is valid for.
779 pub extern "C" fn VerifiedInvoiceRequest_chain(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::ThirtyTwoBytes {
780 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
781 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
784 /// The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
785 /// must be greater than or equal to [`Offer::amount`], converted if necessary.
787 /// [`chain`]: Self::chain
790 pub extern "C" fn VerifiedInvoiceRequest_amount_msats(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
791 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
792 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() }) };
796 /// Features pertaining to requesting an invoice.
799 pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures {
800 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
801 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
804 /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
807 pub extern "C" fn VerifiedInvoiceRequest_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_u64Z {
808 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
809 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() }) };
813 /// A possibly transient pubkey used to sign the invoice request.
816 pub extern "C" fn VerifiedInvoiceRequest_payer_id(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey {
817 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
818 crate::c_types::PublicKey::from_rust(&ret)
821 /// A payer-provided note which will be seen by the recipient and reflected back in the invoice
824 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
827 pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString {
828 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
829 let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
834 /// Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
835 pub extern "C" fn UnsignedInvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
836 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
839 pub(crate) extern "C" fn UnsignedInvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
840 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedInvoiceRequest) })
843 /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
844 pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_u8Z {
845 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
848 pub(crate) extern "C" fn InvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
849 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequest) })