1 //! The logic to monitor for on-chain transactions and create the relevant claim responses lives
4 //! ChannelMonitor objects are generated by ChannelManager in response to relevant
5 //! messages/actions, and MUST be persisted to disk (and, preferably, remotely) before progress can
6 //! be made in responding to certain messages, see ManyChannelMonitor for more.
8 //! Note that ChannelMonitors are an important part of the lightning trust model and a copy of the
9 //! latest ChannelMonitor must always be actively monitoring for chain updates (and no out-of-date
10 //! ChannelMonitors should do so). Thus, if you're building rust-lightning into an HSM or other
11 //! security-domain-separated system design, you should consider having multiple paths for
12 //! ChannelMonitors to get out of the HSM and onto monitoring devices.
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
19 use lightning::ln::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
20 type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
22 /// An update generated by the underlying Channel itself which contains some new information the
23 /// ChannelMonitor should be made aware of.
26 pub struct ChannelMonitorUpdate {
27 /// Nearly everyhwere, inner must be non-null, however in places where
28 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
29 pub inner: *mut nativeChannelMonitorUpdate,
33 impl Drop for ChannelMonitorUpdate {
35 if self.is_owned && !self.inner.is_null() {
36 let _ = unsafe { Box::from_raw(self.inner) };
41 pub extern "C" fn ChannelMonitorUpdate_free(this_ptr: ChannelMonitorUpdate) { }
43 /// Used only if an object of this type is returned as a trait impl by a method
44 extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
45 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitorUpdate); }
48 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
49 impl ChannelMonitorUpdate {
50 pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitorUpdate {
51 assert!(self.is_owned);
53 self.inner = std::ptr::null_mut();
57 impl Clone for ChannelMonitorUpdate {
58 fn clone(&self) -> Self {
60 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
66 /// Used only if an object of this type is returned as a trait impl by a method
67 pub(crate) extern "C" fn ChannelMonitorUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
68 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitorUpdate)).clone() })) as *mut c_void
70 /// The sequence number of this update. Updates *must* be replayed in-order according to this
71 /// sequence number (and updates may panic if they are not). The update_id values are strictly
72 /// increasing and increase by one for each new update.
74 /// This sequence number is also used to track up to which points updates which returned
75 /// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
76 /// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
78 pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUpdate) -> u64 {
79 let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_id;
82 /// The sequence number of this update. Updates *must* be replayed in-order according to this
83 /// sequence number (and updates may panic if they are not). The update_id values are strictly
84 /// increasing and increase by one for each new update.
86 /// This sequence number is also used to track up to which points updates which returned
87 /// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
88 /// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
90 pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) {
91 unsafe { &mut *this_ptr.inner }.update_id = val;
94 pub extern "C" fn ChannelMonitorUpdate_write(obj: *const ChannelMonitorUpdate) -> crate::c_types::derived::CVec_u8Z {
95 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
98 pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> ChannelMonitorUpdate {
99 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
100 ChannelMonitorUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
102 ChannelMonitorUpdate { inner: std::ptr::null_mut(), is_owned: true }
105 /// An error enum representing a failure to persist a channel monitor update.
109 pub enum ChannelMonitorUpdateErr {
110 /// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
111 /// our state failed, but is expected to succeed at some point in the future).
113 /// Such a failure will \"freeze\" a channel, preventing us from revoking old states or
114 /// submitting new commitment transactions to the counterparty. Once the update(s) which failed
115 /// have been successfully applied, ChannelManager::channel_monitor_updated can be used to
116 /// restore the channel to an operational state.
118 /// Note that a given ChannelManager will *never* re-generate a given ChannelMonitorUpdate. If
119 /// you return a TemporaryFailure you must ensure that it is written to disk safely before
120 /// writing out the latest ChannelManager state.
122 /// Even when a channel has been \"frozen\" updates to the ChannelMonitor can continue to occur
123 /// (eg if an inbound HTLC which we forwarded was claimed upstream resulting in us attempting
124 /// to claim it on this channel) and those updates must be applied wherever they can be. At
125 /// least one such updated ChannelMonitor must be persisted otherwise PermanentFailure should
126 /// be returned to get things on-chain ASAP using only the in-memory copy. Obviously updates to
127 /// the channel which would invalidate previous ChannelMonitors are not made when a channel has
130 /// Note that even if updates made after TemporaryFailure succeed you must still call
131 /// channel_monitor_updated to ensure you have the latest monitor and re-enable normal channel
134 /// Note that the update being processed here will not be replayed for you when you call
135 /// ChannelManager::channel_monitor_updated, so you must store the update itself along
136 /// with the persisted ChannelMonitor on your own local disk prior to returning a
137 /// TemporaryFailure. You may, of course, employ a journaling approach, storing only the
138 /// ChannelMonitorUpdate on disk without updating the monitor itself, replaying the journal at
141 /// For deployments where a copy of ChannelMonitors and other local state are backed up in a
142 /// remote location (with local copies persisted immediately), it is anticipated that all
143 /// updates will return TemporaryFailure until the remote copies could be updated.
145 /// Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a
146 /// different watchtower and cannot update with all watchtowers that were previously informed
147 /// of this channel).
149 /// At reception of this error, ChannelManager will force-close the channel and return at
150 /// least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at
151 /// least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel
152 /// update must be rejected.
154 /// This failure may also signal a failure to update the local persisted copy of one of
155 /// the channel monitor instance.
157 /// Note that even when you fail a holder commitment transaction update, you must store the
158 /// update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor
159 /// broadcasts it (e.g distributed channel-monitor deployment)
162 use lightning::ln::channelmonitor::ChannelMonitorUpdateErr as nativeChannelMonitorUpdateErr;
163 impl ChannelMonitorUpdateErr {
165 pub(crate) fn to_native(&self) -> nativeChannelMonitorUpdateErr {
167 ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
168 ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
172 pub(crate) fn into_native(self) -> nativeChannelMonitorUpdateErr {
174 ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
175 ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
179 pub(crate) fn from_native(native: &nativeChannelMonitorUpdateErr) -> Self {
181 nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
182 nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
186 pub(crate) fn native_into(native: nativeChannelMonitorUpdateErr) -> Self {
188 nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
189 nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
194 use lightning::ln::channelmonitor::MonitorUpdateError as nativeMonitorUpdateErrorImport;
195 type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
197 /// General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
198 /// inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
199 /// means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
201 /// Contains a human-readable error message.
204 pub struct MonitorUpdateError {
205 /// Nearly everyhwere, inner must be non-null, however in places where
206 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
207 pub inner: *mut nativeMonitorUpdateError,
211 impl Drop for MonitorUpdateError {
213 if self.is_owned && !self.inner.is_null() {
214 let _ = unsafe { Box::from_raw(self.inner) };
219 pub extern "C" fn MonitorUpdateError_free(this_ptr: MonitorUpdateError) { }
221 /// Used only if an object of this type is returned as a trait impl by a method
222 extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
223 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorUpdateError); }
226 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
227 impl MonitorUpdateError {
228 pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorUpdateError {
229 assert!(self.is_owned);
230 let ret = self.inner;
231 self.inner = std::ptr::null_mut();
236 use lightning::ln::channelmonitor::MonitorEvent as nativeMonitorEventImport;
237 type nativeMonitorEvent = nativeMonitorEventImport;
239 /// An event to be processed by the ChannelManager.
242 pub struct MonitorEvent {
243 /// Nearly everyhwere, inner must be non-null, however in places where
244 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
245 pub inner: *mut nativeMonitorEvent,
249 impl Drop for MonitorEvent {
251 if self.is_owned && !self.inner.is_null() {
252 let _ = unsafe { Box::from_raw(self.inner) };
257 pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { }
259 /// Used only if an object of this type is returned as a trait impl by a method
260 extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) {
261 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorEvent); }
264 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
266 pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorEvent {
267 assert!(self.is_owned);
268 let ret = self.inner;
269 self.inner = std::ptr::null_mut();
274 use lightning::ln::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
275 type nativeHTLCUpdate = nativeHTLCUpdateImport;
277 /// Simple structure send back by ManyChannelMonitor in case of HTLC detected onchain from a
278 /// forward channel and from which info are needed to update HTLC in a backward channel.
281 pub struct HTLCUpdate {
282 /// Nearly everyhwere, inner must be non-null, however in places where
283 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
284 pub inner: *mut nativeHTLCUpdate,
288 impl Drop for HTLCUpdate {
290 if self.is_owned && !self.inner.is_null() {
291 let _ = unsafe { Box::from_raw(self.inner) };
296 pub extern "C" fn HTLCUpdate_free(this_ptr: HTLCUpdate) { }
298 /// Used only if an object of this type is returned as a trait impl by a method
299 extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
300 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCUpdate); }
303 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
305 pub(crate) fn take_ptr(mut self) -> *mut nativeHTLCUpdate {
306 assert!(self.is_owned);
307 let ret = self.inner;
308 self.inner = std::ptr::null_mut();
312 impl Clone for HTLCUpdate {
313 fn clone(&self) -> Self {
315 inner: Box::into_raw(Box::new(unsafe { &*self.inner }.clone())),
321 /// Used only if an object of this type is returned as a trait impl by a method
322 pub(crate) extern "C" fn HTLCUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
323 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCUpdate)).clone() })) as *mut c_void
326 pub extern "C" fn HTLCUpdate_write(obj: *const HTLCUpdate) -> crate::c_types::derived::CVec_u8Z {
327 crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
330 pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> HTLCUpdate {
331 if let Ok(res) = crate::c_types::deserialize_obj(ser) {
332 HTLCUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
334 HTLCUpdate { inner: std::ptr::null_mut(), is_owned: true }
338 use lightning::ln::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
339 type nativeChannelMonitor = nativeChannelMonitorImport<crate::chain::keysinterface::ChannelKeys>;
341 /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
342 /// on-chain transactions to ensure no loss of funds occurs.
344 /// You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
345 /// information and are actively monitoring the chain.
347 /// Pending Events or updated HTLCs which have not yet been read out by
348 /// get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
349 /// reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
350 /// gotten are fully handled before re-serializing the new state.
353 pub struct ChannelMonitor {
354 /// Nearly everyhwere, inner must be non-null, however in places where
355 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
356 pub inner: *mut nativeChannelMonitor,
360 impl Drop for ChannelMonitor {
362 if self.is_owned && !self.inner.is_null() {
363 let _ = unsafe { Box::from_raw(self.inner) };
368 pub extern "C" fn ChannelMonitor_free(this_ptr: ChannelMonitor) { }
370 /// Used only if an object of this type is returned as a trait impl by a method
371 extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
372 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitor); }
375 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
376 impl ChannelMonitor {
377 pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitor {
378 assert!(self.is_owned);
379 let ret = self.inner;
380 self.inner = std::ptr::null_mut();
384 /// Simple trait indicating ability to track a set of ChannelMonitors and multiplex events between
385 /// them. Generally should be implemented by keeping a local SimpleManyChannelMonitor and passing
386 /// events to it, while also taking any add/update_monitor events and passing them to some remote
389 /// In general, you must always have at least one local copy in memory, which must never fail to
390 /// update (as it is responsible for broadcasting the latest state in case the channel is closed),
391 /// and then persist it to various on-disk locations. If, for some reason, the in-memory copy fails
392 /// to update (eg out-of-memory or some other condition), you must immediately shut down without
393 /// taking any further action such as writing the current state to disk. This should likely be
394 /// accomplished via panic!() or abort().
396 /// Note that any updates to a channel's monitor *must* be applied to each instance of the
397 /// channel's monitor everywhere (including remote watchtowers) *before* this function returns. If
398 /// an update occurs and a remote watchtower is left with old state, it may broadcast transactions
399 /// which we have revoked, allowing our counterparty to claim all funds in the channel!
401 /// User needs to notify implementors of ManyChannelMonitor when a new block is connected or
402 /// disconnected using their `block_connected` and `block_disconnected` methods. However, rather
403 /// than calling these methods directly, the user should register implementors as listeners to the
404 /// BlockNotifier and call the BlockNotifier's `block_(dis)connected` methods, which will notify
405 /// all registered listeners in one go.
407 pub struct ManyChannelMonitor {
408 pub this_arg: *mut c_void,
409 /// Adds a monitor for the given `funding_txo`.
411 /// Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
412 /// any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
413 /// callbacks with the funding transaction, or any spends of it.
415 /// Further, the implementer must also ensure that each output returned in
416 /// monitor.get_outputs_to_watch() is registered to ensure that the provided monitor learns about
417 /// any spends of any of the outputs.
419 /// Any spends of outputs which should have been registered which aren't passed to
420 /// ChannelMonitors via block_connected may result in FUNDS LOSS.
422 pub add_monitor: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::ln::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
423 /// Updates a monitor for the given `funding_txo`.
425 /// Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
426 /// any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
427 /// callbacks with the funding transaction, or any spends of it.
429 /// Further, the implementer must also ensure that each output returned in
430 /// monitor.get_watch_outputs() is registered to ensure that the provided monitor learns about
431 /// any spends of any of the outputs.
433 /// Any spends of outputs which should have been registered which aren't passed to
434 /// ChannelMonitors via block_connected may result in FUNDS LOSS.
436 /// In case of distributed watchtowers deployment, even if an Err is return, the new version
437 /// must be written to disk, as state may have been stored but rejected due to a block forcing
438 /// a commitment broadcast. This storage is used to claim outputs of rejected state confirmed
439 /// onchain by another watchtower, lagging behind on block processing.
441 pub update_monitor: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::ln::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
442 /// Used by ChannelManager to get list of HTLC resolved onchain and which needed to be updated
443 /// with success or failure.
445 /// You should probably just call through to
446 /// ChannelMonitor::get_and_clear_pending_monitor_events() for each ChannelMonitor and return
449 pub get_and_clear_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ,
450 pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
452 unsafe impl Send for ManyChannelMonitor {}
453 unsafe impl Sync for ManyChannelMonitor {}
455 use lightning::ln::channelmonitor::ManyChannelMonitor as rustManyChannelMonitor;
456 impl rustManyChannelMonitor for ManyChannelMonitor {
457 type Keys = crate::chain::keysinterface::ChannelKeys;
458 fn add_monitor(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::ln::channelmonitor::ChannelMonitor<Self::Keys>) -> Result<(), lightning::ln::channelmonitor::ChannelMonitorUpdateErr> {
459 let mut ret = (self.add_monitor)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::ln::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
460 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
463 fn update_monitor(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::ln::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::ln::channelmonitor::ChannelMonitorUpdateErr> {
464 let mut ret = (self.update_monitor)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::ln::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
465 let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
468 fn get_and_clear_pending_monitor_events(&self) -> Vec<lightning::ln::channelmonitor::MonitorEvent> {
469 let mut ret = (self.get_and_clear_pending_monitor_events)(self.this_arg);
470 let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
475 // We're essentially a pointer already, or at least a set of pointers, so allow us to be used
476 // directly as a Deref trait in higher-level structs:
477 impl std::ops::Deref for ManyChannelMonitor {
479 fn deref(&self) -> &Self {
483 /// Calls the free function if one is set
485 pub extern "C" fn ManyChannelMonitor_free(this_ptr: ManyChannelMonitor) { }
486 impl Drop for ManyChannelMonitor {
488 if let Some(f) = self.free {
493 /// Updates a ChannelMonitor on the basis of some new information provided by the Channel
496 /// panics if the given update is not the next update by update_id.
499 pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &mut ChannelMonitor, mut updates: crate::ln::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ {
500 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.update_monitor(*unsafe { Box::from_raw(updates.take_ptr()) }, broadcaster, logger);
501 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
505 /// Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
509 pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor) -> u64 {
510 let mut ret = unsafe { &*this_arg.inner }.get_latest_update_id();
514 /// Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
517 pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> crate::c_types::derived::C2Tuple_OutPointScriptZ {
518 let mut ret = unsafe { &*this_arg.inner }.get_funding_txo();
519 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();
523 /// Get the list of HTLCs who's status has been updated on chain. This should be called by
524 /// ChannelManager via ManyChannelMonitor::get_and_clear_pending_monitor_events().
527 pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
528 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_monitor_events();
529 let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
533 /// Gets the list of pending events which were generated by previous actions, clearing the list
536 /// This is called by ManyChannelMonitor::get_and_clear_pending_events() and is equivalent to
537 /// EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
538 /// no internal locking in ChannelMonitors.
541 pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
542 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_events();
543 let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
547 /// Used by ChannelManager deserialization to broadcast the latest holder state if its copy of
548 /// the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of
549 /// fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows
550 /// a higher revocation secret than the holder commitment number we are aware of. Broadcasting these
551 /// transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to
552 /// broadcast them if counterparty don't close channel with his higher commitment transaction after a
553 /// substantial amount of time (a month or even a year) to get back funds. Best may be to contact
554 /// out-of-band the other node operator to coordinate with him if option is available to you.
555 /// In any-case, choice is up to the user.
558 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 {
559 let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_holder_commitment_txn(logger);
560 let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); local_ret_0.into() }); };