X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Fchain%2Fchannelmonitor.rs;h=9fab7e0466a8f19ce06cd01bdd5db91e27847edb;hb=c42ea50cc703f03465d52b5fccfc4a90466d9fea;hp=86617f1bb98e1cdf42cd2ba785ad5e96f4731047;hpb=c2fd68377c15ff923981439bd2815df6b65e6c0c;p=rust-lightning diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs index 86617f1b..9fab7e04 100644 --- a/lightning-c-bindings/src/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/chain/channelmonitor.rs @@ -34,7 +34,7 @@ pub struct ChannelMonitorUpdate { impl Drop for ChannelMonitorUpdate { fn drop(&mut self) { - if self.is_owned && !self.inner.is_null() { + if self.is_owned && !<*mut nativeChannelMonitorUpdate>::is_null(self.inner) { let _ = unsafe { Box::from_raw(self.inner) }; } } @@ -56,24 +56,6 @@ impl ChannelMonitorUpdate { ret } } -impl Clone for ChannelMonitorUpdate { - fn clone(&self) -> Self { - Self { - inner: if self.inner.is_null() { std::ptr::null_mut() } else { - Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelMonitorUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitorUpdate)).clone() })) as *mut c_void -} -#[no_mangle] -pub extern "C" fn ChannelMonitorUpdate_clone(orig: &ChannelMonitorUpdate) -> ChannelMonitorUpdate { - orig.clone() -} /// The sequence number of this update. Updates *must* be replayed in-order according to this /// sequence number (and updates may panic if they are not). The update_id values are strictly /// increasing and increase by one for each new update, with one exception specified below. @@ -109,6 +91,24 @@ pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUp pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) { unsafe { &mut *this_ptr.inner }.update_id = val; } +impl Clone for ChannelMonitorUpdate { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelMonitorUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelMonitorUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitorUpdate)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn ChannelMonitorUpdate_clone(orig: &ChannelMonitorUpdate) -> ChannelMonitorUpdate { + orig.clone() +} #[no_mangle] pub static CLOSED_CHANNEL_UPDATE_ID: u64 = lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID; @@ -243,7 +243,7 @@ pub struct MonitorUpdateError { impl Drop for MonitorUpdateError { fn drop(&mut self) { - if self.is_owned && !self.inner.is_null() { + if self.is_owned && !<*mut nativeMonitorUpdateError>::is_null(self.inner) { let _ = unsafe { Box::from_raw(self.inner) }; } } @@ -268,7 +268,7 @@ impl MonitorUpdateError { impl Clone for MonitorUpdateError { fn clone(&self) -> Self { Self { - inner: if self.inner.is_null() { std::ptr::null_mut() } else { + inner: if <*mut nativeMonitorUpdateError>::is_null(self.inner) { std::ptr::null_mut() } else { Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, is_owned: true, } @@ -283,58 +283,85 @@ pub(crate) extern "C" fn MonitorUpdateError_clone_void(this_ptr: *const c_void) pub extern "C" fn MonitorUpdateError_clone(orig: &MonitorUpdateError) -> MonitorUpdateError { orig.clone() } - -use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEventImport; -type nativeMonitorEvent = nativeMonitorEventImport; - /// An event to be processed by the ChannelManager. #[must_use] +#[derive(Clone)] #[repr(C)] -pub struct MonitorEvent { - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeMonitorEvent, - pub is_owned: bool, +pub enum MonitorEvent { + /// A monitor event containing an HTLCUpdate. + HTLCEvent(crate::chain::channelmonitor::HTLCUpdate), + /// A monitor event that the Channel's commitment transaction was broadcasted. + CommitmentTxBroadcasted(crate::chain::transaction::OutPoint), } - -impl Drop for MonitorEvent { - fn drop(&mut self) { - if self.is_owned && !self.inner.is_null() { - let _ = unsafe { Box::from_raw(self.inner) }; +use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEvent; +impl MonitorEvent { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMonitorEvent { + match self { + MonitorEvent::HTLCEvent (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeMonitorEvent::HTLCEvent ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + MonitorEvent::CommitmentTxBroadcasted (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeMonitorEvent::CommitmentTxBroadcasted ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, } } -} -#[no_mangle] -pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) { - unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorEvent); } -} -#[allow(unused)] -/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy -impl MonitorEvent { - pub(crate) fn take_inner(mut self) -> *mut nativeMonitorEvent { - assert!(self.is_owned); - let ret = self.inner; - self.inner = std::ptr::null_mut(); - ret + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMonitorEvent { + match self { + MonitorEvent::HTLCEvent (mut a, ) => { + nativeMonitorEvent::HTLCEvent ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + MonitorEvent::CommitmentTxBroadcasted (mut a, ) => { + nativeMonitorEvent::CommitmentTxBroadcasted ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } } -} -impl Clone for MonitorEvent { - fn clone(&self) -> Self { - Self { - inner: if self.inner.is_null() { std::ptr::null_mut() } else { - Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, - is_owned: true, + #[allow(unused)] + pub(crate) fn from_native(native: &nativeMonitorEvent) -> Self { + match native { + nativeMonitorEvent::HTLCEvent (ref a, ) => { + let mut a_nonref = (*a).clone(); + MonitorEvent::HTLCEvent ( + crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + nativeMonitorEvent::CommitmentTxBroadcasted (ref a, ) => { + let mut a_nonref = (*a).clone(); + MonitorEvent::CommitmentTxBroadcasted ( + crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMonitorEvent) -> Self { + match native { + nativeMonitorEvent::HTLCEvent (mut a, ) => { + MonitorEvent::HTLCEvent ( + crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, + nativeMonitorEvent::CommitmentTxBroadcasted (mut a, ) => { + MonitorEvent::CommitmentTxBroadcasted ( + crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a)), is_owned: true }, + ) + }, } } } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn MonitorEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMonitorEvent)).clone() })) as *mut c_void -} +#[no_mangle] +pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { } #[no_mangle] pub extern "C" fn MonitorEvent_clone(orig: &MonitorEvent) -> MonitorEvent { orig.clone() @@ -359,7 +386,7 @@ pub struct HTLCUpdate { impl Drop for HTLCUpdate { fn drop(&mut self) { - if self.is_owned && !self.inner.is_null() { + if self.is_owned && !<*mut nativeHTLCUpdate>::is_null(self.inner) { let _ = unsafe { Box::from_raw(self.inner) }; } } @@ -384,7 +411,7 @@ impl HTLCUpdate { impl Clone for HTLCUpdate { fn clone(&self) -> Self { Self { - inner: if self.inner.is_null() { std::ptr::null_mut() } else { + inner: if <*mut nativeHTLCUpdate>::is_null(self.inner) { std::ptr::null_mut() } else { Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, is_owned: true, } @@ -401,23 +428,21 @@ pub extern "C" fn HTLCUpdate_clone(orig: &HTLCUpdate) -> HTLCUpdate { } #[no_mangle] pub extern "C" fn HTLCUpdate_write(obj: &HTLCUpdate) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) }) + crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner }) } #[no_mangle] pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCUpdate) }) } #[no_mangle] -pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> HTLCUpdate { - if let Ok(res) = crate::c_types::deserialize_obj(ser) { - HTLCUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true } - } else { - HTLCUpdate { inner: std::ptr::null_mut(), is_owned: true } - } +pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCUpdateDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res } use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; -type nativeChannelMonitor = nativeChannelMonitorImport; +type nativeChannelMonitor = nativeChannelMonitorImport; /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates /// on-chain transactions to ensure no loss of funds occurs. @@ -430,7 +455,7 @@ type nativeChannelMonitor = nativeChannelMonitorImport::is_null(self.inner) { let _ = unsafe { Box::from_raw(self.inner) }; } } @@ -482,8 +507,8 @@ pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate: /// panics if the given update is not the next update by update_id. #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &mut ChannelMonitor, updates: &crate::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::chain::chaininterface::FeeEstimator, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.update_monitor(unsafe { &*updates.inner }, broadcaster, fee_estimator, logger); +pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &ChannelMonitor, updates: &crate::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::chain::chaininterface::FeeEstimator, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ { + let mut ret = unsafe { &*this_arg.inner }.update_monitor(unsafe { &*updates.inner }, broadcaster, fee_estimator, logger); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_ret } @@ -502,7 +527,7 @@ pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor) #[no_mangle] pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> crate::c_types::derived::C2Tuple_OutPointScriptZ { let mut ret = unsafe { &*this_arg.inner }.get_funding_txo(); - let (ref orig_ret_0, ref orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*orig_ret_0) as *const _) as *mut _) }, is_owned: false }, orig_ret_1.clone().into_bytes().into()).into(); + let (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(orig_ret_0)), is_owned: true }, orig_ret_1.into_bytes().into()).into(); local_ret } @@ -512,9 +537,9 @@ pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> c /// [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_monitor_events(); - let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); }; +pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ { + let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_monitor_events(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent::native_into(item) }); }; local_ret.into() } @@ -526,9 +551,9 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: /// no internal locking in ChannelMonitors. #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_EventZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_events(); - let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); }; +pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_EventZ { + let mut ret = unsafe { &*this_arg.inner }.get_and_clear_pending_events(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); }; local_ret.into() } @@ -543,9 +568,9 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut Cha /// In any-case, choice is up to the user. #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ { - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_holder_commitment_txn(logger); - let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); }; +pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ { + let mut ret = unsafe { &*this_arg.inner }.get_latest_holder_commitment_txn(logger); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); }; local_ret.into() } @@ -562,18 +587,18 @@ pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut /// [`get_outputs_to_watch`]: #method.get_outputs_to_watch #[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_block_connected(this_arg: &mut ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ { +pub extern "C" fn ChannelMonitor_block_connected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); - let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut ret = unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height, broadcaster, fee_estimator, logger); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } /// Determines if the disconnected block contained any transactions of interest and updates /// appropriately. #[no_mangle] -pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &mut ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) { - unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger) +pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) { + unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger) } /// `Persist` defines behavior for persisting channel monitors: this could mean @@ -638,13 +663,13 @@ unsafe impl Send for Persist {} unsafe impl Sync for Persist {} use lightning::chain::channelmonitor::Persist as rustPersist; -impl rustPersist for Persist { - fn persist_new_channel(&self, id: lightning::chain::transaction::OutPoint, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { +impl rustPersist for Persist { + fn persist_new_channel(&self, id: lightning::chain::transaction::OutPoint, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.persist_new_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } - fn update_persisted_channel(&self, id: lightning::chain::transaction::OutPoint, update: &lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { + fn update_persisted_channel(&self, id: lightning::chain::transaction::OutPoint, update: &lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &lightning::chain::channelmonitor::ChannelMonitor) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> { let mut ret = (self.update_persisted_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(id)), is_owned: true }, &crate::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (update as *const _) as *mut _ }, is_owned: false }, &crate::chain::channelmonitor::ChannelMonitor { inner: unsafe { (data as *const _) as *mut _ }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret @@ -672,7 +697,7 @@ impl Drop for Persist { #[no_mangle] pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg: &crate::chain::keysinterface::KeysInterface) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ { let arg_conv = arg; - let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_res }