Update autogenerated bindings to latest LDK 0.0.123-bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / channel_state.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
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.
8
9 //! Information about the state of a channel.
10
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};
19
20 /// Exposes the state of pending inbound HTLCs.
21 ///
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.
31 ///
32 /// This can be used to inspect what next message an HTLC is waiting for to advance its state.
33 #[derive(Clone)]
34 #[must_use]
35 #[repr(C)]
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.
43         ///
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.
48         Committed,
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
57         /// transaction.
58         AwaitingRemoteRevokeToRemoveFail,
59 }
60 use lightning::ln::channel_state::InboundHTLCStateDetails as InboundHTLCStateDetailsImport;
61 pub(crate) type nativeInboundHTLCStateDetails = InboundHTLCStateDetailsImport;
62
63 impl InboundHTLCStateDetails {
64         #[allow(unused)]
65         pub(crate) fn to_native(&self) -> nativeInboundHTLCStateDetails {
66                 match self {
67                         InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
68                         InboundHTLCStateDetails::Committed => nativeInboundHTLCStateDetails::Committed,
69                         InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
70                         InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
71                 }
72         }
73         #[allow(unused)]
74         pub(crate) fn into_native(self) -> nativeInboundHTLCStateDetails {
75                 match self {
76                         InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
77                         InboundHTLCStateDetails::Committed => nativeInboundHTLCStateDetails::Committed,
78                         InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
79                         InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
80                 }
81         }
82         #[allow(unused)]
83         pub(crate) fn from_native(native: &InboundHTLCStateDetailsImport) -> Self {
84                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeInboundHTLCStateDetails) };
85                 match native {
86                         nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
87                         nativeInboundHTLCStateDetails::Committed => InboundHTLCStateDetails::Committed,
88                         nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
89                         nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
90                 }
91         }
92         #[allow(unused)]
93         pub(crate) fn native_into(native: nativeInboundHTLCStateDetails) -> Self {
94                 match native {
95                         nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
96                         nativeInboundHTLCStateDetails::Committed => InboundHTLCStateDetails::Committed,
97                         nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill,
98                         nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail,
99                 }
100         }
101 }
102 /// Creates a copy of the InboundHTLCStateDetails
103 #[no_mangle]
104 pub extern "C" fn InboundHTLCStateDetails_clone(orig: &InboundHTLCStateDetails) -> InboundHTLCStateDetails {
105         orig.clone()
106 }
107 #[allow(unused)]
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
111 }
112 #[allow(unused)]
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) };
116 }
117 #[no_mangle]
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}
121 #[no_mangle]
122 /// Utility method to constructs a new Committed-variant InboundHTLCStateDetails
123 pub extern "C" fn InboundHTLCStateDetails_committed() -> InboundHTLCStateDetails {
124         InboundHTLCStateDetails::Committed}
125 #[no_mangle]
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}
129 #[no_mangle]
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()}
136 #[no_mangle]
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())
140 }
141 #[allow(unused)]
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) })
144 }
145 #[no_mangle]
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() };
150         local_res
151 }
152
153 use lightning::ln::channel_state::InboundHTLCDetails as nativeInboundHTLCDetailsImport;
154 pub(crate) type nativeInboundHTLCDetails = nativeInboundHTLCDetailsImport;
155
156 /// Exposes details around pending inbound HTLCs.
157 #[must_use]
158 #[repr(C)]
159 pub struct InboundHTLCDetails {
160         /// A pointer to the opaque Rust object.
161
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.
166
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.
169         pub is_owned: bool,
170 }
171
172 impl Drop for InboundHTLCDetails {
173         fn drop(&mut self) {
174                 if self.is_owned && !<*mut nativeInboundHTLCDetails>::is_null(self.inner) {
175                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
176                 }
177         }
178 }
179 /// Frees any resources used by the InboundHTLCDetails, if is_owned is set and inner is non-NULL.
180 #[no_mangle]
181 pub extern "C" fn InboundHTLCDetails_free(this_obj: InboundHTLCDetails) { }
182 #[allow(unused)]
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) };
186 }
187 #[allow(unused)]
188 impl InboundHTLCDetails {
189         pub(crate) fn get_native_ref(&self) -> &'static nativeInboundHTLCDetails {
190                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
191         }
192         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInboundHTLCDetails {
193                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
194         }
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();
200                 ret
201         }
202 }
203 /// The HTLC ID.
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.
207 #[no_mangle]
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;
210         *inner_val
211 }
212 /// The 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.
216 #[no_mangle]
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;
219 }
220 /// The amount in msat.
221 #[no_mangle]
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;
224         *inner_val
225 }
226 /// The amount in msat.
227 #[no_mangle]
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;
230 }
231 /// The block height at which this HTLC expires.
232 #[no_mangle]
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;
235         *inner_val
236 }
237 /// The block height at which this HTLC expires.
238 #[no_mangle]
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;
241 }
242 /// The payment hash.
243 #[no_mangle]
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;
246         &inner_val.0
247 }
248 /// The payment hash.
249 #[no_mangle]
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);
252 }
253 /// The state of the HTLC in the state machine.
254 ///
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.
257 ///
258 /// See [`InboundHTLCStateDetails`] for information on the specific states.
259 ///
260 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
261 /// states may result in `None` here.
262 #[no_mangle]
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()) }) };
266         local_inner_val
267 }
268 /// The state of the HTLC in the state machine.
269 ///
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.
272 ///
273 /// See [`InboundHTLCStateDetails`] for information on the specific states.
274 ///
275 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
276 /// states may result in `None` here.
277 #[no_mangle]
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;
281 }
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.
286 ///
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
289 /// fee.
290 ///
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.
293 #[no_mangle]
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;
296         *inner_val
297 }
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.
302 ///
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
305 /// fee.
306 ///
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.
309 #[no_mangle]
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;
312 }
313 /// Constructs a new InboundHTLCDetails given each field
314 #[must_use]
315 #[no_mangle]
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,
325         }), is_owned: true }
326 }
327 impl Clone for InboundHTLCDetails {
328         fn clone(&self) -> Self {
329                 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()) },
332                         is_owned: true,
333                 }
334         }
335 }
336 #[allow(unused)]
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
340 }
341 #[no_mangle]
342 /// Creates a copy of the InboundHTLCDetails
343 pub extern "C" fn InboundHTLCDetails_clone(orig: &InboundHTLCDetails) -> InboundHTLCDetails {
344         orig.clone()
345 }
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()}
349 #[no_mangle]
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())
353 }
354 #[allow(unused)]
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) })
357 }
358 #[no_mangle]
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() };
363         local_res
364 }
365 /// Exposes the state of pending outbound HTLCs.
366 ///
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.
376 ///
377 /// This can be used to inspect what next message an HTLC is waiting for to advance its state.
378 #[derive(Clone)]
379 #[must_use]
380 #[repr(C)]
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.
387         ///
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.
390         Committed,
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,
401 }
402 use lightning::ln::channel_state::OutboundHTLCStateDetails as OutboundHTLCStateDetailsImport;
403 pub(crate) type nativeOutboundHTLCStateDetails = OutboundHTLCStateDetailsImport;
404
405 impl OutboundHTLCStateDetails {
406         #[allow(unused)]
407         pub(crate) fn to_native(&self) -> nativeOutboundHTLCStateDetails {
408                 match self {
409                         OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
410                         OutboundHTLCStateDetails::Committed => nativeOutboundHTLCStateDetails::Committed,
411                         OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
412                         OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
413                 }
414         }
415         #[allow(unused)]
416         pub(crate) fn into_native(self) -> nativeOutboundHTLCStateDetails {
417                 match self {
418                         OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
419                         OutboundHTLCStateDetails::Committed => nativeOutboundHTLCStateDetails::Committed,
420                         OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
421                         OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
422                 }
423         }
424         #[allow(unused)]
425         pub(crate) fn from_native(native: &OutboundHTLCStateDetailsImport) -> Self {
426                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeOutboundHTLCStateDetails) };
427                 match native {
428                         nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
429                         nativeOutboundHTLCStateDetails::Committed => OutboundHTLCStateDetails::Committed,
430                         nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
431                         nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
432                 }
433         }
434         #[allow(unused)]
435         pub(crate) fn native_into(native: nativeOutboundHTLCStateDetails) -> Self {
436                 match native {
437                         nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
438                         nativeOutboundHTLCStateDetails::Committed => OutboundHTLCStateDetails::Committed,
439                         nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess,
440                         nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure,
441                 }
442         }
443 }
444 /// Creates a copy of the OutboundHTLCStateDetails
445 #[no_mangle]
446 pub extern "C" fn OutboundHTLCStateDetails_clone(orig: &OutboundHTLCStateDetails) -> OutboundHTLCStateDetails {
447         orig.clone()
448 }
449 #[allow(unused)]
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
453 }
454 #[allow(unused)]
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) };
458 }
459 #[no_mangle]
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}
463 #[no_mangle]
464 /// Utility method to constructs a new Committed-variant OutboundHTLCStateDetails
465 pub extern "C" fn OutboundHTLCStateDetails_committed() -> OutboundHTLCStateDetails {
466         OutboundHTLCStateDetails::Committed}
467 #[no_mangle]
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}
471 #[no_mangle]
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()}
478 #[no_mangle]
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())
482 }
483 #[allow(unused)]
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) })
486 }
487 #[no_mangle]
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() };
492         local_res
493 }
494
495 use lightning::ln::channel_state::OutboundHTLCDetails as nativeOutboundHTLCDetailsImport;
496 pub(crate) type nativeOutboundHTLCDetails = nativeOutboundHTLCDetailsImport;
497
498 /// Exposes details around pending outbound HTLCs.
499 #[must_use]
500 #[repr(C)]
501 pub struct OutboundHTLCDetails {
502         /// A pointer to the opaque Rust object.
503
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.
508
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.
511         pub is_owned: bool,
512 }
513
514 impl Drop for OutboundHTLCDetails {
515         fn drop(&mut self) {
516                 if self.is_owned && !<*mut nativeOutboundHTLCDetails>::is_null(self.inner) {
517                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
518                 }
519         }
520 }
521 /// Frees any resources used by the OutboundHTLCDetails, if is_owned is set and inner is non-NULL.
522 #[no_mangle]
523 pub extern "C" fn OutboundHTLCDetails_free(this_obj: OutboundHTLCDetails) { }
524 #[allow(unused)]
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) };
528 }
529 #[allow(unused)]
530 impl OutboundHTLCDetails {
531         pub(crate) fn get_native_ref(&self) -> &'static nativeOutboundHTLCDetails {
532                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
533         }
534         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOutboundHTLCDetails {
535                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
536         }
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();
542                 ret
543         }
544 }
545 /// The HTLC ID.
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.
549 ///
550 /// Not present when we are awaiting a remote revocation and the HTLC is not added yet.
551 #[no_mangle]
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() }) };
555         local_inner_val
556 }
557 /// The HTLC ID.
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.
561 ///
562 /// Not present when we are awaiting a remote revocation and the HTLC is not added yet.
563 #[no_mangle]
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;
567 }
568 /// The amount in msat.
569 #[no_mangle]
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;
572         *inner_val
573 }
574 /// The amount in msat.
575 #[no_mangle]
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;
578 }
579 /// The block height at which this HTLC expires.
580 #[no_mangle]
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;
583         *inner_val
584 }
585 /// The block height at which this HTLC expires.
586 #[no_mangle]
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;
589 }
590 /// The payment hash.
591 #[no_mangle]
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;
594         &inner_val.0
595 }
596 /// The payment hash.
597 #[no_mangle]
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);
600 }
601 /// The state of the HTLC in the state machine.
602 ///
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.
605 ///
606 /// See [`OutboundHTLCStateDetails`] for information on the specific states.
607 ///
608 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
609 /// states may result in `None` here.
610 #[no_mangle]
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()) }) };
614         local_inner_val
615 }
616 /// The state of the HTLC in the state machine.
617 ///
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.
620 ///
621 /// See [`OutboundHTLCStateDetails`] for information on the specific states.
622 ///
623 /// LDK will always fill this field in, but when downgrading to prior versions of LDK, new
624 /// states may result in `None` here.
625 #[no_mangle]
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;
629 }
630 /// The extra fee being skimmed off the top of this HTLC.
631 #[no_mangle]
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() }) };
635         local_inner_val
636 }
637 /// The extra fee being skimmed off the top of this HTLC.
638 #[no_mangle]
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;
642 }
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.
647 ///
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
650 /// fee.
651 ///
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.
654 #[no_mangle]
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;
657         *inner_val
658 }
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.
663 ///
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
666 /// fee.
667 ///
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.
670 #[no_mangle]
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;
673 }
674 /// Constructs a new OutboundHTLCDetails given each field
675 #[must_use]
676 #[no_mangle]
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,
689         }), is_owned: true }
690 }
691 impl Clone for OutboundHTLCDetails {
692         fn clone(&self) -> Self {
693                 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()) },
696                         is_owned: true,
697                 }
698         }
699 }
700 #[allow(unused)]
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
704 }
705 #[no_mangle]
706 /// Creates a copy of the OutboundHTLCDetails
707 pub extern "C" fn OutboundHTLCDetails_clone(orig: &OutboundHTLCDetails) -> OutboundHTLCDetails {
708         orig.clone()
709 }
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()}
713 #[no_mangle]
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())
717 }
718 #[allow(unused)]
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) })
721 }
722 #[no_mangle]
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() };
727         local_res
728 }
729
730 use lightning::ln::channel_state::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport;
731 pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport;
732
733 /// Information needed for constructing an invoice route hint for this channel.
734 #[must_use]
735 #[repr(C)]
736 pub struct CounterpartyForwardingInfo {
737         /// A pointer to the opaque Rust object.
738
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.
743
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.
746         pub is_owned: bool,
747 }
748
749 impl Drop for CounterpartyForwardingInfo {
750         fn drop(&mut self) {
751                 if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) {
752                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
753                 }
754         }
755 }
756 /// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL.
757 #[no_mangle]
758 pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { }
759 #[allow(unused)]
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) };
763 }
764 #[allow(unused)]
765 impl CounterpartyForwardingInfo {
766         pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo {
767                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
768         }
769         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo {
770                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
771         }
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();
777                 ret
778         }
779 }
780 /// Base routing fee in millisatoshis.
781 #[no_mangle]
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;
784         *inner_val
785 }
786 /// Base routing fee in millisatoshis.
787 #[no_mangle]
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;
790 }
791 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
792 #[no_mangle]
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;
795         *inner_val
796 }
797 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
798 #[no_mangle]
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;
801 }
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.
805 #[no_mangle]
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;
808         *inner_val
809 }
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.
813 #[no_mangle]
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;
816 }
817 /// Constructs a new CounterpartyForwardingInfo given each field
818 #[must_use]
819 #[no_mangle]
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,
825         }), is_owned: true }
826 }
827 impl Clone for CounterpartyForwardingInfo {
828         fn clone(&self) -> Self {
829                 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()) },
832                         is_owned: true,
833                 }
834         }
835 }
836 #[allow(unused)]
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
840 }
841 #[no_mangle]
842 /// Creates a copy of the CounterpartyForwardingInfo
843 pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo {
844         orig.clone()
845 }
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()}
849 #[no_mangle]
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())
853 }
854 #[allow(unused)]
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) })
857 }
858 #[no_mangle]
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() };
863         local_res
864 }
865
866 use lightning::ln::channel_state::ChannelCounterparty as nativeChannelCounterpartyImport;
867 pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport;
868
869 /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
870 /// to better separate parameters.
871 #[must_use]
872 #[repr(C)]
873 pub struct ChannelCounterparty {
874         /// A pointer to the opaque Rust object.
875
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.
880
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.
883         pub is_owned: bool,
884 }
885
886 impl Drop for ChannelCounterparty {
887         fn drop(&mut self) {
888                 if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) {
889                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
890                 }
891         }
892 }
893 /// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
894 #[no_mangle]
895 pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { }
896 #[allow(unused)]
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) };
900 }
901 #[allow(unused)]
902 impl ChannelCounterparty {
903         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty {
904                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
905         }
906         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty {
907                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
908         }
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();
914                 ret
915         }
916 }
917 /// The node_id of our counterparty
918 #[no_mangle]
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)
922 }
923 /// The node_id of our counterparty
924 #[no_mangle]
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();
927 }
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.
931 #[no_mangle]
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 }
935 }
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.
939 #[no_mangle]
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()) };
942 }
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.
946 ///
947 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
948 ///
949 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
950 #[no_mangle]
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;
953         *inner_val
954 }
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.
958 ///
959 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
960 ///
961 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
962 #[no_mangle]
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;
965 }
966 /// Information on the fees and requirements that the counterparty requires when forwarding
967 /// payments to us through this channel.
968 ///
969 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
970 #[no_mangle]
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 };
974         local_inner_val
975 }
976 /// Information on the fees and requirements that the counterparty requires when forwarding
977 /// payments to us through this channel.
978 ///
979 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
980 #[no_mangle]
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;
984 }
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.
988 #[no_mangle]
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() }) };
992         local_inner_val
993 }
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.
997 #[no_mangle]
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;
1001 }
1002 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
1003 #[no_mangle]
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() }) };
1007         local_inner_val
1008 }
1009 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
1010 #[no_mangle]
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;
1014 }
1015 /// Constructs a new ChannelCounterparty given each field
1016 ///
1017 /// Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1018 #[must_use]
1019 #[no_mangle]
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 }
1032 }
1033 impl Clone for ChannelCounterparty {
1034         fn clone(&self) -> Self {
1035                 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()) },
1038                         is_owned: true,
1039                 }
1040         }
1041 }
1042 #[allow(unused)]
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
1046 }
1047 #[no_mangle]
1048 /// Creates a copy of the ChannelCounterparty
1049 pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty {
1050         orig.clone()
1051 }
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()}
1055 #[no_mangle]
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())
1059 }
1060 #[allow(unused)]
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) })
1063 }
1064 #[no_mangle]
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() };
1069         local_res
1070 }
1071
1072 use lightning::ln::channel_state::ChannelDetails as nativeChannelDetailsImport;
1073 pub(crate) type nativeChannelDetails = nativeChannelDetailsImport;
1074
1075 /// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
1076 ///
1077 /// [`ChannelManager::list_channels`]: crate::ln::channelmanager::ChannelManager::list_channels
1078 /// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
1079 #[must_use]
1080 #[repr(C)]
1081 pub struct ChannelDetails {
1082         /// A pointer to the opaque Rust object.
1083
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.
1088
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.
1091         pub is_owned: bool,
1092 }
1093
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)) };
1098                 }
1099         }
1100 }
1101 /// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
1102 #[no_mangle]
1103 pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
1104 #[allow(unused)]
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) };
1108 }
1109 #[allow(unused)]
1110 impl ChannelDetails {
1111         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails {
1112                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1113         }
1114         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails {
1115                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1116         }
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();
1122                 ret
1123         }
1124 }
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.
1129 #[no_mangle]
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 }
1133 }
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.
1138 #[no_mangle]
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()) };
1141 }
1142 /// Parameters which apply to our counterparty. See individual fields for more information.
1143 #[no_mangle]
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 }
1147 }
1148 /// Parameters which apply to our counterparty. See individual fields for more information.
1149 #[no_mangle]
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()) };
1152 }
1153 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
1154 /// our counterparty already.
1155 ///
1156 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1157 #[no_mangle]
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 };
1161         local_inner_val
1162 }
1163 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
1164 /// our counterparty already.
1165 ///
1166 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1167 #[no_mangle]
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;
1171 }
1172 /// The features which this channel operates with. See individual features for more info.
1173 ///
1174 /// `None` until negotiation completes and the channel type is finalized.
1175 ///
1176 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1177 #[no_mangle]
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 };
1181         local_inner_val
1182 }
1183 /// The features which this channel operates with. See individual features for more info.
1184 ///
1185 /// `None` until negotiation completes and the channel type is finalized.
1186 ///
1187 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1188 #[no_mangle]
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;
1192 }
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.
1195 ///
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`].
1198 ///
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`].
1201 ///
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
1207 #[no_mangle]
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() }) };
1211         local_inner_val
1212 }
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.
1215 ///
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`].
1218 ///
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`].
1221 ///
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
1227 #[no_mangle]
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;
1231 }
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
1235 /// `Some(0)`).
1236 ///
1237 /// This will be `None` as long as the channel is not available for routing outbound payments.
1238 ///
1239 /// [`short_channel_id`]: Self::short_channel_id
1240 /// [`confirmations_required`]: Self::confirmations_required
1241 #[no_mangle]
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() }) };
1245         local_inner_val
1246 }
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
1250 /// `Some(0)`).
1251 ///
1252 /// This will be `None` as long as the channel is not available for routing outbound payments.
1253 ///
1254 /// [`short_channel_id`]: Self::short_channel_id
1255 /// [`confirmations_required`]: Self::confirmations_required
1256 #[no_mangle]
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;
1260 }
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.
1265 ///
1266 /// Our counterparty may choose to rotate this value at any time, though will always recognize
1267 /// previous values for inbound payment forwarding.
1268 ///
1269 /// [`short_channel_id`]: Self::short_channel_id
1270 #[no_mangle]
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() }) };
1274         local_inner_val
1275 }
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.
1280 ///
1281 /// Our counterparty may choose to rotate this value at any time, though will always recognize
1282 /// previous values for inbound payment forwarding.
1283 ///
1284 /// [`short_channel_id`]: Self::short_channel_id
1285 #[no_mangle]
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;
1289 }
1290 /// The value, in satoshis, of this channel as appears in the funding output
1291 #[no_mangle]
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;
1294         *inner_val
1295 }
1296 /// The value, in satoshis, of this channel as appears in the funding output
1297 #[no_mangle]
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;
1300 }
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.
1304 ///
1305 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
1306 ///
1307 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1308 ///
1309 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
1310 #[no_mangle]
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() }) };
1314         local_inner_val
1315 }
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.
1319 ///
1320 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
1321 ///
1322 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1323 ///
1324 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
1325 #[no_mangle]
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;
1329 }
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.
1335 ///
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
1339 #[no_mangle]
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;
1342         inner_val.into()
1343 }
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.
1349 ///
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
1353 #[no_mangle]
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();
1356 }
1357 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
1358 /// which is applied to commitment and HTLC transactions.
1359 ///
1360 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
1361 #[no_mangle]
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() }) };
1365         local_inner_val
1366 }
1367 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
1368 /// which is applied to commitment and HTLC transactions.
1369 ///
1370 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
1371 #[no_mangle]
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;
1375 }
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.
1379 ///
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.
1384 ///
1385 /// See also [`ChannelDetails::outbound_capacity_msat`]
1386 #[no_mangle]
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;
1389         *inner_val
1390 }
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.
1394 ///
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.
1399 ///
1400 /// See also [`ChannelDetails::outbound_capacity_msat`]
1401 #[no_mangle]
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;
1404 }
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.
1409 ///
1410 /// See also [`ChannelDetails::balance_msat`]
1411 ///
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.
1415 #[no_mangle]
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;
1418         *inner_val
1419 }
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.
1424 ///
1425 /// See also [`ChannelDetails::balance_msat`]
1426 ///
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.
1430 #[no_mangle]
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;
1433 }
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.
1438 ///
1439 /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1440 /// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
1441 #[no_mangle]
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;
1444         *inner_val
1445 }
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.
1450 ///
1451 /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1452 /// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
1453 #[no_mangle]
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;
1456 }
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.
1461 #[no_mangle]
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;
1464         *inner_val
1465 }
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.
1470 #[no_mangle]
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;
1473 }
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.
1479 ///
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.
1483 #[no_mangle]
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;
1486         *inner_val
1487 }
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.
1493 ///
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.
1497 #[no_mangle]
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;
1500 }
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`].
1506 ///
1507 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1508 ///
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
1512 #[no_mangle]
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() }) };
1516         local_inner_val
1517 }
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`].
1523 ///
1524 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1525 ///
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
1529 #[no_mangle]
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;
1533 }
1534 /// The current number of confirmations on the funding transaction.
1535 ///
1536 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1537 #[no_mangle]
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() }) };
1541         local_inner_val
1542 }
1543 /// The current number of confirmations on the funding transaction.
1544 ///
1545 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1546 #[no_mangle]
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;
1550 }
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.
1556 ///
1557 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1558 #[no_mangle]
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() }) };
1562         local_inner_val
1563 }
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.
1569 ///
1570 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1571 #[no_mangle]
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;
1575 }
1576 /// True if the channel was initiated (and thus funded) by us.
1577 #[no_mangle]
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;
1580         *inner_val
1581 }
1582 /// True if the channel was initiated (and thus funded) by us.
1583 #[no_mangle]
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;
1586 }
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`].
1592 ///
1593 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1594 #[no_mangle]
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;
1597         *inner_val
1598 }
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`].
1604 ///
1605 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1606 #[no_mangle]
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;
1609 }
1610 /// The stage of the channel's shutdown.
1611 /// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
1612 ///
1613 /// Returns a copy of the field.
1614 #[no_mangle]
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()) }) };
1618         local_inner_val
1619 }
1620 /// The stage of the channel's shutdown.
1621 /// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
1622 #[no_mangle]
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;
1626 }
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.
1629 ///
1630 /// This is a strict superset of `is_channel_ready`.
1631 #[no_mangle]
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;
1634         *inner_val
1635 }
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.
1638 ///
1639 /// This is a strict superset of `is_channel_ready`.
1640 #[no_mangle]
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;
1643 }
1644 /// True if this channel is (or will be) publicly-announced.
1645 #[no_mangle]
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;
1648         *inner_val
1649 }
1650 /// True if this channel is (or will be) publicly-announced.
1651 #[no_mangle]
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;
1654 }
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
1657 #[no_mangle]
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() }) };
1661         local_inner_val
1662 }
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
1665 #[no_mangle]
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;
1669 }
1670 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1671 #[no_mangle]
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() }) };
1675         local_inner_val
1676 }
1677 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1678 #[no_mangle]
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;
1682 }
1683 /// Set of configurable parameters that affect channel operation.
1684 ///
1685 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1686 ///
1687 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1688 #[no_mangle]
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 };
1692         local_inner_val
1693 }
1694 /// Set of configurable parameters that affect channel operation.
1695 ///
1696 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1697 ///
1698 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1699 #[no_mangle]
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;
1703 }
1704 /// Pending inbound HTLCs.
1705 ///
1706 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1707 #[no_mangle]
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()
1712 }
1713 /// Pending inbound HTLCs.
1714 ///
1715 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1716 #[no_mangle]
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;
1720 }
1721 /// Pending outbound HTLCs.
1722 ///
1723 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1724 #[no_mangle]
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()
1729 }
1730 /// Pending outbound HTLCs.
1731 ///
1732 /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
1733 #[no_mangle]
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;
1737 }
1738 /// Constructs a new ChannelDetails given each field
1739 ///
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
1743 #[must_use]
1744 #[no_mangle]
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 }
1793 }
1794 impl Clone for ChannelDetails {
1795         fn clone(&self) -> Self {
1796                 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()) },
1799                         is_owned: true,
1800                 }
1801         }
1802 }
1803 #[allow(unused)]
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
1807 }
1808 #[no_mangle]
1809 /// Creates a copy of the ChannelDetails
1810 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
1811         orig.clone()
1812 }
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.
1819 ///
1820 /// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
1821 /// [`ChannelDetails::short_channel_id`]. See those for more information.
1822 #[must_use]
1823 #[no_mangle]
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() }) };
1827         local_ret
1828 }
1829
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.
1833 ///
1834 /// This is either the [`ChannelDetails::short_channel_id`], if set, or the
1835 /// [`ChannelDetails::outbound_scid_alias`]. See those for more information.
1836 ///
1837 /// [`Route`]: crate::routing::router::Route
1838 #[must_use]
1839 #[no_mangle]
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() }) };
1843         local_ret
1844 }
1845
1846 #[no_mangle]
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())
1850 }
1851 #[allow(unused)]
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) })
1854 }
1855 #[no_mangle]
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() };
1860         local_res
1861 }
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
1868 #[derive(Clone)]
1869 #[must_use]
1870 #[repr(C)]
1871 pub enum ChannelShutdownState {
1872         /// Channel has not sent or received a shutdown message.
1873         NotShuttingDown,
1874         /// Local node has sent a shutdown message for this channel.
1875         ShutdownInitiated,
1876         /// Shutdown message exchanges have concluded and the channels are in the midst of
1877         /// resolving all existing open HTLCs before closing can continue.
1878         ResolvingHTLCs,
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.
1883         ShutdownComplete,
1884 }
1885 use lightning::ln::channel_state::ChannelShutdownState as ChannelShutdownStateImport;
1886 pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport;
1887
1888 impl ChannelShutdownState {
1889         #[allow(unused)]
1890         pub(crate) fn to_native(&self) -> nativeChannelShutdownState {
1891                 match self {
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,
1897                 }
1898         }
1899         #[allow(unused)]
1900         pub(crate) fn into_native(self) -> nativeChannelShutdownState {
1901                 match self {
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,
1907                 }
1908         }
1909         #[allow(unused)]
1910         pub(crate) fn from_native(native: &ChannelShutdownStateImport) -> Self {
1911                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeChannelShutdownState) };
1912                 match native {
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,
1918                 }
1919         }
1920         #[allow(unused)]
1921         pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self {
1922                 match native {
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,
1928                 }
1929         }
1930 }
1931 /// Creates a copy of the ChannelShutdownState
1932 #[no_mangle]
1933 pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState {
1934         orig.clone()
1935 }
1936 #[allow(unused)]
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
1940 }
1941 #[allow(unused)]
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) };
1945 }
1946 #[no_mangle]
1947 /// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState
1948 pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState {
1949         ChannelShutdownState::NotShuttingDown}
1950 #[no_mangle]
1951 /// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState
1952 pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState {
1953         ChannelShutdownState::ShutdownInitiated}
1954 #[no_mangle]
1955 /// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState
1956 pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState {
1957         ChannelShutdownState::ResolvingHTLCs}
1958 #[no_mangle]
1959 /// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState
1960 pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState {
1961         ChannelShutdownState::NegotiatingClosingFee}
1962 #[no_mangle]
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.
1971 #[no_mangle]
1972 pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool {
1973         if &a.to_native() == &b.to_native() { true } else { false }
1974 }
1975 #[no_mangle]
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())
1979 }
1980 #[allow(unused)]
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) })
1983 }
1984 #[no_mangle]
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() };
1989         local_res
1990 }