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>(
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::util::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 /// The chains that may be used when paying a requested invoice.
245 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
247 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
250 pub extern "C" fn UnsignedBolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
251 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
252 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.to_bytes() } }); }; local_ret_0.into() }) };
256 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
257 /// invoice originated from an offer.
259 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
261 /// [`offer_chains`]: Self::offer_chains
262 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
265 pub extern "C" fn UnsignedBolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
266 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
267 crate::c_types::ThirtyTwoBytes { data: ret.to_bytes() }
270 /// Opaque bytes set by the originating [`Offer`].
272 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
273 /// if the [`Offer`] did not set it.
275 /// [`Offer`]: crate::offers::offer::Offer
276 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
279 pub extern "C" fn UnsignedBolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
280 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
281 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() }) };
285 /// The minimum amount required for a successful payment of a single item.
287 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
288 /// the [`Offer`] did not set it.
290 /// [`Offer`]: crate::offers::offer::Offer
291 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
293 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
296 pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::offer::Amount {
297 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
298 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 };
302 /// Features pertaining to the originating [`Offer`].
304 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
307 /// [`Offer`]: crate::offers::offer::Offer
308 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
310 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
313 pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
314 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
315 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 };
319 /// A complete description of the purpose of the originating offer or refund.
321 /// From [`Offer::description`] or [`Refund::description`].
323 /// [`Offer::description`]: crate::offers::offer::Offer::description
326 pub extern "C" fn UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
327 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
328 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
331 /// Duration since the Unix epoch when an invoice should no longer be requested.
333 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
335 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
338 pub extern "C" fn UnsignedBolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
339 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
340 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() }) };
344 /// The issuer of the offer or refund.
346 /// From [`Offer::issuer`] or [`Refund::issuer`].
348 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
350 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
353 pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
354 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
355 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 };
359 /// Paths to the recipient originating from publicly reachable nodes.
361 /// From [`Offer::paths`] or [`Refund::paths`].
363 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
366 pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
367 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
368 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 } }); };
372 /// The quantity of items supported.
374 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
377 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
379 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
382 pub extern "C" fn UnsignedBolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::offer::Quantity {
383 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
384 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 };
388 /// An unpredictable series of bytes from the payer.
390 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
393 pub extern "C" fn UnsignedBolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::u8slice {
394 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
395 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
399 /// Features pertaining to requesting an invoice.
401 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
404 pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
405 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
406 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
409 /// The quantity of items requested or refunded for.
411 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
414 pub extern "C" fn UnsignedBolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_u64Z {
415 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
416 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() }) };
420 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
421 /// refund in case there are no [`message_paths`].
423 /// [`message_paths`]: Self::message_paths
426 pub extern "C" fn UnsignedBolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
427 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
428 crate::c_types::PublicKey::from_rust(&ret)
431 /// A payer-provided note reflected back in the invoice.
433 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
435 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
438 pub extern "C" fn UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString {
439 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
440 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 };
444 /// Duration since the Unix epoch when the invoice was created.
447 pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
448 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
452 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
453 /// should no longer be paid.
456 pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
457 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
461 /// Whether the invoice has expired.
464 pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool {
465 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
469 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
472 pub extern "C" fn UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
473 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
474 crate::c_types::ThirtyTwoBytes { data: ret.0 }
477 /// The minimum amount required for a successful payment of the invoice.
480 pub extern "C" fn UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 {
481 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
485 /// Features pertaining to paying an invoice.
488 pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
489 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
490 crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
493 /// The public key corresponding to the key used to sign the invoice.
496 pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey {
497 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
498 crate::c_types::PublicKey::from_rust(&ret)
501 /// The chains that may be used when paying a requested invoice.
503 /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
505 /// [`Offer::chains`]: crate::offers::offer::Offer::chains
508 pub extern "C" fn Bolt12Invoice_offer_chains(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
509 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_chains();
510 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.to_bytes() } }); }; local_ret_0.into() }) };
514 /// The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
515 /// invoice originated from an offer.
517 /// From [`InvoiceRequest::chain`] or [`Refund::chain`].
519 /// [`offer_chains`]: Self::offer_chains
520 /// [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
523 pub extern "C" fn Bolt12Invoice_chain(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
524 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chain();
525 crate::c_types::ThirtyTwoBytes { data: ret.to_bytes() }
528 /// Opaque bytes set by the originating [`Offer`].
530 /// From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
531 /// if the [`Offer`] did not set it.
533 /// [`Offer`]: crate::offers::offer::Offer
534 /// [`Offer::metadata`]: crate::offers::offer::Offer::metadata
537 pub extern "C" fn Bolt12Invoice_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_CVec_u8ZZ {
538 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.metadata();
539 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() }) };
543 /// The minimum amount required for a successful payment of a single item.
545 /// From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
546 /// the [`Offer`] did not set it.
548 /// [`Offer`]: crate::offers::offer::Offer
549 /// [`Offer::amount`]: crate::offers::offer::Offer::amount
551 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
554 pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::offers::offer::Amount {
555 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount();
556 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 };
560 /// Features pertaining to the originating [`Offer`].
562 /// From [`Offer::offer_features`]; `None` if the invoice was created in response to a
565 /// [`Offer`]: crate::offers::offer::Offer
566 /// [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
568 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
571 pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::OfferFeatures {
572 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features();
573 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 };
577 /// A complete description of the purpose of the originating offer or refund.
579 /// From [`Offer::description`] or [`Refund::description`].
581 /// [`Offer::description`]: crate::offers::offer::Offer::description
584 pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
585 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
586 crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true }
589 /// Duration since the Unix epoch when an invoice should no longer be requested.
591 /// From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
593 /// [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
596 pub extern "C" fn Bolt12Invoice_absolute_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
597 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.absolute_expiry();
598 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() }) };
602 /// The issuer of the offer or refund.
604 /// From [`Offer::issuer`] or [`Refund::issuer`].
606 /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer
608 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
611 pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
612 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer();
613 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 };
617 /// Paths to the recipient originating from publicly reachable nodes.
619 /// From [`Offer::paths`] or [`Refund::paths`].
621 /// [`Offer::paths`]: crate::offers::offer::Offer::paths
624 pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ {
625 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths();
626 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 } }); };
630 /// The quantity of items supported.
632 /// From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
635 /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
637 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
640 pub extern "C" fn Bolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::offers::offer::Quantity {
641 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity();
642 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 };
646 /// An unpredictable series of bytes from the payer.
648 /// From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
651 pub extern "C" fn Bolt12Invoice_payer_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::u8slice {
652 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_metadata();
653 let mut local_ret = crate::c_types::u8slice::from_slice(ret);
657 /// Features pertaining to requesting an invoice.
659 /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
662 pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures {
663 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features();
664 crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false }
667 /// The quantity of items requested or refunded for.
669 /// From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
672 pub extern "C" fn Bolt12Invoice_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_u64Z {
673 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.quantity();
674 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() }) };
678 /// A possibly transient pubkey used to sign the invoice request or to send an invoice for a
679 /// refund in case there are no [`message_paths`].
681 /// [`message_paths`]: Self::message_paths
684 pub extern "C" fn Bolt12Invoice_payer_id(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
685 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_id();
686 crate::c_types::PublicKey::from_rust(&ret)
689 /// A payer-provided note reflected back in the invoice.
691 /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
693 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
696 pub extern "C" fn Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString {
697 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note();
698 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 };
702 /// Duration since the Unix epoch when the invoice was created.
705 pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
706 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at();
710 /// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
711 /// should no longer be paid.
714 pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
715 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry();
719 /// Whether the invoice has expired.
722 pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool {
723 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired();
727 /// SHA256 hash of the payment preimage that will be given in return for paying the invoice.
730 pub extern "C" fn Bolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
731 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
732 crate::c_types::ThirtyTwoBytes { data: ret.0 }
735 /// The minimum amount required for a successful payment of the invoice.
738 pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 {
739 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats();
743 /// Features pertaining to paying an invoice.
746 pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures {
747 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features();
748 crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false }
751 /// The public key corresponding to the key used to sign the invoice.
754 pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey {
755 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey();
756 crate::c_types::PublicKey::from_rust(&ret)
759 /// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
762 pub extern "C" fn Bolt12Invoice_signature(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::SchnorrSignature {
763 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature();
764 crate::c_types::SchnorrSignature::from_rust(&ret)
767 /// Hash that was used for signing the invoice.
770 pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::ThirtyTwoBytes {
771 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signable_hash();
772 crate::c_types::ThirtyTwoBytes { data: ret }
775 /// Verifies that the invoice was for a request or refund created using the given key. Returns
776 /// the associated [`PaymentId`] to use when sending the payment.
779 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 {
780 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1);
781 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() };
786 /// Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read
787 pub extern "C" fn UnsignedBolt12Invoice_write(obj: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
788 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
791 pub(crate) extern "C" fn UnsignedBolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
792 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedBolt12Invoice) })
795 /// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
796 pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z {
797 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
800 pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
801 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) })
804 use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport;
805 pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport;
807 /// Information needed to route a payment across a [`BlindedPath`].
810 pub struct BlindedPayInfo {
811 /// A pointer to the opaque Rust object.
813 /// Nearly everywhere, inner must be non-null, however in places where
814 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
815 pub inner: *mut nativeBlindedPayInfo,
816 /// Indicates that this is the only struct which contains the same pointer.
818 /// Rust functions which take ownership of an object provided via an argument require
819 /// this to be true and invalidate the object pointed to by inner.
823 impl Drop for BlindedPayInfo {
825 if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) {
826 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
830 /// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL.
832 pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { }
834 /// Used only if an object of this type is returned as a trait impl by a method
835 pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) {
836 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) };
839 impl BlindedPayInfo {
840 pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo {
841 unsafe { &*ObjOps::untweak_ptr(self.inner) }
843 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo {
844 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
846 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
847 pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo {
848 assert!(self.is_owned);
849 let ret = ObjOps::untweak_ptr(self.inner);
850 self.inner = core::ptr::null_mut();
854 /// Base fee charged (in millisatoshi) for the entire blinded path.
856 pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 {
857 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
860 /// Base fee charged (in millisatoshi) for the entire blinded path.
862 pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) {
863 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
865 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
866 /// (i.e., 10,000 is 1%).
868 pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 {
869 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
872 /// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path
873 /// (i.e., 10,000 is 1%).
875 pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) {
876 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
878 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
881 pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 {
882 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
885 /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded
888 pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) {
889 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
891 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
892 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
893 /// seen by the recipient.
895 pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 {
896 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat;
899 /// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
900 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
901 /// seen by the recipient.
903 pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
904 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val;
906 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
907 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
908 /// seen by the recipient.
910 pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 {
911 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat;
914 /// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the
915 /// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as
916 /// seen by the recipient.
918 pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) {
919 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val;
921 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
924 pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures {
925 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
926 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 }
928 /// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an
931 pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) {
932 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
934 /// Constructs a new BlindedPayInfo given each field
937 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 {
938 BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo {
939 fee_base_msat: fee_base_msat_arg,
940 fee_proportional_millionths: fee_proportional_millionths_arg,
941 cltv_expiry_delta: cltv_expiry_delta_arg,
942 htlc_minimum_msat: htlc_minimum_msat_arg,
943 htlc_maximum_msat: htlc_maximum_msat_arg,
944 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
947 impl Clone for BlindedPayInfo {
948 fn clone(&self) -> Self {
950 inner: if <*mut nativeBlindedPayInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
951 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
957 /// Used only if an object of this type is returned as a trait impl by a method
958 pub(crate) extern "C" fn BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
959 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void
962 /// Creates a copy of the BlindedPayInfo
963 pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo {
966 /// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo.
968 pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 {
969 if o.inner.is_null() { return 0; }
970 // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
972 let mut hasher = core::hash::SipHasher::new();
973 core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
974 core::hash::Hasher::finish(&hasher)
976 /// Checks if two BlindedPayInfos contain equal inner contents.
977 /// This ignores pointers and is_owned flags and looks at the values in fields.
978 /// Two objects with NULL inner values will be considered "equal" here.
980 pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool {
981 if a.inner == b.inner { return true; }
982 if a.inner.is_null() || b.inner.is_null() { return false; }
983 if a.get_native_ref() == b.get_native_ref() { true } else { false }
986 /// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read
987 pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z {
988 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
991 pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
992 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) })
995 /// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write
996 pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ {
997 let res: Result<lightning::offers::invoice::BlindedPayInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
998 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() };