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 //! Information about the state of a channel.
11 use alloc::str::FromStr;
12 use alloc::string::String;
13 use core::ffi::c_void;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17 #[cfg(feature="no-std")]
18 use alloc::{vec::Vec, boxed::Box};
20 /// Exposes the state of pending inbound HTLCs.
22 /// At a high level, an HTLC being forwarded from one Lightning node to another Lightning node goes
23 /// through the following states in the state machine:
24 /// - Announced for addition by the originating node through the update_add_htlc message.
25 /// - Added to the commitment transaction of the receiving node and originating node in turn
26 /// through the exchange of commitment_signed and revoke_and_ack messages.
27 /// - Announced for resolution (fulfillment or failure) by the receiving node through either one of
28 /// the update_fulfill_htlc, update_fail_htlc, and update_fail_malformed_htlc messages.
29 /// - Removed from the commitment transaction of the originating node and receiving node in turn
30 /// through the exchange of commitment_signed and revoke_and_ack messages.
32 /// This can be used to inspect what next message an HTLC is waiting for to advance its state.
36 pub enum InboundHTLCStateDetails {
37 /// We have added this HTLC in our commitment transaction by receiving commitment_signed and
38 /// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote
39 /// before this HTLC is included on the remote commitment transaction.
40 AwaitingRemoteRevokeToAdd,
41 /// This HTLC has been included in the commitment_signed and revoke_and_ack messages on both sides
42 /// and is included in both commitment transactions.
44 /// This HTLC is now safe to either forward or be claimed as a payment by us. The HTLC will
45 /// remain in this state until the forwarded upstream HTLC has been resolved and we resolve this
46 /// HTLC correspondingly, or until we claim it as a payment. If it is part of a multipart
47 /// payment, it will only be claimed together with other required parts.
49 /// We have received the preimage for this HTLC and it is being removed by fulfilling it with
50 /// update_fulfill_htlc. This HTLC is still on both commitment transactions, but we are awaiting
51 /// the appropriate revoke_and_ack's from the remote before this HTLC is removed from the remote
52 /// commitment transaction after update_fulfill_htlc.
53 AwaitingRemoteRevokeToRemoveFulfill,
54 /// The HTLC is being removed by failing it with update_fail_htlc or update_fail_malformed_htlc.
55 /// This HTLC is still on both commitment transactions, but we are awaiting the appropriate
56 /// revoke_and_ack's from the remote before this HTLC is removed from the remote commitment
58 AwaitingRemoteRevokeToRemoveFail,
60 use lightning::ln::channel_state::InboundHTLCStateDetails as InboundHTLCStateDetailsImport;
61 pub(crate) type nativeInboundHTLCStateDetails = InboundHTLCStateDetailsImport;
63 impl InboundHTLCStateDetails {
65 pub(crate) fn to_native(&self) -> nativeInboundHTLCStateDetails {
67 InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
68 InboundHTLCStateDetails::Committed => nativeInboundHTLCStateDetails::Committed,
69 InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
70 InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
74 pub(crate) fn into_native(self) -> nativeInboundHTLCStateDetails {
76 InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
77 InboundHTLCStateDetails::Committed => nativeInboundHTLCStateDetails::Committed,
78 InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
79 InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
83 pub(crate) fn from_native(native: &InboundHTLCStateDetailsImport) -> Self {
84 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeInboundHTLCStateDetails) };
86 nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
87 nativeInboundHTLCStateDetails::Committed => InboundHTLCStateDetails::Committed,
88 nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
89 nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
93 pub(crate) fn native_into(native: nativeInboundHTLCStateDetails) -> Self {
95 nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
96 nativeInboundHTLCStateDetails::Committed => InboundHTLCStateDetails::Committed,
97 nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
98 nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
102 /// Creates a copy of the InboundHTLCStateDetails
104 pub extern "C" fn InboundHTLCStateDetails_clone(orig: &InboundHTLCStateDetails) -> InboundHTLCStateDetails {
108 /// Used only if an object of this type is returned as a trait impl by a method
109 pub(crate) extern "C" fn InboundHTLCStateDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
110 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const InboundHTLCStateDetails)).clone() })) as *mut c_void
113 /// Used only if an object of this type is returned as a trait impl by a method
114 pub(crate) extern "C" fn InboundHTLCStateDetails_free_void(this_ptr: *mut c_void) {
115 let _ = unsafe { Box::from_raw(this_ptr as *mut InboundHTLCStateDetails) };
118 /// Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant InboundHTLCStateDetails
119 pub extern "C" fn InboundHTLCStateDetails_awaiting_remote_revoke_to_add() -> InboundHTLCStateDetails {
120 InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd}
122 /// Utility method to constructs a new Committed-variant InboundHTLCStateDetails
123 pub extern "C" fn InboundHTLCStateDetails_committed() -> InboundHTLCStateDetails {
124 InboundHTLCStateDetails::Committed}
126 /// Utility method to constructs a new AwaitingRemoteRevokeToRemoveFulfill-variant InboundHTLCStateDetails
127 pub extern "C" fn InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fulfill() -> InboundHTLCStateDetails {
128 InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill}
130 /// Utility method to constructs a new AwaitingRemoteRevokeToRemoveFail-variant InboundHTLCStateDetails
131 pub extern "C" fn InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fail() -> InboundHTLCStateDetails {
132 InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail}
133 /// Get a string which allows debug introspection of a InboundHTLCStateDetails object
134 pub extern "C" fn InboundHTLCStateDetails_debug_str_void(o: *const c_void) -> Str {
135 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::InboundHTLCStateDetails }).into()}
137 /// Serialize the InboundHTLCStateDetails object into a byte array which can be read by InboundHTLCStateDetails_read
138 pub extern "C" fn InboundHTLCStateDetails_write(obj: &crate::lightning::ln::channel_state::InboundHTLCStateDetails) -> crate::c_types::derived::CVec_u8Z {
139 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
142 pub(crate) extern "C" fn InboundHTLCStateDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
143 InboundHTLCStateDetails_write(unsafe { &*(obj as *const InboundHTLCStateDetails) })
146 /// Read a InboundHTLCStateDetails from a byte array, created by InboundHTLCStateDetails_write
147 pub extern "C" fn InboundHTLCStateDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ {
148 let res: Result<Option<lightning::ln::channel_state::InboundHTLCStateDetails>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
149 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::Some( { crate::lightning::ln::channel_state::InboundHTLCStateDetails::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
153 use lightning::ln::channel_state::InboundHTLCDetails as nativeInboundHTLCDetailsImport;
154 pub(crate) type nativeInboundHTLCDetails = nativeInboundHTLCDetailsImport;
156 /// Exposes details around pending inbound HTLCs.
159 pub struct InboundHTLCDetails {
160 /// A pointer to the opaque Rust object.
162 /// Nearly everywhere, inner must be non-null, however in places where
163 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
164 pub inner: *mut nativeInboundHTLCDetails,
165 /// Indicates that this is the only struct which contains the same pointer.
167 /// Rust functions which take ownership of an object provided via an argument require
168 /// this to be true and invalidate the object pointed to by inner.
172 impl Drop for InboundHTLCDetails {
174 if self.is_owned && !<*mut nativeInboundHTLCDetails>::is_null(self.inner) {
175 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
179 /// Frees any resources used by the InboundHTLCDetails, if is_owned is set and inner is non-NULL.
181 pub extern "C" fn InboundHTLCDetails_free(this_obj: InboundHTLCDetails) { }
183 /// Used only if an object of this type is returned as a trait impl by a method
184 pub(crate) extern "C" fn InboundHTLCDetails_free_void(this_ptr: *mut c_void) {
185 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInboundHTLCDetails) };
188 impl InboundHTLCDetails {
189 pub(crate) fn get_native_ref(&self) -> &'static nativeInboundHTLCDetails {
190 unsafe { &*ObjOps::untweak_ptr(self.inner) }
192 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInboundHTLCDetails {
193 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
195 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
196 pub(crate) fn take_inner(mut self) -> *mut nativeInboundHTLCDetails {
197 assert!(self.is_owned);
198 let ret = ObjOps::untweak_ptr(self.inner);
199 self.inner = core::ptr::null_mut();
204 /// The IDs are incremented by 1 starting from 0 for each offered HTLC.
205 /// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced
206 /// and not part of any commitment transaction.
208 pub extern "C" fn InboundHTLCDetails_get_htlc_id(this_ptr: &InboundHTLCDetails) -> u64 {
209 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
213 /// The IDs are incremented by 1 starting from 0 for each offered HTLC.
214 /// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced
215 /// and not part of any commitment transaction.
217 pub extern "C" fn InboundHTLCDetails_set_htlc_id(this_ptr: &mut InboundHTLCDetails, mut val: u64) {
218 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val;
220 /// The amount in msat.
222 pub extern "C" fn InboundHTLCDetails_get_amount_msat(this_ptr: &InboundHTLCDetails) -> u64 {
223 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
226 /// The amount in msat.
228 pub extern "C" fn InboundHTLCDetails_set_amount_msat(this_ptr: &mut InboundHTLCDetails, mut val: u64) {
229 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
231 /// The block height at which this HTLC expires.
233 pub extern "C" fn InboundHTLCDetails_get_cltv_expiry(this_ptr: &InboundHTLCDetails) -> u32 {
234 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
237 /// The block height at which this HTLC expires.
239 pub extern "C" fn InboundHTLCDetails_set_cltv_expiry(this_ptr: &mut InboundHTLCDetails, mut val: u32) {
240 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
242 /// The payment hash.
244 pub extern "C" fn InboundHTLCDetails_get_payment_hash(this_ptr: &InboundHTLCDetails) -> *const [u8; 32] {
245 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
248 /// The payment hash.
250 pub extern "C" fn InboundHTLCDetails_set_payment_hash(this_ptr: &mut InboundHTLCDetails, mut val: crate::c_types::ThirtyTwoBytes) {
251 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data);
253 /// The state of the HTLC in the state machine.
255 /// Determines on which commitment transactions the HTLC is included and what message the HTLC is
256 /// waiting for to advance to the next state.
258 /// See [`InboundHTLCStateDetails`] for information on the specific states.
260 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
261 /// states may result in `None` here.
263 pub extern "C" fn InboundHTLCDetails_get_state(this_ptr: &InboundHTLCDetails) -> crate::c_types::derived::COption_InboundHTLCStateDetailsZ {
264 let mut inner_val = &mut this_ptr.get_native_mut_ref().state;
265 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::channel_state::InboundHTLCStateDetails::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
268 /// The state of the HTLC in the state machine.
270 /// Determines on which commitment transactions the HTLC is included and what message the HTLC is
271 /// waiting for to advance to the next state.
273 /// See [`InboundHTLCStateDetails`] for information on the specific states.
275 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
276 /// states may result in `None` here.
278 pub extern "C" fn InboundHTLCDetails_set_state(this_ptr: &mut InboundHTLCDetails, mut val: crate::c_types::derived::COption_InboundHTLCStateDetailsZ) {
279 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.state = local_val;
282 /// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed
283 /// from the local commitment transaction and added to the commitment transaction fee.
284 /// For non-anchor channels, this takes into account the cost of the second-stage HTLC
285 /// transactions as well.
287 /// When the local commitment transaction is broadcasted as part of a unilateral closure,
288 /// the value of this HTLC will therefore not be claimable but instead burned as a transaction
291 /// Note that dust limits are specific to each party. An HTLC can be dust for the local
292 /// commitment transaction but not for the counterparty's commitment transaction and vice versa.
294 pub extern "C" fn InboundHTLCDetails_get_is_dust(this_ptr: &InboundHTLCDetails) -> bool {
295 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_dust;
298 /// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed
299 /// from the local commitment transaction and added to the commitment transaction fee.
300 /// For non-anchor channels, this takes into account the cost of the second-stage HTLC
301 /// transactions as well.
303 /// When the local commitment transaction is broadcasted as part of a unilateral closure,
304 /// the value of this HTLC will therefore not be claimable but instead burned as a transaction
307 /// Note that dust limits are specific to each party. An HTLC can be dust for the local
308 /// commitment transaction but not for the counterparty's commitment transaction and vice versa.
310 pub extern "C" fn InboundHTLCDetails_set_is_dust(this_ptr: &mut InboundHTLCDetails, mut val: bool) {
311 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_dust = val;
313 /// Constructs a new InboundHTLCDetails given each field
316 pub extern "C" fn InboundHTLCDetails_new(mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut cltv_expiry_arg: u32, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut state_arg: crate::c_types::derived::COption_InboundHTLCStateDetailsZ, mut is_dust_arg: bool) -> InboundHTLCDetails {
317 let mut local_state_arg = { /*state_arg*/ let state_arg_opt = state_arg; if state_arg_opt.is_none() { None } else { Some({ { { state_arg_opt.take() }.into_native() }})} };
318 InboundHTLCDetails { inner: ObjOps::heap_alloc(nativeInboundHTLCDetails {
319 htlc_id: htlc_id_arg,
320 amount_msat: amount_msat_arg,
321 cltv_expiry: cltv_expiry_arg,
322 payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data),
323 state: local_state_arg,
324 is_dust: is_dust_arg,
327 impl Clone for InboundHTLCDetails {
328 fn clone(&self) -> Self {
330 inner: if <*mut nativeInboundHTLCDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
331 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
337 /// Used only if an object of this type is returned as a trait impl by a method
338 pub(crate) extern "C" fn InboundHTLCDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
339 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInboundHTLCDetails)).clone() })) as *mut c_void
342 /// Creates a copy of the InboundHTLCDetails
343 pub extern "C" fn InboundHTLCDetails_clone(orig: &InboundHTLCDetails) -> InboundHTLCDetails {
346 /// Get a string which allows debug introspection of a InboundHTLCDetails object
347 pub extern "C" fn InboundHTLCDetails_debug_str_void(o: *const c_void) -> Str {
348 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::InboundHTLCDetails }).into()}
350 /// Serialize the InboundHTLCDetails object into a byte array which can be read by InboundHTLCDetails_read
351 pub extern "C" fn InboundHTLCDetails_write(obj: &crate::lightning::ln::channel_state::InboundHTLCDetails) -> crate::c_types::derived::CVec_u8Z {
352 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
355 pub(crate) extern "C" fn InboundHTLCDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
356 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInboundHTLCDetails) })
359 /// Read a InboundHTLCDetails from a byte array, created by InboundHTLCDetails_write
360 pub extern "C" fn InboundHTLCDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InboundHTLCDetailsDecodeErrorZ {
361 let res: Result<lightning::ln::channel_state::InboundHTLCDetails, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
362 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::InboundHTLCDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
365 /// Exposes the state of pending outbound HTLCs.
367 /// At a high level, an HTLC being forwarded from one Lightning node to another Lightning node goes
368 /// through the following states in the state machine:
369 /// - Announced for addition by the originating node through the update_add_htlc message.
370 /// - Added to the commitment transaction of the receiving node and originating node in turn
371 /// through the exchange of commitment_signed and revoke_and_ack messages.
372 /// - Announced for resolution (fulfillment or failure) by the receiving node through either one of
373 /// the update_fulfill_htlc, update_fail_htlc, and update_fail_malformed_htlc messages.
374 /// - Removed from the commitment transaction of the originating node and receiving node in turn
375 /// through the exchange of commitment_signed and revoke_and_ack messages.
377 /// This can be used to inspect what next message an HTLC is waiting for to advance its state.
381 pub enum OutboundHTLCStateDetails {
382 /// We are awaiting the appropriate revoke_and_ack's from the remote before the HTLC is added
383 /// on the remote's commitment transaction after update_add_htlc.
384 AwaitingRemoteRevokeToAdd,
385 /// The HTLC has been added to the remote's commitment transaction by sending commitment_signed
386 /// and receiving revoke_and_ack in return.
388 /// The HTLC will remain in this state until the remote node resolves the HTLC, or until we
389 /// unilaterally close the channel due to a timeout with an uncooperative remote node.
391 /// The HTLC has been fulfilled successfully by the remote with a preimage in update_fulfill_htlc,
392 /// and we removed the HTLC from our commitment transaction by receiving commitment_signed and
393 /// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote
394 /// for the removal from its commitment transaction.
395 AwaitingRemoteRevokeToRemoveSuccess,
396 /// The HTLC has been failed by the remote with update_fail_htlc or update_fail_malformed_htlc,
397 /// and we removed the HTLC from our commitment transaction by receiving commitment_signed and
398 /// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote
399 /// for the removal from its commitment transaction.
400 AwaitingRemoteRevokeToRemoveFailure,
402 use lightning::ln::channel_state::OutboundHTLCStateDetails as OutboundHTLCStateDetailsImport;
403 pub(crate) type nativeOutboundHTLCStateDetails = OutboundHTLCStateDetailsImport;
405 impl OutboundHTLCStateDetails {
407 pub(crate) fn to_native(&self) -> nativeOutboundHTLCStateDetails {
409 OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
410 OutboundHTLCStateDetails::Committed => nativeOutboundHTLCStateDetails::Committed,
411 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
412 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
416 pub(crate) fn into_native(self) -> nativeOutboundHTLCStateDetails {
418 OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
419 OutboundHTLCStateDetails::Committed => nativeOutboundHTLCStateDetails::Committed,
420 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
421 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
425 pub(crate) fn from_native(native: &OutboundHTLCStateDetailsImport) -> Self {
426 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeOutboundHTLCStateDetails) };
428 nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
429 nativeOutboundHTLCStateDetails::Committed => OutboundHTLCStateDetails::Committed,
430 nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
431 nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
435 pub(crate) fn native_into(native: nativeOutboundHTLCStateDetails) -> Self {
437 nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
438 nativeOutboundHTLCStateDetails::Committed => OutboundHTLCStateDetails::Committed,
439 nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
440 nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
444 /// Creates a copy of the OutboundHTLCStateDetails
446 pub extern "C" fn OutboundHTLCStateDetails_clone(orig: &OutboundHTLCStateDetails) -> OutboundHTLCStateDetails {
450 /// Used only if an object of this type is returned as a trait impl by a method
451 pub(crate) extern "C" fn OutboundHTLCStateDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
452 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const OutboundHTLCStateDetails)).clone() })) as *mut c_void
455 /// Used only if an object of this type is returned as a trait impl by a method
456 pub(crate) extern "C" fn OutboundHTLCStateDetails_free_void(this_ptr: *mut c_void) {
457 let _ = unsafe { Box::from_raw(this_ptr as *mut OutboundHTLCStateDetails) };
460 /// Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant OutboundHTLCStateDetails
461 pub extern "C" fn OutboundHTLCStateDetails_awaiting_remote_revoke_to_add() -> OutboundHTLCStateDetails {
462 OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd}
464 /// Utility method to constructs a new Committed-variant OutboundHTLCStateDetails
465 pub extern "C" fn OutboundHTLCStateDetails_committed() -> OutboundHTLCStateDetails {
466 OutboundHTLCStateDetails::Committed}
468 /// Utility method to constructs a new AwaitingRemoteRevokeToRemoveSuccess-variant OutboundHTLCStateDetails
469 pub extern "C" fn OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_success() -> OutboundHTLCStateDetails {
470 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess}
472 /// Utility method to constructs a new AwaitingRemoteRevokeToRemoveFailure-variant OutboundHTLCStateDetails
473 pub extern "C" fn OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_failure() -> OutboundHTLCStateDetails {
474 OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure}
475 /// Get a string which allows debug introspection of a OutboundHTLCStateDetails object
476 pub extern "C" fn OutboundHTLCStateDetails_debug_str_void(o: *const c_void) -> Str {
477 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::OutboundHTLCStateDetails }).into()}
479 /// Serialize the OutboundHTLCStateDetails object into a byte array which can be read by OutboundHTLCStateDetails_read
480 pub extern "C" fn OutboundHTLCStateDetails_write(obj: &crate::lightning::ln::channel_state::OutboundHTLCStateDetails) -> crate::c_types::derived::CVec_u8Z {
481 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
484 pub(crate) extern "C" fn OutboundHTLCStateDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
485 OutboundHTLCStateDetails_write(unsafe { &*(obj as *const OutboundHTLCStateDetails) })
488 /// Read a OutboundHTLCStateDetails from a byte array, created by OutboundHTLCStateDetails_write
489 pub extern "C" fn OutboundHTLCStateDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ {
490 let res: Result<Option<lightning::ln::channel_state::OutboundHTLCStateDetails>, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser);
491 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::Some( { crate::lightning::ln::channel_state::OutboundHTLCStateDetails::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
495 use lightning::ln::channel_state::OutboundHTLCDetails as nativeOutboundHTLCDetailsImport;
496 pub(crate) type nativeOutboundHTLCDetails = nativeOutboundHTLCDetailsImport;
498 /// Exposes details around pending outbound HTLCs.
501 pub struct OutboundHTLCDetails {
502 /// A pointer to the opaque Rust object.
504 /// Nearly everywhere, inner must be non-null, however in places where
505 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
506 pub inner: *mut nativeOutboundHTLCDetails,
507 /// Indicates that this is the only struct which contains the same pointer.
509 /// Rust functions which take ownership of an object provided via an argument require
510 /// this to be true and invalidate the object pointed to by inner.
514 impl Drop for OutboundHTLCDetails {
516 if self.is_owned && !<*mut nativeOutboundHTLCDetails>::is_null(self.inner) {
517 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
521 /// Frees any resources used by the OutboundHTLCDetails, if is_owned is set and inner is non-NULL.
523 pub extern "C" fn OutboundHTLCDetails_free(this_obj: OutboundHTLCDetails) { }
525 /// Used only if an object of this type is returned as a trait impl by a method
526 pub(crate) extern "C" fn OutboundHTLCDetails_free_void(this_ptr: *mut c_void) {
527 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOutboundHTLCDetails) };
530 impl OutboundHTLCDetails {
531 pub(crate) fn get_native_ref(&self) -> &'static nativeOutboundHTLCDetails {
532 unsafe { &*ObjOps::untweak_ptr(self.inner) }
534 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOutboundHTLCDetails {
535 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
537 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
538 pub(crate) fn take_inner(mut self) -> *mut nativeOutboundHTLCDetails {
539 assert!(self.is_owned);
540 let ret = ObjOps::untweak_ptr(self.inner);
541 self.inner = core::ptr::null_mut();
546 /// The IDs are incremented by 1 starting from 0 for each offered HTLC.
547 /// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced
548 /// and not part of any commitment transaction.
550 /// Not present when we are awaiting a remote revocation and the HTLC is not added yet.
552 pub extern "C" fn OutboundHTLCDetails_get_htlc_id(this_ptr: &OutboundHTLCDetails) -> crate::c_types::derived::COption_u64Z {
553 let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id;
554 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
558 /// The IDs are incremented by 1 starting from 0 for each offered HTLC.
559 /// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced
560 /// and not part of any commitment transaction.
562 /// Not present when we are awaiting a remote revocation and the HTLC is not added yet.
564 pub extern "C" fn OutboundHTLCDetails_set_htlc_id(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::derived::COption_u64Z) {
565 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
566 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = local_val;
568 /// The amount in msat.
570 pub extern "C" fn OutboundHTLCDetails_get_amount_msat(this_ptr: &OutboundHTLCDetails) -> u64 {
571 let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat;
574 /// The amount in msat.
576 pub extern "C" fn OutboundHTLCDetails_set_amount_msat(this_ptr: &mut OutboundHTLCDetails, mut val: u64) {
577 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val;
579 /// The block height at which this HTLC expires.
581 pub extern "C" fn OutboundHTLCDetails_get_cltv_expiry(this_ptr: &OutboundHTLCDetails) -> u32 {
582 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry;
585 /// The block height at which this HTLC expires.
587 pub extern "C" fn OutboundHTLCDetails_set_cltv_expiry(this_ptr: &mut OutboundHTLCDetails, mut val: u32) {
588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val;
590 /// The payment hash.
592 pub extern "C" fn OutboundHTLCDetails_get_payment_hash(this_ptr: &OutboundHTLCDetails) -> *const [u8; 32] {
593 let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash;
596 /// The payment hash.
598 pub extern "C" fn OutboundHTLCDetails_set_payment_hash(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::ThirtyTwoBytes) {
599 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data);
601 /// The state of the HTLC in the state machine.
603 /// Determines on which commitment transactions the HTLC is included and what message the HTLC is
604 /// waiting for to advance to the next state.
606 /// See [`OutboundHTLCStateDetails`] for information on the specific states.
608 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
609 /// states may result in `None` here.
611 pub extern "C" fn OutboundHTLCDetails_get_state(this_ptr: &OutboundHTLCDetails) -> crate::c_types::derived::COption_OutboundHTLCStateDetailsZ {
612 let mut inner_val = &mut this_ptr.get_native_mut_ref().state;
613 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option<Enum> is otherwise un-expressable. */ { crate::lightning::ln::channel_state::OutboundHTLCStateDetails::native_into((*inner_val.as_ref().unwrap()).clone()) }) };
616 /// The state of the HTLC in the state machine.
618 /// Determines on which commitment transactions the HTLC is included and what message the HTLC is
619 /// waiting for to advance to the next state.
621 /// See [`OutboundHTLCStateDetails`] for information on the specific states.
623 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
624 /// states may result in `None` here.
626 pub extern "C" fn OutboundHTLCDetails_set_state(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::derived::COption_OutboundHTLCStateDetailsZ) {
627 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
628 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.state = local_val;
630 /// The extra fee being skimmed off the top of this HTLC.
632 pub extern "C" fn OutboundHTLCDetails_get_skimmed_fee_msat(this_ptr: &OutboundHTLCDetails) -> crate::c_types::derived::COption_u64Z {
633 let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat;
634 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
637 /// The extra fee being skimmed off the top of this HTLC.
639 pub extern "C" fn OutboundHTLCDetails_set_skimmed_fee_msat(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::derived::COption_u64Z) {
640 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
641 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val;
643 /// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed
644 /// from the local commitment transaction and added to the commitment transaction fee.
645 /// For non-anchor channels, this takes into account the cost of the second-stage HTLC
646 /// transactions as well.
648 /// When the local commitment transaction is broadcasted as part of a unilateral closure,
649 /// the value of this HTLC will therefore not be claimable but instead burned as a transaction
652 /// Note that dust limits are specific to each party. An HTLC can be dust for the local
653 /// commitment transaction but not for the counterparty's commitment transaction and vice versa.
655 pub extern "C" fn OutboundHTLCDetails_get_is_dust(this_ptr: &OutboundHTLCDetails) -> bool {
656 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_dust;
659 /// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed
660 /// from the local commitment transaction and added to the commitment transaction fee.
661 /// For non-anchor channels, this takes into account the cost of the second-stage HTLC
662 /// transactions as well.
664 /// When the local commitment transaction is broadcasted as part of a unilateral closure,
665 /// the value of this HTLC will therefore not be claimable but instead burned as a transaction
668 /// Note that dust limits are specific to each party. An HTLC can be dust for the local
669 /// commitment transaction but not for the counterparty's commitment transaction and vice versa.
671 pub extern "C" fn OutboundHTLCDetails_set_is_dust(this_ptr: &mut OutboundHTLCDetails, mut val: bool) {
672 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_dust = val;
674 /// Constructs a new OutboundHTLCDetails given each field
677 pub extern "C" fn OutboundHTLCDetails_new(mut htlc_id_arg: crate::c_types::derived::COption_u64Z, mut amount_msat_arg: u64, mut cltv_expiry_arg: u32, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut state_arg: crate::c_types::derived::COption_OutboundHTLCStateDetailsZ, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut is_dust_arg: bool) -> OutboundHTLCDetails {
678 let mut local_htlc_id_arg = if htlc_id_arg.is_some() { Some( { htlc_id_arg.take() }) } else { None };
679 let mut local_state_arg = { /*state_arg*/ let state_arg_opt = state_arg; if state_arg_opt.is_none() { None } else { Some({ { { state_arg_opt.take() }.into_native() }})} };
680 let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None };
681 OutboundHTLCDetails { inner: ObjOps::heap_alloc(nativeOutboundHTLCDetails {
682 htlc_id: local_htlc_id_arg,
683 amount_msat: amount_msat_arg,
684 cltv_expiry: cltv_expiry_arg,
685 payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data),
686 state: local_state_arg,
687 skimmed_fee_msat: local_skimmed_fee_msat_arg,
688 is_dust: is_dust_arg,
691 impl Clone for OutboundHTLCDetails {
692 fn clone(&self) -> Self {
694 inner: if <*mut nativeOutboundHTLCDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
695 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
701 /// Used only if an object of this type is returned as a trait impl by a method
702 pub(crate) extern "C" fn OutboundHTLCDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
703 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOutboundHTLCDetails)).clone() })) as *mut c_void
706 /// Creates a copy of the OutboundHTLCDetails
707 pub extern "C" fn OutboundHTLCDetails_clone(orig: &OutboundHTLCDetails) -> OutboundHTLCDetails {
710 /// Get a string which allows debug introspection of a OutboundHTLCDetails object
711 pub extern "C" fn OutboundHTLCDetails_debug_str_void(o: *const c_void) -> Str {
712 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::OutboundHTLCDetails }).into()}
714 /// Serialize the OutboundHTLCDetails object into a byte array which can be read by OutboundHTLCDetails_read
715 pub extern "C" fn OutboundHTLCDetails_write(obj: &crate::lightning::ln::channel_state::OutboundHTLCDetails) -> crate::c_types::derived::CVec_u8Z {
716 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
719 pub(crate) extern "C" fn OutboundHTLCDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
720 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOutboundHTLCDetails) })
723 /// Read a OutboundHTLCDetails from a byte array, created by OutboundHTLCDetails_write
724 pub extern "C" fn OutboundHTLCDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OutboundHTLCDetailsDecodeErrorZ {
725 let res: Result<lightning::ln::channel_state::OutboundHTLCDetails, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
726 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::OutboundHTLCDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
730 use lightning::ln::channel_state::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport;
731 pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport;
733 /// Information needed for constructing an invoice route hint for this channel.
736 pub struct CounterpartyForwardingInfo {
737 /// A pointer to the opaque Rust object.
739 /// Nearly everywhere, inner must be non-null, however in places where
740 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
741 pub inner: *mut nativeCounterpartyForwardingInfo,
742 /// Indicates that this is the only struct which contains the same pointer.
744 /// Rust functions which take ownership of an object provided via an argument require
745 /// this to be true and invalidate the object pointed to by inner.
749 impl Drop for CounterpartyForwardingInfo {
751 if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) {
752 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
756 /// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL.
758 pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { }
760 /// Used only if an object of this type is returned as a trait impl by a method
761 pub(crate) extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) {
762 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCounterpartyForwardingInfo) };
765 impl CounterpartyForwardingInfo {
766 pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo {
767 unsafe { &*ObjOps::untweak_ptr(self.inner) }
769 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo {
770 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
772 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
773 pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo {
774 assert!(self.is_owned);
775 let ret = ObjOps::untweak_ptr(self.inner);
776 self.inner = core::ptr::null_mut();
780 /// Base routing fee in millisatoshis.
782 pub extern "C" fn CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: &CounterpartyForwardingInfo) -> u32 {
783 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
786 /// Base routing fee in millisatoshis.
788 pub extern "C" fn CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
789 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
791 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
793 pub extern "C" fn CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: &CounterpartyForwardingInfo) -> u32 {
794 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
797 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
799 pub extern "C" fn CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
800 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
802 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
803 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
804 /// `cltv_expiry_delta` for more details.
806 pub extern "C" fn CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: &CounterpartyForwardingInfo) -> u16 {
807 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
810 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
811 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
812 /// `cltv_expiry_delta` for more details.
814 pub extern "C" fn CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: &mut CounterpartyForwardingInfo, mut val: u16) {
815 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
817 /// Constructs a new CounterpartyForwardingInfo given each field
820 pub extern "C" fn CounterpartyForwardingInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16) -> CounterpartyForwardingInfo {
821 CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(nativeCounterpartyForwardingInfo {
822 fee_base_msat: fee_base_msat_arg,
823 fee_proportional_millionths: fee_proportional_millionths_arg,
824 cltv_expiry_delta: cltv_expiry_delta_arg,
827 impl Clone for CounterpartyForwardingInfo {
828 fn clone(&self) -> Self {
830 inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
831 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
837 /// Used only if an object of this type is returned as a trait impl by a method
838 pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
839 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCounterpartyForwardingInfo)).clone() })) as *mut c_void
842 /// Creates a copy of the CounterpartyForwardingInfo
843 pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo {
846 /// Get a string which allows debug introspection of a CounterpartyForwardingInfo object
847 pub extern "C" fn CounterpartyForwardingInfo_debug_str_void(o: *const c_void) -> Str {
848 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::CounterpartyForwardingInfo }).into()}
850 /// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read
851 pub extern "C" fn CounterpartyForwardingInfo_write(obj: &crate::lightning::ln::channel_state::CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z {
852 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
855 pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
856 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) })
859 /// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write
860 pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ {
861 let res: Result<lightning::ln::channel_state::CounterpartyForwardingInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
862 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
866 use lightning::ln::channel_state::ChannelCounterparty as nativeChannelCounterpartyImport;
867 pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport;
869 /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
870 /// to better separate parameters.
873 pub struct ChannelCounterparty {
874 /// A pointer to the opaque Rust object.
876 /// Nearly everywhere, inner must be non-null, however in places where
877 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
878 pub inner: *mut nativeChannelCounterparty,
879 /// Indicates that this is the only struct which contains the same pointer.
881 /// Rust functions which take ownership of an object provided via an argument require
882 /// this to be true and invalidate the object pointed to by inner.
886 impl Drop for ChannelCounterparty {
888 if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) {
889 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
893 /// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
895 pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { }
897 /// Used only if an object of this type is returned as a trait impl by a method
898 pub(crate) extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) {
899 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelCounterparty) };
902 impl ChannelCounterparty {
903 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty {
904 unsafe { &*ObjOps::untweak_ptr(self.inner) }
906 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty {
907 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
909 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
910 pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
911 assert!(self.is_owned);
912 let ret = ObjOps::untweak_ptr(self.inner);
913 self.inner = core::ptr::null_mut();
917 /// The node_id of our counterparty
919 pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey {
920 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
921 crate::c_types::PublicKey::from_rust(&inner_val)
923 /// The node_id of our counterparty
925 pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) {
926 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
928 /// The Features the channel counterparty provided upon last connection.
929 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
930 /// many routing-relevant features are present in the init context.
932 pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures {
933 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
934 crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false }
936 /// The Features the channel counterparty provided upon last connection.
937 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
938 /// many routing-relevant features are present in the init context.
940 pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) {
941 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
943 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
944 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
945 /// claiming at least this value on chain.
947 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
949 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
951 pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 {
952 let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
955 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
956 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
957 /// claiming at least this value on chain.
959 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
961 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
963 pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) {
964 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = val;
966 /// Information on the fees and requirements that the counterparty requires when forwarding
967 /// payments to us through this channel.
969 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
971 pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channel_state::CounterpartyForwardingInfo {
972 let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info;
973 let mut local_inner_val = crate::lightning::ln::channel_state::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channel_state::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false };
976 /// Information on the fees and requirements that the counterparty requires when forwarding
977 /// payments to us through this channel.
979 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
981 pub extern "C" fn ChannelCounterparty_set_forwarding_info(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::channel_state::CounterpartyForwardingInfo) {
982 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
983 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_info = local_val;
985 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
986 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
987 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
989 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_minimum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
990 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_minimum_msat;
991 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
994 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
995 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
996 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
998 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_minimum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
999 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1000 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_minimum_msat = local_val;
1002 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
1004 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_maximum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
1005 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_maximum_msat;
1006 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1009 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
1011 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
1012 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1013 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_maximum_msat = local_val;
1015 /// Constructs a new ChannelCounterparty given each field
1017 /// Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1020 pub extern "C" fn ChannelCounterparty_new(mut node_id_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InitFeatures, mut unspendable_punishment_reserve_arg: u64, mut forwarding_info_arg: crate::lightning::ln::channel_state::CounterpartyForwardingInfo, mut outbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut outbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> ChannelCounterparty {
1021 let mut local_forwarding_info_arg = if forwarding_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(forwarding_info_arg.take_inner()) } }) };
1022 let mut local_outbound_htlc_minimum_msat_arg = if outbound_htlc_minimum_msat_arg.is_some() { Some( { outbound_htlc_minimum_msat_arg.take() }) } else { None };
1023 let mut local_outbound_htlc_maximum_msat_arg = if outbound_htlc_maximum_msat_arg.is_some() { Some( { outbound_htlc_maximum_msat_arg.take() }) } else { None };
1024 ChannelCounterparty { inner: ObjOps::heap_alloc(nativeChannelCounterparty {
1025 node_id: node_id_arg.into_rust(),
1026 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
1027 unspendable_punishment_reserve: unspendable_punishment_reserve_arg,
1028 forwarding_info: local_forwarding_info_arg,
1029 outbound_htlc_minimum_msat: local_outbound_htlc_minimum_msat_arg,
1030 outbound_htlc_maximum_msat: local_outbound_htlc_maximum_msat_arg,
1031 }), is_owned: true }
1033 impl Clone for ChannelCounterparty {
1034 fn clone(&self) -> Self {
1036 inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else {
1037 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1043 /// Used only if an object of this type is returned as a trait impl by a method
1044 pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void {
1045 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelCounterparty)).clone() })) as *mut c_void
1048 /// Creates a copy of the ChannelCounterparty
1049 pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty {
1052 /// Get a string which allows debug introspection of a ChannelCounterparty object
1053 pub extern "C" fn ChannelCounterparty_debug_str_void(o: *const c_void) -> Str {
1054 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::ChannelCounterparty }).into()}
1056 /// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
1057 pub extern "C" fn ChannelCounterparty_write(obj: &crate::lightning::ln::channel_state::ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z {
1058 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1061 pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1062 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) })
1065 /// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
1066 pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ {
1067 let res: Result<lightning::ln::channel_state::ChannelCounterparty, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1068 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::ChannelCounterparty { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1072 use lightning::ln::channel_state::ChannelDetails as nativeChannelDetailsImport;
1073 pub(crate) type nativeChannelDetails = nativeChannelDetailsImport;
1075 /// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
1077 /// [`ChannelManager::list_channels`]: crate::ln::channelmanager::ChannelManager::list_channels
1078 /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
1081 pub struct ChannelDetails {
1082 /// A pointer to the opaque Rust object.
1084 /// Nearly everywhere, inner must be non-null, however in places where
1085 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1086 pub inner: *mut nativeChannelDetails,
1087 /// Indicates that this is the only struct which contains the same pointer.
1089 /// Rust functions which take ownership of an object provided via an argument require
1090 /// this to be true and invalidate the object pointed to by inner.
1094 impl Drop for ChannelDetails {
1095 fn drop(&mut self) {
1096 if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) {
1097 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1101 /// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
1103 pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
1105 /// Used only if an object of this type is returned as a trait impl by a method
1106 pub(crate) extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
1107 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDetails) };
1110 impl ChannelDetails {
1111 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails {
1112 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1114 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails {
1115 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1117 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1118 pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
1119 assert!(self.is_owned);
1120 let ret = ObjOps::untweak_ptr(self.inner);
1121 self.inner = core::ptr::null_mut();
1125 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
1126 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
1127 /// Note that this means this value is *not* persistent - it can change once during the
1128 /// lifetime of the channel.
1130 pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> crate::lightning::ln::types::ChannelId {
1131 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
1132 crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false }
1134 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
1135 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
1136 /// Note that this means this value is *not* persistent - it can change once during the
1137 /// lifetime of the channel.
1139 pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::types::ChannelId) {
1140 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) };
1142 /// Parameters which apply to our counterparty. See individual fields for more information.
1144 pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channel_state::ChannelCounterparty {
1145 let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty;
1146 crate::lightning::ln::channel_state::ChannelCounterparty { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::channel_state::ChannelCounterparty<>) as *mut _) }, is_owned: false }
1148 /// Parameters which apply to our counterparty. See individual fields for more information.
1150 pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channel_state::ChannelCounterparty) {
1151 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty = *unsafe { Box::from_raw(val.take_inner()) };
1153 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
1154 /// our counterparty already.
1156 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1158 pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
1159 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo;
1160 let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
1163 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
1164 /// our counterparty already.
1166 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1168 pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) {
1169 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1170 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val;
1172 /// The features which this channel operates with. See individual features for more info.
1174 /// `None` until negotiation completes and the channel type is finalized.
1176 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1178 pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures {
1179 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
1180 let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
1183 /// The features which this channel operates with. See individual features for more info.
1185 /// `None` until negotiation completes and the channel type is finalized.
1187 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1189 pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
1190 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1191 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
1193 /// The position of the funding transaction in the chain. None if the funding transaction has
1194 /// not yet been confirmed and the channel fully opened.
1196 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
1197 /// payments instead of this. See [`get_inbound_payment_scid`].
1199 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
1200 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
1202 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
1203 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
1204 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
1205 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
1206 /// [`confirmations_required`]: Self::confirmations_required
1208 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1209 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
1210 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1213 /// The position of the funding transaction in the chain. None if the funding transaction has
1214 /// not yet been confirmed and the channel fully opened.
1216 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
1217 /// payments instead of this. See [`get_inbound_payment_scid`].
1219 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
1220 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
1222 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
1223 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
1224 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
1225 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
1226 /// [`confirmations_required`]: Self::confirmations_required
1228 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1229 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1230 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val;
1232 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
1233 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
1234 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
1237 /// This will be `None` as long as the channel is not available for routing outbound payments.
1239 /// [`short_channel_id`]: Self::short_channel_id
1240 /// [`confirmations_required`]: Self::confirmations_required
1242 pub extern "C" fn ChannelDetails_get_outbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1243 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_scid_alias;
1244 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1247 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
1248 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
1249 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
1252 /// This will be `None` as long as the channel is not available for routing outbound payments.
1254 /// [`short_channel_id`]: Self::short_channel_id
1255 /// [`confirmations_required`]: Self::confirmations_required
1257 pub extern "C" fn ChannelDetails_set_outbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1258 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1259 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_scid_alias = local_val;
1261 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
1262 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
1263 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
1264 /// when they see a payment to be routed to us.
1266 /// Our counterparty may choose to rotate this value at any time, though will always recognize
1267 /// previous values for inbound payment forwarding.
1269 /// [`short_channel_id`]: Self::short_channel_id
1271 pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1272 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias;
1273 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1276 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
1277 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
1278 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
1279 /// when they see a payment to be routed to us.
1281 /// Our counterparty may choose to rotate this value at any time, though will always recognize
1282 /// previous values for inbound payment forwarding.
1284 /// [`short_channel_id`]: Self::short_channel_id
1286 pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1287 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1288 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val;
1290 /// The value, in satoshis, of this channel as appears in the funding output
1292 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
1293 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis;
1296 /// The value, in satoshis, of this channel as appears in the funding output
1298 pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
1299 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val;
1301 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
1302 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
1303 /// this value on chain.
1305 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
1307 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1309 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
1311 pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1312 let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
1313 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1316 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
1317 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
1318 /// this value on chain.
1320 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
1322 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1324 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
1326 pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1327 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1328 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = local_val;
1330 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1331 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1332 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1333 /// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
1334 /// serialized with LDK versions prior to 0.0.113.
1336 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1337 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1338 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1340 pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::U128 {
1341 let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
1344 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
1345 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
1346 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
1347 /// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
1348 /// serialized with LDK versions prior to 0.0.113.
1350 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
1351 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
1352 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
1354 pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) {
1355 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
1357 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
1358 /// which is applied to commitment and HTLC transactions.
1360 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
1362 pub extern "C" fn ChannelDetails_get_feerate_sat_per_1000_weight(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
1363 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
1364 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) };
1367 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
1368 /// which is applied to commitment and HTLC transactions.
1370 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
1372 pub extern "C" fn ChannelDetails_set_feerate_sat_per_1000_weight(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
1373 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1374 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = local_val;
1376 /// Our total balance. This is the amount we would get if we close the channel.
1377 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
1378 /// amount is not likely to be recoverable on close.
1380 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
1381 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
1382 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
1383 /// This does not consider any on-chain fees.
1385 /// See also [`ChannelDetails::outbound_capacity_msat`]
1387 pub extern "C" fn ChannelDetails_get_balance_msat(this_ptr: &ChannelDetails) -> u64 {
1388 let mut inner_val = &mut this_ptr.get_native_mut_ref().balance_msat;
1391 /// Our total balance. This is the amount we would get if we close the channel.
1392 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
1393 /// amount is not likely to be recoverable on close.
1395 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
1396 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
1397 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
1398 /// This does not consider any on-chain fees.
1400 /// See also [`ChannelDetails::outbound_capacity_msat`]
1402 pub extern "C" fn ChannelDetails_set_balance_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1403 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.balance_msat = val;
1405 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
1406 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1407 /// available for inclusion in new outbound HTLCs). This further does not include any pending
1408 /// outgoing HTLCs which are awaiting some other resolution to be sent.
1410 /// See also [`ChannelDetails::balance_msat`]
1412 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1413 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
1414 /// should be able to spend nearly this amount.
1416 pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
1417 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_capacity_msat;
1420 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
1421 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1422 /// available for inclusion in new outbound HTLCs). This further does not include any pending
1423 /// outgoing HTLCs which are awaiting some other resolution to be sent.
1425 /// See also [`ChannelDetails::balance_msat`]
1427 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1428 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
1429 /// should be able to spend nearly this amount.
1431 pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1432 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_capacity_msat = val;
1434 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
1435 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
1436 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
1437 /// to use a limit as close as possible to the HTLC limit we can currently send.
1439 /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1440 /// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
1442 pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 {
1443 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat;
1446 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
1447 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
1448 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
1449 /// to use a limit as close as possible to the HTLC limit we can currently send.
1451 /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1452 /// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
1454 pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1455 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val;
1457 /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
1458 /// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
1459 /// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
1460 /// route which is valid.
1462 pub extern "C" fn ChannelDetails_get_next_outbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> u64 {
1463 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_minimum_msat;
1466 /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
1467 /// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
1468 /// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
1469 /// route which is valid.
1471 pub extern "C" fn ChannelDetails_set_next_outbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1472 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_minimum_msat = val;
1474 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
1475 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1476 /// available for inclusion in new inbound HTLCs).
1477 /// Note that there are some corner cases not fully handled here, so the actual available
1478 /// inbound capacity may be slightly higher than this.
1480 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1481 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
1482 /// However, our counterparty should be able to spend nearly this amount.
1484 pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
1485 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_capacity_msat;
1488 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
1489 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1490 /// available for inclusion in new inbound HTLCs).
1491 /// Note that there are some corner cases not fully handled here, so the actual available
1492 /// inbound capacity may be slightly higher than this.
1494 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1495 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
1496 /// However, our counterparty should be able to spend nearly this amount.
1498 pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1499 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_capacity_msat = val;
1501 /// The number of required confirmations on the funding transaction before the funding will be
1502 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
1503 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
1504 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
1505 /// [`ChannelHandshakeLimits::max_minimum_depth`].
1507 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1509 /// [`is_outbound`]: ChannelDetails::is_outbound
1510 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
1511 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
1513 pub extern "C" fn ChannelDetails_get_confirmations_required(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
1514 let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations_required;
1515 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) };
1518 /// The number of required confirmations on the funding transaction before the funding will be
1519 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
1520 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
1521 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
1522 /// [`ChannelHandshakeLimits::max_minimum_depth`].
1524 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1526 /// [`is_outbound`]: ChannelDetails::is_outbound
1527 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
1528 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
1530 pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
1531 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1532 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations_required = local_val;
1534 /// The current number of confirmations on the funding transaction.
1536 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1538 pub extern "C" fn ChannelDetails_get_confirmations(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
1539 let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations;
1540 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) };
1543 /// The current number of confirmations on the funding transaction.
1545 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1547 pub extern "C" fn ChannelDetails_set_confirmations(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
1548 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1549 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations = local_val;
1551 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
1552 /// until we can claim our funds after we force-close the channel. During this time our
1553 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
1554 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
1555 /// time to claim our non-HTLC-encumbered funds.
1557 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1559 pub extern "C" fn ChannelDetails_get_force_close_spend_delay(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u16Z {
1560 let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_spend_delay;
1561 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { inner_val.unwrap() }) };
1564 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
1565 /// until we can claim our funds after we force-close the channel. During this time our
1566 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
1567 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
1568 /// time to claim our non-HTLC-encumbered funds.
1570 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1572 pub extern "C" fn ChannelDetails_set_force_close_spend_delay(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u16Z) {
1573 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1574 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_spend_delay = local_val;
1576 /// True if the channel was initiated (and thus funded) by us.
1578 pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool {
1579 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_outbound;
1582 /// True if the channel was initiated (and thus funded) by us.
1584 pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) {
1585 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_outbound = val;
1587 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1588 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1589 /// required confirmation count has been reached (and we were connected to the peer at some
1590 /// point after the funding transaction received enough confirmations). The required
1591 /// confirmation count is provided in [`confirmations_required`].
1593 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1595 pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) -> bool {
1596 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_channel_ready;
1599 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1600 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1601 /// required confirmation count has been reached (and we were connected to the peer at some
1602 /// point after the funding transaction received enough confirmations). The required
1603 /// confirmation count is provided in [`confirmations_required`].
1605 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1607 pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) {
1608 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val;
1610 /// The stage of the channel's shutdown.
1611 /// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
1613 /// Returns a copy of the field.
1615 pub extern "C" fn ChannelDetails_get_channel_shutdown_state(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_ChannelShutdownStateZ {
1616 let mut inner_val = this_ptr.get_native_mut_ref().channel_shutdown_state.clone();
1617 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ChannelShutdownStateZ::None } else { crate::c_types::derived::COption_ChannelShutdownStateZ::Some( { crate::lightning::ln::channel_state::ChannelShutdownState::native_into(inner_val.unwrap()) }) };
1620 /// The stage of the channel's shutdown.
1621 /// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
1623 pub extern "C" fn ChannelDetails_set_channel_shutdown_state(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_ChannelShutdownStateZ) {
1624 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
1625 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_shutdown_state = local_val;
1627 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1628 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1630 /// This is a strict superset of `is_channel_ready`.
1632 pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool {
1633 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_usable;
1636 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1637 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1639 /// This is a strict superset of `is_channel_ready`.
1641 pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) {
1642 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_usable = val;
1644 /// True if this channel is (or will be) publicly-announced.
1646 pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool {
1647 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_public;
1650 /// True if this channel is (or will be) publicly-announced.
1652 pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) {
1653 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_public = val;
1655 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1656 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1658 pub extern "C" fn ChannelDetails_get_inbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1659 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_minimum_msat;
1660 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1663 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1664 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1666 pub extern "C" fn ChannelDetails_set_inbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1667 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1668 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_minimum_msat = local_val;
1670 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1672 pub extern "C" fn ChannelDetails_get_inbound_htlc_maximum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1673 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_maximum_msat;
1674 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1677 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1679 pub extern "C" fn ChannelDetails_set_inbound_htlc_maximum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1680 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1681 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_maximum_msat = local_val;
1683 /// Set of configurable parameters that affect channel operation.
1685 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1687 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1689 pub extern "C" fn ChannelDetails_get_config(this_ptr: &ChannelDetails) -> crate::lightning::util::config::ChannelConfig {
1690 let mut inner_val = &mut this_ptr.get_native_mut_ref().config;
1691 let mut local_inner_val = crate::lightning::util::config::ChannelConfig { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::util::config::ChannelConfig<>) as *mut _ }, is_owned: false };
1694 /// Set of configurable parameters that affect channel operation.
1696 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1698 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1700 pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut val: crate::lightning::util::config::ChannelConfig) {
1701 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1702 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.config = local_val;
1704 /// Pending inbound HTLCs.
1706 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1708 pub extern "C" fn ChannelDetails_get_pending_inbound_htlcs(this_ptr: &ChannelDetails) -> crate::c_types::derived::CVec_InboundHTLCDetailsZ {
1709 let mut inner_val = &mut this_ptr.get_native_mut_ref().pending_inbound_htlcs;
1710 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channel_state::InboundHTLCDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channel_state::InboundHTLCDetails<>) as *mut _) }, is_owned: false } }); };
1711 local_inner_val.into()
1713 /// Pending inbound HTLCs.
1715 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1717 pub extern "C" fn ChannelDetails_set_pending_inbound_htlcs(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::CVec_InboundHTLCDetailsZ) {
1718 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1719 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pending_inbound_htlcs = local_val;
1721 /// Pending outbound HTLCs.
1723 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1725 pub extern "C" fn ChannelDetails_get_pending_outbound_htlcs(this_ptr: &ChannelDetails) -> crate::c_types::derived::CVec_OutboundHTLCDetailsZ {
1726 let mut inner_val = &mut this_ptr.get_native_mut_ref().pending_outbound_htlcs;
1727 let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channel_state::OutboundHTLCDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channel_state::OutboundHTLCDetails<>) as *mut _) }, is_owned: false } }); };
1728 local_inner_val.into()
1730 /// Pending outbound HTLCs.
1732 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1734 pub extern "C" fn ChannelDetails_set_pending_outbound_htlcs(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::CVec_OutboundHTLCDetailsZ) {
1735 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1736 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pending_outbound_htlcs = local_val;
1738 /// Constructs a new ChannelDetails given each field
1740 /// Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1741 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1742 /// Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1745 pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut counterparty_arg: crate::lightning::ln::channel_state::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut next_outbound_htlc_minimum_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut channel_shutdown_state_arg: crate::c_types::derived::COption_ChannelShutdownStateZ, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig, mut pending_inbound_htlcs_arg: crate::c_types::derived::CVec_InboundHTLCDetailsZ, mut pending_outbound_htlcs_arg: crate::c_types::derived::CVec_OutboundHTLCDetailsZ) -> ChannelDetails {
1746 let mut local_funding_txo_arg = if funding_txo_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_txo_arg.take_inner()) } }) };
1747 let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) };
1748 let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None };
1749 let mut local_outbound_scid_alias_arg = if outbound_scid_alias_arg.is_some() { Some( { outbound_scid_alias_arg.take() }) } else { None };
1750 let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None };
1751 let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None };
1752 let mut local_feerate_sat_per_1000_weight_arg = if feerate_sat_per_1000_weight_arg.is_some() { Some( { feerate_sat_per_1000_weight_arg.take() }) } else { None };
1753 let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None };
1754 let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None };
1755 let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None };
1756 let mut local_channel_shutdown_state_arg = { /*channel_shutdown_state_arg*/ let channel_shutdown_state_arg_opt = channel_shutdown_state_arg; if channel_shutdown_state_arg_opt.is_none() { None } else { Some({ { { channel_shutdown_state_arg_opt.take() }.into_native() }})} };
1757 let mut local_inbound_htlc_minimum_msat_arg = if inbound_htlc_minimum_msat_arg.is_some() { Some( { inbound_htlc_minimum_msat_arg.take() }) } else { None };
1758 let mut local_inbound_htlc_maximum_msat_arg = if inbound_htlc_maximum_msat_arg.is_some() { Some( { inbound_htlc_maximum_msat_arg.take() }) } else { None };
1759 let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) };
1760 let mut local_pending_inbound_htlcs_arg = Vec::new(); for mut item in pending_inbound_htlcs_arg.into_rust().drain(..) { local_pending_inbound_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1761 let mut local_pending_outbound_htlcs_arg = Vec::new(); for mut item in pending_outbound_htlcs_arg.into_rust().drain(..) { local_pending_outbound_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1762 ChannelDetails { inner: ObjOps::heap_alloc(nativeChannelDetails {
1763 channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) },
1764 counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) },
1765 funding_txo: local_funding_txo_arg,
1766 channel_type: local_channel_type_arg,
1767 short_channel_id: local_short_channel_id_arg,
1768 outbound_scid_alias: local_outbound_scid_alias_arg,
1769 inbound_scid_alias: local_inbound_scid_alias_arg,
1770 channel_value_satoshis: channel_value_satoshis_arg,
1771 unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg,
1772 user_channel_id: user_channel_id_arg.into(),
1773 feerate_sat_per_1000_weight: local_feerate_sat_per_1000_weight_arg,
1774 balance_msat: balance_msat_arg,
1775 outbound_capacity_msat: outbound_capacity_msat_arg,
1776 next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg,
1777 next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat_arg,
1778 inbound_capacity_msat: inbound_capacity_msat_arg,
1779 confirmations_required: local_confirmations_required_arg,
1780 confirmations: local_confirmations_arg,
1781 force_close_spend_delay: local_force_close_spend_delay_arg,
1782 is_outbound: is_outbound_arg,
1783 is_channel_ready: is_channel_ready_arg,
1784 channel_shutdown_state: local_channel_shutdown_state_arg,
1785 is_usable: is_usable_arg,
1786 is_public: is_public_arg,
1787 inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg,
1788 inbound_htlc_maximum_msat: local_inbound_htlc_maximum_msat_arg,
1789 config: local_config_arg,
1790 pending_inbound_htlcs: local_pending_inbound_htlcs_arg,
1791 pending_outbound_htlcs: local_pending_outbound_htlcs_arg,
1792 }), is_owned: true }
1794 impl Clone for ChannelDetails {
1795 fn clone(&self) -> Self {
1797 inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
1798 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1804 /// Used only if an object of this type is returned as a trait impl by a method
1805 pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
1806 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelDetails)).clone() })) as *mut c_void
1809 /// Creates a copy of the ChannelDetails
1810 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
1813 /// Get a string which allows debug introspection of a ChannelDetails object
1814 pub extern "C" fn ChannelDetails_debug_str_void(o: *const c_void) -> Str {
1815 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::ChannelDetails }).into()}
1816 /// Gets the current SCID which should be used to identify this channel for inbound payments.
1817 /// This should be used for providing invoice hints or in any other context where our
1818 /// counterparty will forward a payment to us.
1820 /// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
1821 /// [`ChannelDetails::short_channel_id`]. See those for more information.
1824 pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &crate::lightning::ln::channel_state::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1825 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid();
1826 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
1830 /// Gets the current SCID which should be used to identify this channel for outbound payments.
1831 /// This should be used in [`Route`]s to describe the first hop or in other contexts where
1832 /// we're sending or forwarding a payment outbound over this channel.
1834 /// This is either the [`ChannelDetails::short_channel_id`], if set, or the
1835 /// [`ChannelDetails::outbound_scid_alias`]. See those for more information.
1837 /// [`Route`]: crate::routing::router::Route
1840 pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lightning::ln::channel_state::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1841 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_outbound_payment_scid();
1842 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) };
1847 /// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read
1848 pub extern "C" fn ChannelDetails_write(obj: &crate::lightning::ln::channel_state::ChannelDetails) -> crate::c_types::derived::CVec_u8Z {
1849 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1852 pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1853 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) })
1856 /// Read a ChannelDetails from a byte array, created by ChannelDetails_write
1857 pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ {
1858 let res: Result<lightning::ln::channel_state::ChannelDetails, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1859 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
1862 /// Further information on the details of the channel shutdown.
1863 /// Upon channels being forced closed (i.e. commitment transaction confirmation detected
1864 /// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or
1865 /// the channel will be removed shortly.
1866 /// Also note, that in normal operation, peers could disconnect at any of these states
1867 /// and require peer re-connection before making progress onto other states
1871 pub enum ChannelShutdownState {
1872 /// Channel has not sent or received a shutdown message.
1874 /// Local node has sent a shutdown message for this channel.
1876 /// Shutdown message exchanges have concluded and the channels are in the midst of
1877 /// resolving all existing open HTLCs before closing can continue.
1879 /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates.
1880 NegotiatingClosingFee,
1881 /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about
1882 /// to drop the channel.
1885 use lightning::ln::channel_state::ChannelShutdownState as ChannelShutdownStateImport;
1886 pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport;
1888 impl ChannelShutdownState {
1890 pub(crate) fn to_native(&self) -> nativeChannelShutdownState {
1892 ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown,
1893 ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated,
1894 ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs,
1895 ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee,
1896 ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete,
1900 pub(crate) fn into_native(self) -> nativeChannelShutdownState {
1902 ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown,
1903 ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated,
1904 ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs,
1905 ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee,
1906 ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete,
1910 pub(crate) fn from_native(native: &ChannelShutdownStateImport) -> Self {
1911 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeChannelShutdownState) };
1913 nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown,
1914 nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated,
1915 nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs,
1916 nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee,
1917 nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete,
1921 pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self {
1923 nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown,
1924 nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated,
1925 nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs,
1926 nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee,
1927 nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete,
1931 /// Creates a copy of the ChannelShutdownState
1933 pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState {
1937 /// Used only if an object of this type is returned as a trait impl by a method
1938 pub(crate) extern "C" fn ChannelShutdownState_clone_void(this_ptr: *const c_void) -> *mut c_void {
1939 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ChannelShutdownState)).clone() })) as *mut c_void
1942 /// Used only if an object of this type is returned as a trait impl by a method
1943 pub(crate) extern "C" fn ChannelShutdownState_free_void(this_ptr: *mut c_void) {
1944 let _ = unsafe { Box::from_raw(this_ptr as *mut ChannelShutdownState) };
1947 /// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState
1948 pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState {
1949 ChannelShutdownState::NotShuttingDown}
1951 /// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState
1952 pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState {
1953 ChannelShutdownState::ShutdownInitiated}
1955 /// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState
1956 pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState {
1957 ChannelShutdownState::ResolvingHTLCs}
1959 /// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState
1960 pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState {
1961 ChannelShutdownState::NegotiatingClosingFee}
1963 /// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState
1964 pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState {
1965 ChannelShutdownState::ShutdownComplete}
1966 /// Get a string which allows debug introspection of a ChannelShutdownState object
1967 pub extern "C" fn ChannelShutdownState_debug_str_void(o: *const c_void) -> Str {
1968 alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::ChannelShutdownState }).into()}
1969 /// Checks if two ChannelShutdownStates contain equal inner contents.
1970 /// This ignores pointers and is_owned flags and looks at the values in fields.
1972 pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool {
1973 if &a.to_native() == &b.to_native() { true } else { false }
1976 /// Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read
1977 pub extern "C" fn ChannelShutdownState_write(obj: &crate::lightning::ln::channel_state::ChannelShutdownState) -> crate::c_types::derived::CVec_u8Z {
1978 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
1981 pub(crate) extern "C" fn ChannelShutdownState_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1982 ChannelShutdownState_write(unsafe { &*(obj as *const ChannelShutdownState) })
1985 /// Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write
1986 pub extern "C" fn ChannelShutdownState_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelShutdownStateDecodeErrorZ {
1987 let res: Result<lightning::ln::channel_state::ChannelShutdownState, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1988 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::ChannelShutdownState::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };