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::TryFrom;
25 //! use lightning::offers::invoice::UnsignedBolt12Invoice;
26 //! use lightning::offers::invoice_request::InvoiceRequest;
27 //! use lightning::offers::refund::Refund;
28 //! use lightning::util::ser::Writeable;
30 //! # use lightning::ln::types::PaymentHash;
31 //! # use lightning::offers::invoice::{BlindedPayInfo, ExplicitSigningPubkey, InvoiceBuilder};
32 //! # use lightning::blinded_path::BlindedPath;
34 //! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() }
35 //! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
37 //! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
38 //! let payment_paths = create_payment_paths();
39 //! let payment_hash = create_payment_hash();
40 //! let secp_ctx = Secp256k1::new();
41 //! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
42 //! let pubkey = PublicKey::from(keys);
43 //! let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
44 //! let mut buffer = Vec::new();
46 //! // Invoice for the \"offer to be paid\" flow.
47 //! # <InvoiceBuilder<ExplicitSigningPubkey>>::from(
48 //! InvoiceRequest::try_from(bytes)?
50 //! .respond_with(payment_paths, payment_hash)?
53 //! .relative_expiry(3600)
55 //! .fallback_v0_p2wpkh(&wpubkey_hash)
57 //! .sign(|message: &UnsignedBolt12Invoice|
58 //! Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
60 //! .expect(\"failed verifying signature\")
61 //! .write(&mut buffer)
66 //! # fn parse_refund(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
67 //! # let payment_paths = create_payment_paths();
68 //! # let payment_hash = create_payment_hash();
69 //! # let secp_ctx = Secp256k1::new();
70 //! # let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
71 //! # let pubkey = PublicKey::from(keys);
72 //! # let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
73 //! # let mut buffer = Vec::new();
75 //! // Invoice for the \"offer for money\" flow.
76 //! # <InvoiceBuilder<ExplicitSigningPubkey>>::from(
77 //! \"lnr1qcp4256ypq\"
78 //! .parse::<Refund>()?
80 //! .respond_with(payment_paths, payment_hash, pubkey)?
83 //! .relative_expiry(3600)
85 //! .fallback_v0_p2wpkh(&wpubkey_hash)
87 //! .sign(|message: &UnsignedBolt12Invoice|
88 //! Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
90 //! .expect(\"failed verifying signature\")
91 //! .write(&mut buffer)
98 use alloc::str::FromStr;
99 use alloc::string::String;
100 use core::ffi::c_void;
101 use core::convert::Infallible;
102 use bitcoin::hashes::Hash;
103 use crate::c_types::*;
104 #[cfg(feature="no-std")]
105 use alloc::{vec::Vec, boxed::Box};
108 use lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder as nativeInvoiceWithExplicitSigningPubkeyBuilderImport;
109 pub(crate) type nativeInvoiceWithExplicitSigningPubkeyBuilder = nativeInvoiceWithExplicitSigningPubkeyBuilderImport<'static, >;
111 /// Builds a [`Bolt12Invoice`] from either:
112 /// - an [`InvoiceRequest`] for the \"offer to be paid\" flow or
113 /// - a [`Refund`] for the \"offer for money\" flow.
115 /// See [module-level documentation] for usage.
117 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
118 /// [`Refund`]: crate::offers::refund::Refund
119 /// [module-level documentation]: self
122 pub struct InvoiceWithExplicitSigningPubkeyBuilder {
123 /// A pointer to the opaque Rust object.
125 /// Nearly everywhere, inner must be non-null, however in places where
126 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
127 pub inner: *mut nativeInvoiceWithExplicitSigningPubkeyBuilder,
128 /// Indicates that this is the only struct which contains the same pointer.
130 /// Rust functions which take ownership of an object provided via an argument require
131 /// this to be true and invalidate the object pointed to by inner.
135 impl Drop for InvoiceWithExplicitSigningPubkeyBuilder {
137 if self.is_owned && !<*mut nativeInvoiceWithExplicitSigningPubkeyBuilder>::is_null(self.inner) {
138 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
142 /// Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL.
144 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_free(this_obj: InvoiceWithExplicitSigningPubkeyBuilder) { }
146 /// Used only if an object of this type is returned as a trait impl by a method
147 pub(crate) extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_free_void(this_ptr: *mut c_void) {
148 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceWithExplicitSigningPubkeyBuilder) };
151 impl InvoiceWithExplicitSigningPubkeyBuilder {
152 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceWithExplicitSigningPubkeyBuilder {
153 unsafe { &*ObjOps::untweak_ptr(self.inner) }
155 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceWithExplicitSigningPubkeyBuilder {
156 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
158 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
159 pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceWithExplicitSigningPubkeyBuilder {
160 assert!(self.is_owned);
161 let ret = ObjOps::untweak_ptr(self.inner);
162 self.inner = core::ptr::null_mut();
167 use lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder as nativeInvoiceWithDerivedSigningPubkeyBuilderImport;
168 pub(crate) type nativeInvoiceWithDerivedSigningPubkeyBuilder = nativeInvoiceWithDerivedSigningPubkeyBuilderImport<'static, >;
170 /// Builds a [`Bolt12Invoice`] from either:
171 /// - an [`InvoiceRequest`] for the \"offer to be paid\" flow or
172 /// - a [`Refund`] for the \"offer for money\" flow.
174 /// See [module-level documentation] for usage.
176 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
177 /// [`Refund`]: crate::offers::refund::Refund
178 /// [module-level documentation]: self
181 pub struct InvoiceWithDerivedSigningPubkeyBuilder {
182 /// A pointer to the opaque Rust object.
184 /// Nearly everywhere, inner must be non-null, however in places where
185 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
186 pub inner: *mut nativeInvoiceWithDerivedSigningPubkeyBuilder,
187 /// Indicates that this is the only struct which contains the same pointer.
189 /// Rust functions which take ownership of an object provided via an argument require
190 /// this to be true and invalidate the object pointed to by inner.
194 impl Drop for InvoiceWithDerivedSigningPubkeyBuilder {
196 if self.is_owned && !<*mut nativeInvoiceWithDerivedSigningPubkeyBuilder>::is_null(self.inner) {
197 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
201 /// Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL.
203 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_free(this_obj: InvoiceWithDerivedSigningPubkeyBuilder) { }
205 /// Used only if an object of this type is returned as a trait impl by a method
206 pub(crate) extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_free_void(this_ptr: *mut c_void) {
207 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceWithDerivedSigningPubkeyBuilder) };
210 impl InvoiceWithDerivedSigningPubkeyBuilder {
211 pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceWithDerivedSigningPubkeyBuilder {
212 unsafe { &*ObjOps::untweak_ptr(self.inner) }
214 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceWithDerivedSigningPubkeyBuilder {
215 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
217 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
218 pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceWithDerivedSigningPubkeyBuilder {
219 assert!(self.is_owned);
220 let ret = ObjOps::untweak_ptr(self.inner);
221 self.inner = core::ptr::null_mut();
225 /// Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by
226 /// [`UnsignedBolt12Invoice::sign`].
229 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_build(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) -> crate::c_types::derived::CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ {
230 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build();
231 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
235 /// Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
236 /// Any expiry that has already passed is valid and can be checked for using
237 /// [`Bolt12Invoice::is_expired`].
239 /// Successive calls to this method will override the previous setting.
242 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, mut relative_expiry_secs: u32) {
243 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).relative_expiry(relative_expiry_secs);
247 /// Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
249 /// Successive calls to this method will add another address. Caller is responsible for not
250 /// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
253 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, script_hash: *const [u8; 32]) {
254 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone())));
258 /// Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
260 /// Successive calls to this method will add another address. Caller is responsible for not
261 /// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
264 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) {
265 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone())));
269 /// Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
271 /// Successive calls to this method will add another address. Caller is responsible for not
272 /// adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
275 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, mut output_key: crate::c_types::TweakedPublicKey) {
276 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v1_p2tr_tweaked(&output_key.into_rust());
280 /// Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
284 pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) {
285 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).allow_mpp();
289 /// Builds a signed [`Bolt12Invoice`] after checking for valid semantics.
292 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) -> crate::c_types::derived::CResult_Bolt12InvoiceBolt12SemanticErrorZ {
293 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build_and_sign(secp256k1::global::SECP256K1);
294 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
298 /// Sets the [`Bolt12Invoice::relative_expiry`] as seconds since [`Bolt12Invoice::created_at`].
299 /// Any expiry that has already passed is valid and can be checked for using
300 /// [`Bolt12Invoice::is_expired`].
302 /// Successive calls to this method will override the previous setting.
305 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, mut relative_expiry_secs: u32) {
306 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).relative_expiry(relative_expiry_secs);
310 /// Adds a P2WSH address to [`Bolt12Invoice::fallbacks`].
312 /// Successive calls to this method will add another address. Caller is responsible for not
313 /// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses.
316 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, script_hash: *const [u8; 32]) {
317 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone())));
321 /// Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`].
323 /// Successive calls to this method will add another address. Caller is responsible for not
324 /// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses.
327 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) {
328 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone())));
332 /// Adds a P2TR address to [`Bolt12Invoice::fallbacks`].
334 /// Successive calls to this method will add another address. Caller is responsible for not
335 /// adding duplicate addresses and only calling if capable of receiving to P2TR addresses.
338 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, mut output_key: crate::c_types::TweakedPublicKey) {
339 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v1_p2tr_tweaked(&output_key.into_rust());
343 /// Sets [`Bolt12Invoice::invoice_features`] to indicate MPP may be used. Otherwise, MPP is
347 pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) {
348 let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).allow_mpp();
353 use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport;
354 pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport;
356 /// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
360 /// This is serialized as a TLV stream, which includes TLV records from the originating message. As
361 /// such, it may include unknown, odd TLV records.
364 pub struct UnsignedBolt12Invoice {
365 /// A pointer to the opaque Rust object.
367 /// Nearly everywhere, inner must be non-null, however in places where
368 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
369 pub inner: *mut nativeUnsignedBolt12Invoice,
370 /// Indicates that this is the only struct which contains the same pointer.
372 /// Rust functions which take ownership of an object provided via an argument require
373 /// this to be true and invalidate the object pointed to by inner.
377 impl Drop for UnsignedBolt12Invoice {
379 if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) {
380 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
384 /// Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL.
386 pub extern "C" fn UnsignedBolt12Invoice_free(this_obj: UnsignedBolt12Invoice) { }
388 /// Used only if an object of this type is returned as a trait impl by a method
389 pub(crate) extern "C" fn UnsignedBolt12Invoice_free_void(this_ptr: *mut c_void) {
390 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedBolt12Invoice) };
393 impl UnsignedBolt12Invoice {
394 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedBolt12Invoice {
395 unsafe { &*ObjOps::untweak_ptr(self.inner) }
397 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedBolt12Invoice {
398 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
400 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
401 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedBolt12Invoice {
402 assert!(self.is_owned);
403 let ret = ObjOps::untweak_ptr(self.inner);
404 self.inner = core::ptr::null_mut();
408 impl Clone for UnsignedBolt12Invoice {
409 fn clone(&self) -> Self {
411 inner: if <*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
412 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
418 /// Used only if an object of this type is returned as a trait impl by a method
419 pub(crate) extern "C" fn UnsignedBolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
420 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedBolt12Invoice)).clone() })) as *mut c_void
423 /// Creates a copy of the UnsignedBolt12Invoice
424 pub extern "C" fn UnsignedBolt12Invoice_clone(orig: &UnsignedBolt12Invoice) -> UnsignedBolt12Invoice {
427 /// A function for signing an [`UnsignedBolt12Invoice`].
429 pub struct SignBolt12InvoiceFn {
430 /// An opaque pointer which is passed to your function implementations as an argument.
431 /// This has no meaning in the LDK, and can be NULL or any other value.
432 pub this_arg: *mut c_void,
433 /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
434 pub sign_invoice: extern "C" fn (this_arg: *const c_void, message: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ,
435 /// Frees any resources associated with this object given its this_arg pointer.
436 /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
437 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
439 unsafe impl Send for SignBolt12InvoiceFn {}
440 unsafe impl Sync for SignBolt12InvoiceFn {}
442 pub(crate) fn SignBolt12InvoiceFn_clone_fields(orig: &SignBolt12InvoiceFn) -> SignBolt12InvoiceFn {
443 SignBolt12InvoiceFn {
444 this_arg: orig.this_arg,
445 sign_invoice: Clone::clone(&orig.sign_invoice),
446 free: Clone::clone(&orig.free),
450 use lightning::offers::invoice::SignBolt12InvoiceFn as rustSignBolt12InvoiceFn;
451 impl rustSignBolt12InvoiceFn for SignBolt12InvoiceFn {
452 fn sign_invoice(&self, mut message: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result<bitcoin::secp256k1::schnorr::Signature, ()> {
453 let mut ret = (self.sign_invoice)(self.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) as *mut _) }, is_owned: false });
454 let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })};
459 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
460 // directly as a Deref trait in higher-level structs:
461 impl core::ops::Deref for SignBolt12InvoiceFn {
463 fn deref(&self) -> &Self {
467 impl core::ops::DerefMut for SignBolt12InvoiceFn {
468 fn deref_mut(&mut self) -> &mut Self {
472 /// Calls the free function if one is set
474 pub extern "C" fn SignBolt12InvoiceFn_free(this_ptr: SignBolt12InvoiceFn) { }
475 impl Drop for SignBolt12InvoiceFn {
477 if let Some(f) = self.free {
482 /// Returns the [`TaggedHash`] of the invoice to sign.
485 pub extern "C" fn UnsignedBolt12Invoice_tagged_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::merkle::TaggedHash {
486 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tagged_hash();
487 crate::lightning::offers::merkle::TaggedHash { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::offers::merkle::TaggedHash<>) as *mut _) }, is_owned: false }
491 use lightning::offers::invoice::Bolt12Invoice as nativeBolt12InvoiceImport;
492 pub(crate) type nativeBolt12Invoice = nativeBolt12InvoiceImport;
494 /// A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`].
496 /// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent
497 /// directly after scanning a refund. It includes all the information needed to pay a recipient.
499 /// [`Offer`]: crate::offers::offer::Offer
500 /// [`Refund`]: crate::offers::refund::Refund
501 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
504 pub struct Bolt12Invoice {
505 /// A pointer to the opaque Rust object.
507 /// Nearly everywhere, inner must be non-null, however in places where
508 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
509 pub inner: *mut nativeBolt12Invoice,
510 /// Indicates that this is the only struct which contains the same pointer.
512 /// Rust functions which take ownership of an object provided via an argument require
513 /// this to be true and invalidate the object pointed to by inner.
517 impl Drop for Bolt12Invoice {
519 if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) {
520 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
524 /// Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL.
526 pub extern "C" fn Bolt12Invoice_free(this_obj: Bolt12Invoice) { }
528 /// Used only if an object of this type is returned as a trait impl by a method
529 pub(crate) extern "C" fn Bolt12Invoice_free_void(this_ptr: *mut c_void) {
530 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12Invoice) };
534 pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12Invoice {
535 unsafe { &*ObjOps::untweak_ptr(self.inner) }
537 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12Invoice {
538 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
540 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
541 pub(crate) fn take_inner(mut self) -> *mut nativeBolt12Invoice {
542 assert!(self.is_owned);
543 let ret = ObjOps::untweak_ptr(self.inner);
544 self.inner = core::ptr::null_mut();
548 impl Clone for Bolt12Invoice {
549 fn clone(&self) -> Self {
551 inner: if <*mut nativeBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
552 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
558 /// Used only if an object of this type is returned as a trait impl by a method
559 pub(crate) extern "C" fn Bolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
560 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12Invoice)).clone() })) as *mut c_void
563 /// Creates a copy of the Bolt12Invoice
564 pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice {
567 /// Get a string which allows debug introspection of a Bolt12Invoice object
568 pub extern "C" fn Bolt12Invoice_debug_str_void(o: *const c_void) -> Str {
569 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::Bolt12Invoice }).into()}
570 /// The chains that may be used when paying a requested invoice.
572 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
574 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
577 pub extern "C" fn UnsignedBolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
578 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
579 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() }) };
583 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
584 /// invoice originated from an offer.
586 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
588 /// [`offer_chains`]: Self::offer_chains
589 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
592 pub extern "C" fn UnsignedBolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
593 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
594 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
597 /// Opaque bytes set by the originating [`Offer`].
599 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
600 /// if the [`Offer`] did not set it.
602 /// [`Offer`]: crate::offers::offer::Offer
603 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
606 pub extern "C" fn UnsignedBolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
607 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
608 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() }) };
612 /// The minimum amount required for a successful payment of a single item.
614 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
615 /// the [`Offer`] did not set it.
617 /// [`Offer`]: crate::offers::offer::Offer
618 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
621 pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_AmountZ {
622 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
623 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) };
627 /// Features pertaining to the originating [`Offer`].
629 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
632 /// [`Offer`]: crate::offers::offer::Offer
633 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
635 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
638 pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
639 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
640 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 };
644 /// A complete description of the purpose of the originating offer or refund.
646 /// From [`Offer::description`] or [`Refund::description`].
648 /// [`Offer::description`]: crate::offers::offer::Offer::description
650 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
653 pub extern "C" fn UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
654 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
655 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 };
659 /// Duration since the Unix epoch when an invoice should no longer be requested.
661 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
663 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
666 pub extern "C" fn UnsignedBolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
667 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
668 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() }) };
672 /// The issuer of the offer or refund.
674 /// From [`Offer::issuer`] or [`Refund::issuer`].
676 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
678 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
681 pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
682 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
683 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 };
687 /// Paths to the recipient originating from publicly reachable nodes.
689 /// From [`Offer::paths`] or [`Refund::paths`].
691 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
694 pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
695 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
696 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 } }); };
700 /// The quantity of items supported.
702 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
705 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
708 pub extern "C" fn UnsignedBolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_QuantityZ {
709 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
710 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_QuantityZ::None } else { crate::c_types::derived::COption_QuantityZ::Some( { crate::lightning::offers::offer::Quantity::native_into(ret.unwrap()) }) };
714 /// An unpredictable series of bytes from the payer.
716 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
719 pub extern "C" fn UnsignedBolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::u8slice {
720 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
721 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
725 /// Features pertaining to requesting an invoice.
727 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
730 pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
731 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
732 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
735 /// The quantity of items requested or refunded for.
737 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
740 pub extern "C" fn UnsignedBolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
741 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
742 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() }) };
746 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
747 /// refund in case there are no [`message_paths`].
749 /// [`message_paths`]: Self::message_paths
752 pub extern "C" fn UnsignedBolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
753 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
754 crate::c_types::PublicKey::from_rust(&ret)
757 /// A payer-provided note reflected back in the invoice.
759 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
761 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
764 pub extern "C" fn UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
765 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
766 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 };
770 /// Duration since the Unix epoch when the invoice was created.
773 pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
774 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
778 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
779 /// should no longer be paid.
782 pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
783 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
787 /// Whether the invoice has expired.
790 pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool {
791 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
795 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
798 pub extern "C" fn UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
799 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
800 crate::c_types::ThirtyTwoBytes { data: ret.0 }
803 /// The minimum amount required for a successful payment of the invoice.
806 pub extern "C" fn UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
807 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
811 /// Features pertaining to paying an invoice.
814 pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
815 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
816 crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
819 /// The public key corresponding to the key used to sign the invoice.
822 pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
823 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
824 crate::c_types::PublicKey::from_rust(&ret)
827 /// The chains that may be used when paying a requested invoice.
829 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
831 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
834 pub extern "C" fn Bolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
835 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
836 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() }) };
840 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
841 /// invoice originated from an offer.
843 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
845 /// [`offer_chains`]: Self::offer_chains
846 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
849 pub extern "C" fn Bolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
850 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
851 crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() }
854 /// Opaque bytes set by the originating [`Offer`].
856 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
857 /// if the [`Offer`] did not set it.
859 /// [`Offer`]: crate::offers::offer::Offer
860 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
863 pub extern "C" fn Bolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
864 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
865 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() }) };
869 /// The minimum amount required for a successful payment of a single item.
871 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
872 /// the [`Offer`] did not set it.
874 /// [`Offer`]: crate::offers::offer::Offer
875 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
878 pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_AmountZ {
879 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
880 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) };
884 /// Features pertaining to the originating [`Offer`].
886 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
889 /// [`Offer`]: crate::offers::offer::Offer
890 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
892 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
895 pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
896 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
897 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 };
901 /// A complete description of the purpose of the originating offer or refund.
903 /// From [`Offer::description`] or [`Refund::description`].
905 /// [`Offer::description`]: crate::offers::offer::Offer::description
907 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
910 pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
911 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
912 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 };
916 /// Duration since the Unix epoch when an invoice should no longer be requested.
918 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
920 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
923 pub extern "C" fn Bolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
924 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
925 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap().as_secs() }) };
929 /// The issuer of the offer or refund.
931 /// From [`Offer::issuer`] or [`Refund::issuer`].
933 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
935 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
938 pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
939 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
940 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 };
944 /// Paths to the recipient originating from publicly reachable nodes.
946 /// From [`Offer::paths`] or [`Refund::paths`].
948 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
951 pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
952 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
953 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 } }); };
957 /// The quantity of items supported.
959 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
962 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
965 pub extern "C" fn Bolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_QuantityZ {
966 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
967 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_QuantityZ::None } else { crate::c_types::derived::COption_QuantityZ::Some( { crate::lightning::offers::offer::Quantity::native_into(ret.unwrap()) }) };
971 /// An unpredictable series of bytes from the payer.
973 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
976 pub extern "C" fn Bolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::u8slice {
977 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
978 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
982 /// Features pertaining to requesting an invoice.
984 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
987 pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
988 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
989 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
992 /// The quantity of items requested or refunded for.
994 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
997 pub extern "C" fn Bolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
998 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
999 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() }) };
1003 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
1004 /// refund in case there are no [`message_paths`].
1006 /// [`message_paths`]: Self::message_paths
1009 pub extern "C" fn Bolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
1010 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
1011 crate::c_types::PublicKey::from_rust(&ret)
1014 /// A payer-provided note reflected back in the invoice.
1016 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
1018 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1021 pub extern "C" fn Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
1022 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
1023 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 };
1027 /// Duration since the Unix epoch when the invoice was created.
1030 pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
1031 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
1035 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
1036 /// should no longer be paid.
1039 pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
1040 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
1044 /// Whether the invoice has expired.
1047 pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool {
1048 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
1052 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
1055 pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
1056 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
1057 crate::c_types::ThirtyTwoBytes { data: ret.0 }
1060 /// The minimum amount required for a successful payment of the invoice.
1063 pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
1064 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
1068 /// Features pertaining to paying an invoice.
1071 pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
1072 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
1073 crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
1076 /// The public key corresponding to the key used to sign the invoice.
1079 pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
1080 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
1081 crate::c_types::PublicKey::from_rust(&ret)
1084 /// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
1087 pub extern "C" fn Bolt12Invoice_signature(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::SchnorrSignature {
1088 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
1089 crate::c_types::SchnorrSignature::from_rust(&ret)
1092 /// Hash that was used for signing the invoice.
1095 pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
1096 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
1097 crate::c_types::ThirtyTwoBytes { data: ret }
1100 /// Verifies that the invoice was for a request or refund created using the given key. Returns
1101 /// the associated [`PaymentId`] to use when sending the payment.
1104 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 {
1105 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1);
1106 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() };
1110 /// Generates a non-cryptographic 64-bit hash of the Bolt12Invoice.
1112 pub extern "C" fn Bolt12Invoice_hash(o: &Bolt12Invoice) -> u64 {
1113 if o.inner.is_null() { return 0; }
1114 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1115 #[allow(deprecated)]
1116 let mut hasher = core::hash::SipHasher::new();
1117 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1118 core::hash::Hasher::finish(&hasher)
1121 /// Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read
1122 pub extern "C" fn UnsignedBolt12Invoice_write(obj: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
1123 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1126 pub(crate) extern "C" fn UnsignedBolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1127 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedBolt12Invoice) })
1130 /// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
1131 pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
1132 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1135 pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1136 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) })
1139 use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport;
1140 pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport;
1142 /// Information needed to route a payment across a [`BlindedPath`].
1145 pub struct BlindedPayInfo {
1146 /// A pointer to the opaque Rust object.
1148 /// Nearly everywhere, inner must be non-null, however in places where
1149 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1150 pub inner: *mut nativeBlindedPayInfo,
1151 /// Indicates that this is the only struct which contains the same pointer.
1153 /// Rust functions which take ownership of an object provided via an argument require
1154 /// this to be true and invalidate the object pointed to by inner.
1158 impl Drop for BlindedPayInfo {
1159 fn drop(&mut self) {
1160 if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) {
1161 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1165 /// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL.
1167 pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { }
1169 /// Used only if an object of this type is returned as a trait impl by a method
1170 pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) {
1171 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) };
1174 impl BlindedPayInfo {
1175 pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo {
1176 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1178 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo {
1179 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1181 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1182 pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo {
1183 assert!(self.is_owned);
1184 let ret = ObjOps::untweak_ptr(self.inner);
1185 self.inner = core::ptr::null_mut();
1189 /// Base fee charged (in millisatoshi) for the entire blinded path.
1191 pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 {
1192 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
1195 /// Base fee charged (in millisatoshi) for the entire blinded path.
1197 pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) {
1198 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
1200 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
1201 /// (i.e., 10,000 is 1%).
1203 pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 {
1204 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
1207 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
1208 /// (i.e., 10,000 is 1%).
1210 pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) {
1211 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
1213 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
1216 pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 {
1217 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
1220 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
1223 pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) {
1224 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
1226 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1227 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1228 /// seen by the recipient.
1230 pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 {
1231 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
1234 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1235 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1236 /// seen by the recipient.
1238 pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
1239 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
1241 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1242 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1243 /// seen by the recipient.
1245 pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 {
1246 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
1249 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
1250 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
1251 /// seen by the recipient.
1253 pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
1254 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
1256 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
1259 pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures {
1260 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
1261 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 }
1263 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
1266 pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
1267 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
1269 /// Constructs a new BlindedPayInfo given each field
1272 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 {
1273 BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo {
1274 fee_base_msat: fee_base_msat_arg,
1275 fee_proportional_millionths: fee_proportional_millionths_arg,
1276 cltv_expiry_delta: cltv_expiry_delta_arg,
1277 htlc_minimum_msat: htlc_minimum_msat_arg,
1278 htlc_maximum_msat: htlc_maximum_msat_arg,
1279 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1280 }), is_owned: true }
1282 impl Clone for BlindedPayInfo {
1283 fn clone(&self) -> Self {
1285 inner: if <*mut nativeBlindedPayInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
1286 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1292 /// Used only if an object of this type is returned as a trait impl by a method
1293 pub(crate) extern "C" fn BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
1294 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void
1297 /// Creates a copy of the BlindedPayInfo
1298 pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo {
1301 /// Get a string which allows debug introspection of a BlindedPayInfo object
1302 pub extern "C" fn BlindedPayInfo_debug_str_void(o: *const c_void) -> Str {
1303 alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::BlindedPayInfo }).into()}
1304 /// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo.
1306 pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 {
1307 if o.inner.is_null() { return 0; }
1308 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
1309 #[allow(deprecated)]
1310 let mut hasher = core::hash::SipHasher::new();
1311 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
1312 core::hash::Hasher::finish(&hasher)
1314 /// Checks if two BlindedPayInfos contain equal inner contents.
1315 /// This ignores pointers and is_owned flags and looks at the values in fields.
1316 /// Two objects with NULL inner values will be considered "equal" here.
1318 pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool {
1319 if a.inner == b.inner { return true; }
1320 if a.inner.is_null() || b.inner.is_null() { return false; }
1321 if a.get_native_ref() == b.get_native_ref() { true } else { false }
1324 /// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read
1325 pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z {
1326 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1329 pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1330 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) })
1333 /// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write
1334 pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ {
1335 let res: Result<lightning::offers::invoice::BlindedPayInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1336 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() };