X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Frouting%2Futxo.rs;h=187badd8629479e12a50ead78002b053b00bb354;hb=3e46e1794f14640e35f09cc6da4169c152de34ce;hp=c9ed69527e2a71757e57088abf8fe02e3a9ed665;hpb=11b997c3a0452ea1da5b7b352e7887798105db29;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/routing/utxo.rs b/lightning-c-bindings/src/lightning/routing/utxo.rs index c9ed695..187badd 100644 --- a/lightning-c-bindings/src/lightning/routing/utxo.rs +++ b/lightning-c-bindings/src/lightning/routing/utxo.rs @@ -13,6 +13,7 @@ //! order to announce a channel. This module handles that checking. use alloc::str::FromStr; +use alloc::string::String; use core::ffi::c_void; use core::convert::Infallible; use bitcoin::hashes::Hash; @@ -140,7 +141,7 @@ impl UtxoResult { match native { nativeUtxoResult::Sync (ref a, ) => { let mut a_nonref = Clone::clone(a); - let mut local_a_nonref = match a_nonref { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; + let mut local_a_nonref = match a_nonref { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; UtxoResult::Sync ( local_a_nonref, ) @@ -157,7 +158,7 @@ impl UtxoResult { pub(crate) fn native_into(native: nativeUtxoResult) -> Self { match native { nativeUtxoResult::Sync (mut a, ) => { - let mut local_a = match a { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; + let mut local_a = match a { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::TxOut::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::routing::utxo::UtxoLookupError::native_into(e) }).into() }; UtxoResult::Sync ( local_a, ) @@ -199,7 +200,6 @@ pub struct UtxoLookup { /// is unknown. /// /// [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id - #[must_use] pub get_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: *const [u8; 32], short_channel_id: u64) -> crate::lightning::routing::utxo::UtxoResult, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -207,8 +207,7 @@ pub struct UtxoLookup { } unsafe impl Send for UtxoLookup {} unsafe impl Sync for UtxoLookup {} -#[no_mangle] -pub(crate) extern "C" fn UtxoLookup_clone_fields(orig: &UtxoLookup) -> UtxoLookup { +pub(crate) fn UtxoLookup_clone_fields(orig: &UtxoLookup) -> UtxoLookup { UtxoLookup { this_arg: orig.this_arg, get_utxo: Clone::clone(&orig.get_utxo), @@ -232,6 +231,11 @@ impl core::ops::Deref for UtxoLookup { self } } +impl core::ops::DerefMut for UtxoLookup { + fn deref_mut(&mut self) -> &mut Self { + self + } +} /// Calls the free function if one is set #[no_mangle] pub extern "C" fn UtxoLookup_free(this_ptr: UtxoLookup) { }