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::util::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>(|digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys)))
55 //! .expect(\"failed verifying signature\")
56 //! .write(&mut buffer)
61 //! # fn parse_refund(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::Bolt12ParseError> {
62 //! # let payment_paths = create_payment_paths();
63 //! # let payment_hash = create_payment_hash();
64 //! # let secp_ctx = Secp256k1::new();
65 //! # let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?);
66 //! # let pubkey = PublicKey::from(keys);
67 //! # let wpubkey_hash = bitcoin::util::key::PublicKey::new(pubkey).wpubkey_hash().unwrap();
68 //! # let mut buffer = Vec::new();
70 //! // Invoice for the \"offer for money\" flow.
71 //! \"lnr1qcp4256ypq\"
72 //! .parse::<Refund>()?
74 //! .respond_with(payment_paths, payment_hash, pubkey)?
76 //! .relative_expiry(3600)
78 //! .fallback_v0_p2wpkh(&wpubkey_hash)
80 //! .sign::<_, Infallible>(|digest| Ok(secp_ctx.sign_schnorr_no_aux_rand(digest, &keys)))
81 //! .expect(\"failed verifying signature\")
82 //! .write(&mut buffer)
89 use alloc::str::FromStr;
90 use core::ffi::c_void;
91 use core::convert::Infallible;
92 use bitcoin::hashes::Hash;
93 use crate::c_types::*;
94 #[cfg(feature="no-std")]
95 use alloc::{vec::Vec, boxed::Box};
98 use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport;
99 pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport<'static>;
101 /// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
104 pub struct UnsignedBolt12Invoice {
105 /// A pointer to the opaque Rust object.
107 /// Nearly everywhere, inner must be non-null, however in places where
108 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
109 pub inner: *mut nativeUnsignedBolt12Invoice,
110 /// Indicates that this is the only struct which contains the same pointer.
112 /// Rust functions which take ownership of an object provided via an argument require
113 /// this to be true and invalidate the object pointed to by inner.
117 impl Drop for UnsignedBolt12Invoice {
119 if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) {
120 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
124 /// Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL.
126 pub extern "C" fn UnsignedBolt12Invoice_free(this_obj: UnsignedBolt12Invoice) { }
128 /// Used only if an object of this type is returned as a trait impl by a method
129 pub(crate) extern "C" fn UnsignedBolt12Invoice_free_void(this_ptr: *mut c_void) {
130 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnsignedBolt12Invoice) };
133 impl UnsignedBolt12Invoice {
134 pub(crate) fn get_native_ref(&self) -> &'static nativeUnsignedBolt12Invoice {
135 unsafe { &*ObjOps::untweak_ptr(self.inner) }
137 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnsignedBolt12Invoice {
138 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
140 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
141 pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedBolt12Invoice {
142 assert!(self.is_owned);
143 let ret = ObjOps::untweak_ptr(self.inner);
144 self.inner = core::ptr::null_mut();
148 /// The public key corresponding to the key needed to sign the invoice.
151 pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
152 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
153 crate::c_types::PublicKey::from_rust(&ret)
157 use lightning::offers::invoice::Bolt12Invoice as nativeBolt12InvoiceImport;
158 pub(crate) type nativeBolt12Invoice = nativeBolt12InvoiceImport;
160 /// A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`].
162 /// An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent
163 /// directly after scanning a refund. It includes all the information needed to pay a recipient.
165 /// [`Offer`]: crate::offers::offer::Offer
166 /// [`Refund`]: crate::offers::refund::Refund
167 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
170 pub struct Bolt12Invoice {
171 /// A pointer to the opaque Rust object.
173 /// Nearly everywhere, inner must be non-null, however in places where
174 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
175 pub inner: *mut nativeBolt12Invoice,
176 /// Indicates that this is the only struct which contains the same pointer.
178 /// Rust functions which take ownership of an object provided via an argument require
179 /// this to be true and invalidate the object pointed to by inner.
183 impl Drop for Bolt12Invoice {
185 if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) {
186 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
190 /// Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL.
192 pub extern "C" fn Bolt12Invoice_free(this_obj: Bolt12Invoice) { }
194 /// Used only if an object of this type is returned as a trait impl by a method
195 pub(crate) extern "C" fn Bolt12Invoice_free_void(this_ptr: *mut c_void) {
196 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12Invoice) };
200 pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12Invoice {
201 unsafe { &*ObjOps::untweak_ptr(self.inner) }
203 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12Invoice {
204 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
206 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
207 pub(crate) fn take_inner(mut self) -> *mut nativeBolt12Invoice {
208 assert!(self.is_owned);
209 let ret = ObjOps::untweak_ptr(self.inner);
210 self.inner = core::ptr::null_mut();
214 impl Clone for Bolt12Invoice {
215 fn clone(&self) -> Self {
217 inner: if <*mut nativeBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else {
218 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
224 /// Used only if an object of this type is returned as a trait impl by a method
225 pub(crate) extern "C" fn Bolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void {
226 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBolt12Invoice)).clone() })) as *mut c_void
229 /// Creates a copy of the Bolt12Invoice
230 pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice {
233 /// A complete description of the purpose of the originating offer or refund. Intended to be
234 /// displayed to the user but with the caveat that it has not been verified in any way.
237 pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
238 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
239 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
242 /// Duration since the Unix epoch when the invoice was created.
245 pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
246 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
250 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
251 /// should no longer be paid.
254 pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
255 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
259 /// Whether the invoice has expired.
262 pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool {
263 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
267 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
270 pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
271 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
272 crate::c_types::ThirtyTwoBytes { data: ret.0 }
275 /// The minimum amount required for a successful payment of the invoice.
278 pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
279 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
283 /// Features pertaining to paying an invoice.
286 pub extern "C" fn Bolt12Invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
287 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
288 crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
291 /// The public key corresponding to the key used to sign the invoice.
294 pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
295 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
296 crate::c_types::PublicKey::from_rust(&ret)
299 /// Hash that was used for signing the invoice.
302 pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
303 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
304 crate::c_types::ThirtyTwoBytes { data: ret }
307 /// Verifies that the invoice was for a request or refund created using the given key.
310 pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> bool {
311 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1);
316 /// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
317 pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
318 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
321 pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
322 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) })
325 use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport;
326 pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport;
328 /// Information needed to route a payment across a [`BlindedPath`].
331 pub struct BlindedPayInfo {
332 /// A pointer to the opaque Rust object.
334 /// Nearly everywhere, inner must be non-null, however in places where
335 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
336 pub inner: *mut nativeBlindedPayInfo,
337 /// Indicates that this is the only struct which contains the same pointer.
339 /// Rust functions which take ownership of an object provided via an argument require
340 /// this to be true and invalidate the object pointed to by inner.
344 impl Drop for BlindedPayInfo {
346 if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) {
347 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
351 /// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL.
353 pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { }
355 /// Used only if an object of this type is returned as a trait impl by a method
356 pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) {
357 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) };
360 impl BlindedPayInfo {
361 pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo {
362 unsafe { &*ObjOps::untweak_ptr(self.inner) }
364 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo {
365 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
367 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
368 pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo {
369 assert!(self.is_owned);
370 let ret = ObjOps::untweak_ptr(self.inner);
371 self.inner = core::ptr::null_mut();
375 /// Base fee charged (in millisatoshi) for the entire blinded path.
377 pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 {
378 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
381 /// Base fee charged (in millisatoshi) for the entire blinded path.
383 pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) {
384 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
386 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
387 /// (i.e., 10,000 is 1%).
389 pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 {
390 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
393 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
394 /// (i.e., 10,000 is 1%).
396 pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) {
397 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
399 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
402 pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 {
403 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
406 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
409 pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) {
410 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
412 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
413 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
414 /// seen by the recipient.
416 pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 {
417 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
420 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
421 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
422 /// seen by the recipient.
424 pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
425 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
427 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
428 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
429 /// seen by the recipient.
431 pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 {
432 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
435 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
436 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
437 /// seen by the recipient.
439 pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
440 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
442 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
445 pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures {
446 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
447 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 }
449 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
452 pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
453 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
455 /// Constructs a new BlindedPayInfo given each field
458 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 {
459 BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo {
460 fee_base_msat: fee_base_msat_arg,
461 fee_proportional_millionths: fee_proportional_millionths_arg,
462 cltv_expiry_delta: cltv_expiry_delta_arg,
463 htlc_minimum_msat: htlc_minimum_msat_arg,
464 htlc_maximum_msat: htlc_maximum_msat_arg,
465 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
468 impl Clone for BlindedPayInfo {
469 fn clone(&self) -> Self {
471 inner: if <*mut nativeBlindedPayInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
472 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
478 /// Used only if an object of this type is returned as a trait impl by a method
479 pub(crate) extern "C" fn BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
480 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBlindedPayInfo)).clone() })) as *mut c_void
483 /// Creates a copy of the BlindedPayInfo
484 pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo {
487 /// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo.
489 pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 {
490 if o.inner.is_null() { return 0; }
491 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
493 let mut hasher = core::hash::SipHasher::new();
494 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
495 core::hash::Hasher::finish(&hasher)
497 /// Checks if two BlindedPayInfos contain equal inner contents.
498 /// This ignores pointers and is_owned flags and looks at the values in fields.
499 /// Two objects with NULL inner values will be considered "equal" here.
501 pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool {
502 if a.inner == b.inner { return true; }
503 if a.inner.is_null() || b.inner.is_null() { return false; }
504 if a.get_native_ref() == b.get_native_ref() { true } else { false }
507 /// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read
508 pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z {
509 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
512 pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
513 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) })
516 /// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write
517 pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ {
518 let res: Result<lightning::offers::invoice::BlindedPayInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
519 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() };