1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
9 //! The logic to monitor for on-chain transactions and create the relevant claim responses lives
12 //! ChannelMonitor objects are generated by ChannelManager in response to relevant
13 //! messages/actions, and MUST be persisted to disk (and, preferably, remotely) before progress can
14 //! be made in responding to certain messages, see [`chain::Watch`] for more.
16 //! Note that ChannelMonitors are an important part of the lightning trust model and a copy of the
17 //! latest ChannelMonitor must always be actively monitoring for chain updates (and no out-of-date
18 //! ChannelMonitors should do so). Thus, if you're building rust-lightning into an HSM or other
19 //! security-domain-separated system design, you should consider having multiple paths for
20 //! ChannelMonitors to get out of the HSM and onto monitoring devices.
22 use std::str::FromStr;
24 use core::convert::Infallible;
25 use bitcoin::hashes::Hash;
26 use crate::c_types::*;
29 use lightning::chain::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
30 type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
32 /// An update generated by the underlying Channel itself which contains some new information the
33 /// ChannelMonitor should be made aware of.
36 pub struct ChannelMonitorUpdate {
37 /// A pointer to the opaque Rust object.
39 /// Nearly everywhere, inner must be non-null, however in places where
40 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
41 pub inner: *mut nativeChannelMonitorUpdate,
42 /// Indicates that this is the only struct which contains the same pointer.
44 /// Rust functions which take ownership of an object provided via an argument require
45 /// this to be true and invalidate the object pointed to by inner.
49 impl Drop for ChannelMonitorUpdate {
51 if self.is_owned && !<*mut nativeChannelMonitorUpdate>::is_null(self.inner) {
52 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
56 /// Frees any resources used by the ChannelMonitorUpdate, if is_owned is set and inner is non-NULL.
58 pub extern "C" fn ChannelMonitorUpdate_free(this_obj: ChannelMonitorUpdate) { }
60 /// Used only if an object of this type is returned as a trait impl by a method
61 extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
62 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitorUpdate); }
65 impl ChannelMonitorUpdate {
66 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelMonitorUpdate {
67 unsafe { &*ObjOps::untweak_ptr(self.inner) }
69 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelMonitorUpdate {
70 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
72 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
73 pub(crate) fn take_inner(mut self) -> *mut nativeChannelMonitorUpdate {
74 assert!(self.is_owned);
75 let ret = ObjOps::untweak_ptr(self.inner);
76 self.inner = std::ptr::null_mut();
80 /// The sequence number of this update. Updates *must* be replayed in-order according to this
81 /// sequence number (and updates may panic if they are not). The update_id values are strictly
82 /// increasing and increase by one for each new update, with one exception specified below.
84 /// This sequence number is also used to track up to which points updates which returned
85 /// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
86 /// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
88 /// The only instance where update_id values are not strictly increasing is the case where we
89 /// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See
90 /// its docs for more details.
92 pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUpdate) -> u64 {
93 let mut inner_val = &mut this_ptr.get_native_mut_ref().update_id;
96 /// The sequence number of this update. Updates *must* be replayed in-order according to this
97 /// sequence number (and updates may panic if they are not). The update_id values are strictly
98 /// increasing and increase by one for each new update, with one exception specified below.
100 /// This sequence number is also used to track up to which points updates which returned
101 /// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
102 /// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
104 /// The only instance where update_id values are not strictly increasing is the case where we
105 /// allow post-force-close updates with a special update ID of [`CLOSED_CHANNEL_UPDATE_ID`]. See
106 /// its docs for more details.
108 pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) {
109 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_id = val;
111 impl Clone for ChannelMonitorUpdate {
112 fn clone(&self) -> Self {
114 inner: if <*mut nativeChannelMonitorUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
115 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
121 /// Used only if an object of this type is returned as a trait impl by a method
122 pub(crate) extern "C" fn ChannelMonitorUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
123 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitorUpdate)).clone() })) as *mut c_void
126 /// Creates a copy of the ChannelMonitorUpdate
127 pub extern "C" fn ChannelMonitorUpdate_clone(orig: &ChannelMonitorUpdate) -> ChannelMonitorUpdate {
131 /// (1) a channel has been force closed and
132 /// (2) we receive a preimage from a forward link that allows us to spend an HTLC output on
133 /// this channel's (the backward link's) broadcasted commitment transaction
134 /// then we allow the `ChannelManager` to send a `ChannelMonitorUpdate` with this update ID,
135 /// with the update providing said payment preimage. No other update types are allowed after
139 pub static CLOSED_CHANNEL_UPDATE_ID: u64 = lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
141 /// Serialize the ChannelMonitorUpdate object into a byte array which can be read by ChannelMonitorUpdate_read
142 pub extern "C" fn ChannelMonitorUpdate_write(obj: &ChannelMonitorUpdate) -> crate::c_types::derived::CVec_u8Z {
143 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
146 pub(crate) extern "C" fn ChannelMonitorUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
147 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitorUpdate) })
150 /// Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write
151 pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelMonitorUpdateDecodeErrorZ {
152 let res = crate::c_types::deserialize_obj(ser);
153 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
157 use lightning::chain::channelmonitor::MonitorUpdateError as nativeMonitorUpdateErrorImport;
158 type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
160 /// General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
161 /// inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
162 /// means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
164 /// Contains a developer-readable error message.
167 pub struct MonitorUpdateError {
168 /// A pointer to the opaque Rust object.
170 /// Nearly everywhere, inner must be non-null, however in places where
171 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
172 pub inner: *mut nativeMonitorUpdateError,
173 /// Indicates that this is the only struct which contains the same pointer.
175 /// Rust functions which take ownership of an object provided via an argument require
176 /// this to be true and invalidate the object pointed to by inner.
180 impl Drop for MonitorUpdateError {
182 if self.is_owned && !<*mut nativeMonitorUpdateError>::is_null(self.inner) {
183 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
187 /// Frees any resources used by the MonitorUpdateError, if is_owned is set and inner is non-NULL.
189 pub extern "C" fn MonitorUpdateError_free(this_obj: MonitorUpdateError) { }
191 /// Used only if an object of this type is returned as a trait impl by a method
192 extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
193 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorUpdateError); }
196 impl MonitorUpdateError {
197 pub(crate) fn get_native_ref(&self) -> &'static nativeMonitorUpdateError {
198 unsafe { &*ObjOps::untweak_ptr(self.inner) }
200 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMonitorUpdateError {
201 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
203 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
204 pub(crate) fn take_inner(mut self) -> *mut nativeMonitorUpdateError {
205 assert!(self.is_owned);
206 let ret = ObjOps::untweak_ptr(self.inner);
207 self.inner = std::ptr::null_mut();
211 impl Clone for MonitorUpdateError {
212 fn clone(&self) -> Self {
214 inner: if <*mut nativeMonitorUpdateError>::is_null(self.inner) { std::ptr::null_mut() } else {
215 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
221 /// Used only if an object of this type is returned as a trait impl by a method
222 pub(crate) extern "C" fn MonitorUpdateError_clone_void(this_ptr: *const c_void) -> *mut c_void {
223 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMonitorUpdateError)).clone() })) as *mut c_void
226 /// Creates a copy of the MonitorUpdateError
227 pub extern "C" fn MonitorUpdateError_clone(orig: &MonitorUpdateError) -> MonitorUpdateError {
230 /// An event to be processed by the ChannelManager.
234 pub enum MonitorEvent {
235 /// A monitor event containing an HTLCUpdate.
236 HTLCEvent(crate::lightning::chain::channelmonitor::HTLCUpdate),
237 /// A monitor event that the Channel's commitment transaction was confirmed.
238 CommitmentTxConfirmed(crate::lightning::chain::transaction::OutPoint),
240 use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEvent;
243 pub(crate) fn to_native(&self) -> nativeMonitorEvent {
245 MonitorEvent::HTLCEvent (ref a, ) => {
246 let mut a_nonref = (*a).clone();
247 nativeMonitorEvent::HTLCEvent (
248 *unsafe { Box::from_raw(a_nonref.take_inner()) },
251 MonitorEvent::CommitmentTxConfirmed (ref a, ) => {
252 let mut a_nonref = (*a).clone();
253 nativeMonitorEvent::CommitmentTxConfirmed (
254 *unsafe { Box::from_raw(a_nonref.take_inner()) },
260 pub(crate) fn into_native(self) -> nativeMonitorEvent {
262 MonitorEvent::HTLCEvent (mut a, ) => {
263 nativeMonitorEvent::HTLCEvent (
264 *unsafe { Box::from_raw(a.take_inner()) },
267 MonitorEvent::CommitmentTxConfirmed (mut a, ) => {
268 nativeMonitorEvent::CommitmentTxConfirmed (
269 *unsafe { Box::from_raw(a.take_inner()) },
275 pub(crate) fn from_native(native: &nativeMonitorEvent) -> Self {
277 nativeMonitorEvent::HTLCEvent (ref a, ) => {
278 let mut a_nonref = (*a).clone();
279 MonitorEvent::HTLCEvent (
280 crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
283 nativeMonitorEvent::CommitmentTxConfirmed (ref a, ) => {
284 let mut a_nonref = (*a).clone();
285 MonitorEvent::CommitmentTxConfirmed (
286 crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
292 pub(crate) fn native_into(native: nativeMonitorEvent) -> Self {
294 nativeMonitorEvent::HTLCEvent (mut a, ) => {
295 MonitorEvent::HTLCEvent (
296 crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
299 nativeMonitorEvent::CommitmentTxConfirmed (mut a, ) => {
300 MonitorEvent::CommitmentTxConfirmed (
301 crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a), is_owned: true },
307 /// Frees any resources used by the MonitorEvent
309 pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { }
310 /// Creates a copy of the MonitorEvent
312 pub extern "C" fn MonitorEvent_clone(orig: &MonitorEvent) -> MonitorEvent {
316 /// Utility method to constructs a new HTLCEvent-variant MonitorEvent
317 pub extern "C" fn MonitorEvent_htlcevent(a: crate::lightning::chain::channelmonitor::HTLCUpdate) -> MonitorEvent {
318 MonitorEvent::HTLCEvent(a, )
321 /// Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent
322 pub extern "C" fn MonitorEvent_commitment_tx_confirmed(a: crate::lightning::chain::transaction::OutPoint) -> MonitorEvent {
323 MonitorEvent::CommitmentTxConfirmed(a, )
326 use lightning::chain::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
327 type nativeHTLCUpdate = nativeHTLCUpdateImport;
329 /// Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
330 /// chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
331 /// preimage claim backward will lead to loss of funds.
334 pub struct HTLCUpdate {
335 /// A pointer to the opaque Rust object.
337 /// Nearly everywhere, inner must be non-null, however in places where
338 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
339 pub inner: *mut nativeHTLCUpdate,
340 /// Indicates that this is the only struct which contains the same pointer.
342 /// Rust functions which take ownership of an object provided via an argument require
343 /// this to be true and invalidate the object pointed to by inner.
347 impl Drop for HTLCUpdate {
349 if self.is_owned && !<*mut nativeHTLCUpdate>::is_null(self.inner) {
350 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
354 /// Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL.
356 pub extern "C" fn HTLCUpdate_free(this_obj: HTLCUpdate) { }
358 /// Used only if an object of this type is returned as a trait impl by a method
359 extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
360 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCUpdate); }
364 pub(crate) fn get_native_ref(&self) -> &'static nativeHTLCUpdate {
365 unsafe { &*ObjOps::untweak_ptr(self.inner) }
367 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeHTLCUpdate {
368 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
370 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
371 pub(crate) fn take_inner(mut self) -> *mut nativeHTLCUpdate {
372 assert!(self.is_owned);
373 let ret = ObjOps::untweak_ptr(self.inner);
374 self.inner = std::ptr::null_mut();
378 impl Clone for HTLCUpdate {
379 fn clone(&self) -> Self {
381 inner: if <*mut nativeHTLCUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
382 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
388 /// Used only if an object of this type is returned as a trait impl by a method
389 pub(crate) extern "C" fn HTLCUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
390 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCUpdate)).clone() })) as *mut c_void
393 /// Creates a copy of the HTLCUpdate
394 pub extern "C" fn HTLCUpdate_clone(orig: &HTLCUpdate) -> HTLCUpdate {
398 /// Serialize the HTLCUpdate object into a byte array which can be read by HTLCUpdate_read
399 pub extern "C" fn HTLCUpdate_write(obj: &HTLCUpdate) -> crate::c_types::derived::CVec_u8Z {
400 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
403 pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
404 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCUpdate) })
407 /// Read a HTLCUpdate from a byte array, created by HTLCUpdate_write
408 pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HTLCUpdateDecodeErrorZ {
409 let res = crate::c_types::deserialize_obj(ser);
410 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
413 /// Number of blocks we wait on seeing a HTLC output being solved before we fail corresponding
414 /// inbound HTLCs. This prevents us from failing backwards and then getting a reorg resulting in us
417 /// Note that this is a library-wide security assumption. If a reorg deeper than this number of
418 /// blocks occurs, counterparties may be able to steal funds or claims made by and balances exposed
419 /// by a [`ChannelMonitor`] may be incorrect.
422 pub static ANTI_REORG_DELAY: u32 = lightning::chain::channelmonitor::ANTI_REORG_DELAY;
423 /// Details about the balance(s) available for spending once the channel appears on chain.
425 /// See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not
431 /// The channel is not yet closed (or the commitment or closing transaction has not yet
432 /// appeared in a block). The given balance is claimable (less on-chain fees) if the channel is
433 /// force-closed now.
434 ClaimableOnChannelClose {
435 /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
436 /// required to do so.
437 claimable_amount_satoshis: u64,
439 /// The channel has been closed, and the given balance is ours but awaiting confirmations until
440 /// we consider it spendable.
441 ClaimableAwaitingConfirmations {
442 /// The amount available to claim, in satoshis, possibly excluding the on-chain fees which
443 /// were spent in broadcasting the transaction.
444 claimable_amount_satoshis: u64,
445 /// The height at which an [`Event::SpendableOutputs`] event will be generated for this
447 confirmation_height: u32,
449 /// The channel has been closed, and the given balance should be ours but awaiting spending
450 /// transaction confirmation. If the spending transaction does not confirm in time, it is
451 /// possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain.
453 /// Once the spending transaction confirms, before it has reached enough confirmations to be
454 /// considered safe from chain reorganizations, the balance will instead be provided via
455 /// [`Balance::ClaimableAwaitingConfirmations`].
456 ContentiousClaimable {
457 /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
458 /// required to do so.
459 claimable_amount_satoshis: u64,
460 /// The height at which the counterparty may be able to claim the balance if we have not
464 /// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
465 /// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
466 /// likely to be claimed by our counterparty before we do.
467 MaybeClaimableHTLCAwaitingTimeout {
468 /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
469 /// required to do so.
470 claimable_amount_satoshis: u64,
471 /// The height at which we will be able to claim the balance if our counterparty has not
473 claimable_height: u32,
476 use lightning::chain::channelmonitor::Balance as nativeBalance;
479 pub(crate) fn to_native(&self) -> nativeBalance {
481 Balance::ClaimableOnChannelClose {ref claimable_amount_satoshis, } => {
482 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
483 nativeBalance::ClaimableOnChannelClose {
484 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
487 Balance::ClaimableAwaitingConfirmations {ref claimable_amount_satoshis, ref confirmation_height, } => {
488 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
489 let mut confirmation_height_nonref = (*confirmation_height).clone();
490 nativeBalance::ClaimableAwaitingConfirmations {
491 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
492 confirmation_height: confirmation_height_nonref,
495 Balance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => {
496 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
497 let mut timeout_height_nonref = (*timeout_height).clone();
498 nativeBalance::ContentiousClaimable {
499 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
500 timeout_height: timeout_height_nonref,
503 Balance::MaybeClaimableHTLCAwaitingTimeout {ref claimable_amount_satoshis, ref claimable_height, } => {
504 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
505 let mut claimable_height_nonref = (*claimable_height).clone();
506 nativeBalance::MaybeClaimableHTLCAwaitingTimeout {
507 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
508 claimable_height: claimable_height_nonref,
514 pub(crate) fn into_native(self) -> nativeBalance {
516 Balance::ClaimableOnChannelClose {mut claimable_amount_satoshis, } => {
517 nativeBalance::ClaimableOnChannelClose {
518 claimable_amount_satoshis: claimable_amount_satoshis,
521 Balance::ClaimableAwaitingConfirmations {mut claimable_amount_satoshis, mut confirmation_height, } => {
522 nativeBalance::ClaimableAwaitingConfirmations {
523 claimable_amount_satoshis: claimable_amount_satoshis,
524 confirmation_height: confirmation_height,
527 Balance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => {
528 nativeBalance::ContentiousClaimable {
529 claimable_amount_satoshis: claimable_amount_satoshis,
530 timeout_height: timeout_height,
533 Balance::MaybeClaimableHTLCAwaitingTimeout {mut claimable_amount_satoshis, mut claimable_height, } => {
534 nativeBalance::MaybeClaimableHTLCAwaitingTimeout {
535 claimable_amount_satoshis: claimable_amount_satoshis,
536 claimable_height: claimable_height,
542 pub(crate) fn from_native(native: &nativeBalance) -> Self {
544 nativeBalance::ClaimableOnChannelClose {ref claimable_amount_satoshis, } => {
545 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
546 Balance::ClaimableOnChannelClose {
547 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
550 nativeBalance::ClaimableAwaitingConfirmations {ref claimable_amount_satoshis, ref confirmation_height, } => {
551 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
552 let mut confirmation_height_nonref = (*confirmation_height).clone();
553 Balance::ClaimableAwaitingConfirmations {
554 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
555 confirmation_height: confirmation_height_nonref,
558 nativeBalance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => {
559 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
560 let mut timeout_height_nonref = (*timeout_height).clone();
561 Balance::ContentiousClaimable {
562 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
563 timeout_height: timeout_height_nonref,
566 nativeBalance::MaybeClaimableHTLCAwaitingTimeout {ref claimable_amount_satoshis, ref claimable_height, } => {
567 let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
568 let mut claimable_height_nonref = (*claimable_height).clone();
569 Balance::MaybeClaimableHTLCAwaitingTimeout {
570 claimable_amount_satoshis: claimable_amount_satoshis_nonref,
571 claimable_height: claimable_height_nonref,
577 pub(crate) fn native_into(native: nativeBalance) -> Self {
579 nativeBalance::ClaimableOnChannelClose {mut claimable_amount_satoshis, } => {
580 Balance::ClaimableOnChannelClose {
581 claimable_amount_satoshis: claimable_amount_satoshis,
584 nativeBalance::ClaimableAwaitingConfirmations {mut claimable_amount_satoshis, mut confirmation_height, } => {
585 Balance::ClaimableAwaitingConfirmations {
586 claimable_amount_satoshis: claimable_amount_satoshis,
587 confirmation_height: confirmation_height,
590 nativeBalance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => {
591 Balance::ContentiousClaimable {
592 claimable_amount_satoshis: claimable_amount_satoshis,
593 timeout_height: timeout_height,
596 nativeBalance::MaybeClaimableHTLCAwaitingTimeout {mut claimable_amount_satoshis, mut claimable_height, } => {
597 Balance::MaybeClaimableHTLCAwaitingTimeout {
598 claimable_amount_satoshis: claimable_amount_satoshis,
599 claimable_height: claimable_height,
605 /// Frees any resources used by the Balance
607 pub extern "C" fn Balance_free(this_ptr: Balance) { }
608 /// Creates a copy of the Balance
610 pub extern "C" fn Balance_clone(orig: &Balance) -> Balance {
614 /// Utility method to constructs a new ClaimableOnChannelClose-variant Balance
615 pub extern "C" fn Balance_claimable_on_channel_close(claimable_amount_satoshis: u64) -> Balance {
616 Balance::ClaimableOnChannelClose {
617 claimable_amount_satoshis,
621 /// Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance
622 pub extern "C" fn Balance_claimable_awaiting_confirmations(claimable_amount_satoshis: u64, confirmation_height: u32) -> Balance {
623 Balance::ClaimableAwaitingConfirmations {
624 claimable_amount_satoshis,
629 /// Utility method to constructs a new ContentiousClaimable-variant Balance
630 pub extern "C" fn Balance_contentious_claimable(claimable_amount_satoshis: u64, timeout_height: u32) -> Balance {
631 Balance::ContentiousClaimable {
632 claimable_amount_satoshis,
637 /// Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance
638 pub extern "C" fn Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis: u64, claimable_height: u32) -> Balance {
639 Balance::MaybeClaimableHTLCAwaitingTimeout {
640 claimable_amount_satoshis,
644 /// Checks if two Balances contain equal inner contents.
645 /// This ignores pointers and is_owned flags and looks at the values in fields.
647 pub extern "C" fn Balance_eq(a: &Balance, b: &Balance) -> bool {
648 if &a.to_native() == &b.to_native() { true } else { false }
651 use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
652 type nativeChannelMonitor = nativeChannelMonitorImport<crate::lightning::chain::keysinterface::Sign>;
654 /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
655 /// on-chain transactions to ensure no loss of funds occurs.
657 /// You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
658 /// information and are actively monitoring the chain.
660 /// Pending Events or updated HTLCs which have not yet been read out by
661 /// get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
662 /// reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
663 /// gotten are fully handled before re-serializing the new state.
665 /// Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which
666 /// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
667 /// the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
668 /// returned block hash and the the current chain and then reconnecting blocks to get to the
669 /// best chain) upon deserializing the object!
672 pub struct ChannelMonitor {
673 /// A pointer to the opaque Rust object.
675 /// Nearly everywhere, inner must be non-null, however in places where
676 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
677 pub inner: *mut nativeChannelMonitor,
678 /// Indicates that this is the only struct which contains the same pointer.
680 /// Rust functions which take ownership of an object provided via an argument require
681 /// this to be true and invalidate the object pointed to by inner.
685 impl Drop for ChannelMonitor {
687 if self.is_owned && !<*mut nativeChannelMonitor>::is_null(self.inner) {
688 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
692 /// Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL.
694 pub extern "C" fn ChannelMonitor_free(this_obj: ChannelMonitor) { }
696 /// Used only if an object of this type is returned as a trait impl by a method
697 extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
698 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitor); }
701 impl ChannelMonitor {
702 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelMonitor {
703 unsafe { &*ObjOps::untweak_ptr(self.inner) }
705 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelMonitor {
706 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
708 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
709 pub(crate) fn take_inner(mut self) -> *mut nativeChannelMonitor {
710 assert!(self.is_owned);
711 let ret = ObjOps::untweak_ptr(self.inner);
712 self.inner = std::ptr::null_mut();
717 /// Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read
718 pub extern "C" fn ChannelMonitor_write(obj: &ChannelMonitor) -> crate::c_types::derived::CVec_u8Z {
719 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
722 pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
723 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitor) })
725 /// Updates a ChannelMonitor on the basis of some new information provided by the Channel
728 /// panics if the given update is not the next update by update_id.
731 pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &ChannelMonitor, updates: &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::lightning::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::lightning::chain::chaininterface::FeeEstimator, logger: &crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ {
732 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_monitor(updates.get_native_ref(), broadcaster, fee_estimator, logger);
733 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::chain::channelmonitor::MonitorUpdateError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
737 /// Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
741 pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor) -> u64 {
742 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_latest_update_id();
746 /// Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
749 pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> crate::c_types::derived::C2Tuple_OutPointScriptZ {
750 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_funding_txo();
751 let (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0), is_owned: true }, orig_ret_1.into_bytes().into()).into();
755 /// Gets a list of txids, with their output scripts (in the order they appear in the
756 /// transaction), which we must learn about spends of via block_connected().
759 pub extern "C" fn ChannelMonitor_get_outputs_to_watch(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ {
760 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_outputs_to_watch();
761 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, orig_orig_ret_0_1_0_1.into_bytes().into()).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 }); };
765 /// Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly
766 /// calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs
767 /// have been registered.
769 pub extern "C" fn ChannelMonitor_load_outputs_to_watch(this_arg: &ChannelMonitor, filter: &crate::lightning::chain::Filter) {
770 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.load_outputs_to_watch(filter)
773 /// Get the list of HTLCs who's status has been updated on chain. This should be called by
774 /// ChannelManager via [`chain::Watch::release_pending_monitor_events`].
777 pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
778 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_and_clear_pending_monitor_events();
779 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::chain::channelmonitor::MonitorEvent::native_into(item) }); };
783 /// Gets the list of pending events which were generated by previous actions, clearing the list
786 /// This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to
787 /// EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
788 /// no internal locking in ChannelMonitors.
791 pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
792 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_and_clear_pending_events();
793 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); };
797 /// Used by ChannelManager deserialization to broadcast the latest holder state if its copy of
798 /// the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of
799 /// fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows
800 /// a higher revocation secret than the holder commitment number we are aware of. Broadcasting these
801 /// transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to
802 /// broadcast them if counterparty don't close channel with his higher commitment transaction after a
803 /// substantial amount of time (a month or even a year) to get back funds. Best may be to contact
804 /// out-of-band the other node operator to coordinate with him if option is available to you.
805 /// In any-case, choice is up to the user.
808 pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &ChannelMonitor, logger: &crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
809 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_latest_holder_commitment_txn(logger);
810 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::Transaction::from_bitcoin(&item) }); };
814 /// Processes transactions in a newly connected block, which may result in any of the following:
815 /// - update the monitor's state against resolved HTLCs
816 /// - punish the counterparty in the case of seeing a revoked commitment transaction
817 /// - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration
818 /// - detect settled outputs for later spending
819 /// - schedule and bump any in-flight claims
821 /// Returns any new outputs to watch from `txdata`; after called, these are also included in
822 /// [`get_outputs_to_watch`].
824 /// [`get_outputs_to_watch`]: #method.get_outputs_to_watch
827 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::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ {
828 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 }); };
829 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height, broadcaster, fee_estimator, logger);
830 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 }); };
834 /// Determines if the disconnected block contained any transactions of interest and updates
837 pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) {
838 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger)
841 /// Processes transactions confirmed in a block with the given header and height, returning new
842 /// outputs to watch. See [`block_connected`] for details.
844 /// Used instead of [`block_connected`] by clients that are notified of transactions rather than
845 /// blocks. See [`chain::Confirm`] for calling expectations.
847 /// [`block_connected`]: Self::block_connected
850 pub extern "C" fn ChannelMonitor_transactions_confirmed(this_arg: &ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ {
851 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 }); };
852 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.transactions_confirmed(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height, broadcaster, fee_estimator, logger);
853 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 }); };
857 /// Processes a transaction that was reorganized out of the chain.
859 /// Used instead of [`block_disconnected`] by clients that are notified of transactions rather
860 /// than blocks. See [`chain::Confirm`] for calling expectations.
862 /// [`block_disconnected`]: Self::block_disconnected
864 pub extern "C" fn ChannelMonitor_transaction_unconfirmed(this_arg: &ChannelMonitor, txid: *const [u8; 32], mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) {
865 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.transaction_unconfirmed(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), broadcaster, fee_estimator, logger)
868 /// Updates the monitor with the current best chain tip, returning new outputs to watch. See
869 /// [`block_connected`] for details.
871 /// Used instead of [`block_connected`] by clients that are notified of transactions rather than
872 /// blocks. See [`chain::Confirm`] for calling expectations.
874 /// [`block_connected`]: Self::block_connected
877 pub extern "C" fn ChannelMonitor_best_block_updated(this_arg: &ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut logger: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionOutputsZ {
878 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.best_block_updated(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger);
879 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 }); };
883 /// Returns the set of txids that should be monitored for re-organization out of the chain.
886 pub extern "C" fn ChannelMonitor_get_relevant_txids(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_TxidZ {
887 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_relevant_txids();
888 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); };
892 /// Gets the latest best block which was connected either via the [`chain::Listen`] or
893 /// [`chain::Confirm`] interfaces.
896 pub extern "C" fn ChannelMonitor_current_best_block(this_arg: &ChannelMonitor) -> crate::lightning::chain::BestBlock {
897 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.current_best_block();
898 crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true }
901 /// Gets the balances in this channel which are either claimable by us if we were to
902 /// force-close the channel now or which are claimable on-chain (possibly awaiting
905 /// Any balances in the channel which are available on-chain (excluding on-chain fees) are
906 /// included here until an [`Event::SpendableOutputs`] event has been generated for the
907 /// balance, or until our counterparty has claimed the balance and accrued several
908 /// confirmations on the claim transaction.
910 /// Note that the balances available when you or your counterparty have broadcasted revoked
911 /// state(s) may not be fully captured here.
913 /// See [`Balance`] for additional details on the types of claimable balances which
914 /// may be returned here and their meanings.
917 pub extern "C" fn ChannelMonitor_get_claimable_balances(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_BalanceZ {
918 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_claimable_balances();
919 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::chain::channelmonitor::Balance::native_into(item) }); };
924 /// Read a C2Tuple_BlockHashChannelMonitorZ from a byte array, created by C2Tuple_BlockHashChannelMonitorZ_write
925 pub extern "C" fn C2Tuple_BlockHashChannelMonitorZ_read(ser: crate::c_types::u8slice, arg: &crate::lightning::chain::keysinterface::KeysInterface) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
927 let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor<crate::lightning::chain::keysinterface::Sign>), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
928 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::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };