Update auto-generated bindings to LDK 0.0.121
[ldk-c-bindings] / lightning-c-bindings / src / lightning / offers / offer.rs
index c4f0c064a72161add6d4e7604a7966c204672ca7..bc2bcb4f953bff435e47baf878f931426440990a 100644 (file)
@@ -12,6 +12,8 @@
 //! published as a QR code to be scanned by a customer. The customer uses the offer to request an
 //! invoice from the merchant to be paid.
 //!
+//! # Example
+//!
 //! ```
 //! extern crate bitcoin;
 //! extern crate core;
 //! # Ok(())
 //! # }
 //! ```
+//!
+//! # Note
+//!
+//! If constructing an [`Offer`] for use with a [`ChannelManager`], use
+//! [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`].
+//!
+//! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+//! [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder
 
 use alloc::str::FromStr;
 use alloc::string::String;
@@ -149,13 +159,16 @@ impl Clone for Offer {
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn Offer_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeOffer)).clone() })) as *mut c_void
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOffer)).clone() })) as *mut c_void
 }
 #[no_mangle]
 /// Creates a copy of the Offer
 pub extern "C" fn Offer_clone(orig: &Offer) -> Offer {
        orig.clone()
 }
+/// Get a string which allows debug introspection of a Offer object
+pub extern "C" fn Offer_debug_str_void(o: *const c_void) -> Str {
+       alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::offer::Offer }).into()}
 /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
 /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
 /// for the selected chain.
@@ -163,7 +176,7 @@ pub extern "C" fn Offer_clone(orig: &Offer) -> Offer {
 #[no_mangle]
 pub extern "C" fn Offer_chains(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ {
        let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.chains();
-       let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); };
+       let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); };
        local_ret.into()
 }
 
@@ -258,7 +271,7 @@ pub extern "C" fn Offer_signing_pubkey(this_arg: &crate::lightning::offers::offe
 #[must_use]
 #[no_mangle]
 pub extern "C" fn Offer_supports_chain(this_arg: &crate::lightning::offers::offer::Offer, mut chain: crate::c_types::ThirtyTwoBytes) -> bool {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_chain(::bitcoin::blockdata::constants::ChainHash::from(&chain.data[..]));
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_chain(::bitcoin::blockdata::constants::ChainHash::from(&chain.data));
        ret
 }
 
@@ -270,6 +283,14 @@ pub extern "C" fn Offer_is_expired(this_arg: &crate::lightning::offers::offer::O
        ret
 }
 
+/// Whether the offer has expired given the duration since the Unix epoch.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Offer_is_expired_no_std(this_arg: &crate::lightning::offers::offer::Offer, mut duration_since_epoch: u64) -> bool {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired_no_std(core::time::Duration::from_secs(duration_since_epoch));
+       ret
+}
+
 /// Returns whether the given quantity is valid for the offer.
 #[must_use]
 #[no_mangle]
@@ -293,7 +314,7 @@ pub extern "C" fn Offer_expects_quantity(this_arg: &crate::lightning::offers::of
 pub extern "C" fn Offer_write(obj: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
 }
-#[no_mangle]
+#[allow(unused)]
 pub(crate) extern "C" fn Offer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOffer) })
 }
@@ -361,13 +382,16 @@ impl Clone for Amount {
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn Amount_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeAmount)).clone() })) as *mut c_void
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAmount)).clone() })) as *mut c_void
 }
 #[no_mangle]
 /// Creates a copy of the Amount
 pub extern "C" fn Amount_clone(orig: &Amount) -> Amount {
        orig.clone()
 }
+/// Get a string which allows debug introspection of a Amount object
+pub extern "C" fn Amount_debug_str_void(o: *const c_void) -> Str {
+       alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::offer::Amount }).into()}
 
 use lightning::offers::offer::Quantity as nativeQuantityImport;
 pub(crate) type nativeQuantity = nativeQuantityImport;
@@ -431,13 +455,16 @@ impl Clone for Quantity {
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
 pub(crate) extern "C" fn Quantity_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeQuantity)).clone() })) as *mut c_void
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQuantity)).clone() })) as *mut c_void
 }
 #[no_mangle]
 /// Creates a copy of the Quantity
 pub extern "C" fn Quantity_clone(orig: &Quantity) -> Quantity {
        orig.clone()
 }
+/// Get a string which allows debug introspection of a Quantity object
+pub extern "C" fn Quantity_debug_str_void(o: *const c_void) -> Str {
+       alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::offer::Quantity }).into()}
 #[no_mangle]
 /// Read a Offer object from a string
 pub extern "C" fn Offer_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_OfferBolt12ParseErrorZ {