X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Foffers%2Foffer.rs;fp=lightning-c-bindings%2Fsrc%2Flightning%2Foffers%2Foffer.rs;h=bc2bcb4f953bff435e47baf878f931426440990a;hp=f9691b4c2af516a68b079c32876807be8a41a556;hb=0ac4dbdb8352c898100b34f0ef8ed9cebfea7786;hpb=c16401631dddadcefa37b05074ca7def51b85af4 diff --git a/lightning-c-bindings/src/lightning/offers/offer.rs b/lightning-c-bindings/src/lightning/offers/offer.rs index f9691b4..bc2bcb4 100644 --- a/lightning-c-bindings/src/lightning/offers/offer.rs +++ b/lightning-c-bindings/src/lightning/offers/offer.rs @@ -166,6 +166,9 @@ pub(crate) extern "C" fn Offer_clone_void(this_ptr: *const c_void) -> *mut c_voi 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. @@ -173,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() } @@ -268,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 } @@ -280,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] @@ -378,6 +389,9 @@ pub(crate) extern "C" fn Amount_clone_void(this_ptr: *const c_void) -> *mut c_vo 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; @@ -448,6 +462,9 @@ pub(crate) extern "C" fn Quantity_clone_void(this_ptr: *const c_void) -> *mut c_ 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 {