Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / chain / channelmonitor.rs
index 31c4f9e2d4af3f07a7ee3fa9c65ecf70425fced5..dcf6d132a4e65aa63ac3e9510c41249a96627c0c 100644 (file)
@@ -27,7 +27,7 @@ use crate::c_types::*;
 
 
 use lightning::chain::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
-type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
+pub(crate) type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
 
 /// An update generated by the underlying Channel itself which contains some new information the
 /// ChannelMonitor should be made aware of.
@@ -58,7 +58,7 @@ impl Drop for ChannelMonitorUpdate {
 pub extern "C" fn ChannelMonitorUpdate_free(this_obj: ChannelMonitorUpdate) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitorUpdate); }
 }
 #[allow(unused)]
@@ -155,7 +155,7 @@ pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> cra
 }
 
 use lightning::chain::channelmonitor::MonitorUpdateError as nativeMonitorUpdateErrorImport;
-type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
+pub(crate) type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
 
 /// General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
 /// inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
@@ -189,7 +189,7 @@ impl Drop for MonitorUpdateError {
 pub extern "C" fn MonitorUpdateError_free(this_obj: MonitorUpdateError) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorUpdateError); }
 }
 #[allow(unused)]
@@ -208,6 +208,23 @@ impl MonitorUpdateError {
                ret
        }
 }
+#[no_mangle]
+pub extern "C" fn MonitorUpdateError_get_a(this_ptr: &MonitorUpdateError) -> crate::c_types::Str {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().0;
+       inner_val.into()
+}
+#[no_mangle]
+pub extern "C" fn MonitorUpdateError_set_a(this_ptr: &mut MonitorUpdateError, mut val: crate::c_types::Str) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_str();
+}
+/// Constructs a new MonitorUpdateError given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn MonitorUpdateError_new(mut a_arg: crate::c_types::Str) -> MonitorUpdateError {
+       MonitorUpdateError { inner: ObjOps::heap_alloc(lightning::chain::channelmonitor::MonitorUpdateError (
+               a_arg.into_str(),
+       )), is_owned: true }
+}
 impl Clone for MonitorUpdateError {
        fn clone(&self) -> Self {
                Self {
@@ -236,6 +253,25 @@ pub enum MonitorEvent {
        HTLCEvent(crate::lightning::chain::channelmonitor::HTLCUpdate),
        /// A monitor event that the Channel's commitment transaction was confirmed.
        CommitmentTxConfirmed(crate::lightning::chain::transaction::OutPoint),
+       /// Indicates a [`ChannelMonitor`] update has completed. See
+       /// [`ChannelMonitorUpdateErr::TemporaryFailure`] for more information on how this is used.
+       ///
+       /// [`ChannelMonitorUpdateErr::TemporaryFailure`]: super::ChannelMonitorUpdateErr::TemporaryFailure
+       UpdateCompleted {
+               /// The funding outpoint of the [`ChannelMonitor`] that was updated
+               funding_txo: crate::lightning::chain::transaction::OutPoint,
+               /// The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or
+               /// [`ChannelMonitor::get_latest_update_id`].
+               ///
+               /// Note that this should only be set to a given update's ID if all previous updates for the
+               /// same [`ChannelMonitor`] have been applied and persisted.
+               monitor_update_id: u64,
+       },
+       /// Indicates a [`ChannelMonitor`] update has failed. See
+       /// [`ChannelMonitorUpdateErr::PermanentFailure`] for more information on how this is used.
+       ///
+       /// [`ChannelMonitorUpdateErr::PermanentFailure`]: super::ChannelMonitorUpdateErr::PermanentFailure
+       UpdateFailed(crate::lightning::chain::transaction::OutPoint),
 }
 use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEvent;
 impl MonitorEvent {
@@ -254,6 +290,20 @@ impl MonitorEvent {
                                        *unsafe { Box::from_raw(a_nonref.take_inner()) },
                                )
                        },
+                       MonitorEvent::UpdateCompleted {ref funding_txo, ref monitor_update_id, } => {
+                               let mut funding_txo_nonref = (*funding_txo).clone();
+                               let mut monitor_update_id_nonref = (*monitor_update_id).clone();
+                               nativeMonitorEvent::UpdateCompleted {
+                                       funding_txo: *unsafe { Box::from_raw(funding_txo_nonref.take_inner()) },
+                                       monitor_update_id: monitor_update_id_nonref,
+                               }
+                       },
+                       MonitorEvent::UpdateFailed (ref a, ) => {
+                               let mut a_nonref = (*a).clone();
+                               nativeMonitorEvent::UpdateFailed (
+                                       *unsafe { Box::from_raw(a_nonref.take_inner()) },
+                               )
+                       },
                }
        }
        #[allow(unused)]
@@ -269,6 +319,17 @@ impl MonitorEvent {
                                        *unsafe { Box::from_raw(a.take_inner()) },
                                )
                        },
+                       MonitorEvent::UpdateCompleted {mut funding_txo, mut monitor_update_id, } => {
+                               nativeMonitorEvent::UpdateCompleted {
+                                       funding_txo: *unsafe { Box::from_raw(funding_txo.take_inner()) },
+                                       monitor_update_id: monitor_update_id,
+                               }
+                       },
+                       MonitorEvent::UpdateFailed (mut a, ) => {
+                               nativeMonitorEvent::UpdateFailed (
+                                       *unsafe { Box::from_raw(a.take_inner()) },
+                               )
+                       },
                }
        }
        #[allow(unused)]
@@ -286,6 +347,20 @@ impl MonitorEvent {
                                        crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
                                )
                        },
+                       nativeMonitorEvent::UpdateCompleted {ref funding_txo, ref monitor_update_id, } => {
+                               let mut funding_txo_nonref = (*funding_txo).clone();
+                               let mut monitor_update_id_nonref = (*monitor_update_id).clone();
+                               MonitorEvent::UpdateCompleted {
+                                       funding_txo: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo_nonref), is_owned: true },
+                                       monitor_update_id: monitor_update_id_nonref,
+                               }
+                       },
+                       nativeMonitorEvent::UpdateFailed (ref a, ) => {
+                               let mut a_nonref = (*a).clone();
+                               MonitorEvent::UpdateFailed (
+                                       crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
+                               )
+                       },
                }
        }
        #[allow(unused)]
@@ -301,6 +376,17 @@ impl MonitorEvent {
                                        crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a), is_owned: true },
                                )
                        },
+                       nativeMonitorEvent::UpdateCompleted {mut funding_txo, mut monitor_update_id, } => {
+                               MonitorEvent::UpdateCompleted {
+                                       funding_txo: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true },
+                                       monitor_update_id: monitor_update_id,
+                               }
+                       },
+                       nativeMonitorEvent::UpdateFailed (mut a, ) => {
+                               MonitorEvent::UpdateFailed (
+                                       crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a), is_owned: true },
+                               )
+                       },
                }
        }
 }
@@ -322,9 +408,27 @@ pub extern "C" fn MonitorEvent_htlcevent(a: crate::lightning::chain::channelmoni
 pub extern "C" fn MonitorEvent_commitment_tx_confirmed(a: crate::lightning::chain::transaction::OutPoint) -> MonitorEvent {
        MonitorEvent::CommitmentTxConfirmed(a, )
 }
+#[no_mangle]
+/// Utility method to constructs a new UpdateCompleted-variant MonitorEvent
+pub extern "C" fn MonitorEvent_update_completed(funding_txo: crate::lightning::chain::transaction::OutPoint, monitor_update_id: u64) -> MonitorEvent {
+       MonitorEvent::UpdateCompleted {
+               funding_txo,
+               monitor_update_id,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new UpdateFailed-variant MonitorEvent
+pub extern "C" fn MonitorEvent_update_failed(a: crate::lightning::chain::transaction::OutPoint) -> MonitorEvent {
+       MonitorEvent::UpdateFailed(a, )
+}
+#[no_mangle]
+/// Serialize the MonitorEvent object into a byte array which can be read by MonitorEvent_read
+pub extern "C" fn MonitorEvent_write(obj: &MonitorEvent) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
+}
 
 use lightning::chain::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
-type nativeHTLCUpdate = nativeHTLCUpdateImport;
+pub(crate) type nativeHTLCUpdate = nativeHTLCUpdateImport;
 
 /// Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
 /// chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
@@ -356,7 +460,7 @@ impl Drop for HTLCUpdate {
 pub extern "C" fn HTLCUpdate_free(this_obj: HTLCUpdate) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCUpdate); }
 }
 #[allow(unused)]
@@ -649,7 +753,7 @@ pub extern "C" fn Balance_eq(a: &Balance, b: &Balance) -> bool {
 }
 
 use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
-type nativeChannelMonitor = nativeChannelMonitorImport<crate::lightning::chain::keysinterface::Sign>;
+pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport<crate::lightning::chain::keysinterface::Sign>;
 
 /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
 /// on-chain transactions to ensure no loss of funds occurs.
@@ -694,7 +798,7 @@ impl Drop for ChannelMonitor {
 pub extern "C" fn ChannelMonitor_free(this_obj: ChannelMonitor) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
+pub(crate) extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
        unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitor); }
 }
 #[allow(unused)]