Update auto-generated bindings to 0.0.113
[ldk-c-bindings] / lightning-c-bindings / src / lightning / ln / channelmanager.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 //! The top-level channel management and payment tracking stuff lives here.
10 //!
11 //! The ChannelManager is the main chunk of logic implementing the lightning protocol and is
12 //! responsible for tracking which channels are open, HTLCs are in flight and reestablishing those
13 //! upon reconnect to the relevant peer(s).
14 //!
15 //! It does not manage routing logic (see [`find_route`] for that) nor does it manage constructing
16 //! on-chain transactions (it only monitors the chain to watch for any force-closes that might
17 //! imply it needs to fail HTLCs/payments/channels it manages).
18 //!
19 //! [`find_route`]: crate::routing::router::find_route
20
21 use alloc::str::FromStr;
22 use core::ffi::c_void;
23 use core::convert::Infallible;
24 use bitcoin::hashes::Hash;
25 use crate::c_types::*;
26 #[cfg(feature="no-std")]
27 use alloc::{vec::Vec, boxed::Box};
28
29
30 use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport;
31 pub(crate) type nativeChannelManager = nativeChannelManagerImport<crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>;
32
33 /// Manager which keeps track of a number of channels and sends messages to the appropriate
34 /// channel, also tracking HTLC preimages and forwarding onion packets appropriately.
35 ///
36 /// Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
37 /// to individual Channels.
38 ///
39 /// Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
40 /// all peers during write/read (though does not modify this instance, only the instance being
41 /// serialized). This will result in any channels which have not yet exchanged funding_created (ie
42 /// called funding_transaction_generated for outbound channels).
43 ///
44 /// Note that you can be a bit lazier about writing out ChannelManager than you can be with
45 /// ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
46 /// returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
47 /// happens out-of-band (and will prevent any other ChannelManager operations from occurring during
48 /// the serialization process). If the deserialized version is out-of-date compared to the
49 /// ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
50 /// ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
51 ///
52 /// Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
53 /// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
54 /// the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
55 /// block_connected() to step towards your best block) upon deserialization before using the
56 /// object!
57 ///
58 /// Note that ChannelManager is responsible for tracking liveness of its channels and generating
59 /// ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
60 /// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
61 /// offline for a full minute. In order to track this, you must call
62 /// timer_tick_occurred roughly once per minute, though it doesn't have to be perfect.
63 ///
64 /// Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
65 /// a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
66 /// essentially you should default to using a SimpleRefChannelManager, and use a
67 /// SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
68 /// you're using lightning-net-tokio.
69 #[must_use]
70 #[repr(C)]
71 pub struct ChannelManager {
72         /// A pointer to the opaque Rust object.
73
74         /// Nearly everywhere, inner must be non-null, however in places where
75         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
76         pub inner: *mut nativeChannelManager,
77         /// Indicates that this is the only struct which contains the same pointer.
78
79         /// Rust functions which take ownership of an object provided via an argument require
80         /// this to be true and invalidate the object pointed to by inner.
81         pub is_owned: bool,
82 }
83
84 impl Drop for ChannelManager {
85         fn drop(&mut self) {
86                 if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) {
87                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
88                 }
89         }
90 }
91 /// Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL.
92 #[no_mangle]
93 pub extern "C" fn ChannelManager_free(this_obj: ChannelManager) { }
94 #[allow(unused)]
95 /// Used only if an object of this type is returned as a trait impl by a method
96 pub(crate) extern "C" fn ChannelManager_free_void(this_ptr: *mut c_void) {
97         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelManager) };
98 }
99 #[allow(unused)]
100 impl ChannelManager {
101         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelManager {
102                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
103         }
104         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelManager {
105                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
106         }
107         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
108         pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager {
109                 assert!(self.is_owned);
110                 let ret = ObjOps::untweak_ptr(self.inner);
111                 self.inner = core::ptr::null_mut();
112                 ret
113         }
114 }
115
116 use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport;
117 pub(crate) type nativeChainParameters = nativeChainParametersImport;
118
119 /// Chain-related parameters used to construct a new `ChannelManager`.
120 ///
121 /// Typically, the block-specific parameters are derived from the best block hash for the network,
122 /// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters
123 /// are not needed when deserializing a previously constructed `ChannelManager`.
124 #[must_use]
125 #[repr(C)]
126 pub struct ChainParameters {
127         /// A pointer to the opaque Rust object.
128
129         /// Nearly everywhere, inner must be non-null, however in places where
130         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
131         pub inner: *mut nativeChainParameters,
132         /// Indicates that this is the only struct which contains the same pointer.
133
134         /// Rust functions which take ownership of an object provided via an argument require
135         /// this to be true and invalidate the object pointed to by inner.
136         pub is_owned: bool,
137 }
138
139 impl Drop for ChainParameters {
140         fn drop(&mut self) {
141                 if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) {
142                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
143                 }
144         }
145 }
146 /// Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL.
147 #[no_mangle]
148 pub extern "C" fn ChainParameters_free(this_obj: ChainParameters) { }
149 #[allow(unused)]
150 /// Used only if an object of this type is returned as a trait impl by a method
151 pub(crate) extern "C" fn ChainParameters_free_void(this_ptr: *mut c_void) {
152         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChainParameters) };
153 }
154 #[allow(unused)]
155 impl ChainParameters {
156         pub(crate) fn get_native_ref(&self) -> &'static nativeChainParameters {
157                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
158         }
159         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChainParameters {
160                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
161         }
162         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
163         pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters {
164                 assert!(self.is_owned);
165                 let ret = ObjOps::untweak_ptr(self.inner);
166                 self.inner = core::ptr::null_mut();
167                 ret
168         }
169 }
170 /// The network for determining the `chain_hash` in Lightning messages.
171 #[no_mangle]
172 pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network {
173         let mut inner_val = &mut this_ptr.get_native_mut_ref().network;
174         crate::bitcoin::network::Network::from_bitcoin(inner_val)
175 }
176 /// The network for determining the `chain_hash` in Lightning messages.
177 #[no_mangle]
178 pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) {
179         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network = val.into_bitcoin();
180 }
181 /// The hash and height of the latest block successfully connected.
182 ///
183 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
184 #[no_mangle]
185 pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::chain::BestBlock {
186         let mut inner_val = &mut this_ptr.get_native_mut_ref().best_block;
187         crate::lightning::chain::BestBlock { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::BestBlock<>) as *mut _) }, is_owned: false }
188 }
189 /// The hash and height of the latest block successfully connected.
190 ///
191 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
192 #[no_mangle]
193 pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::chain::BestBlock) {
194         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.best_block = *unsafe { Box::from_raw(val.take_inner()) };
195 }
196 /// Constructs a new ChainParameters given each field
197 #[must_use]
198 #[no_mangle]
199 pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::chain::BestBlock) -> ChainParameters {
200         ChainParameters { inner: ObjOps::heap_alloc(nativeChainParameters {
201                 network: network_arg.into_bitcoin(),
202                 best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) },
203         }), is_owned: true }
204 }
205 impl Clone for ChainParameters {
206         fn clone(&self) -> Self {
207                 Self {
208                         inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
209                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
210                         is_owned: true,
211                 }
212         }
213 }
214 #[allow(unused)]
215 /// Used only if an object of this type is returned as a trait impl by a method
216 pub(crate) extern "C" fn ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
217         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChainParameters)).clone() })) as *mut c_void
218 }
219 #[no_mangle]
220 /// Creates a copy of the ChainParameters
221 pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters {
222         orig.clone()
223 }
224 /// The amount of time in blocks we require our counterparty wait to claim their money (ie time
225 /// between when we, or our watchtower, must check for them having broadcast a theft transaction).
226 ///
227 /// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
228 ///
229 /// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
230
231 #[no_mangle]
232 pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT;
233 /// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
234 /// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour.
235 ///
236 /// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`]
237 ///
238 /// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta
239
240 #[no_mangle]
241 pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA;
242 /// Minimum CLTV difference between the current block height and received inbound payments.
243 /// Invoices generated for payment to us must set their `min_final_cltv_expiry` field to at least
244 /// this value.
245
246 #[no_mangle]
247 pub static MIN_FINAL_CLTV_EXPIRY: u32 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY;
248
249 use lightning::ln::channelmanager::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport;
250 pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport;
251
252 /// Information needed for constructing an invoice route hint for this channel.
253 #[must_use]
254 #[repr(C)]
255 pub struct CounterpartyForwardingInfo {
256         /// A pointer to the opaque Rust object.
257
258         /// Nearly everywhere, inner must be non-null, however in places where
259         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
260         pub inner: *mut nativeCounterpartyForwardingInfo,
261         /// Indicates that this is the only struct which contains the same pointer.
262
263         /// Rust functions which take ownership of an object provided via an argument require
264         /// this to be true and invalidate the object pointed to by inner.
265         pub is_owned: bool,
266 }
267
268 impl Drop for CounterpartyForwardingInfo {
269         fn drop(&mut self) {
270                 if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) {
271                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
272                 }
273         }
274 }
275 /// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL.
276 #[no_mangle]
277 pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { }
278 #[allow(unused)]
279 /// Used only if an object of this type is returned as a trait impl by a method
280 pub(crate) extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) {
281         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCounterpartyForwardingInfo) };
282 }
283 #[allow(unused)]
284 impl CounterpartyForwardingInfo {
285         pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo {
286                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
287         }
288         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo {
289                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
290         }
291         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
292         pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo {
293                 assert!(self.is_owned);
294                 let ret = ObjOps::untweak_ptr(self.inner);
295                 self.inner = core::ptr::null_mut();
296                 ret
297         }
298 }
299 /// Base routing fee in millisatoshis.
300 #[no_mangle]
301 pub extern "C" fn CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: &CounterpartyForwardingInfo) -> u32 {
302         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
303         *inner_val
304 }
305 /// Base routing fee in millisatoshis.
306 #[no_mangle]
307 pub extern "C" fn CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
308         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
309 }
310 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
311 #[no_mangle]
312 pub extern "C" fn CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: &CounterpartyForwardingInfo) -> u32 {
313         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
314         *inner_val
315 }
316 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
317 #[no_mangle]
318 pub extern "C" fn CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
319         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
320 }
321 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
322 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
323 /// `cltv_expiry_delta` for more details.
324 #[no_mangle]
325 pub extern "C" fn CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: &CounterpartyForwardingInfo) -> u16 {
326         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
327         *inner_val
328 }
329 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
330 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
331 /// `cltv_expiry_delta` for more details.
332 #[no_mangle]
333 pub extern "C" fn CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: &mut CounterpartyForwardingInfo, mut val: u16) {
334         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
335 }
336 /// Constructs a new CounterpartyForwardingInfo given each field
337 #[must_use]
338 #[no_mangle]
339 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 {
340         CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(nativeCounterpartyForwardingInfo {
341                 fee_base_msat: fee_base_msat_arg,
342                 fee_proportional_millionths: fee_proportional_millionths_arg,
343                 cltv_expiry_delta: cltv_expiry_delta_arg,
344         }), is_owned: true }
345 }
346 impl Clone for CounterpartyForwardingInfo {
347         fn clone(&self) -> Self {
348                 Self {
349                         inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
350                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
351                         is_owned: true,
352                 }
353         }
354 }
355 #[allow(unused)]
356 /// Used only if an object of this type is returned as a trait impl by a method
357 pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
358         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyForwardingInfo)).clone() })) as *mut c_void
359 }
360 #[no_mangle]
361 /// Creates a copy of the CounterpartyForwardingInfo
362 pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo {
363         orig.clone()
364 }
365
366 use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport;
367 pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport;
368
369 /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
370 /// to better separate parameters.
371 #[must_use]
372 #[repr(C)]
373 pub struct ChannelCounterparty {
374         /// A pointer to the opaque Rust object.
375
376         /// Nearly everywhere, inner must be non-null, however in places where
377         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
378         pub inner: *mut nativeChannelCounterparty,
379         /// Indicates that this is the only struct which contains the same pointer.
380
381         /// Rust functions which take ownership of an object provided via an argument require
382         /// this to be true and invalidate the object pointed to by inner.
383         pub is_owned: bool,
384 }
385
386 impl Drop for ChannelCounterparty {
387         fn drop(&mut self) {
388                 if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) {
389                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
390                 }
391         }
392 }
393 /// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
394 #[no_mangle]
395 pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { }
396 #[allow(unused)]
397 /// Used only if an object of this type is returned as a trait impl by a method
398 pub(crate) extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) {
399         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelCounterparty) };
400 }
401 #[allow(unused)]
402 impl ChannelCounterparty {
403         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty {
404                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
405         }
406         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty {
407                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
408         }
409         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
410         pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
411                 assert!(self.is_owned);
412                 let ret = ObjOps::untweak_ptr(self.inner);
413                 self.inner = core::ptr::null_mut();
414                 ret
415         }
416 }
417 /// The node_id of our counterparty
418 #[no_mangle]
419 pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey {
420         let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
421         crate::c_types::PublicKey::from_rust(&inner_val)
422 }
423 /// The node_id of our counterparty
424 #[no_mangle]
425 pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) {
426         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
427 }
428 /// The Features the channel counterparty provided upon last connection.
429 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
430 /// many routing-relevant features are present in the init context.
431 #[no_mangle]
432 pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures {
433         let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
434         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 }
435 }
436 /// The Features the channel counterparty provided upon last connection.
437 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
438 /// many routing-relevant features are present in the init context.
439 #[no_mangle]
440 pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) {
441         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
442 }
443 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
444 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
445 /// claiming at least this value on chain.
446 ///
447 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
448 ///
449 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
450 #[no_mangle]
451 pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 {
452         let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
453         *inner_val
454 }
455 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
456 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
457 /// claiming at least this value on chain.
458 ///
459 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
460 ///
461 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
462 #[no_mangle]
463 pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) {
464         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = val;
465 }
466 /// Information on the fees and requirements that the counterparty requires when forwarding
467 /// payments to us through this channel.
468 ///
469 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
470 #[no_mangle]
471 pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channelmanager::CounterpartyForwardingInfo {
472         let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info;
473         let mut local_inner_val = crate::lightning::ln::channelmanager::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::channelmanager::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false };
474         local_inner_val
475 }
476 /// Information on the fees and requirements that the counterparty requires when forwarding
477 /// payments to us through this channel.
478 ///
479 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
480 #[no_mangle]
481 pub extern "C" fn ChannelCounterparty_set_forwarding_info(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) {
482         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
483         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_info = local_val;
484 }
485 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
486 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
487 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
488 #[no_mangle]
489 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_minimum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
490         let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_minimum_msat;
491         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() }) };
492         local_inner_val
493 }
494 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
495 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
496 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
497 #[no_mangle]
498 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_minimum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
499         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
500         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_minimum_msat = local_val;
501 }
502 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
503 #[no_mangle]
504 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_maximum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
505         let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_maximum_msat;
506         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() }) };
507         local_inner_val
508 }
509 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
510 #[no_mangle]
511 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
512         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
513         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_maximum_msat = local_val;
514 }
515 /// Constructs a new ChannelCounterparty given each field
516 #[must_use]
517 #[no_mangle]
518 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::channelmanager::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 {
519         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()) } }) };
520         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 };
521         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 };
522         ChannelCounterparty { inner: ObjOps::heap_alloc(nativeChannelCounterparty {
523                 node_id: node_id_arg.into_rust(),
524                 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
525                 unspendable_punishment_reserve: unspendable_punishment_reserve_arg,
526                 forwarding_info: local_forwarding_info_arg,
527                 outbound_htlc_minimum_msat: local_outbound_htlc_minimum_msat_arg,
528                 outbound_htlc_maximum_msat: local_outbound_htlc_maximum_msat_arg,
529         }), is_owned: true }
530 }
531 impl Clone for ChannelCounterparty {
532         fn clone(&self) -> Self {
533                 Self {
534                         inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else {
535                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
536                         is_owned: true,
537                 }
538         }
539 }
540 #[allow(unused)]
541 /// Used only if an object of this type is returned as a trait impl by a method
542 pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void {
543         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelCounterparty)).clone() })) as *mut c_void
544 }
545 #[no_mangle]
546 /// Creates a copy of the ChannelCounterparty
547 pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty {
548         orig.clone()
549 }
550
551 use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport;
552 pub(crate) type nativeChannelDetails = nativeChannelDetailsImport;
553
554 /// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
555 #[must_use]
556 #[repr(C)]
557 pub struct ChannelDetails {
558         /// A pointer to the opaque Rust object.
559
560         /// Nearly everywhere, inner must be non-null, however in places where
561         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
562         pub inner: *mut nativeChannelDetails,
563         /// Indicates that this is the only struct which contains the same pointer.
564
565         /// Rust functions which take ownership of an object provided via an argument require
566         /// this to be true and invalidate the object pointed to by inner.
567         pub is_owned: bool,
568 }
569
570 impl Drop for ChannelDetails {
571         fn drop(&mut self) {
572                 if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) {
573                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
574                 }
575         }
576 }
577 /// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
578 #[no_mangle]
579 pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
580 #[allow(unused)]
581 /// Used only if an object of this type is returned as a trait impl by a method
582 pub(crate) extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
583         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDetails) };
584 }
585 #[allow(unused)]
586 impl ChannelDetails {
587         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails {
588                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
589         }
590         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails {
591                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
592         }
593         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
594         pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
595                 assert!(self.is_owned);
596                 let ret = ObjOps::untweak_ptr(self.inner);
597                 self.inner = core::ptr::null_mut();
598                 ret
599         }
600 }
601 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
602 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
603 /// Note that this means this value is *not* persistent - it can change once during the
604 /// lifetime of the channel.
605 #[no_mangle]
606 pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] {
607         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
608         inner_val
609 }
610 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
611 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
612 /// Note that this means this value is *not* persistent - it can change once during the
613 /// lifetime of the channel.
614 #[no_mangle]
615 pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
616         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
617 }
618 /// Parameters which apply to our counterparty. See individual fields for more information.
619 #[no_mangle]
620 pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channelmanager::ChannelCounterparty {
621         let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty;
622         crate::lightning::ln::channelmanager::ChannelCounterparty { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::channelmanager::ChannelCounterparty<>) as *mut _) }, is_owned: false }
623 }
624 /// Parameters which apply to our counterparty. See individual fields for more information.
625 #[no_mangle]
626 pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channelmanager::ChannelCounterparty) {
627         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty = *unsafe { Box::from_raw(val.take_inner()) };
628 }
629 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
630 /// our counterparty already.
631 ///
632 /// Note that, if this has been set, `channel_id` will be equivalent to
633 /// `funding_txo.unwrap().to_channel_id()`.
634 ///
635 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
636 #[no_mangle]
637 pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
638         let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo;
639         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 };
640         local_inner_val
641 }
642 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
643 /// our counterparty already.
644 ///
645 /// Note that, if this has been set, `channel_id` will be equivalent to
646 /// `funding_txo.unwrap().to_channel_id()`.
647 ///
648 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
649 #[no_mangle]
650 pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) {
651         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
652         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val;
653 }
654 /// The features which this channel operates with. See individual features for more info.
655 ///
656 /// `None` until negotiation completes and the channel type is finalized.
657 ///
658 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
659 #[no_mangle]
660 pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures {
661         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
662         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 };
663         local_inner_val
664 }
665 /// The features which this channel operates with. See individual features for more info.
666 ///
667 /// `None` until negotiation completes and the channel type is finalized.
668 ///
669 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
670 #[no_mangle]
671 pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
672         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
673         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
674 }
675 /// The position of the funding transaction in the chain. None if the funding transaction has
676 /// not yet been confirmed and the channel fully opened.
677 ///
678 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
679 /// payments instead of this. See [`get_inbound_payment_scid`].
680 ///
681 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
682 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
683 ///
684 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
685 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
686 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
687 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
688 /// [`confirmations_required`]: Self::confirmations_required
689 #[no_mangle]
690 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
691         let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
692         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() }) };
693         local_inner_val
694 }
695 /// The position of the funding transaction in the chain. None if the funding transaction has
696 /// not yet been confirmed and the channel fully opened.
697 ///
698 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
699 /// payments instead of this. See [`get_inbound_payment_scid`].
700 ///
701 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
702 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
703 ///
704 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
705 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
706 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
707 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
708 /// [`confirmations_required`]: Self::confirmations_required
709 #[no_mangle]
710 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
711         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
712         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val;
713 }
714 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
715 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
716 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
717 /// `Some(0)`).
718 ///
719 /// This will be `None` as long as the channel is not available for routing outbound payments.
720 ///
721 /// [`short_channel_id`]: Self::short_channel_id
722 /// [`confirmations_required`]: Self::confirmations_required
723 #[no_mangle]
724 pub extern "C" fn ChannelDetails_get_outbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
725         let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_scid_alias;
726         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() }) };
727         local_inner_val
728 }
729 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
730 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
731 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
732 /// `Some(0)`).
733 ///
734 /// This will be `None` as long as the channel is not available for routing outbound payments.
735 ///
736 /// [`short_channel_id`]: Self::short_channel_id
737 /// [`confirmations_required`]: Self::confirmations_required
738 #[no_mangle]
739 pub extern "C" fn ChannelDetails_set_outbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
740         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
741         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_scid_alias = local_val;
742 }
743 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
744 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
745 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
746 /// when they see a payment to be routed to us.
747 ///
748 /// Our counterparty may choose to rotate this value at any time, though will always recognize
749 /// previous values for inbound payment forwarding.
750 ///
751 /// [`short_channel_id`]: Self::short_channel_id
752 #[no_mangle]
753 pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
754         let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias;
755         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() }) };
756         local_inner_val
757 }
758 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
759 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
760 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
761 /// when they see a payment to be routed to us.
762 ///
763 /// Our counterparty may choose to rotate this value at any time, though will always recognize
764 /// previous values for inbound payment forwarding.
765 ///
766 /// [`short_channel_id`]: Self::short_channel_id
767 #[no_mangle]
768 pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
769         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
770         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val;
771 }
772 /// The value, in satoshis, of this channel as appears in the funding output
773 #[no_mangle]
774 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
775         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis;
776         *inner_val
777 }
778 /// The value, in satoshis, of this channel as appears in the funding output
779 #[no_mangle]
780 pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
781         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val;
782 }
783 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
784 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
785 /// this value on chain.
786 ///
787 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
788 ///
789 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
790 ///
791 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
792 #[no_mangle]
793 pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
794         let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
795         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() }) };
796         local_inner_val
797 }
798 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
799 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
800 /// this value on chain.
801 ///
802 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
803 ///
804 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
805 ///
806 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
807 #[no_mangle]
808 pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
809         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
810         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = local_val;
811 }
812 /// The `user_channel_id` passed in to create_channel, or a random value if the channel was
813 /// inbound. This may be zero for inbound channels serialized with LDK versions prior to
814 /// 0.0.113.
815 #[no_mangle]
816 pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::U128 {
817         let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
818         inner_val.into()
819 }
820 /// The `user_channel_id` passed in to create_channel, or a random value if the channel was
821 /// inbound. This may be zero for inbound channels serialized with LDK versions prior to
822 /// 0.0.113.
823 #[no_mangle]
824 pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) {
825         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
826 }
827 /// Our total balance.  This is the amount we would get if we close the channel.
828 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
829 /// amount is not likely to be recoverable on close.
830 ///
831 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
832 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
833 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
834 /// This does not consider any on-chain fees.
835 ///
836 /// See also [`ChannelDetails::outbound_capacity_msat`]
837 #[no_mangle]
838 pub extern "C" fn ChannelDetails_get_balance_msat(this_ptr: &ChannelDetails) -> u64 {
839         let mut inner_val = &mut this_ptr.get_native_mut_ref().balance_msat;
840         *inner_val
841 }
842 /// Our total balance.  This is the amount we would get if we close the channel.
843 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
844 /// amount is not likely to be recoverable on close.
845 ///
846 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
847 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
848 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
849 /// This does not consider any on-chain fees.
850 ///
851 /// See also [`ChannelDetails::outbound_capacity_msat`]
852 #[no_mangle]
853 pub extern "C" fn ChannelDetails_set_balance_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
854         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.balance_msat = val;
855 }
856 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
857 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
858 /// available for inclusion in new outbound HTLCs). This further does not include any pending
859 /// outgoing HTLCs which are awaiting some other resolution to be sent.
860 ///
861 /// See also [`ChannelDetails::balance_msat`]
862 ///
863 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
864 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
865 /// should be able to spend nearly this amount.
866 #[no_mangle]
867 pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
868         let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_capacity_msat;
869         *inner_val
870 }
871 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
872 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
873 /// available for inclusion in new outbound HTLCs). This further does not include any pending
874 /// outgoing HTLCs which are awaiting some other resolution to be sent.
875 ///
876 /// See also [`ChannelDetails::balance_msat`]
877 ///
878 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
879 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
880 /// should be able to spend nearly this amount.
881 #[no_mangle]
882 pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
883         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_capacity_msat = val;
884 }
885 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
886 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
887 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
888 /// to use a limit as close as possible to the HTLC limit we can currently send.
889 ///
890 /// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`].
891 #[no_mangle]
892 pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 {
893         let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat;
894         *inner_val
895 }
896 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
897 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
898 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
899 /// to use a limit as close as possible to the HTLC limit we can currently send.
900 ///
901 /// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`].
902 #[no_mangle]
903 pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
904         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val;
905 }
906 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
907 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
908 /// available for inclusion in new inbound HTLCs).
909 /// Note that there are some corner cases not fully handled here, so the actual available
910 /// inbound capacity may be slightly higher than this.
911 ///
912 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
913 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
914 /// However, our counterparty should be able to spend nearly this amount.
915 #[no_mangle]
916 pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
917         let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_capacity_msat;
918         *inner_val
919 }
920 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
921 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
922 /// available for inclusion in new inbound HTLCs).
923 /// Note that there are some corner cases not fully handled here, so the actual available
924 /// inbound capacity may be slightly higher than this.
925 ///
926 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
927 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
928 /// However, our counterparty should be able to spend nearly this amount.
929 #[no_mangle]
930 pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
931         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_capacity_msat = val;
932 }
933 /// The number of required confirmations on the funding transaction before the funding will be
934 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
935 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
936 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
937 /// [`ChannelHandshakeLimits::max_minimum_depth`].
938 ///
939 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
940 ///
941 /// [`is_outbound`]: ChannelDetails::is_outbound
942 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
943 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
944 #[no_mangle]
945 pub extern "C" fn ChannelDetails_get_confirmations_required(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
946         let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations_required;
947         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() }) };
948         local_inner_val
949 }
950 /// The number of required confirmations on the funding transaction before the funding will be
951 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
952 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
953 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
954 /// [`ChannelHandshakeLimits::max_minimum_depth`].
955 ///
956 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
957 ///
958 /// [`is_outbound`]: ChannelDetails::is_outbound
959 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
960 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
961 #[no_mangle]
962 pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
963         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
964         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations_required = local_val;
965 }
966 /// The current number of confirmations on the funding transaction.
967 ///
968 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
969 #[no_mangle]
970 pub extern "C" fn ChannelDetails_get_confirmations(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
971         let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations;
972         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() }) };
973         local_inner_val
974 }
975 /// The current number of confirmations on the funding transaction.
976 ///
977 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
978 #[no_mangle]
979 pub extern "C" fn ChannelDetails_set_confirmations(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
980         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
981         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations = local_val;
982 }
983 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
984 /// until we can claim our funds after we force-close the channel. During this time our
985 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
986 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
987 /// time to claim our non-HTLC-encumbered funds.
988 ///
989 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
990 #[no_mangle]
991 pub extern "C" fn ChannelDetails_get_force_close_spend_delay(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u16Z {
992         let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_spend_delay;
993         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() }) };
994         local_inner_val
995 }
996 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
997 /// until we can claim our funds after we force-close the channel. During this time our
998 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
999 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
1000 /// time to claim our non-HTLC-encumbered funds.
1001 ///
1002 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1003 #[no_mangle]
1004 pub extern "C" fn ChannelDetails_set_force_close_spend_delay(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u16Z) {
1005         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1006         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_spend_delay = local_val;
1007 }
1008 /// True if the channel was initiated (and thus funded) by us.
1009 #[no_mangle]
1010 pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool {
1011         let mut inner_val = &mut this_ptr.get_native_mut_ref().is_outbound;
1012         *inner_val
1013 }
1014 /// True if the channel was initiated (and thus funded) by us.
1015 #[no_mangle]
1016 pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) {
1017         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_outbound = val;
1018 }
1019 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1020 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1021 /// required confirmation count has been reached (and we were connected to the peer at some
1022 /// point after the funding transaction received enough confirmations). The required
1023 /// confirmation count is provided in [`confirmations_required`].
1024 ///
1025 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1026 #[no_mangle]
1027 pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) -> bool {
1028         let mut inner_val = &mut this_ptr.get_native_mut_ref().is_channel_ready;
1029         *inner_val
1030 }
1031 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1032 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1033 /// required confirmation count has been reached (and we were connected to the peer at some
1034 /// point after the funding transaction received enough confirmations). The required
1035 /// confirmation count is provided in [`confirmations_required`].
1036 ///
1037 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1038 #[no_mangle]
1039 pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) {
1040         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val;
1041 }
1042 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1043 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1044 ///
1045 /// This is a strict superset of `is_channel_ready`.
1046 #[no_mangle]
1047 pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool {
1048         let mut inner_val = &mut this_ptr.get_native_mut_ref().is_usable;
1049         *inner_val
1050 }
1051 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1052 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1053 ///
1054 /// This is a strict superset of `is_channel_ready`.
1055 #[no_mangle]
1056 pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) {
1057         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_usable = val;
1058 }
1059 /// True if this channel is (or will be) publicly-announced.
1060 #[no_mangle]
1061 pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool {
1062         let mut inner_val = &mut this_ptr.get_native_mut_ref().is_public;
1063         *inner_val
1064 }
1065 /// True if this channel is (or will be) publicly-announced.
1066 #[no_mangle]
1067 pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) {
1068         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_public = val;
1069 }
1070 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1071 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1072 #[no_mangle]
1073 pub extern "C" fn ChannelDetails_get_inbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1074         let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_minimum_msat;
1075         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() }) };
1076         local_inner_val
1077 }
1078 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1079 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1080 #[no_mangle]
1081 pub extern "C" fn ChannelDetails_set_inbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1082         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1083         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_minimum_msat = local_val;
1084 }
1085 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1086 #[no_mangle]
1087 pub extern "C" fn ChannelDetails_get_inbound_htlc_maximum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1088         let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_maximum_msat;
1089         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() }) };
1090         local_inner_val
1091 }
1092 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1093 #[no_mangle]
1094 pub extern "C" fn ChannelDetails_set_inbound_htlc_maximum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1095         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1096         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_maximum_msat = local_val;
1097 }
1098 /// Set of configurable parameters that affect channel operation.
1099 ///
1100 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1101 ///
1102 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1103 #[no_mangle]
1104 pub extern "C" fn ChannelDetails_get_config(this_ptr: &ChannelDetails) -> crate::lightning::util::config::ChannelConfig {
1105         let mut inner_val = &mut this_ptr.get_native_mut_ref().config;
1106         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 };
1107         local_inner_val
1108 }
1109 /// Set of configurable parameters that affect channel operation.
1110 ///
1111 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1112 ///
1113 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1114 #[no_mangle]
1115 pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut val: crate::lightning::util::config::ChannelConfig) {
1116         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1117         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.config = local_val;
1118 }
1119 /// Constructs a new ChannelDetails given each field
1120 #[must_use]
1121 #[no_mangle]
1122 pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::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 balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_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 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) -> ChannelDetails {
1123         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()) } }) };
1124         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()) } }) };
1125         let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None };
1126         let mut local_outbound_scid_alias_arg = if outbound_scid_alias_arg.is_some() { Some( { outbound_scid_alias_arg.take() }) } else { None };
1127         let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None };
1128         let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None };
1129         let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None };
1130         let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None };
1131         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 };
1132         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 };
1133         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 };
1134         let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) };
1135         ChannelDetails { inner: ObjOps::heap_alloc(nativeChannelDetails {
1136                 channel_id: channel_id_arg.data,
1137                 counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) },
1138                 funding_txo: local_funding_txo_arg,
1139                 channel_type: local_channel_type_arg,
1140                 short_channel_id: local_short_channel_id_arg,
1141                 outbound_scid_alias: local_outbound_scid_alias_arg,
1142                 inbound_scid_alias: local_inbound_scid_alias_arg,
1143                 channel_value_satoshis: channel_value_satoshis_arg,
1144                 unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg,
1145                 user_channel_id: user_channel_id_arg.into(),
1146                 balance_msat: balance_msat_arg,
1147                 outbound_capacity_msat: outbound_capacity_msat_arg,
1148                 next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg,
1149                 inbound_capacity_msat: inbound_capacity_msat_arg,
1150                 confirmations_required: local_confirmations_required_arg,
1151                 confirmations: local_confirmations_arg,
1152                 force_close_spend_delay: local_force_close_spend_delay_arg,
1153                 is_outbound: is_outbound_arg,
1154                 is_channel_ready: is_channel_ready_arg,
1155                 is_usable: is_usable_arg,
1156                 is_public: is_public_arg,
1157                 inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg,
1158                 inbound_htlc_maximum_msat: local_inbound_htlc_maximum_msat_arg,
1159                 config: local_config_arg,
1160         }), is_owned: true }
1161 }
1162 impl Clone for ChannelDetails {
1163         fn clone(&self) -> Self {
1164                 Self {
1165                         inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
1166                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1167                         is_owned: true,
1168                 }
1169         }
1170 }
1171 #[allow(unused)]
1172 /// Used only if an object of this type is returned as a trait impl by a method
1173 pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
1174         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDetails)).clone() })) as *mut c_void
1175 }
1176 #[no_mangle]
1177 /// Creates a copy of the ChannelDetails
1178 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
1179         orig.clone()
1180 }
1181 /// Gets the current SCID which should be used to identify this channel for inbound payments.
1182 /// This should be used for providing invoice hints or in any other context where our
1183 /// counterparty will forward a payment to us.
1184 ///
1185 /// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
1186 /// [`ChannelDetails::short_channel_id`]. See those for more information.
1187 #[must_use]
1188 #[no_mangle]
1189 pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1190         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid();
1191         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() }) };
1192         local_ret
1193 }
1194
1195 /// Gets the current SCID which should be used to identify this channel for outbound payments.
1196 /// This should be used in [`Route`]s to describe the first hop or in other contexts where
1197 /// we're sending or forwarding a payment outbound over this channel.
1198 ///
1199 /// This is either the [`ChannelDetails::short_channel_id`], if set, or the
1200 /// [`ChannelDetails::outbound_scid_alias`]. See those for more information.
1201 #[must_use]
1202 #[no_mangle]
1203 pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1204         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_outbound_payment_scid();
1205         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() }) };
1206         local_ret
1207 }
1208
1209 /// If a payment fails to send, it can be in one of several states. This enum is returned as the
1210 /// Err() type describing which state the payment is in, see the description of individual enum
1211 /// states for more.
1212 #[derive(Clone)]
1213 #[must_use]
1214 #[repr(C)]
1215 pub enum PaymentSendFailure {
1216         /// A parameter which was passed to send_payment was invalid, preventing us from attempting to
1217         /// send the payment at all.
1218         ///
1219         /// You can freely resend the payment in full (with the parameter error fixed).
1220         ///
1221         /// Because the payment failed outright, no payment tracking is done, you do not need to call
1222         /// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1223         /// for this payment.
1224         ParameterError(
1225                 crate::lightning::util::errors::APIError),
1226         /// A parameter in a single path which was passed to send_payment was invalid, preventing us
1227         /// from attempting to send the payment at all.
1228         ///
1229         /// You can freely resend the payment in full (with the parameter error fixed).
1230         ///
1231         /// The results here are ordered the same as the paths in the route object which was passed to
1232         /// send_payment.
1233         ///
1234         /// Because the payment failed outright, no payment tracking is done, you do not need to call
1235         /// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1236         /// for this payment.
1237         PathParameterError(
1238                 crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
1239         /// All paths which were attempted failed to send, with no channel state change taking place.
1240         /// You can freely resend the payment in full (though you probably want to do so over different
1241         /// paths than the ones selected).
1242         ///
1243         /// Because the payment failed outright, no payment tracking is done, you do not need to call
1244         /// [`ChannelManager::abandon_payment`] and [`ChannelManager::retry_payment`] will *not* work
1245         /// for this payment.
1246         AllFailedResendSafe(
1247                 crate::c_types::derived::CVec_APIErrorZ),
1248         /// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not
1249         /// yet completed (i.e. generated an [`Event::PaymentSent`]) or been abandoned (via
1250         /// [`ChannelManager::abandon_payment`]).
1251         ///
1252         /// [`Event::PaymentSent`]: events::Event::PaymentSent
1253         DuplicatePayment,
1254         /// Some paths which were attempted failed to send, though possibly not all. At least some
1255         /// paths have irrevocably committed to the HTLC and retrying the payment in full would result
1256         /// in over-/re-payment.
1257         ///
1258         /// The results here are ordered the same as the paths in the route object which was passed to
1259         /// send_payment, and any `Err`s which are not [`APIError::MonitorUpdateInProgress`] can be
1260         /// safely retried via [`ChannelManager::retry_payment`].
1261         ///
1262         /// Any entries which contain `Err(APIError::MonitorUpdateInprogress)` or `Ok(())` MUST NOT be
1263         /// retried as they will result in over-/re-payment. These HTLCs all either successfully sent
1264         /// (in the case of `Ok(())`) or will send once a [`MonitorEvent::Completed`] is provided for
1265         /// the next-hop channel with the latest update_id.
1266         PartialFailure {
1267                 /// The errors themselves, in the same order as the route hops.
1268                 results: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ,
1269                 /// If some paths failed without irrevocably committing to the new HTLC(s), this will
1270                 /// contain a [`RouteParameters`] object which can be used to calculate a new route that
1271                 /// will pay all remaining unpaid balance.
1272                 ///
1273                 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1274                 failed_paths_retry: crate::lightning::routing::router::RouteParameters,
1275                 /// The payment id for the payment, which is now at least partially pending.
1276                 payment_id: crate::c_types::ThirtyTwoBytes,
1277         },
1278 }
1279 use lightning::ln::channelmanager::PaymentSendFailure as PaymentSendFailureImport;
1280 pub(crate) type nativePaymentSendFailure = PaymentSendFailureImport;
1281
1282 impl PaymentSendFailure {
1283         #[allow(unused)]
1284         pub(crate) fn to_native(&self) -> nativePaymentSendFailure {
1285                 match self {
1286                         PaymentSendFailure::ParameterError (ref a, ) => {
1287                                 let mut a_nonref = Clone::clone(a);
1288                                 nativePaymentSendFailure::ParameterError (
1289                                         a_nonref.into_native(),
1290                                 )
1291                         },
1292                         PaymentSendFailure::PathParameterError (ref a, ) => {
1293                                 let mut a_nonref = Clone::clone(a);
1294                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); };
1295                                 nativePaymentSendFailure::PathParameterError (
1296                                         local_a_nonref,
1297                                 )
1298                         },
1299                         PaymentSendFailure::AllFailedResendSafe (ref a, ) => {
1300                                 let mut a_nonref = Clone::clone(a);
1301                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into_native() }); };
1302                                 nativePaymentSendFailure::AllFailedResendSafe (
1303                                         local_a_nonref,
1304                                 )
1305                         },
1306                         PaymentSendFailure::DuplicatePayment => nativePaymentSendFailure::DuplicatePayment,
1307                         PaymentSendFailure::PartialFailure {ref results, ref failed_paths_retry, ref payment_id, } => {
1308                                 let mut results_nonref = Clone::clone(results);
1309                                 let mut local_results_nonref = Vec::new(); for mut item in results_nonref.into_rust().drain(..) { local_results_nonref.push( { let mut local_results_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_results_nonref_0 }); };
1310                                 let mut failed_paths_retry_nonref = Clone::clone(failed_paths_retry);
1311                                 let mut local_failed_paths_retry_nonref = if failed_paths_retry_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(failed_paths_retry_nonref.take_inner()) } }) };
1312                                 let mut payment_id_nonref = Clone::clone(payment_id);
1313                                 nativePaymentSendFailure::PartialFailure {
1314                                         results: local_results_nonref,
1315                                         failed_paths_retry: local_failed_paths_retry_nonref,
1316                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1317                                 }
1318                         },
1319                 }
1320         }
1321         #[allow(unused)]
1322         pub(crate) fn into_native(self) -> nativePaymentSendFailure {
1323                 match self {
1324                         PaymentSendFailure::ParameterError (mut a, ) => {
1325                                 nativePaymentSendFailure::ParameterError (
1326                                         a.into_native(),
1327                                 )
1328                         },
1329                         PaymentSendFailure::PathParameterError (mut a, ) => {
1330                                 let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); };
1331                                 nativePaymentSendFailure::PathParameterError (
1332                                         local_a,
1333                                 )
1334                         },
1335                         PaymentSendFailure::AllFailedResendSafe (mut a, ) => {
1336                                 let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into_native() }); };
1337                                 nativePaymentSendFailure::AllFailedResendSafe (
1338                                         local_a,
1339                                 )
1340                         },
1341                         PaymentSendFailure::DuplicatePayment => nativePaymentSendFailure::DuplicatePayment,
1342                         PaymentSendFailure::PartialFailure {mut results, mut failed_paths_retry, mut payment_id, } => {
1343                                 let mut local_results = Vec::new(); for mut item in results.into_rust().drain(..) { local_results.push( { let mut local_results_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_results_0 }); };
1344                                 let mut local_failed_paths_retry = if failed_paths_retry.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(failed_paths_retry.take_inner()) } }) };
1345                                 nativePaymentSendFailure::PartialFailure {
1346                                         results: local_results,
1347                                         failed_paths_retry: local_failed_paths_retry,
1348                                         payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1349                                 }
1350                         },
1351                 }
1352         }
1353         #[allow(unused)]
1354         pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self {
1355                 match native {
1356                         nativePaymentSendFailure::ParameterError (ref a, ) => {
1357                                 let mut a_nonref = Clone::clone(a);
1358                                 PaymentSendFailure::ParameterError (
1359                                         crate::lightning::util::errors::APIError::native_into(a_nonref),
1360                                 )
1361                         },
1362                         nativePaymentSendFailure::PathParameterError (ref a, ) => {
1363                                 let mut a_nonref = Clone::clone(a);
1364                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); };
1365                                 PaymentSendFailure::PathParameterError (
1366                                         local_a_nonref.into(),
1367                                 )
1368                         },
1369                         nativePaymentSendFailure::AllFailedResendSafe (ref a, ) => {
1370                                 let mut a_nonref = Clone::clone(a);
1371                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::lightning::util::errors::APIError::native_into(item) }); };
1372                                 PaymentSendFailure::AllFailedResendSafe (
1373                                         local_a_nonref.into(),
1374                                 )
1375                         },
1376                         nativePaymentSendFailure::DuplicatePayment => PaymentSendFailure::DuplicatePayment,
1377                         nativePaymentSendFailure::PartialFailure {ref results, ref failed_paths_retry, ref payment_id, } => {
1378                                 let mut results_nonref = Clone::clone(results);
1379                                 let mut local_results_nonref = Vec::new(); for mut item in results_nonref.drain(..) { local_results_nonref.push( { let mut local_results_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_nonref_0 }); };
1380                                 let mut failed_paths_retry_nonref = Clone::clone(failed_paths_retry);
1381                                 let mut local_failed_paths_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry_nonref.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry_nonref.unwrap())) } }, is_owned: true };
1382                                 let mut payment_id_nonref = Clone::clone(payment_id);
1383                                 PaymentSendFailure::PartialFailure {
1384                                         results: local_results_nonref.into(),
1385                                         failed_paths_retry: local_failed_paths_retry_nonref,
1386                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1387                                 }
1388                         },
1389                 }
1390         }
1391         #[allow(unused)]
1392         pub(crate) fn native_into(native: nativePaymentSendFailure) -> Self {
1393                 match native {
1394                         nativePaymentSendFailure::ParameterError (mut a, ) => {
1395                                 PaymentSendFailure::ParameterError (
1396                                         crate::lightning::util::errors::APIError::native_into(a),
1397                                 )
1398                         },
1399                         nativePaymentSendFailure::PathParameterError (mut a, ) => {
1400                                 let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); };
1401                                 PaymentSendFailure::PathParameterError (
1402                                         local_a.into(),
1403                                 )
1404                         },
1405                         nativePaymentSendFailure::AllFailedResendSafe (mut a, ) => {
1406                                 let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::util::errors::APIError::native_into(item) }); };
1407                                 PaymentSendFailure::AllFailedResendSafe (
1408                                         local_a.into(),
1409                                 )
1410                         },
1411                         nativePaymentSendFailure::DuplicatePayment => PaymentSendFailure::DuplicatePayment,
1412                         nativePaymentSendFailure::PartialFailure {mut results, mut failed_paths_retry, mut payment_id, } => {
1413                                 let mut local_results = Vec::new(); for mut item in results.drain(..) { local_results.push( { let mut local_results_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_0 }); };
1414                                 let mut local_failed_paths_retry = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry.is_none() { core::ptr::null_mut() } else {  { ObjOps::heap_alloc((failed_paths_retry.unwrap())) } }, is_owned: true };
1415                                 PaymentSendFailure::PartialFailure {
1416                                         results: local_results.into(),
1417                                         failed_paths_retry: local_failed_paths_retry,
1418                                         payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1419                                 }
1420                         },
1421                 }
1422         }
1423 }
1424 /// Frees any resources used by the PaymentSendFailure
1425 #[no_mangle]
1426 pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { }
1427 /// Creates a copy of the PaymentSendFailure
1428 #[no_mangle]
1429 pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure {
1430         orig.clone()
1431 }
1432 #[no_mangle]
1433 /// Utility method to constructs a new ParameterError-variant PaymentSendFailure
1434 pub extern "C" fn PaymentSendFailure_parameter_error(a: crate::lightning::util::errors::APIError) -> PaymentSendFailure {
1435         PaymentSendFailure::ParameterError(a, )
1436 }
1437 #[no_mangle]
1438 /// Utility method to constructs a new PathParameterError-variant PaymentSendFailure
1439 pub extern "C" fn PaymentSendFailure_path_parameter_error(a: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ) -> PaymentSendFailure {
1440         PaymentSendFailure::PathParameterError(a, )
1441 }
1442 #[no_mangle]
1443 /// Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure
1444 pub extern "C" fn PaymentSendFailure_all_failed_resend_safe(a: crate::c_types::derived::CVec_APIErrorZ) -> PaymentSendFailure {
1445         PaymentSendFailure::AllFailedResendSafe(a, )
1446 }
1447 #[no_mangle]
1448 /// Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure
1449 pub extern "C" fn PaymentSendFailure_duplicate_payment() -> PaymentSendFailure {
1450         PaymentSendFailure::DuplicatePayment}
1451 #[no_mangle]
1452 /// Utility method to constructs a new PartialFailure-variant PaymentSendFailure
1453 pub extern "C" fn PaymentSendFailure_partial_failure(results: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ, failed_paths_retry: crate::lightning::routing::router::RouteParameters, payment_id: crate::c_types::ThirtyTwoBytes) -> PaymentSendFailure {
1454         PaymentSendFailure::PartialFailure {
1455                 results,
1456                 failed_paths_retry,
1457                 payment_id,
1458         }
1459 }
1460
1461 use lightning::ln::channelmanager::PhantomRouteHints as nativePhantomRouteHintsImport;
1462 pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport;
1463
1464 /// Route hints used in constructing invoices for [phantom node payents].
1465 ///
1466 /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
1467 #[must_use]
1468 #[repr(C)]
1469 pub struct PhantomRouteHints {
1470         /// A pointer to the opaque Rust object.
1471
1472         /// Nearly everywhere, inner must be non-null, however in places where
1473         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1474         pub inner: *mut nativePhantomRouteHints,
1475         /// Indicates that this is the only struct which contains the same pointer.
1476
1477         /// Rust functions which take ownership of an object provided via an argument require
1478         /// this to be true and invalidate the object pointed to by inner.
1479         pub is_owned: bool,
1480 }
1481
1482 impl Drop for PhantomRouteHints {
1483         fn drop(&mut self) {
1484                 if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) {
1485                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1486                 }
1487         }
1488 }
1489 /// Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL.
1490 #[no_mangle]
1491 pub extern "C" fn PhantomRouteHints_free(this_obj: PhantomRouteHints) { }
1492 #[allow(unused)]
1493 /// Used only if an object of this type is returned as a trait impl by a method
1494 pub(crate) extern "C" fn PhantomRouteHints_free_void(this_ptr: *mut c_void) {
1495         let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomRouteHints) };
1496 }
1497 #[allow(unused)]
1498 impl PhantomRouteHints {
1499         pub(crate) fn get_native_ref(&self) -> &'static nativePhantomRouteHints {
1500                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1501         }
1502         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomRouteHints {
1503                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1504         }
1505         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1506         pub(crate) fn take_inner(mut self) -> *mut nativePhantomRouteHints {
1507                 assert!(self.is_owned);
1508                 let ret = ObjOps::untweak_ptr(self.inner);
1509                 self.inner = core::ptr::null_mut();
1510                 ret
1511         }
1512 }
1513 /// The list of channels to be included in the invoice route hints.
1514 #[no_mangle]
1515 pub extern "C" fn PhantomRouteHints_get_channels(this_ptr: &PhantomRouteHints) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1516         let mut inner_val = &mut this_ptr.get_native_mut_ref().channels;
1517         let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); };
1518         local_inner_val.into()
1519 }
1520 /// The list of channels to be included in the invoice route hints.
1521 #[no_mangle]
1522 pub extern "C" fn PhantomRouteHints_set_channels(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::derived::CVec_ChannelDetailsZ) {
1523         let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1524         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
1525 }
1526 /// A fake scid used for representing the phantom node's fake channel in generating the invoice
1527 /// route hints.
1528 #[no_mangle]
1529 pub extern "C" fn PhantomRouteHints_get_phantom_scid(this_ptr: &PhantomRouteHints) -> u64 {
1530         let mut inner_val = &mut this_ptr.get_native_mut_ref().phantom_scid;
1531         *inner_val
1532 }
1533 /// A fake scid used for representing the phantom node's fake channel in generating the invoice
1534 /// route hints.
1535 #[no_mangle]
1536 pub extern "C" fn PhantomRouteHints_set_phantom_scid(this_ptr: &mut PhantomRouteHints, mut val: u64) {
1537         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.phantom_scid = val;
1538 }
1539 /// The pubkey of the real backing node that would ultimately receive the payment.
1540 #[no_mangle]
1541 pub extern "C" fn PhantomRouteHints_get_real_node_pubkey(this_ptr: &PhantomRouteHints) -> crate::c_types::PublicKey {
1542         let mut inner_val = &mut this_ptr.get_native_mut_ref().real_node_pubkey;
1543         crate::c_types::PublicKey::from_rust(&inner_val)
1544 }
1545 /// The pubkey of the real backing node that would ultimately receive the payment.
1546 #[no_mangle]
1547 pub extern "C" fn PhantomRouteHints_set_real_node_pubkey(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::PublicKey) {
1548         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.real_node_pubkey = val.into_rust();
1549 }
1550 /// Constructs a new PhantomRouteHints given each field
1551 #[must_use]
1552 #[no_mangle]
1553 pub extern "C" fn PhantomRouteHints_new(mut channels_arg: crate::c_types::derived::CVec_ChannelDetailsZ, mut phantom_scid_arg: u64, mut real_node_pubkey_arg: crate::c_types::PublicKey) -> PhantomRouteHints {
1554         let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1555         PhantomRouteHints { inner: ObjOps::heap_alloc(nativePhantomRouteHints {
1556                 channels: local_channels_arg,
1557                 phantom_scid: phantom_scid_arg,
1558                 real_node_pubkey: real_node_pubkey_arg.into_rust(),
1559         }), is_owned: true }
1560 }
1561 impl Clone for PhantomRouteHints {
1562         fn clone(&self) -> Self {
1563                 Self {
1564                         inner: if <*mut nativePhantomRouteHints>::is_null(self.inner) { core::ptr::null_mut() } else {
1565                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1566                         is_owned: true,
1567                 }
1568         }
1569 }
1570 #[allow(unused)]
1571 /// Used only if an object of this type is returned as a trait impl by a method
1572 pub(crate) extern "C" fn PhantomRouteHints_clone_void(this_ptr: *const c_void) -> *mut c_void {
1573         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePhantomRouteHints)).clone() })) as *mut c_void
1574 }
1575 #[no_mangle]
1576 /// Creates a copy of the PhantomRouteHints
1577 pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRouteHints {
1578         orig.clone()
1579 }
1580 /// Constructs a new ChannelManager to hold several channels and route between them.
1581 ///
1582 /// This is the main \"logic hub\" for all channel-related actions, and implements
1583 /// ChannelMessageHandler.
1584 ///
1585 /// Non-proportional fees are fixed according to our risk using the provided fee estimator.
1586 ///
1587 /// Users need to notify the new ChannelManager when a new block is connected or
1588 /// disconnected using its `block_connected` and `block_disconnected` methods, starting
1589 /// from after `params.latest_hash`.
1590 #[must_use]
1591 #[no_mangle]
1592 pub extern "C" fn ChannelManager_new(mut fee_est: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut logger: crate::lightning::util::logger::Logger, mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters) -> crate::lightning::ln::channelmanager::ChannelManager {
1593         let mut ret = lightning::ln::channelmanager::ChannelManager::new(fee_est, chain_monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_inner()) }, *unsafe { Box::from_raw(params.take_inner()) });
1594         crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
1595 }
1596
1597 /// Gets the current configuration applied to all new channels.
1598 #[must_use]
1599 #[no_mangle]
1600 pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::config::UserConfig {
1601         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_current_default_configuration();
1602         crate::lightning::util::config::UserConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::util::config::UserConfig<>) as *mut _) }, is_owned: false }
1603 }
1604
1605 /// Creates a new outbound channel to the given remote node and with the given value.
1606 ///
1607 /// `user_channel_id` will be provided back as in
1608 /// [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
1609 /// correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
1610 /// randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
1611 /// is simply copied to events and otherwise ignored.
1612 ///
1613 /// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
1614 /// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
1615 ///
1616 /// Note that we do not check if you are currently connected to the given peer. If no
1617 /// connection is available, the outbound `open_channel` message may fail to send, resulting in
1618 /// the channel eventually being silently forgotten (dropped on reload).
1619 ///
1620 /// Returns the new Channel's temporary `channel_id`. This ID will appear as
1621 /// [`Event::FundingGenerationReady::temporary_channel_id`] and in
1622 /// [`ChannelDetails::channel_id`] until after
1623 /// [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
1624 /// one derived from the funding transaction's TXID. If the counterparty rejects the channel
1625 /// immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
1626 ///
1627 /// [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
1628 /// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
1629 /// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
1630 ///
1631 /// Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
1632 #[must_use]
1633 #[no_mangle]
1634 pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_channel_id: crate::c_types::U128, mut override_config: crate::lightning::util::config::UserConfig) -> crate::c_types::derived::CResult__u832APIErrorZ {
1635         let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) };
1636         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_channel_id.into(), local_override_config);
1637         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1638         local_ret
1639 }
1640
1641 /// Gets the list of open channels, in random order. See ChannelDetail field documentation for
1642 /// more information.
1643 #[must_use]
1644 #[no_mangle]
1645 pub extern "C" fn ChannelManager_list_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1646         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels();
1647         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
1648         local_ret.into()
1649 }
1650
1651 /// Gets the list of usable channels, in random order. Useful as an argument to [`find_route`]
1652 /// to ensure non-announced channels are used.
1653 ///
1654 /// These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
1655 /// documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
1656 /// are.
1657 ///
1658 /// [`find_route`]: crate::routing::router::find_route
1659 #[must_use]
1660 #[no_mangle]
1661 pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1662         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_usable_channels();
1663         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
1664         local_ret.into()
1665 }
1666
1667 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
1668 /// will be accepted on the given channel, and after additional timeout/the closing of all
1669 /// pending HTLCs, the channel will be closed on chain.
1670 ///
1671 ///  * If we are the channel initiator, we will pay between our [`Background`] and
1672 ///    [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
1673 ///    estimate.
1674 ///  * If our counterparty is the channel initiator, we will require a channel closing
1675 ///    transaction feerate of at least our [`Background`] feerate or the feerate which
1676 ///    would appear on a force-closure transaction, whichever is lower. We will allow our
1677 ///    counterparty to pay as much fee as they'd like, however.
1678 ///
1679 /// May generate a SendShutdown message event on success, which should be relayed.
1680 ///
1681 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1682 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1683 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1684 #[must_use]
1685 #[no_mangle]
1686 pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1687         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel(unsafe { &*channel_id}, &counterparty_node_id.into_rust());
1688         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1689         local_ret
1690 }
1691
1692 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
1693 /// will be accepted on the given channel, and after additional timeout/the closing of all
1694 /// pending HTLCs, the channel will be closed on chain.
1695 ///
1696 /// `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
1697 /// the channel being closed or not:
1698 ///  * If we are the channel initiator, we will pay at least this feerate on the closing
1699 ///    transaction. The upper-bound is set by
1700 ///    [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
1701 ///    estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
1702 ///  * If our counterparty is the channel initiator, we will refuse to accept a channel closure
1703 ///    transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
1704 ///    will appear on a force-closure transaction, whichever is lower).
1705 ///
1706 /// May generate a SendShutdown message event on success, which should be relayed.
1707 ///
1708 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1709 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1710 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1711 #[must_use]
1712 #[no_mangle]
1713 pub extern "C" fn ChannelManager_close_channel_with_target_feerate(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: u32) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1714         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_target_feerate(unsafe { &*channel_id}, &counterparty_node_id.into_rust(), target_feerate_sats_per_1000_weight);
1715         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1716         local_ret
1717 }
1718
1719 /// Force closes a channel, immediately broadcasting the latest local transaction(s) and
1720 /// rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
1721 /// the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
1722 /// channel.
1723 #[must_use]
1724 #[no_mangle]
1725 pub extern "C" fn ChannelManager_force_close_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1726         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(unsafe { &*channel_id}, &counterparty_node_id.into_rust());
1727         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1728         local_ret
1729 }
1730
1731 /// Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
1732 /// the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
1733 /// `counterparty_node_id` isn't the counterparty of the corresponding channel.
1734 ///
1735 /// You can always get the latest local transaction(s) to broadcast from
1736 /// [`ChannelMonitor::get_latest_holder_commitment_txn`].
1737 #[must_use]
1738 #[no_mangle]
1739 pub extern "C" fn ChannelManager_force_close_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1740         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(unsafe { &*channel_id}, &counterparty_node_id.into_rust());
1741         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1742         local_ret
1743 }
1744
1745 /// Force close all channels, immediately broadcasting the latest local commitment transaction
1746 /// for each to the chain and rejecting new HTLCs on each.
1747 #[no_mangle]
1748 pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
1749         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn()
1750 }
1751
1752 /// Force close all channels rejecting new HTLCs on each but without broadcasting the latest
1753 /// local transaction(s).
1754 #[no_mangle]
1755 pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
1756         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn()
1757 }
1758
1759 /// Sends a payment along a given route.
1760 ///
1761 /// Value parameters are provided via the last hop in route, see documentation for RouteHop
1762 /// fields for more info.
1763 ///
1764 /// If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
1765 /// method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
1766 /// is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
1767 /// [`Event::PaymentSent`]) LDK will not stop you from sending a second payment with the same
1768 /// [`PaymentId`].
1769 ///
1770 /// Thus, in order to ensure duplicate payments are not sent, you should implement your own
1771 /// tracking of payments, including state to indicate once a payment has completed. Because you
1772 /// should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
1773 /// consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
1774 /// [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
1775 ///
1776 /// May generate SendHTLCs message(s) event on success, which should be relayed (e.g. via
1777 /// [`PeerManager::process_events`]).
1778 ///
1779 /// Each path may have a different return value, and PaymentSendValue may return a Vec with
1780 /// each entry matching the corresponding-index entry in the route paths, see
1781 /// PaymentSendFailure for more info.
1782 ///
1783 /// In general, a path may raise:
1784 ///  * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
1785 ///    node public key) is specified.
1786 ///  * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates
1787 ///    (including due to previous monitor update failure or new permanent monitor update
1788 ///    failure).
1789 ///  * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
1790 ///    relevant updates.
1791 ///
1792 /// Note that depending on the type of the PaymentSendFailure the HTLC may have been
1793 /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
1794 /// different route unless you intend to pay twice!
1795 ///
1796 /// payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
1797 /// the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
1798 /// newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
1799 /// must not contain multiple paths as multi-path payments require a recipient-provided
1800 /// payment_secret.
1801 ///
1802 /// If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
1803 /// bit set (either as required or as available). If multiple paths are present in the Route,
1804 /// we assume the invoice had the basic_mpp feature set.
1805 ///
1806 /// [`Event::PaymentSent`]: events::Event::PaymentSent
1807 /// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
1808 ///
1809 /// Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
1810 #[must_use]
1811 #[no_mangle]
1812 pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
1813         let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret.data) }) };
1814         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment(route.get_native_ref(), ::lightning::ln::PaymentHash(payment_hash.data), &local_payment_secret, ::lightning::ln::channelmanager::PaymentId(payment_id.data));
1815         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
1816         local_ret
1817 }
1818
1819 /// Retries a payment along the given [`Route`].
1820 ///
1821 /// Errors returned are a superset of those returned from [`send_payment`], so see
1822 /// [`send_payment`] documentation for more details on errors. This method will also error if the
1823 /// retry amount puts the payment more than 10% over the payment's total amount, if the payment
1824 /// for the given `payment_id` cannot be found (likely due to timeout or success), or if
1825 /// further retries have been disabled with [`abandon_payment`].
1826 ///
1827 /// [`send_payment`]: [`ChannelManager::send_payment`]
1828 /// [`abandon_payment`]: [`ChannelManager::abandon_payment`]
1829 #[must_use]
1830 #[no_mangle]
1831 pub extern "C" fn ChannelManager_retry_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
1832         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.retry_payment(route.get_native_ref(), ::lightning::ln::channelmanager::PaymentId(payment_id.data));
1833         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
1834         local_ret
1835 }
1836
1837 /// Signals that no further retries for the given payment will occur.
1838 ///
1839 /// After this method returns, no future calls to [`retry_payment`] for the given `payment_id`
1840 /// are allowed. If no [`Event::PaymentFailed`] event had been generated before, one will be
1841 /// generated as soon as there are no remaining pending HTLCs for this payment.
1842 ///
1843 /// Note that calling this method does *not* prevent a payment from succeeding. You must still
1844 /// wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
1845 /// determine the ultimate status of a payment.
1846 ///
1847 /// If an [`Event::PaymentFailed`] event is generated and we restart without this
1848 /// [`ChannelManager`] having been persisted, the payment may still be in the pending state
1849 /// upon restart. This allows further calls to [`retry_payment`] (and requiring a second call
1850 /// to [`abandon_payment`] to mark the payment as failed again). Otherwise, future calls to
1851 /// [`retry_payment`] will fail with [`PaymentSendFailure::ParameterError`].
1852 ///
1853 /// [`abandon_payment`]: Self::abandon_payment
1854 /// [`retry_payment`]: Self::retry_payment
1855 /// [`Event::PaymentFailed`]: events::Event::PaymentFailed
1856 /// [`Event::PaymentSent`]: events::Event::PaymentSent
1857 #[no_mangle]
1858 pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_id: crate::c_types::ThirtyTwoBytes) {
1859         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.abandon_payment(::lightning::ln::channelmanager::PaymentId(payment_id.data))
1860 }
1861
1862 /// Send a spontaneous payment, which is a payment that does not require the recipient to have
1863 /// generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
1864 /// the preimage, it must be a cryptographically secure random value that no intermediate node
1865 /// would be able to guess -- otherwise, an intermediate node may claim the payment and it will
1866 /// never reach the recipient.
1867 ///
1868 /// See [`send_payment`] documentation for more details on the return value of this function
1869 /// and idempotency guarantees provided by the [`PaymentId`] key.
1870 ///
1871 /// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
1872 /// [`send_payment`] for more information about the risks of duplicate preimage usage.
1873 ///
1874 /// Note that `route` must have exactly one path.
1875 ///
1876 /// [`send_payment`]: Self::send_payment
1877 ///
1878 /// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
1879 #[must_use]
1880 #[no_mangle]
1881 pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ {
1882         let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) };
1883         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, ::lightning::ln::channelmanager::PaymentId(payment_id.data));
1884         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
1885         local_ret
1886 }
1887
1888 /// Send a payment that is probing the given route for liquidity. We calculate the
1889 /// [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
1890 /// us to easily discern them from real payments.
1891 #[must_use]
1892 #[no_mangle]
1893 pub extern "C" fn ChannelManager_send_probe(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut hops: crate::c_types::derived::CVec_RouteHopZ) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ {
1894         let mut local_hops = Vec::new(); for mut item in hops.into_rust().drain(..) { local_hops.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1895         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_probe(local_hops);
1896         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
1897         local_ret
1898 }
1899
1900 /// Call this upon creation of a funding transaction for the given channel.
1901 ///
1902 /// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
1903 /// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
1904 ///
1905 /// Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
1906 /// across the p2p network.
1907 ///
1908 /// Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
1909 /// for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
1910 ///
1911 /// May panic if the output found in the funding transaction is duplicative with some other
1912 /// channel (note that this should be trivially prevented by using unique funding transaction
1913 /// keys per-channel).
1914 ///
1915 /// Do NOT broadcast the funding transaction yourself. When we have safely received our
1916 /// counterparty's signature the funding transaction will automatically be broadcast via the
1917 /// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
1918 ///
1919 /// Note that this includes RBF or similar transaction replacement strategies - lightning does
1920 /// not currently support replacing a funding transaction on an existing channel. Instead,
1921 /// create a new channel with a conflicting funding transaction.
1922 ///
1923 /// Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
1924 /// the wallet software generating the funding transaction to apply anti-fee sniping as
1925 /// implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
1926 /// for more details.
1927 ///
1928 /// [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
1929 /// [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
1930 #[must_use]
1931 #[no_mangle]
1932 pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1933         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_transaction_generated(unsafe { &*temporary_channel_id}, &counterparty_node_id.into_rust(), funding_transaction.into_bitcoin());
1934         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1935         local_ret
1936 }
1937
1938 /// Atomically updates the [`ChannelConfig`] for the given channels.
1939 ///
1940 /// Once the updates are applied, each eligible channel (advertised with a known short channel
1941 /// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
1942 /// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
1943 /// containing the new [`ChannelUpdate`] message which should be broadcast to the network.
1944 ///
1945 /// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
1946 /// `counterparty_node_id` is provided.
1947 ///
1948 /// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
1949 /// below [`MIN_CLTV_EXPIRY_DELTA`].
1950 ///
1951 /// If an error is returned, none of the updates should be considered applied.
1952 ///
1953 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
1954 /// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
1955 /// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
1956 /// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
1957 /// [`ChannelUpdate`]: msgs::ChannelUpdate
1958 /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
1959 /// [`APIMisuseError`]: APIError::APIMisuseError
1960 #[must_use]
1961 #[no_mangle]
1962 pub extern "C" fn ChannelManager_update_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ThirtyTwoBytesZ, config: &crate::lightning::util::config::ChannelConfig) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1963         let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { item.data }); };
1964         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_config(&counterparty_node_id.into_rust(), &local_channel_ids.iter().map(|a| *a).collect::<Vec<_>>()[..], config.get_native_ref());
1965         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1966         local_ret
1967 }
1968
1969 /// Attempts to forward an intercepted HTLC over the provided channel id and with the provided
1970 /// amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
1971 ///
1972 /// Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
1973 /// channel to a receiving node if the node lacks sufficient inbound liquidity.
1974 ///
1975 /// To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
1976 /// [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
1977 /// receiver's invoice route hints. These route hints will signal to LDK to generate an
1978 /// [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
1979 /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
1980 ///
1981 /// Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
1982 /// you from forwarding more than you received.
1983 ///
1984 /// Errors if the event was not handled in time, in which case the HTLC was automatically failed
1985 /// backwards.
1986 ///
1987 /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
1988 /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
1989 #[must_use]
1990 #[no_mangle]
1991 pub extern "C" fn ChannelManager_forward_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes, next_hop_channel_id: *const [u8; 32], mut _next_node_id: crate::c_types::PublicKey, mut amt_to_forward_msat: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1992         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.forward_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data), unsafe { &*next_hop_channel_id}, _next_node_id.into_rust(), amt_to_forward_msat);
1993         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1994         local_ret
1995 }
1996
1997 /// Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
1998 /// an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
1999 ///
2000 /// Errors if the event was not handled in time, in which case the HTLC was automatically failed
2001 /// backwards.
2002 ///
2003 /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
2004 #[must_use]
2005 #[no_mangle]
2006 pub extern "C" fn ChannelManager_fail_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
2007         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data));
2008         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
2009         local_ret
2010 }
2011
2012 /// Processes HTLCs which are pending waiting on random forward delay.
2013 ///
2014 /// Should only really ever be called in response to a PendingHTLCsForwardable event.
2015 /// Will likely generate further events.
2016 #[no_mangle]
2017 pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2018         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_htlc_forwards()
2019 }
2020
2021 /// Performs actions which should happen on startup and roughly once per minute thereafter.
2022 ///
2023 /// This currently includes:
2024 ///  * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
2025 ///  * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
2026 ///    than a minute, informing the network that they should no longer attempt to route over
2027 ///    the channel.
2028 ///  * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs
2029 ///    with the current `ChannelConfig`.
2030 ///
2031 /// Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
2032 /// estimate fetches.
2033 #[no_mangle]
2034 pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2035         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timer_tick_occurred()
2036 }
2037
2038 /// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
2039 /// after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
2040 /// along the path (including in our own channel on which we received it).
2041 ///
2042 /// Note that in some cases around unclean shutdown, it is possible the payment may have
2043 /// already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
2044 /// second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
2045 /// may have already been failed automatically by LDK if it was nearing its expiration time.
2046 ///
2047 /// While LDK will never claim a payment automatically on your behalf (i.e. without you calling
2048 /// [`ChannelManager::claim_funds`]), you should still monitor for
2049 /// [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
2050 /// startup during which time claims that were in-progress at shutdown may be replayed.
2051 #[no_mangle]
2052 pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, payment_hash: *const [u8; 32]) {
2053         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards(&::lightning::ln::PaymentHash(unsafe { *payment_hash }))
2054 }
2055
2056 /// Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
2057 /// [`MessageSendEvent`]s needed to claim the payment.
2058 ///
2059 /// Note that calling this method does *not* guarantee that the payment has been claimed. You
2060 /// *must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be
2061 /// provided to your [`EventHandler`] when [`process_pending_events`] is next called.
2062 ///
2063 /// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
2064 /// [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
2065 /// event matches your expectation. If you fail to do so and call this method, you may provide
2066 /// the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
2067 ///
2068 /// [`Event::PaymentClaimable`]: crate::util::events::Event::PaymentClaimable
2069 /// [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed
2070 /// [`process_pending_events`]: EventsProvider::process_pending_events
2071 /// [`create_inbound_payment`]: Self::create_inbound_payment
2072 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2073 #[no_mangle]
2074 pub extern "C" fn ChannelManager_claim_funds(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) {
2075         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds(::lightning::ln::PaymentPreimage(payment_preimage.data))
2076 }
2077
2078 /// Gets the node_id held by this ChannelManager
2079 #[must_use]
2080 #[no_mangle]
2081 pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::PublicKey {
2082         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_our_node_id();
2083         crate::c_types::PublicKey::from_rust(&ret)
2084 }
2085
2086 /// Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
2087 ///
2088 /// The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
2089 /// and the `counterparty_node_id` parameter is the id of the peer which has requested to open
2090 /// the channel.
2091 ///
2092 /// The `user_channel_id` parameter will be provided back in
2093 /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2094 /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2095 ///
2096 /// Note that this method will return an error and reject the channel, if it requires support
2097 /// for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
2098 /// used to accept such channels.
2099 ///
2100 /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2101 /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2102 #[must_use]
2103 #[no_mangle]
2104 pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut user_channel_id: crate::c_types::U128) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
2105         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(unsafe { &*temporary_channel_id}, &counterparty_node_id.into_rust(), user_channel_id.into());
2106         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
2107         local_ret
2108 }
2109
2110 /// Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
2111 /// it as confirmed immediately.
2112 ///
2113 /// The `user_channel_id` parameter will be provided back in
2114 /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2115 /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2116 ///
2117 /// Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
2118 /// and (if the counterparty agrees), enables forwarding of payments immediately.
2119 ///
2120 /// This fully trusts that the counterparty has honestly and correctly constructed the funding
2121 /// transaction and blindly assumes that it will eventually confirm.
2122 ///
2123 /// If it does not confirm before we decide to close the channel, or if the funding transaction
2124 /// does not pay to the correct script the correct amount, *you will lose funds*.
2125 ///
2126 /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2127 /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2128 #[must_use]
2129 #[no_mangle]
2130 pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut user_channel_id: crate::c_types::U128) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
2131         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel_from_trusted_peer_0conf(unsafe { &*temporary_channel_id}, &counterparty_node_id.into_rust(), user_channel_id.into());
2132         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
2133         local_ret
2134 }
2135
2136 /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
2137 /// to pay us.
2138 ///
2139 /// This differs from [`create_inbound_payment_for_hash`] only in that it generates the
2140 /// [`PaymentHash`] and [`PaymentPreimage`] for you.
2141 ///
2142 /// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which
2143 /// will have the [`PaymentClaimable::payment_preimage`] field filled in. That should then be
2144 /// passed directly to [`claim_funds`].
2145 ///
2146 /// See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
2147 ///
2148 /// Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2149 /// `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2150 ///
2151 /// # Note
2152 ///
2153 /// If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2154 /// deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2155 ///
2156 /// Errors if `min_value_msat` is greater than total bitcoin supply.
2157 ///
2158 /// [`claim_funds`]: Self::claim_funds
2159 /// [`PaymentClaimable`]: events::Event::PaymentClaimable
2160 /// [`PaymentClaimable::payment_preimage`]: events::Event::PaymentClaimable::payment_preimage
2161 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2162 #[must_use]
2163 #[no_mangle]
2164 pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ {
2165         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2166         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment(local_min_value_msat, invoice_expiry_delta_secs);
2167         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2168         local_ret
2169 }
2170
2171 /// Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
2172 /// serialized state with LDK node(s) running 0.0.103 and earlier.
2173 ///
2174 /// May panic if `invoice_expiry_delta_secs` is greater than one year.
2175 ///
2176 /// # Note
2177 /// This method is deprecated and will be removed soon.
2178 ///
2179 /// [`create_inbound_payment`]: Self::create_inbound_payment
2180 #[must_use]
2181 #[no_mangle]
2182 pub extern "C" fn ChannelManager_create_inbound_payment_legacy(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ {
2183         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2184         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_legacy(local_min_value_msat, invoice_expiry_delta_secs);
2185         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
2186         local_ret
2187 }
2188
2189 /// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
2190 /// stored external to LDK.
2191 ///
2192 /// A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
2193 /// payment secret fetched via this method or [`create_inbound_payment`], and which is at least
2194 /// the `min_value_msat` provided here, if one is provided.
2195 ///
2196 /// The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
2197 /// note that LDK will not stop you from registering duplicate payment hashes for inbound
2198 /// payments.
2199 ///
2200 /// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
2201 /// received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
2202 /// before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
2203 /// sender \"proof-of-payment\" unless they have paid the required amount.
2204 ///
2205 /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
2206 /// in excess of the current time. This should roughly match the expiry time set in the invoice.
2207 /// After this many seconds, we will remove the inbound payment, resulting in any attempts to
2208 /// pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
2209 /// invoices when no timeout is set.
2210 ///
2211 /// Note that we use block header time to time-out pending inbound payments (with some margin
2212 /// to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
2213 /// accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
2214 /// If you need exact expiry semantics, you should enforce them upon receipt of
2215 /// [`PaymentClaimable`].
2216 ///
2217 /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
2218 /// set to at least [`MIN_FINAL_CLTV_EXPIRY`].
2219 ///
2220 /// Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2221 /// `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2222 ///
2223 /// # Note
2224 ///
2225 /// If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2226 /// deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2227 ///
2228 /// Errors if `min_value_msat` is greater than total bitcoin supply.
2229 ///
2230 /// [`create_inbound_payment`]: Self::create_inbound_payment
2231 /// [`PaymentClaimable`]: events::Event::PaymentClaimable
2232 #[must_use]
2233 #[no_mangle]
2234 pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_PaymentSecretNoneZ {
2235         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2236         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_for_hash(::lightning::ln::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs);
2237         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2238         local_ret
2239 }
2240
2241 /// Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
2242 /// serialized state with LDK node(s) running 0.0.103 and earlier.
2243 ///
2244 /// May panic if `invoice_expiry_delta_secs` is greater than one year.
2245 ///
2246 /// # Note
2247 /// This method is deprecated and will be removed soon.
2248 ///
2249 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2250 #[must_use]
2251 #[no_mangle]
2252 pub extern "C" fn ChannelManager_create_inbound_payment_for_hash_legacy(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32) -> crate::c_types::derived::CResult_PaymentSecretAPIErrorZ {
2253         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2254         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_for_hash_legacy(::lightning::ln::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs);
2255         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
2256         local_ret
2257 }
2258
2259 /// Gets an LDK-generated payment preimage from a payment hash and payment secret that were
2260 /// previously returned from [`create_inbound_payment`].
2261 ///
2262 /// [`create_inbound_payment`]: Self::create_inbound_payment
2263 #[must_use]
2264 #[no_mangle]
2265 pub extern "C" fn ChannelManager_get_payment_preimage(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentPreimageAPIErrorZ {
2266         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_payment_preimage(::lightning::ln::PaymentHash(payment_hash.data), ::lightning::ln::PaymentSecret(payment_secret.data));
2267         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
2268         local_ret
2269 }
2270
2271 /// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
2272 /// are used when constructing the phantom invoice's route hints.
2273 ///
2274 /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
2275 #[must_use]
2276 #[no_mangle]
2277 pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 {
2278         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_scid();
2279         ret
2280 }
2281
2282 /// Gets route hints for use in receiving [phantom node payments].
2283 ///
2284 /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
2285 #[must_use]
2286 #[no_mangle]
2287 pub extern "C" fn ChannelManager_get_phantom_route_hints(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::channelmanager::PhantomRouteHints {
2288         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_route_hints();
2289         crate::lightning::ln::channelmanager::PhantomRouteHints { inner: ObjOps::heap_alloc(ret), is_owned: true }
2290 }
2291
2292 /// Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
2293 /// used when constructing the route hints for HTLCs intended to be intercepted. See
2294 /// [`ChannelManager::forward_intercepted_htlc`].
2295 ///
2296 /// Note that this method is not guaranteed to return unique values, you may need to call it a few
2297 /// times to get a unique scid.
2298 #[must_use]
2299 #[no_mangle]
2300 pub extern "C" fn ChannelManager_get_intercept_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 {
2301         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_intercept_scid();
2302         ret
2303 }
2304
2305 /// Gets inflight HTLC information by processing pending outbound payments that are in
2306 /// our channels. May be used during pathfinding to account for in-use channel liquidity.
2307 #[must_use]
2308 #[no_mangle]
2309 pub extern "C" fn ChannelManager_compute_inflight_htlcs(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::routing::router::InFlightHtlcs {
2310         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.compute_inflight_htlcs();
2311         crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(ret), is_owned: true }
2312 }
2313
2314 impl From<nativeChannelManager> for crate::lightning::util::events::MessageSendEventsProvider {
2315         fn from(obj: nativeChannelManager) -> Self {
2316                 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2317                 let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj);
2318                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2319                 rust_obj.inner = core::ptr::null_mut();
2320                 ret.free = Some(ChannelManager_free_void);
2321                 ret
2322         }
2323 }
2324 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
2325 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
2326 #[no_mangle]
2327 pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::MessageSendEventsProvider {
2328         crate::lightning::util::events::MessageSendEventsProvider {
2329                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2330                 free: None,
2331                 get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
2332         }
2333 }
2334
2335 #[must_use]
2336 extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
2337         let mut ret = <nativeChannelManager as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
2338         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
2339         local_ret.into()
2340 }
2341
2342 impl From<nativeChannelManager> for crate::lightning::util::events::EventsProvider {
2343         fn from(obj: nativeChannelManager) -> Self {
2344                 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2345                 let mut ret = ChannelManager_as_EventsProvider(&rust_obj);
2346                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2347                 rust_obj.inner = core::ptr::null_mut();
2348                 ret.free = Some(ChannelManager_free_void);
2349                 ret
2350         }
2351 }
2352 /// Constructs a new EventsProvider which calls the relevant methods on this_arg.
2353 /// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
2354 #[no_mangle]
2355 pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::EventsProvider {
2356         crate::lightning::util::events::EventsProvider {
2357                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2358                 free: None,
2359                 process_pending_events: ChannelManager_EventsProvider_process_pending_events,
2360         }
2361 }
2362
2363 extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::util::events::EventHandler) {
2364         <nativeChannelManager as lightning::util::events::EventsProvider<>>::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler)
2365 }
2366
2367 impl From<nativeChannelManager> for crate::lightning::chain::Listen {
2368         fn from(obj: nativeChannelManager) -> Self {
2369                 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2370                 let mut ret = ChannelManager_as_Listen(&rust_obj);
2371                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2372                 rust_obj.inner = core::ptr::null_mut();
2373                 ret.free = Some(ChannelManager_free_void);
2374                 ret
2375         }
2376 }
2377 /// Constructs a new Listen which calls the relevant methods on this_arg.
2378 /// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
2379 #[no_mangle]
2380 pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate::lightning::chain::Listen {
2381         crate::lightning::chain::Listen {
2382                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2383                 free: None,
2384                 filtered_block_connected: ChannelManager_Listen_filtered_block_connected,
2385                 block_connected: ChannelManager_Listen_block_connected,
2386                 block_disconnected: ChannelManager_Listen_block_disconnected,
2387         }
2388 }
2389
2390 extern "C" fn ChannelManager_Listen_filtered_block_connected(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) {
2391         let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); };
2392         <nativeChannelManager as lightning::chain::Listen<>>::filtered_block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height)
2393 }
2394 extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) {
2395         <nativeChannelManager as lightning::chain::Listen<>>::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height)
2396 }
2397 extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
2398         <nativeChannelManager as lightning::chain::Listen<>>::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
2399 }
2400
2401 impl From<nativeChannelManager> for crate::lightning::chain::Confirm {
2402         fn from(obj: nativeChannelManager) -> Self {
2403                 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2404                 let mut ret = ChannelManager_as_Confirm(&rust_obj);
2405                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2406                 rust_obj.inner = core::ptr::null_mut();
2407                 ret.free = Some(ChannelManager_free_void);
2408                 ret
2409         }
2410 }
2411 /// Constructs a new Confirm which calls the relevant methods on this_arg.
2412 /// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
2413 #[no_mangle]
2414 pub extern "C" fn ChannelManager_as_Confirm(this_arg: &ChannelManager) -> crate::lightning::chain::Confirm {
2415         crate::lightning::chain::Confirm {
2416                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2417                 free: None,
2418                 transactions_confirmed: ChannelManager_Confirm_transactions_confirmed,
2419                 transaction_unconfirmed: ChannelManager_Confirm_transaction_unconfirmed,
2420                 best_block_updated: ChannelManager_Confirm_best_block_updated,
2421                 get_relevant_txids: ChannelManager_Confirm_get_relevant_txids,
2422         }
2423 }
2424
2425 extern "C" fn ChannelManager_Confirm_transactions_confirmed(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) {
2426         let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); };
2427         <nativeChannelManager as lightning::chain::Confirm<>>::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height)
2428 }
2429 extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) {
2430         <nativeChannelManager as lightning::chain::Confirm<>>::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap())
2431 }
2432 extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
2433         <nativeChannelManager as lightning::chain::Confirm<>>::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
2434 }
2435 #[must_use]
2436 extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ {
2437         let mut ret = <nativeChannelManager as lightning::chain::Confirm<>>::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
2438         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (orig_ret_0_1.unwrap()).into_inner() } } }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1).into(); local_ret_0 }); };
2439         local_ret.into()
2440 }
2441
2442 /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
2443 /// indicating whether persistence is necessary. Only one listener on
2444 /// [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by
2445 /// [`get_persistable_update_future`] is guaranteed to be woken up.
2446 ///
2447 /// Note that this method is not available with the `no-std` feature.
2448 ///
2449 /// [`await_persistable_update`]: Self::await_persistable_update
2450 /// [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout
2451 /// [`get_persistable_update_future`]: Self::get_persistable_update_future
2452 #[must_use]
2453 #[no_mangle]
2454 pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut max_wait: u64) -> bool {
2455         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update_timeout(core::time::Duration::from_secs(max_wait));
2456         ret
2457 }
2458
2459 /// Blocks until ChannelManager needs to be persisted. Only one listener on
2460 /// [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by
2461 /// [`get_persistable_update_future`] is guaranteed to be woken up.
2462 ///
2463 /// [`await_persistable_update`]: Self::await_persistable_update
2464 /// [`get_persistable_update_future`]: Self::get_persistable_update_future
2465 #[no_mangle]
2466 pub extern "C" fn ChannelManager_await_persistable_update(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2467         unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update()
2468 }
2469
2470 /// Gets a [`Future`] that completes when a persistable update is available. Note that
2471 /// callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
2472 /// should instead register actions to be taken later.
2473 #[must_use]
2474 #[no_mangle]
2475 pub extern "C" fn ChannelManager_get_persistable_update_future(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::wakers::Future {
2476         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_persistable_update_future();
2477         crate::lightning::util::wakers::Future { inner: ObjOps::heap_alloc(ret), is_owned: true }
2478 }
2479
2480 /// Gets the latest best block which was connected either via the [`chain::Listen`] or
2481 /// [`chain::Confirm`] interfaces.
2482 #[must_use]
2483 #[no_mangle]
2484 pub extern "C" fn ChannelManager_current_best_block(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::chain::BestBlock {
2485         let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.current_best_block();
2486         crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true }
2487 }
2488
2489 impl From<nativeChannelManager> for crate::lightning::ln::msgs::ChannelMessageHandler {
2490         fn from(obj: nativeChannelManager) -> Self {
2491                 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2492                 let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj);
2493                 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
2494                 rust_obj.inner = core::ptr::null_mut();
2495                 ret.free = Some(ChannelManager_free_void);
2496                 ret
2497         }
2498 }
2499 /// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
2500 /// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
2501 #[no_mangle]
2502 pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelManager) -> crate::lightning::ln::msgs::ChannelMessageHandler {
2503         crate::lightning::ln::msgs::ChannelMessageHandler {
2504                 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2505                 free: None,
2506                 handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel,
2507                 handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel,
2508                 handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created,
2509                 handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed,
2510                 handle_channel_ready: ChannelManager_ChannelMessageHandler_handle_channel_ready,
2511                 handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown,
2512                 handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed,
2513                 handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc,
2514                 handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc,
2515                 handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc,
2516                 handle_update_fail_malformed_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc,
2517                 handle_commitment_signed: ChannelManager_ChannelMessageHandler_handle_commitment_signed,
2518                 handle_revoke_and_ack: ChannelManager_ChannelMessageHandler_handle_revoke_and_ack,
2519                 handle_update_fee: ChannelManager_ChannelMessageHandler_handle_update_fee,
2520                 handle_announcement_signatures: ChannelManager_ChannelMessageHandler_handle_announcement_signatures,
2521                 peer_disconnected: ChannelManager_ChannelMessageHandler_peer_disconnected,
2522                 peer_connected: ChannelManager_ChannelMessageHandler_peer_connected,
2523                 handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish,
2524                 handle_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update,
2525                 handle_error: ChannelManager_ChannelMessageHandler_handle_error,
2526                 provided_node_features: ChannelManager_ChannelMessageHandler_provided_node_features,
2527                 provided_init_features: ChannelManager_ChannelMessageHandler_provided_init_features,
2528                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
2529                         this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2530                         free: None,
2531                         get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
2532                 },
2533         }
2534 }
2535
2536 extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) {
2537         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
2538 }
2539 extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) {
2540         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, msg.get_native_ref())
2541 }
2542 extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) {
2543         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2544 }
2545 extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) {
2546         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2547 }
2548 extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_ready(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady) {
2549         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2550 }
2551 extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) {
2552         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), their_features.get_native_ref(), msg.get_native_ref())
2553 }
2554 extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) {
2555         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2556 }
2557 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) {
2558         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2559 }
2560 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) {
2561         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2562 }
2563 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) {
2564         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2565 }
2566 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) {
2567         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2568 }
2569 extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) {
2570         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2571 }
2572 extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) {
2573         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2574 }
2575 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) {
2576         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2577 }
2578 extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) {
2579         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2580 }
2581 extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
2582         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), no_connection_possible)
2583 }
2584 #[must_use]
2585 extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init) -> crate::c_types::derived::CResult_NoneNoneZ {
2586         let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref());
2587         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
2588         local_ret
2589 }
2590 extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) {
2591         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2592 }
2593 extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) {
2594         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2595 }
2596 extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) {
2597         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2598 }
2599 #[must_use]
2600 extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
2601         let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
2602         crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2603 }
2604 #[must_use]
2605 extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures {
2606         let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust());
2607         crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2608 }
2609
2610 /// Fetches the set of [`NodeFeatures`] flags which are provided by or required by
2611 /// [`ChannelManager`].
2612 #[no_mangle]
2613 pub extern "C" fn provided_node_features() -> crate::lightning::ln::features::NodeFeatures {
2614         let mut ret = lightning::ln::channelmanager::provided_node_features();
2615         crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2616 }
2617
2618 /// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
2619 /// [`ChannelManager`].
2620 #[no_mangle]
2621 pub extern "C" fn provided_channel_features() -> crate::lightning::ln::features::ChannelFeatures {
2622         let mut ret = lightning::ln::channelmanager::provided_channel_features();
2623         crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2624 }
2625
2626 /// Fetches the set of [`InitFeatures`] flags which are provided by or required by
2627 /// [`ChannelManager`].
2628 #[no_mangle]
2629 pub extern "C" fn provided_init_features() -> crate::lightning::ln::features::InitFeatures {
2630         let mut ret = lightning::ln::channelmanager::provided_init_features();
2631         crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2632 }
2633
2634 #[no_mangle]
2635 /// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read
2636 pub extern "C" fn CounterpartyForwardingInfo_write(obj: &crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z {
2637         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2638 }
2639 #[no_mangle]
2640 pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2641         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) })
2642 }
2643 #[no_mangle]
2644 /// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write
2645 pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ {
2646         let res: Result<lightning::ln::channelmanager::CounterpartyForwardingInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2647         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::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() };
2648         local_res
2649 }
2650 #[no_mangle]
2651 /// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
2652 pub extern "C" fn ChannelCounterparty_write(obj: &crate::lightning::ln::channelmanager::ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z {
2653         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2654 }
2655 #[no_mangle]
2656 pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2657         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) })
2658 }
2659 #[no_mangle]
2660 /// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
2661 pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ {
2662         let res: Result<lightning::ln::channelmanager::ChannelCounterparty, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2663         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::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() };
2664         local_res
2665 }
2666 #[no_mangle]
2667 /// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read
2668 pub extern "C" fn ChannelDetails_write(obj: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::CVec_u8Z {
2669         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2670 }
2671 #[no_mangle]
2672 pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2673         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) })
2674 }
2675 #[no_mangle]
2676 /// Read a ChannelDetails from a byte array, created by ChannelDetails_write
2677 pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ {
2678         let res: Result<lightning::ln::channelmanager::ChannelDetails, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2679         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::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() };
2680         local_res
2681 }
2682 #[no_mangle]
2683 /// Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
2684 pub extern "C" fn PhantomRouteHints_write(obj: &crate::lightning::ln::channelmanager::PhantomRouteHints) -> crate::c_types::derived::CVec_u8Z {
2685         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2686 }
2687 #[no_mangle]
2688 pub(crate) extern "C" fn PhantomRouteHints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2689         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePhantomRouteHints) })
2690 }
2691 #[no_mangle]
2692 /// Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
2693 pub extern "C" fn PhantomRouteHints_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PhantomRouteHintsDecodeErrorZ {
2694         let res: Result<lightning::ln::channelmanager::PhantomRouteHints, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2695         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::PhantomRouteHints { 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() };
2696         local_res
2697 }
2698 #[no_mangle]
2699 /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
2700 pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_u8Z {
2701         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2702 }
2703 #[no_mangle]
2704 pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2705         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) })
2706 }
2707
2708 use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport;
2709 pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>;
2710
2711 /// Arguments for the creation of a ChannelManager that are not deserialized.
2712 ///
2713 /// At a high-level, the process for deserializing a ChannelManager and resuming normal operation
2714 /// is:
2715 /// 1) Deserialize all stored [`ChannelMonitor`]s.
2716 /// 2) Deserialize the [`ChannelManager`] by filling in this struct and calling:
2717 ///    `<(BlockHash, ChannelManager)>::read(reader, args)`
2718 ///    This may result in closing some channels if the [`ChannelMonitor`] is newer than the stored
2719 ///    [`ChannelManager`] state to ensure no loss of funds. Thus, transactions may be broadcasted.
2720 /// 3) If you are not fetching full blocks, register all relevant [`ChannelMonitor`] outpoints the
2721 ///    same way you would handle a [`chain::Filter`] call using
2722 ///    [`ChannelMonitor::get_outputs_to_watch`] and [`ChannelMonitor::get_funding_txo`].
2723 /// 4) Reconnect blocks on your [`ChannelMonitor`]s.
2724 /// 5) Disconnect/connect blocks on the [`ChannelManager`].
2725 /// 6) Re-persist the [`ChannelMonitor`]s to ensure the latest state is on disk.
2726 ///    Note that if you're using a [`ChainMonitor`] for your [`chain::Watch`] implementation, you
2727 ///    will likely accomplish this as a side-effect of calling [`chain::Watch::watch_channel`] in
2728 ///    the next step.
2729 /// 7) Move the [`ChannelMonitor`]s into your local [`chain::Watch`]. If you're using a
2730 ///    [`ChainMonitor`], this is done by calling [`chain::Watch::watch_channel`].
2731 ///
2732 /// Note that the ordering of #4-7 is not of importance, however all four must occur before you
2733 /// call any other methods on the newly-deserialized [`ChannelManager`].
2734 ///
2735 /// Note that because some channels may be closed during deserialization, it is critical that you
2736 /// always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
2737 /// you. If you deserialize an old ChannelManager (during which force-closure transactions may be
2738 /// broadcast), and then later deserialize a newer version of the same ChannelManager (which will
2739 /// not force-close the same channels but consider them live), you may end up revoking a state for
2740 /// which you've already broadcasted the transaction.
2741 ///
2742 /// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
2743 #[must_use]
2744 #[repr(C)]
2745 pub struct ChannelManagerReadArgs {
2746         /// A pointer to the opaque Rust object.
2747
2748         /// Nearly everywhere, inner must be non-null, however in places where
2749         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2750         pub inner: *mut nativeChannelManagerReadArgs,
2751         /// Indicates that this is the only struct which contains the same pointer.
2752
2753         /// Rust functions which take ownership of an object provided via an argument require
2754         /// this to be true and invalidate the object pointed to by inner.
2755         pub is_owned: bool,
2756 }
2757
2758 impl Drop for ChannelManagerReadArgs {
2759         fn drop(&mut self) {
2760                 if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) {
2761                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2762                 }
2763         }
2764 }
2765 /// Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL.
2766 #[no_mangle]
2767 pub extern "C" fn ChannelManagerReadArgs_free(this_obj: ChannelManagerReadArgs) { }
2768 #[allow(unused)]
2769 /// Used only if an object of this type is returned as a trait impl by a method
2770 pub(crate) extern "C" fn ChannelManagerReadArgs_free_void(this_ptr: *mut c_void) {
2771         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelManagerReadArgs) };
2772 }
2773 #[allow(unused)]
2774 impl ChannelManagerReadArgs {
2775         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelManagerReadArgs {
2776                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2777         }
2778         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelManagerReadArgs {
2779                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2780         }
2781         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2782         pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs {
2783                 assert!(self.is_owned);
2784                 let ret = ObjOps::untweak_ptr(self.inner);
2785                 self.inner = core::ptr::null_mut();
2786                 ret
2787         }
2788 }
2789 /// The keys provider which will give us relevant keys. Some keys will be loaded during
2790 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
2791 /// signing data.
2792 #[no_mangle]
2793 pub extern "C" fn ChannelManagerReadArgs_get_keys_manager(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::KeysInterface {
2794         let mut inner_val = &mut this_ptr.get_native_mut_ref().keys_manager;
2795         inner_val
2796 }
2797 /// The keys provider which will give us relevant keys. Some keys will be loaded during
2798 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
2799 /// signing data.
2800 #[no_mangle]
2801 pub extern "C" fn ChannelManagerReadArgs_set_keys_manager(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::KeysInterface) {
2802         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys_manager = val;
2803 }
2804 /// The fee_estimator for use in the ChannelManager in the future.
2805 ///
2806 /// No calls to the FeeEstimator will be made during deserialization.
2807 #[no_mangle]
2808 pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::FeeEstimator {
2809         let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_estimator;
2810         inner_val
2811 }
2812 /// The fee_estimator for use in the ChannelManager in the future.
2813 ///
2814 /// No calls to the FeeEstimator will be made during deserialization.
2815 #[no_mangle]
2816 pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::FeeEstimator) {
2817         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_estimator = val;
2818 }
2819 /// The chain::Watch for use in the ChannelManager in the future.
2820 ///
2821 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
2822 /// you have deserialized ChannelMonitors separately and will add them to your
2823 /// chain::Watch after deserializing this ChannelManager.
2824 #[no_mangle]
2825 pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::Watch {
2826         let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_monitor;
2827         inner_val
2828 }
2829 /// The chain::Watch for use in the ChannelManager in the future.
2830 ///
2831 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
2832 /// you have deserialized ChannelMonitors separately and will add them to your
2833 /// chain::Watch after deserializing this ChannelManager.
2834 #[no_mangle]
2835 pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::Watch) {
2836         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_monitor = val;
2837 }
2838 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
2839 /// used to broadcast the latest local commitment transactions of channels which must be
2840 /// force-closed during deserialization.
2841 #[no_mangle]
2842 pub extern "C" fn ChannelManagerReadArgs_get_tx_broadcaster(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::BroadcasterInterface {
2843         let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_broadcaster;
2844         inner_val
2845 }
2846 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
2847 /// used to broadcast the latest local commitment transactions of channels which must be
2848 /// force-closed during deserialization.
2849 #[no_mangle]
2850 pub extern "C" fn ChannelManagerReadArgs_set_tx_broadcaster(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::BroadcasterInterface) {
2851         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_broadcaster = val;
2852 }
2853 /// The Logger for use in the ChannelManager and which may be used to log information during
2854 /// deserialization.
2855 #[no_mangle]
2856 pub extern "C" fn ChannelManagerReadArgs_get_logger(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::util::logger::Logger {
2857         let mut inner_val = &mut this_ptr.get_native_mut_ref().logger;
2858         inner_val
2859 }
2860 /// The Logger for use in the ChannelManager and which may be used to log information during
2861 /// deserialization.
2862 #[no_mangle]
2863 pub extern "C" fn ChannelManagerReadArgs_set_logger(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::logger::Logger) {
2864         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.logger = val;
2865 }
2866 /// Default settings used for new channels. Any existing channels will continue to use the
2867 /// runtime settings which were stored when the ChannelManager was serialized.
2868 #[no_mangle]
2869 pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelManagerReadArgs) -> crate::lightning::util::config::UserConfig {
2870         let mut inner_val = &mut this_ptr.get_native_mut_ref().default_config;
2871         crate::lightning::util::config::UserConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::config::UserConfig<>) as *mut _) }, is_owned: false }
2872 }
2873 /// Default settings used for new channels. Any existing channels will continue to use the
2874 /// runtime settings which were stored when the ChannelManager was serialized.
2875 #[no_mangle]
2876 pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::config::UserConfig) {
2877         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.default_config = *unsafe { Box::from_raw(val.take_inner()) };
2878 }
2879 /// Simple utility function to create a ChannelManagerReadArgs which creates the monitor
2880 /// HashMap for you. This is primarily useful for C bindings where it is not practical to
2881 /// populate a HashMap directly from C.
2882 #[must_use]
2883 #[no_mangle]
2884 pub extern "C" fn ChannelManagerReadArgs_new(mut keys_manager: crate::lightning::chain::keysinterface::KeysInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::lightning::chain::Watch, mut tx_broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut logger: crate::lightning::util::logger::Logger, mut default_config: crate::lightning::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> crate::lightning::ln::channelmanager::ChannelManagerReadArgs {
2885         let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { item.get_native_mut_ref() }); };
2886         let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(keys_manager, fee_estimator, chain_monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_inner()) }, local_channel_monitors);
2887         crate::lightning::ln::channelmanager::ChannelManagerReadArgs { inner: ObjOps::heap_alloc(ret), is_owned: true }
2888 }
2889
2890 #[no_mangle]
2891 /// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
2892 pub extern "C" fn C2Tuple_BlockHashChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::lightning::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ {
2893         let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) };
2894         let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager<crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv);
2895         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: orig_res_0_0.into_inner() }, crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
2896         local_res
2897 }