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` messages.
11 //! A [`Bolt12Invoice`] can be built from a parsed [`InvoiceRequest`] for the \"offer to be paid\"
12 //! flow or from a [`Refund`] as an \"offer for money\" flow. The expected recipient of the payment
13 //! then sends the invoice to the intended payer, who will then pay it.
15 //! The payment recipient must include a [`PaymentHash`], so as to reveal the preimage upon payment
16 //! receipt, and one or more [`BlindedPath`]s for the payer to use when sending the payment.
19 //! extern crate bitcoin;
20 //! extern crate lightning;
22 //! use bitcoin::hashes::Hash;
23 //! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
24 //! use core::convert::{Infallible, TryFrom};
25 //! use lightning::offers::invoice_request::InvoiceRequest;
26 //! use lightning::offers::refund::Refund;
27 //! use lightning::util::ser::Writeable;
29 //! # use lightning::ln::PaymentHash;
30 //! # use lightning::offers::invoice::BlindedPayInfo;
31 //! # use lightning::blinded_path::BlindedPath;
33 //! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() }
34 //! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
36 //! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
37 //! let payment_paths = create_payment_paths();
38 //! let payment_hash = create_payment_hash();
39 //! let secp_ctx = Secp256k1::new();
40 //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
41 //! let pubkey = PublicKey::from(keys);
42 //! let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
43 //! let mut buffer = Vec::new();
45 //! // Invoice for the \"offer to be paid\" flow.
46 //! InvoiceRequest::try_from(bytes)?
48 //! .respond_with(payment_paths, payment_hash)?
50 //! .relative_expiry(3600)
52 //! .fallback_v0_p2wpkh(&wpubkey_hash)
54 //! .sign::<_, Infallible>(
55 //! |message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
57 //! .expect(\"failed verifying signature\")
58 //! .write(&mut buffer)
63 //! # fn parse_refund(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
64 //! # let payment_paths = create_payment_paths();
65 //! # let payment_hash = create_payment_hash();
66 //! # let secp_ctx = Secp256k1::new();
67 //! # let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
68 //! # let pubkey = PublicKey::from(keys);
69 //! # let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
70 //! # let mut buffer = Vec::new();
72 //! // Invoice for the \"offer for money\" flow.
73 //! \"lnr1qcp4256ypq\"
74 //! .parse::<Refund>()?
76 //! .respond_with(payment_paths, payment_hash, pubkey)?
78 //! .relative_expiry(3600)
80 //! .fallback_v0_p2wpkh(&wpubkey_hash)
82 //! .sign::<_, Infallible>(
83 //! |message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
85 //! .expect(\"failed verifying signature\")
86 //! .write(&mut buffer)
93 use alloc::str::FromStr;
94 use alloc::string::String;
95 use core::ffi::c_void;
96 use core::convert::Infallible;
97 use bitcoin::hashes::Hash;
98 use crate::c_types::*;
99 #[cfg(feature="no-std")]
100 use alloc::{vec::Vec, boxed::Box};
103 use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport;
104 pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport;
106 /// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
110 /// This is serialized as a TLV stream, which includes TLV records from the originating message. As
111 /// such, it may include unknown, odd TLV records.
114 pub struct UnsignedBolt12Invoice {
115 /// A pointer to the opaque Rust object.
117 /// Nearly everywhere, inner must be non-null, however in places where
118 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
119 pub inner: *mut nativeUnsignedBolt12Invoice,
120 /// Indicates that this is the only struct which contains the same pointer.
122 /// Rust functions which take ownership of an object provided via an argument require
123 /// this to be true and invalidate the object pointed to by inner.
127 impl Drop for UnsignedBolt12Invoice {
129 if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) {
130 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
134 /// Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL.
136 pub extern "C" fn UnsignedBolt12Invoice_free(this_obj: UnsignedBolt12Invoice) { }
138 /// Used only if an object of this type is returned as a trait impl by a method
139 pub(crate) extern "C" fn UnsignedBolt12Invoice_free_void(this_ptr: *mut c_void) {
140 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedBolt12Invoice) };
143 impl UnsignedBolt12Invoice {
144 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedBolt12Invoice {
145 unsafe { &*ObjOps::untweak_ptr(self.inner) }
147 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedBolt12Invoice {
148 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
150 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
151 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedBolt12Invoice {
152 assert!(self.is_owned);
153 let ret = ObjOps::untweak_ptr(self.inner);
154 self.inner = core::ptr::null_mut();
158 /// Returns the [`TaggedHash`] of the invoice to sign.
161 pub extern "C" fn UnsignedBolt12Invoice_tagged_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::merkle::TaggedHash {
162 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tagged_hash();
163 crate::lightning::offers::merkle::TaggedHash { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::offers::merkle::TaggedHash<>) as *mut _) }, is_owned: false }
167 use lightning::offers::invoice::Bolt12Invoice as nativeBolt12InvoiceImport;
168 pub(crate) type nativeBolt12Invoice = nativeBolt12InvoiceImport;
170 /// A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`].
172 /// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent
173 /// directly after scanning a refund. It includes all the information needed to pay a recipient.
175 /// [`Offer`]: crate::offers::offer::Offer
176 /// [`Refund`]: crate::offers::refund::Refund
177 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
180 pub struct Bolt12Invoice {
181 /// A pointer to the opaque Rust object.
183 /// Nearly everywhere, inner must be non-null, however in places where
184 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
185 pub inner: *mut nativeBolt12Invoice,
186 /// Indicates that this is the only struct which contains the same pointer.
188 /// Rust functions which take ownership of an object provided via an argument require
189 /// this to be true and invalidate the object pointed to by inner.
193 impl Drop for Bolt12Invoice {
195 if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) {
196 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
200 /// Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL.
202 pub extern "C" fn Bolt12Invoice_free(this_obj: Bolt12Invoice) { }
204 /// Used only if an object of this type is returned as a trait impl by a method
205 pub(crate) extern "C" fn Bolt12Invoice_free_void(this_ptr: *mut c_void) {
206 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12Invoice) };
210 pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12Invoice {
211 unsafe { &*ObjOps::untweak_ptr(self.inner) }
213 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12Invoice {
214 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
216 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
217 pub(crate) fn take_inner(mut self) -> *mut nativeBolt12Invoice {
218 assert!(self.is_owned);
219 let ret = ObjOps::untweak_ptr(self.inner);
220 self.inner = core::ptr::null_mut();
224 impl Clone for Bolt12Invoice {
225 fn clone(&self) -> Self {
227 inner: if <*mut nativeBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
228 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
234 /// Used only if an object of this type is returned as a trait impl by a method
235 pub(crate) extern "C" fn Bolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
236 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12Invoice)).clone() })) as *mut c_void
239 /// Creates a copy of the Bolt12Invoice
240 pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice {
243 /// Get a string which allows debug introspection of a Bolt12Invoice object
244 pub extern "C" fn Bolt12Invoice_debug_str_void(o: *const c_void) -> Str {
245 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::Bolt12Invoice }).into()}
246 /// The chains that may be used when paying a requested invoice.
248 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
250 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
253 pub extern "C" fn UnsignedBolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
254 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
255 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_ret_0.into() }) };
259 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
260 /// invoice originated from an offer.
262 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
264 /// [`offer_chains`]: Self::offer_chains
265 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
268 pub extern "C" fn UnsignedBolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
269 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
270 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
273 /// Opaque bytes set by the originating [`Offer`].
275 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
276 /// if the [`Offer`] did not set it.
278 /// [`Offer`]: crate::offers::offer::Offer
279 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
282 pub extern "C" fn UnsignedBolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
283 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
284 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() }) };
288 /// The minimum amount required for a successful payment of a single item.
290 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
291 /// the [`Offer`] did not set it.
293 /// [`Offer`]: crate::offers::offer::Offer
294 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
296 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
299 pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::offer::Amount {
300 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
301 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 };
305 /// Features pertaining to the originating [`Offer`].
307 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
310 /// [`Offer`]: crate::offers::offer::Offer
311 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
313 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
316 pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
317 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
318 let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false };
322 /// A complete description of the purpose of the originating offer or refund.
324 /// From [`Offer::description`] or [`Refund::description`].
326 /// [`Offer::description`]: crate::offers::offer::Offer::description
329 pub extern "C" fn UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
330 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
331 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
334 /// Duration since the Unix epoch when an invoice should no longer be requested.
336 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
338 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
341 pub extern "C" fn UnsignedBolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
342 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
343 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() }) };
347 /// The issuer of the offer or refund.
349 /// From [`Offer::issuer`] or [`Refund::issuer`].
351 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
353 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
356 pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
357 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
358 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 };
362 /// Paths to the recipient originating from publicly reachable nodes.
364 /// From [`Offer::paths`] or [`Refund::paths`].
366 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
369 pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
370 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
371 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 } }); };
375 /// The quantity of items supported.
377 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
380 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
382 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
385 pub extern "C" fn UnsignedBolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::offer::Quantity {
386 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
387 let mut local_ret = crate::lightning::offers::offer::Quantity { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
391 /// An unpredictable series of bytes from the payer.
393 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
396 pub extern "C" fn UnsignedBolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::u8slice {
397 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
398 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
402 /// Features pertaining to requesting an invoice.
404 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
407 pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
408 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
409 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
412 /// The quantity of items requested or refunded for.
414 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
417 pub extern "C" fn UnsignedBolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
418 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
419 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() }) };
423 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
424 /// refund in case there are no [`message_paths`].
426 /// [`message_paths`]: Self::message_paths
429 pub extern "C" fn UnsignedBolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
430 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
431 crate::c_types::PublicKey::from_rust(&ret)
434 /// A payer-provided note reflected back in the invoice.
436 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
438 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
441 pub extern "C" fn UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
442 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
443 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 };
447 /// Duration since the Unix epoch when the invoice was created.
450 pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
451 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
455 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
456 /// should no longer be paid.
459 pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
460 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
464 /// Whether the invoice has expired.
467 pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool {
468 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
472 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
475 pub extern "C" fn UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
476 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
477 crate::c_types::ThirtyTwoBytes { data: ret.0 }
480 /// The minimum amount required for a successful payment of the invoice.
483 pub extern "C" fn UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
484 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
488 /// Features pertaining to paying an invoice.
491 pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
492 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
493 crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
496 /// The public key corresponding to the key used to sign the invoice.
499 pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
500 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
501 crate::c_types::PublicKey::from_rust(&ret)
504 /// The chains that may be used when paying a requested invoice.
506 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
508 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
511 pub extern "C" fn Bolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
512 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
513 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_ret_0.into() }) };
517 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
518 /// invoice originated from an offer.
520 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
522 /// [`offer_chains`]: Self::offer_chains
523 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
526 pub extern "C" fn Bolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
527 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
528 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
531 /// Opaque bytes set by the originating [`Offer`].
533 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
534 /// if the [`Offer`] did not set it.
536 /// [`Offer`]: crate::offers::offer::Offer
537 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
540 pub extern "C" fn Bolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
541 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
542 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() }) };
546 /// The minimum amount required for a successful payment of a single item.
548 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
549 /// the [`Offer`] did not set it.
551 /// [`Offer`]: crate::offers::offer::Offer
552 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
554 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
557 pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::offers::offer::Amount {
558 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
559 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 };
563 /// Features pertaining to the originating [`Offer`].
565 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
568 /// [`Offer`]: crate::offers::offer::Offer
569 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
571 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
574 pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
575 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
576 let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false };
580 /// A complete description of the purpose of the originating offer or refund.
582 /// From [`Offer::description`] or [`Refund::description`].
584 /// [`Offer::description`]: crate::offers::offer::Offer::description
587 pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
588 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
589 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
592 /// Duration since the Unix epoch when an invoice should no longer be requested.
594 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
596 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
599 pub extern "C" fn Bolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
600 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
601 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() }) };
605 /// The issuer of the offer or refund.
607 /// From [`Offer::issuer`] or [`Refund::issuer`].
609 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
611 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
614 pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
615 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
616 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 };
620 /// Paths to the recipient originating from publicly reachable nodes.
622 /// From [`Offer::paths`] or [`Refund::paths`].
624 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
627 pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
628 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
629 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 } }); };
633 /// The quantity of items supported.
635 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
638 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
640 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
643 pub extern "C" fn Bolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::offers::offer::Quantity {
644 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
645 let mut local_ret = crate::lightning::offers::offer::Quantity { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true };
649 /// An unpredictable series of bytes from the payer.
651 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
654 pub extern "C" fn Bolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::u8slice {
655 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
656 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
660 /// Features pertaining to requesting an invoice.
662 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
665 pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
666 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
667 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
670 /// The quantity of items requested or refunded for.
672 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
675 pub extern "C" fn Bolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
676 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
677 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() }) };
681 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
682 /// refund in case there are no [`message_paths`].
684 /// [`message_paths`]: Self::message_paths
687 pub extern "C" fn Bolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
688 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
689 crate::c_types::PublicKey::from_rust(&ret)
692 /// A payer-provided note reflected back in the invoice.
694 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
696 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
699 pub extern "C" fn Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
700 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
701 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 };
705 /// Duration since the Unix epoch when the invoice was created.
708 pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
709 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
713 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
714 /// should no longer be paid.
717 pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
718 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
722 /// Whether the invoice has expired.
725 pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool {
726 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
730 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
733 pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
734 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
735 crate::c_types::ThirtyTwoBytes { data: ret.0 }
738 /// The minimum amount required for a successful payment of the invoice.
741 pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
742 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
746 /// Features pertaining to paying an invoice.
749 pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
750 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
751 crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
754 /// The public key corresponding to the key used to sign the invoice.
757 pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
758 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
759 crate::c_types::PublicKey::from_rust(&ret)
762 /// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
765 pub extern "C" fn Bolt12Invoice_signature(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::SchnorrSignature {
766 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
767 crate::c_types::SchnorrSignature::from_rust(&ret)
770 /// Hash that was used for signing the invoice.
773 pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
774 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
775 crate::c_types::ThirtyTwoBytes { data: ret }
778 /// Verifies that the invoice was for a request or refund created using the given key. Returns
779 /// the associated [`PaymentId`] to use when sending the payment.
782 pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ {
783 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1);
784 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
789 /// Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read
790 pub extern "C" fn UnsignedBolt12Invoice_write(obj: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
791 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
794 pub(crate) extern "C" fn UnsignedBolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
795 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedBolt12Invoice) })
798 /// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
799 pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
800 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
803 pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
804 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) })
807 use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport;
808 pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport;
810 /// Information needed to route a payment across a [`BlindedPath`].
813 pub struct BlindedPayInfo {
814 /// A pointer to the opaque Rust object.
816 /// Nearly everywhere, inner must be non-null, however in places where
817 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
818 pub inner: *mut nativeBlindedPayInfo,
819 /// Indicates that this is the only struct which contains the same pointer.
821 /// Rust functions which take ownership of an object provided via an argument require
822 /// this to be true and invalidate the object pointed to by inner.
826 impl Drop for BlindedPayInfo {
828 if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) {
829 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
833 /// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL.
835 pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { }
837 /// Used only if an object of this type is returned as a trait impl by a method
838 pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) {
839 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) };
842 impl BlindedPayInfo {
843 pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo {
844 unsafe { &*ObjOps::untweak_ptr(self.inner) }
846 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo {
847 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
849 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
850 pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo {
851 assert!(self.is_owned);
852 let ret = ObjOps::untweak_ptr(self.inner);
853 self.inner = core::ptr::null_mut();
857 /// Base fee charged (in millisatoshi) for the entire blinded path.
859 pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 {
860 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
863 /// Base fee charged (in millisatoshi) for the entire blinded path.
865 pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) {
866 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
868 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
869 /// (i.e., 10,000 is 1%).
871 pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 {
872 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
875 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
876 /// (i.e., 10,000 is 1%).
878 pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) {
879 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
881 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
884 pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 {
885 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
888 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
891 pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) {
892 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
894 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
895 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
896 /// seen by the recipient.
898 pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 {
899 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
902 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
903 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
904 /// seen by the recipient.
906 pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
907 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
909 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
910 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
911 /// seen by the recipient.
913 pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 {
914 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
917 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
918 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
919 /// seen by the recipient.
921 pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
922 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
924 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
927 pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures {
928 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
929 crate::lightning::ln::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false }
931 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
934 pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
935 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
937 /// Constructs a new BlindedPayInfo given each field
940 pub extern "C" fn BlindedPayInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut features_arg: crate::lightning::ln::features::BlindedHopFeatures) -> BlindedPayInfo {
941 BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo {
942 fee_base_msat: fee_base_msat_arg,
943 fee_proportional_millionths: fee_proportional_millionths_arg,
944 cltv_expiry_delta: cltv_expiry_delta_arg,
945 htlc_minimum_msat: htlc_minimum_msat_arg,
946 htlc_maximum_msat: htlc_maximum_msat_arg,
947 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
950 impl Clone for BlindedPayInfo {
951 fn clone(&self) -> Self {
953 inner: if <*mut nativeBlindedPayInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
954 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
960 /// Used only if an object of this type is returned as a trait impl by a method
961 pub(crate) extern "C" fn BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
962 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void
965 /// Creates a copy of the BlindedPayInfo
966 pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo {
969 /// Get a string which allows debug introspection of a BlindedPayInfo object
970 pub extern "C" fn BlindedPayInfo_debug_str_void(o: *const c_void) -> Str {
971 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::BlindedPayInfo }).into()}
972 /// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo.
974 pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 {
975 if o.inner.is_null() { return 0; }
976 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
978 let mut hasher = core::hash::SipHasher::new();
979 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
980 core::hash::Hasher::finish(&hasher)
982 /// Checks if two BlindedPayInfos contain equal inner contents.
983 /// This ignores pointers and is_owned flags and looks at the values in fields.
984 /// Two objects with NULL inner values will be considered "equal" here.
986 pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool {
987 if a.inner == b.inner { return true; }
988 if a.inner.is_null() || b.inner.is_null() { return false; }
989 if a.get_native_ref() == b.get_native_ref() { true } else { false }
992 /// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read
993 pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z {
994 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
997 pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
998 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) })
1001 /// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write
1002 pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ {
1003 let res: Result<lightning::offers::invoice::BlindedPayInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1004 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::BlindedPayInfo { 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() };