Merge pull request #38 from TheBlueMatt/main
[ldk-c-bindings] / lightning-c-bindings / src / lightning / chain / channelmonitor.rs
index 6bfd3c3863cfed993240faa41ccb5cd428de8ef1..11612160ec4b3c78d551a2ab7565a2e002fbf9dc 100644 (file)
@@ -244,6 +244,14 @@ impl ChannelMonitorUpdateErr {
 pub extern "C" fn ChannelMonitorUpdateErr_clone(orig: &ChannelMonitorUpdateErr) -> ChannelMonitorUpdateErr {
        orig.clone()
 }
+#[no_mangle]
+/// Utility method to constructs a new TemporaryFailure-variant ChannelMonitorUpdateErr
+pub extern "C" fn ChannelMonitorUpdateErr_temporary_failure() -> ChannelMonitorUpdateErr {
+       ChannelMonitorUpdateErr::TemporaryFailure}
+#[no_mangle]
+/// Utility method to constructs a new PermanentFailure-variant ChannelMonitorUpdateErr
+pub extern "C" fn ChannelMonitorUpdateErr_permanent_failure() -> ChannelMonitorUpdateErr {
+       ChannelMonitorUpdateErr::PermanentFailure}
 
 use lightning::chain::channelmonitor::MonitorUpdateError as nativeMonitorUpdateErrorImport;
 type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
@@ -397,6 +405,16 @@ pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { }
 pub extern "C" fn MonitorEvent_clone(orig: &MonitorEvent) -> MonitorEvent {
        orig.clone()
 }
+#[no_mangle]
+/// Utility method to constructs a new HTLCEvent-variant MonitorEvent
+pub extern "C" fn MonitorEvent_htlcevent(a: crate::lightning::chain::channelmonitor::HTLCUpdate) -> MonitorEvent {
+       MonitorEvent::HTLCEvent(a, )
+}
+#[no_mangle]
+/// Utility method to constructs a new CommitmentTxBroadcasted-variant MonitorEvent
+pub extern "C" fn MonitorEvent_commitment_tx_broadcasted(a: crate::lightning::chain::transaction::OutPoint) -> MonitorEvent {
+       MonitorEvent::CommitmentTxBroadcasted(a, )
+}
 
 use lightning::chain::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
 type nativeHTLCUpdate = nativeHTLCUpdateImport;
@@ -479,6 +497,11 @@ pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_type
        let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
        local_res
 }
+/// Number of blocks we wait on seeing a HTLC output being solved before we fail corresponding inbound
+/// HTLCs. This prevents us from failing backwards and then getting a reorg resulting in us losing money.
+
+#[no_mangle]
+pub static ANTI_REORG_DELAY: u32 = lightning::chain::channelmonitor::ANTI_REORG_DELAY;
 
 use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
 type nativeChannelMonitor = nativeChannelMonitorImport<crate::lightning::chain::keysinterface::Sign>;
@@ -715,6 +738,15 @@ pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &ChannelMonitor) -
        local_ret.into()
 }
 
+/// Gets the latest best block which was connected either via the [`chain::Listen`] or
+/// [`chain::Confirm`] interfaces.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_current_best_block(this_arg: &ChannelMonitor) -> crate::lightning::chain::BestBlock {
+       let mut ret = unsafe { &*this_arg.inner }.current_best_block();
+       crate::lightning::chain::BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
 /// `Persist` defines behavior for persisting channel monitors: this could mean
 /// writing once to disk, and/or uploading to one or more backup services.
 ///
@@ -769,6 +801,17 @@ pub struct Persist {
        /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed.
        pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
 }
+unsafe impl Send for Persist {}
+unsafe impl Sync for Persist {}
+#[no_mangle]
+pub(crate) extern "C" fn Persist_clone_fields(orig: &Persist) -> Persist {
+       Persist {
+               this_arg: orig.this_arg,
+               persist_new_channel: Clone::clone(&orig.persist_new_channel),
+               update_persisted_channel: Clone::clone(&orig.update_persisted_channel),
+               free: Clone::clone(&orig.free),
+       }
+}
 
 use lightning::chain::channelmonitor::Persist as rustPersist;
 impl rustPersist<crate::lightning::chain::keysinterface::Sign> for Persist {