0f5d3cc3ac2a7dc484385eaf85a1d483cf9a3fbe
[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 routing::router::get_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
20 use std::str::FromStr;
21 use std::ffi::c_void;
22 use bitcoin::hashes::Hash;
23 use crate::c_types::*;
24
25
26 use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport;
27 type nativeChannelManager = nativeChannelManagerImport<crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>;
28
29 /// Manager which keeps track of a number of channels and sends messages to the appropriate
30 /// channel, also tracking HTLC preimages and forwarding onion packets appropriately.
31 ///
32 /// Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
33 /// to individual Channels.
34 ///
35 /// Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
36 /// all peers during write/read (though does not modify this instance, only the instance being
37 /// serialized). This will result in any channels which have not yet exchanged funding_created (ie
38 /// called funding_transaction_generated for outbound channels).
39 ///
40 /// Note that you can be a bit lazier about writing out ChannelManager than you can be with
41 /// ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
42 /// returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
43 /// happens out-of-band (and will prevent any other ChannelManager operations from occurring during
44 /// the serialization process). If the deserialized version is out-of-date compared to the
45 /// ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
46 /// ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
47 ///
48 /// Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
49 /// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
50 /// the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
51 /// block_connected() to step towards your best block) upon deserialization before using the
52 /// object!
53 ///
54 /// Note that ChannelManager is responsible for tracking liveness of its channels and generating
55 /// ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
56 /// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
57 /// offline for a full minute. In order to track this, you must call
58 /// timer_tick_occurred roughly once per minute, though it doesn't have to be perfect.
59 ///
60 /// Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
61 /// a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
62 /// essentially you should default to using a SimpleRefChannelManager, and use a
63 /// SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
64 /// you're using lightning-net-tokio.
65 #[must_use]
66 #[repr(C)]
67 pub struct ChannelManager {
68         /// A pointer to the opaque Rust object.
69
70         /// Nearly everywhere, inner must be non-null, however in places where
71         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
72         pub inner: *mut nativeChannelManager,
73         /// Indicates that this is the only struct which contains the same pointer.
74
75         /// Rust functions which take ownership of an object provided via an argument require
76         /// this to be true and invalidate the object pointed to by inner.
77         pub is_owned: bool,
78 }
79
80 impl Drop for ChannelManager {
81         fn drop(&mut self) {
82                 if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) {
83                         let _ = unsafe { Box::from_raw(self.inner) };
84                 }
85         }
86 }
87 /// Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL.
88 #[no_mangle]
89 pub extern "C" fn ChannelManager_free(this_obj: ChannelManager) { }
90 #[allow(unused)]
91 /// Used only if an object of this type is returned as a trait impl by a method
92 extern "C" fn ChannelManager_free_void(this_ptr: *mut c_void) {
93         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelManager); }
94 }
95 #[allow(unused)]
96 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
97 impl ChannelManager {
98         pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager {
99                 assert!(self.is_owned);
100                 let ret = self.inner;
101                 self.inner = std::ptr::null_mut();
102                 ret
103         }
104 }
105
106 use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport;
107 type nativeChainParameters = nativeChainParametersImport;
108
109 /// Chain-related parameters used to construct a new `ChannelManager`.
110 ///
111 /// Typically, the block-specific parameters are derived from the best block hash for the network,
112 /// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters
113 /// are not needed when deserializing a previously constructed `ChannelManager`.
114 #[must_use]
115 #[repr(C)]
116 pub struct ChainParameters {
117         /// A pointer to the opaque Rust object.
118
119         /// Nearly everywhere, inner must be non-null, however in places where
120         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
121         pub inner: *mut nativeChainParameters,
122         /// Indicates that this is the only struct which contains the same pointer.
123
124         /// Rust functions which take ownership of an object provided via an argument require
125         /// this to be true and invalidate the object pointed to by inner.
126         pub is_owned: bool,
127 }
128
129 impl Drop for ChainParameters {
130         fn drop(&mut self) {
131                 if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) {
132                         let _ = unsafe { Box::from_raw(self.inner) };
133                 }
134         }
135 }
136 /// Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL.
137 #[no_mangle]
138 pub extern "C" fn ChainParameters_free(this_obj: ChainParameters) { }
139 #[allow(unused)]
140 /// Used only if an object of this type is returned as a trait impl by a method
141 extern "C" fn ChainParameters_free_void(this_ptr: *mut c_void) {
142         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainParameters); }
143 }
144 #[allow(unused)]
145 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
146 impl ChainParameters {
147         pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters {
148                 assert!(self.is_owned);
149                 let ret = self.inner;
150                 self.inner = std::ptr::null_mut();
151                 ret
152         }
153 }
154 /// The network for determining the `chain_hash` in Lightning messages.
155 #[no_mangle]
156 pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network {
157         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.network;
158         crate::bitcoin::network::Network::from_bitcoin(inner_val)
159 }
160 /// The network for determining the `chain_hash` in Lightning messages.
161 #[no_mangle]
162 pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) {
163         unsafe { &mut *this_ptr.inner }.network = val.into_bitcoin();
164 }
165 /// The hash and height of the latest block successfully connected.
166 ///
167 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
168 #[no_mangle]
169 pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::chain::BestBlock {
170         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.best_block;
171         crate::lightning::chain::BestBlock { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
172 }
173 /// The hash and height of the latest block successfully connected.
174 ///
175 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
176 #[no_mangle]
177 pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::chain::BestBlock) {
178         unsafe { &mut *this_ptr.inner }.best_block = *unsafe { Box::from_raw(val.take_inner()) };
179 }
180 /// Constructs a new ChainParameters given each field
181 #[must_use]
182 #[no_mangle]
183 pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::chain::BestBlock) -> ChainParameters {
184         ChainParameters { inner: Box::into_raw(Box::new(nativeChainParameters {
185                 network: network_arg.into_bitcoin(),
186                 best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) },
187         })), is_owned: true }
188 }
189 impl Clone for ChainParameters {
190         fn clone(&self) -> Self {
191                 Self {
192                         inner: if <*mut nativeChainParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
193                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
194                         is_owned: true,
195                 }
196         }
197 }
198 #[allow(unused)]
199 /// Used only if an object of this type is returned as a trait impl by a method
200 pub(crate) extern "C" fn ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
201         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChainParameters)).clone() })) as *mut c_void
202 }
203 #[no_mangle]
204 /// Creates a copy of the ChainParameters
205 pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters {
206         orig.clone()
207 }
208 /// The amount of time in blocks we require our counterparty wait to claim their money (ie time
209 /// between when we, or our watchtower, must check for them having broadcast a theft transaction).
210 ///
211 /// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
212 ///
213 /// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
214
215 #[no_mangle]
216 pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT;
217 /// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
218 /// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour.
219 ///
220 /// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`]
221 ///
222 /// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta
223
224 #[no_mangle]
225 pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA;
226 /// Minimum CLTV difference between the current block height and received inbound payments.
227 /// Invoices generated for payment to us must set their `min_final_cltv_expiry` field to at least
228 /// this value.
229
230 #[no_mangle]
231 pub static MIN_FINAL_CLTV_EXPIRY: u32 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY;
232
233 use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport;
234 type nativeChannelCounterparty = nativeChannelCounterpartyImport;
235
236 /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
237 /// to better separate parameters.
238 #[must_use]
239 #[repr(C)]
240 pub struct ChannelCounterparty {
241         /// A pointer to the opaque Rust object.
242
243         /// Nearly everywhere, inner must be non-null, however in places where
244         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
245         pub inner: *mut nativeChannelCounterparty,
246         /// Indicates that this is the only struct which contains the same pointer.
247
248         /// Rust functions which take ownership of an object provided via an argument require
249         /// this to be true and invalidate the object pointed to by inner.
250         pub is_owned: bool,
251 }
252
253 impl Drop for ChannelCounterparty {
254         fn drop(&mut self) {
255                 if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) {
256                         let _ = unsafe { Box::from_raw(self.inner) };
257                 }
258         }
259 }
260 /// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
261 #[no_mangle]
262 pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { }
263 #[allow(unused)]
264 /// Used only if an object of this type is returned as a trait impl by a method
265 extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) {
266         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelCounterparty); }
267 }
268 #[allow(unused)]
269 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
270 impl ChannelCounterparty {
271         pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
272                 assert!(self.is_owned);
273                 let ret = self.inner;
274                 self.inner = std::ptr::null_mut();
275                 ret
276         }
277 }
278 /// The node_id of our counterparty
279 #[no_mangle]
280 pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey {
281         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id;
282         crate::c_types::PublicKey::from_rust(&inner_val)
283 }
284 /// The node_id of our counterparty
285 #[no_mangle]
286 pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) {
287         unsafe { &mut *this_ptr.inner }.node_id = val.into_rust();
288 }
289 /// The Features the channel counterparty provided upon last connection.
290 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
291 /// many routing-relevant features are present in the init context.
292 #[no_mangle]
293 pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures {
294         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
295         crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
296 }
297 /// The Features the channel counterparty provided upon last connection.
298 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
299 /// many routing-relevant features are present in the init context.
300 #[no_mangle]
301 pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) {
302         unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_inner()) };
303 }
304 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
305 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
306 /// claiming at least this value on chain.
307 ///
308 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
309 ///
310 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
311 #[no_mangle]
312 pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 {
313         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.unspendable_punishment_reserve;
314         *inner_val
315 }
316 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
317 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
318 /// claiming at least this value on chain.
319 ///
320 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
321 ///
322 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
323 #[no_mangle]
324 pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) {
325         unsafe { &mut *this_ptr.inner }.unspendable_punishment_reserve = val;
326 }
327 impl Clone for ChannelCounterparty {
328         fn clone(&self) -> Self {
329                 Self {
330                         inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { std::ptr::null_mut() } else {
331                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
332                         is_owned: true,
333                 }
334         }
335 }
336 #[allow(unused)]
337 /// Used only if an object of this type is returned as a trait impl by a method
338 pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void {
339         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelCounterparty)).clone() })) as *mut c_void
340 }
341 #[no_mangle]
342 /// Creates a copy of the ChannelCounterparty
343 pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty {
344         orig.clone()
345 }
346
347 use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport;
348 type nativeChannelDetails = nativeChannelDetailsImport;
349
350 /// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
351 #[must_use]
352 #[repr(C)]
353 pub struct ChannelDetails {
354         /// A pointer to the opaque Rust object.
355
356         /// Nearly everywhere, inner must be non-null, however in places where
357         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
358         pub inner: *mut nativeChannelDetails,
359         /// Indicates that this is the only struct which contains the same pointer.
360
361         /// Rust functions which take ownership of an object provided via an argument require
362         /// this to be true and invalidate the object pointed to by inner.
363         pub is_owned: bool,
364 }
365
366 impl Drop for ChannelDetails {
367         fn drop(&mut self) {
368                 if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) {
369                         let _ = unsafe { Box::from_raw(self.inner) };
370                 }
371         }
372 }
373 /// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
374 #[no_mangle]
375 pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
376 #[allow(unused)]
377 /// Used only if an object of this type is returned as a trait impl by a method
378 extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
379         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelDetails); }
380 }
381 #[allow(unused)]
382 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
383 impl ChannelDetails {
384         pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
385                 assert!(self.is_owned);
386                 let ret = self.inner;
387                 self.inner = std::ptr::null_mut();
388                 ret
389         }
390 }
391 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
392 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
393 /// Note that this means this value is *not* persistent - it can change once during the
394 /// lifetime of the channel.
395 #[no_mangle]
396 pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] {
397         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
398         inner_val
399 }
400 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
401 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
402 /// Note that this means this value is *not* persistent - it can change once during the
403 /// lifetime of the channel.
404 #[no_mangle]
405 pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
406         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
407 }
408 /// Parameters which apply to our counterparty. See individual fields for more information.
409 #[no_mangle]
410 pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channelmanager::ChannelCounterparty {
411         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty;
412         crate::lightning::ln::channelmanager::ChannelCounterparty { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
413 }
414 /// Parameters which apply to our counterparty. See individual fields for more information.
415 #[no_mangle]
416 pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channelmanager::ChannelCounterparty) {
417         unsafe { &mut *this_ptr.inner }.counterparty = *unsafe { Box::from_raw(val.take_inner()) };
418 }
419 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
420 /// our counterparty already.
421 ///
422 /// Note that, if this has been set, `channel_id` will be equivalent to
423 /// `funding_txo.unwrap().to_channel_id()`.
424 ///
425 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
426 #[no_mangle]
427 pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
428         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txo;
429         let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else {  { (inner_val.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
430         local_inner_val
431 }
432 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
433 /// our counterparty already.
434 ///
435 /// Note that, if this has been set, `channel_id` will be equivalent to
436 /// `funding_txo.unwrap().to_channel_id()`.
437 ///
438 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
439 #[no_mangle]
440 pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) {
441         let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
442         unsafe { &mut *this_ptr.inner }.funding_txo = local_val;
443 }
444 /// The position of the funding transaction in the chain. None if the funding transaction has
445 /// not yet been confirmed and the channel fully opened.
446 #[no_mangle]
447 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
448         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
449         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()) } };
450         local_inner_val
451 }
452 /// The position of the funding transaction in the chain. None if the funding transaction has
453 /// not yet been confirmed and the channel fully opened.
454 #[no_mangle]
455 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
456         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
457         unsafe { &mut *this_ptr.inner }.short_channel_id = local_val;
458 }
459 /// The value, in satoshis, of this channel as appears in the funding output
460 #[no_mangle]
461 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
462         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis;
463         *inner_val
464 }
465 /// The value, in satoshis, of this channel as appears in the funding output
466 #[no_mangle]
467 pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
468         unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val;
469 }
470 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
471 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
472 /// this value on chain.
473 ///
474 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
475 ///
476 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
477 ///
478 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
479 #[no_mangle]
480 pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
481         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.unspendable_punishment_reserve;
482         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()) } };
483         local_inner_val
484 }
485 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
486 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
487 /// this value on chain.
488 ///
489 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
490 ///
491 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
492 ///
493 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
494 #[no_mangle]
495 pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
496         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
497         unsafe { &mut *this_ptr.inner }.unspendable_punishment_reserve = local_val;
498 }
499 /// The user_id passed in to create_channel, or 0 if the channel was inbound.
500 #[no_mangle]
501 pub extern "C" fn ChannelDetails_get_user_id(this_ptr: &ChannelDetails) -> u64 {
502         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.user_id;
503         *inner_val
504 }
505 /// The user_id passed in to create_channel, or 0 if the channel was inbound.
506 #[no_mangle]
507 pub extern "C" fn ChannelDetails_set_user_id(this_ptr: &mut ChannelDetails, mut val: u64) {
508         unsafe { &mut *this_ptr.inner }.user_id = val;
509 }
510 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
511 /// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
512 /// available for inclusion in new outbound HTLCs). This further does not include any pending
513 /// outgoing HTLCs which are awaiting some other resolution to be sent.
514 ///
515 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
516 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
517 /// should be able to spend nearly this amount.
518 #[no_mangle]
519 pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
520         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outbound_capacity_msat;
521         *inner_val
522 }
523 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
524 /// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
525 /// available for inclusion in new outbound HTLCs). This further does not include any pending
526 /// outgoing HTLCs which are awaiting some other resolution to be sent.
527 ///
528 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
529 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
530 /// should be able to spend nearly this amount.
531 #[no_mangle]
532 pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
533         unsafe { &mut *this_ptr.inner }.outbound_capacity_msat = val;
534 }
535 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
536 /// include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
537 /// available for inclusion in new inbound HTLCs).
538 /// Note that there are some corner cases not fully handled here, so the actual available
539 /// inbound capacity may be slightly higher than this.
540 ///
541 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
542 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
543 /// However, our counterparty should be able to spend nearly this amount.
544 #[no_mangle]
545 pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
546         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.inbound_capacity_msat;
547         *inner_val
548 }
549 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
550 /// include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
551 /// available for inclusion in new inbound HTLCs).
552 /// Note that there are some corner cases not fully handled here, so the actual available
553 /// inbound capacity may be slightly higher than this.
554 ///
555 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
556 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
557 /// However, our counterparty should be able to spend nearly this amount.
558 #[no_mangle]
559 pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
560         unsafe { &mut *this_ptr.inner }.inbound_capacity_msat = val;
561 }
562 /// The number of required confirmations on the funding transaction before the funding will be
563 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
564 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
565 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
566 /// [`ChannelHandshakeLimits::max_minimum_depth`].
567 ///
568 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
569 ///
570 /// [`is_outbound`]: ChannelDetails::is_outbound
571 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
572 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
573 #[no_mangle]
574 pub extern "C" fn ChannelDetails_get_confirmations_required(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
575         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.confirmations_required;
576         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()) } };
577         local_inner_val
578 }
579 /// The number of required confirmations on the funding transaction before the funding will be
580 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
581 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
582 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
583 /// [`ChannelHandshakeLimits::max_minimum_depth`].
584 ///
585 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
586 ///
587 /// [`is_outbound`]: ChannelDetails::is_outbound
588 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
589 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
590 #[no_mangle]
591 pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
592         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
593         unsafe { &mut *this_ptr.inner }.confirmations_required = local_val;
594 }
595 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
596 /// until we can claim our funds after we force-close the channel. During this time our
597 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
598 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
599 /// time to claim our non-HTLC-encumbered funds.
600 ///
601 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
602 #[no_mangle]
603 pub extern "C" fn ChannelDetails_get_force_close_spend_delay(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u16Z {
604         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.force_close_spend_delay;
605         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()) } };
606         local_inner_val
607 }
608 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
609 /// until we can claim our funds after we force-close the channel. During this time our
610 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
611 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
612 /// time to claim our non-HTLC-encumbered funds.
613 ///
614 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
615 #[no_mangle]
616 pub extern "C" fn ChannelDetails_set_force_close_spend_delay(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u16Z) {
617         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
618         unsafe { &mut *this_ptr.inner }.force_close_spend_delay = local_val;
619 }
620 /// True if the channel was initiated (and thus funded) by us.
621 #[no_mangle]
622 pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool {
623         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_outbound;
624         *inner_val
625 }
626 /// True if the channel was initiated (and thus funded) by us.
627 #[no_mangle]
628 pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) {
629         unsafe { &mut *this_ptr.inner }.is_outbound = val;
630 }
631 /// True if the channel is confirmed, funding_locked messages have been exchanged, and the
632 /// channel is not currently being shut down. `funding_locked` message exchange implies the
633 /// required confirmation count has been reached (and we were connected to the peer at some
634 /// point after the funding transaction received enough confirmations). The required
635 /// confirmation count is provided in [`confirmations_required`].
636 ///
637 /// [`confirmations_required`]: ChannelDetails::confirmations_required
638 #[no_mangle]
639 pub extern "C" fn ChannelDetails_get_is_funding_locked(this_ptr: &ChannelDetails) -> bool {
640         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_funding_locked;
641         *inner_val
642 }
643 /// True if the channel is confirmed, funding_locked messages have been exchanged, and the
644 /// channel is not currently being shut down. `funding_locked` message exchange implies the
645 /// required confirmation count has been reached (and we were connected to the peer at some
646 /// point after the funding transaction received enough confirmations). The required
647 /// confirmation count is provided in [`confirmations_required`].
648 ///
649 /// [`confirmations_required`]: ChannelDetails::confirmations_required
650 #[no_mangle]
651 pub extern "C" fn ChannelDetails_set_is_funding_locked(this_ptr: &mut ChannelDetails, mut val: bool) {
652         unsafe { &mut *this_ptr.inner }.is_funding_locked = val;
653 }
654 /// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
655 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
656 ///
657 /// This is a strict superset of `is_funding_locked`.
658 #[no_mangle]
659 pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool {
660         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_usable;
661         *inner_val
662 }
663 /// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
664 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
665 ///
666 /// This is a strict superset of `is_funding_locked`.
667 #[no_mangle]
668 pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) {
669         unsafe { &mut *this_ptr.inner }.is_usable = val;
670 }
671 /// True if this channel is (or will be) publicly-announced.
672 #[no_mangle]
673 pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool {
674         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_public;
675         *inner_val
676 }
677 /// True if this channel is (or will be) publicly-announced.
678 #[no_mangle]
679 pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) {
680         unsafe { &mut *this_ptr.inner }.is_public = val;
681 }
682 /// Constructs a new ChannelDetails given each field
683 #[must_use]
684 #[no_mangle]
685 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 short_channel_id_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_id_arg: u64, mut outbound_capacity_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_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_funding_locked_arg: bool, mut is_usable_arg: bool, mut is_public_arg: bool) -> ChannelDetails {
686         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()) } }) };
687         let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None };
688         let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None };
689         let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None };
690         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 };
691         ChannelDetails { inner: Box::into_raw(Box::new(nativeChannelDetails {
692                 channel_id: channel_id_arg.data,
693                 counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) },
694                 funding_txo: local_funding_txo_arg,
695                 short_channel_id: local_short_channel_id_arg,
696                 channel_value_satoshis: channel_value_satoshis_arg,
697                 unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg,
698                 user_id: user_id_arg,
699                 outbound_capacity_msat: outbound_capacity_msat_arg,
700                 inbound_capacity_msat: inbound_capacity_msat_arg,
701                 confirmations_required: local_confirmations_required_arg,
702                 force_close_spend_delay: local_force_close_spend_delay_arg,
703                 is_outbound: is_outbound_arg,
704                 is_funding_locked: is_funding_locked_arg,
705                 is_usable: is_usable_arg,
706                 is_public: is_public_arg,
707         })), is_owned: true }
708 }
709 impl Clone for ChannelDetails {
710         fn clone(&self) -> Self {
711                 Self {
712                         inner: if <*mut nativeChannelDetails>::is_null(self.inner) { std::ptr::null_mut() } else {
713                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
714                         is_owned: true,
715                 }
716         }
717 }
718 #[allow(unused)]
719 /// Used only if an object of this type is returned as a trait impl by a method
720 pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
721         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDetails)).clone() })) as *mut c_void
722 }
723 #[no_mangle]
724 /// Creates a copy of the ChannelDetails
725 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
726         orig.clone()
727 }
728 /// If a payment fails to send, it can be in one of several states. This enum is returned as the
729 /// Err() type describing which state the payment is in, see the description of individual enum
730 /// states for more.
731 #[must_use]
732 #[derive(Clone)]
733 #[repr(C)]
734 pub enum PaymentSendFailure {
735         /// A parameter which was passed to send_payment was invalid, preventing us from attempting to
736         /// send the payment at all. No channel state has been changed or messages sent to peers, and
737         /// once you've changed the parameter at error, you can freely retry the payment in full.
738         ParameterError(crate::lightning::util::errors::APIError),
739         /// A parameter in a single path which was passed to send_payment was invalid, preventing us
740         /// from attempting to send the payment at all. No channel state has been changed or messages
741         /// sent to peers, and once you've changed the parameter at error, you can freely retry the
742         /// payment in full.
743         ///
744         /// The results here are ordered the same as the paths in the route object which was passed to
745         /// send_payment.
746         PathParameterError(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
747         /// All paths which were attempted failed to send, with no channel state change taking place.
748         /// You can freely retry the payment in full (though you probably want to do so over different
749         /// paths than the ones selected).
750         AllFailedRetrySafe(crate::c_types::derived::CVec_APIErrorZ),
751         /// Some paths which were attempted failed to send, though possibly not all. At least some
752         /// paths have irrevocably committed to the HTLC and retrying the payment in full would result
753         /// in over-/re-payment.
754         ///
755         /// The results here are ordered the same as the paths in the route object which was passed to
756         /// send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely
757         /// retried (though there is currently no API with which to do so).
758         ///
759         /// Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried
760         /// as they will result in over-/re-payment. These HTLCs all either successfully sent (in the
761         /// case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel
762         /// with the latest update_id.
763         PartialFailure(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
764 }
765 use lightning::ln::channelmanager::PaymentSendFailure as nativePaymentSendFailure;
766 impl PaymentSendFailure {
767         #[allow(unused)]
768         pub(crate) fn to_native(&self) -> nativePaymentSendFailure {
769                 match self {
770                         PaymentSendFailure::ParameterError (ref a, ) => {
771                                 let mut a_nonref = (*a).clone();
772                                 nativePaymentSendFailure::ParameterError (
773                                         a_nonref.into_native(),
774                                 )
775                         },
776                         PaymentSendFailure::PathParameterError (ref a, ) => {
777                                 let mut a_nonref = (*a).clone();
778                                 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 }); };
779                                 nativePaymentSendFailure::PathParameterError (
780                                         local_a_nonref,
781                                 )
782                         },
783                         PaymentSendFailure::AllFailedRetrySafe (ref a, ) => {
784                                 let mut a_nonref = (*a).clone();
785                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into_native() }); };
786                                 nativePaymentSendFailure::AllFailedRetrySafe (
787                                         local_a_nonref,
788                                 )
789                         },
790                         PaymentSendFailure::PartialFailure (ref a, ) => {
791                                 let mut a_nonref = (*a).clone();
792                                 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 }); };
793                                 nativePaymentSendFailure::PartialFailure (
794                                         local_a_nonref,
795                                 )
796                         },
797                 }
798         }
799         #[allow(unused)]
800         pub(crate) fn into_native(self) -> nativePaymentSendFailure {
801                 match self {
802                         PaymentSendFailure::ParameterError (mut a, ) => {
803                                 nativePaymentSendFailure::ParameterError (
804                                         a.into_native(),
805                                 )
806                         },
807                         PaymentSendFailure::PathParameterError (mut a, ) => {
808                                 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 }); };
809                                 nativePaymentSendFailure::PathParameterError (
810                                         local_a,
811                                 )
812                         },
813                         PaymentSendFailure::AllFailedRetrySafe (mut a, ) => {
814                                 let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into_native() }); };
815                                 nativePaymentSendFailure::AllFailedRetrySafe (
816                                         local_a,
817                                 )
818                         },
819                         PaymentSendFailure::PartialFailure (mut a, ) => {
820                                 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 }); };
821                                 nativePaymentSendFailure::PartialFailure (
822                                         local_a,
823                                 )
824                         },
825                 }
826         }
827         #[allow(unused)]
828         pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self {
829                 match native {
830                         nativePaymentSendFailure::ParameterError (ref a, ) => {
831                                 let mut a_nonref = (*a).clone();
832                                 PaymentSendFailure::ParameterError (
833                                         crate::lightning::util::errors::APIError::native_into(a_nonref),
834                                 )
835                         },
836                         nativePaymentSendFailure::PathParameterError (ref a, ) => {
837                                 let mut a_nonref = (*a).clone();
838                                 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 }); };
839                                 PaymentSendFailure::PathParameterError (
840                                         local_a_nonref.into(),
841                                 )
842                         },
843                         nativePaymentSendFailure::AllFailedRetrySafe (ref a, ) => {
844                                 let mut a_nonref = (*a).clone();
845                                 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) }); };
846                                 PaymentSendFailure::AllFailedRetrySafe (
847                                         local_a_nonref.into(),
848                                 )
849                         },
850                         nativePaymentSendFailure::PartialFailure (ref a, ) => {
851                                 let mut a_nonref = (*a).clone();
852                                 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 }); };
853                                 PaymentSendFailure::PartialFailure (
854                                         local_a_nonref.into(),
855                                 )
856                         },
857                 }
858         }
859         #[allow(unused)]
860         pub(crate) fn native_into(native: nativePaymentSendFailure) -> Self {
861                 match native {
862                         nativePaymentSendFailure::ParameterError (mut a, ) => {
863                                 PaymentSendFailure::ParameterError (
864                                         crate::lightning::util::errors::APIError::native_into(a),
865                                 )
866                         },
867                         nativePaymentSendFailure::PathParameterError (mut a, ) => {
868                                 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 }); };
869                                 PaymentSendFailure::PathParameterError (
870                                         local_a.into(),
871                                 )
872                         },
873                         nativePaymentSendFailure::AllFailedRetrySafe (mut a, ) => {
874                                 let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::util::errors::APIError::native_into(item) }); };
875                                 PaymentSendFailure::AllFailedRetrySafe (
876                                         local_a.into(),
877                                 )
878                         },
879                         nativePaymentSendFailure::PartialFailure (mut a, ) => {
880                                 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 }); };
881                                 PaymentSendFailure::PartialFailure (
882                                         local_a.into(),
883                                 )
884                         },
885                 }
886         }
887 }
888 /// Frees any resources used by the PaymentSendFailure
889 #[no_mangle]
890 pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { }
891 /// Creates a copy of the PaymentSendFailure
892 #[no_mangle]
893 pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure {
894         orig.clone()
895 }
896 #[no_mangle]
897 /// Utility method to constructs a new ParameterError-variant PaymentSendFailure
898 pub extern "C" fn PaymentSendFailure_parameter_error(a: crate::lightning::util::errors::APIError) -> PaymentSendFailure {
899         PaymentSendFailure::ParameterError(a, )
900 }
901 #[no_mangle]
902 /// Utility method to constructs a new PathParameterError-variant PaymentSendFailure
903 pub extern "C" fn PaymentSendFailure_path_parameter_error(a: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ) -> PaymentSendFailure {
904         PaymentSendFailure::PathParameterError(a, )
905 }
906 #[no_mangle]
907 /// Utility method to constructs a new AllFailedRetrySafe-variant PaymentSendFailure
908 pub extern "C" fn PaymentSendFailure_all_failed_retry_safe(a: crate::c_types::derived::CVec_APIErrorZ) -> PaymentSendFailure {
909         PaymentSendFailure::AllFailedRetrySafe(a, )
910 }
911 #[no_mangle]
912 /// Utility method to constructs a new PartialFailure-variant PaymentSendFailure
913 pub extern "C" fn PaymentSendFailure_partial_failure(a: crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ) -> PaymentSendFailure {
914         PaymentSendFailure::PartialFailure(a, )
915 }
916 /// Constructs a new ChannelManager to hold several channels and route between them.
917 ///
918 /// This is the main \"logic hub\" for all channel-related actions, and implements
919 /// ChannelMessageHandler.
920 ///
921 /// Non-proportional fees are fixed according to our risk using the provided fee estimator.
922 ///
923 /// panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
924 ///
925 /// Users need to notify the new ChannelManager when a new block is connected or
926 /// disconnected using its `block_connected` and `block_disconnected` methods, starting
927 /// from after `params.latest_hash`.
928 #[must_use]
929 #[no_mangle]
930 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) -> ChannelManager {
931         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()) });
932         ChannelManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
933 }
934
935 /// Gets the current configuration applied to all new channels,  as
936 #[must_use]
937 #[no_mangle]
938 pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &ChannelManager) -> crate::lightning::util::config::UserConfig {
939         let mut ret = unsafe { &*this_arg.inner }.get_current_default_configuration();
940         crate::lightning::util::config::UserConfig { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
941 }
942
943 /// Creates a new outbound channel to the given remote node and with the given value.
944 ///
945 /// user_id will be provided back as user_channel_id in FundingGenerationReady events to allow
946 /// tracking of which events correspond with which create_channel call. Note that the
947 /// user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for
948 /// user_id here. user_id has no meaning inside of LDK, it is simply copied to events and
949 /// otherwise ignored.
950 ///
951 /// If successful, will generate a SendOpenChannel message event, so you should probably poll
952 /// PeerManager::process_events afterwards.
953 ///
954 /// Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
955 /// greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
956 ///
957 /// Note that we do not check if you are currently connected to the given peer. If no
958 /// connection is available, the outbound `open_channel` message may fail to send, resulting in
959 /// the channel eventually being silently forgotten.
960 ///
961 /// Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
962 #[must_use]
963 #[no_mangle]
964 pub extern "C" fn ChannelManager_create_channel(this_arg: &ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_id: u64, mut override_config: crate::lightning::util::config::UserConfig) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
965         let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) };
966         let mut ret = unsafe { &*this_arg.inner }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_id, local_override_config);
967         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() };
968         local_ret
969 }
970
971 /// Gets the list of open channels, in random order. See ChannelDetail field documentation for
972 /// more information.
973 #[must_use]
974 #[no_mangle]
975 pub extern "C" fn ChannelManager_list_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
976         let mut ret = unsafe { &*this_arg.inner }.list_channels();
977         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
978         local_ret.into()
979 }
980
981 /// Gets the list of usable channels, in random order. Useful as an argument to
982 /// get_route to ensure non-announced channels are used.
983 ///
984 /// These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
985 /// documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
986 /// are.
987 #[must_use]
988 #[no_mangle]
989 pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
990         let mut ret = unsafe { &*this_arg.inner }.list_usable_channels();
991         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
992         local_ret.into()
993 }
994
995 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
996 /// will be accepted on the given channel, and after additional timeout/the closing of all
997 /// pending HTLCs, the channel will be closed on chain.
998 ///
999 ///  * If we are the channel initiator, we will pay between our [`Background`] and
1000 ///    [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
1001 ///    estimate.
1002 ///  * If our counterparty is the channel initiator, we will require a channel closing
1003 ///    transaction feerate of at least our [`Background`] feerate or the feerate which
1004 ///    would appear on a force-closure transaction, whichever is lower. We will allow our
1005 ///    counterparty to pay as much fee as they'd like, however.
1006 ///
1007 /// May generate a SendShutdown message event on success, which should be relayed.
1008 ///
1009 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1010 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1011 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1012 #[must_use]
1013 #[no_mangle]
1014 pub extern "C" fn ChannelManager_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1015         let mut ret = unsafe { &*this_arg.inner }.close_channel(unsafe { &*channel_id});
1016         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() };
1017         local_ret
1018 }
1019
1020 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
1021 /// will be accepted on the given channel, and after additional timeout/the closing of all
1022 /// pending HTLCs, the channel will be closed on chain.
1023 ///
1024 /// `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
1025 /// the channel being closed or not:
1026 ///  * If we are the channel initiator, we will pay at least this feerate on the closing
1027 ///    transaction. The upper-bound is set by
1028 ///    [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
1029 ///    estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
1030 ///  * If our counterparty is the channel initiator, we will refuse to accept a channel closure
1031 ///    transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
1032 ///    will appear on a force-closure transaction, whichever is lower).
1033 ///
1034 /// May generate a SendShutdown message event on success, which should be relayed.
1035 ///
1036 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1037 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1038 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1039 #[must_use]
1040 #[no_mangle]
1041 pub extern "C" fn ChannelManager_close_channel_with_target_feerate(this_arg: &ChannelManager, channel_id: *const [u8; 32], mut target_feerate_sats_per_1000_weight: u32) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1042         let mut ret = unsafe { &*this_arg.inner }.close_channel_with_target_feerate(unsafe { &*channel_id}, target_feerate_sats_per_1000_weight);
1043         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() };
1044         local_ret
1045 }
1046
1047 /// Force closes a channel, immediately broadcasting the latest local commitment transaction to
1048 /// the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager.
1049 #[must_use]
1050 #[no_mangle]
1051 pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1052         let mut ret = unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id});
1053         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() };
1054         local_ret
1055 }
1056
1057 /// Force close all channels, immediately broadcasting the latest local commitment transaction
1058 /// for each to the chain and rejecting new HTLCs on each.
1059 #[no_mangle]
1060 pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: &ChannelManager) {
1061         unsafe { &*this_arg.inner }.force_close_all_channels()
1062 }
1063
1064 /// Sends a payment along a given route.
1065 ///
1066 /// Value parameters are provided via the last hop in route, see documentation for RouteHop
1067 /// fields for more info.
1068 ///
1069 /// Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
1070 /// payment), we don't do anything to stop you! We always try to ensure that if the provided
1071 /// next hop knows the preimage to payment_hash they can claim an additional amount as
1072 /// specified in the last hop in the route! Thus, you should probably do your own
1073 /// payment_preimage tracking (which you should already be doing as they represent \"proof of
1074 /// payment\") and prevent double-sends yourself.
1075 ///
1076 /// May generate SendHTLCs message(s) event on success, which should be relayed.
1077 ///
1078 /// Each path may have a different return value, and PaymentSendValue may return a Vec with
1079 /// each entry matching the corresponding-index entry in the route paths, see
1080 /// PaymentSendFailure for more info.
1081 ///
1082 /// In general, a path may raise:
1083 ///  * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
1084 ///    node public key) is specified.
1085 ///  * APIError::ChannelUnavailable if the next-hop channel is not available for updates
1086 ///    (including due to previous monitor update failure or new permanent monitor update
1087 ///    failure).
1088 ///  * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
1089 ///    relevant updates.
1090 ///
1091 /// Note that depending on the type of the PaymentSendFailure the HTLC may have been
1092 /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
1093 /// different route unless you intend to pay twice!
1094 ///
1095 /// payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
1096 /// the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
1097 /// newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
1098 /// must not contain multiple paths as multi-path payments require a recipient-provided
1099 /// payment_secret.
1100 /// If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
1101 /// bit set (either as required or as available). If multiple paths are present in the Route,
1102 /// we assume the invoice had the basic_mpp feature set.
1103 ///
1104 /// Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
1105 #[must_use]
1106 #[no_mangle]
1107 pub extern "C" fn ChannelManager_send_payment(this_arg: &ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
1108         let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentSecret(payment_secret.data) }) };
1109         let mut ret = unsafe { &*this_arg.inner }.send_payment(unsafe { &*route.inner }, ::lightning::ln::PaymentHash(payment_hash.data), &local_payment_secret);
1110         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() };
1111         local_ret
1112 }
1113
1114 /// Send a spontaneous payment, which is a payment that does not require the recipient to have
1115 /// generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
1116 /// the preimage, it must be a cryptographically secure random value that no intermediate node
1117 /// would be able to guess -- otherwise, an intermediate node may claim the payment and it will
1118 /// never reach the recipient.
1119 ///
1120 /// See [`send_payment`] documentation for more details on the return value of this function.
1121 ///
1122 /// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
1123 /// [`send_payment`] for more information about the risks of duplicate preimage usage.
1124 ///
1125 /// Note that `route` must have exactly one path.
1126 ///
1127 /// [`send_payment`]: Self::send_payment
1128 ///
1129 /// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
1130 #[must_use]
1131 #[no_mangle]
1132 pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ {
1133         let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) };
1134         let mut ret = unsafe { &*this_arg.inner }.send_spontaneous_payment(unsafe { &*route.inner }, local_payment_preimage);
1135         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() };
1136         local_ret
1137 }
1138
1139 /// Call this upon creation of a funding transaction for the given channel.
1140 ///
1141 /// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
1142 /// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
1143 ///
1144 /// Panics if a funding transaction has already been provided for this channel.
1145 ///
1146 /// May panic if the output found in the funding transaction is duplicative with some other
1147 /// channel (note that this should be trivially prevented by using unique funding transaction
1148 /// keys per-channel).
1149 ///
1150 /// Do NOT broadcast the funding transaction yourself. When we have safely received our
1151 /// counterparty's signature the funding transaction will automatically be broadcast via the
1152 /// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
1153 ///
1154 /// Note that this includes RBF or similar transaction replacement strategies - lightning does
1155 /// not currently support replacing a funding transaction on an existing channel. Instead,
1156 /// create a new channel with a conflicting funding transaction.
1157 ///
1158 /// [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
1159 #[must_use]
1160 #[no_mangle]
1161 pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &ChannelManager, temporary_channel_id: *const [u8; 32], mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
1162         let mut ret = unsafe { &*this_arg.inner }.funding_transaction_generated(unsafe { &*temporary_channel_id}, funding_transaction.into_bitcoin());
1163         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() };
1164         local_ret
1165 }
1166
1167 /// Regenerates channel_announcements and generates a signed node_announcement from the given
1168 /// arguments, providing them in corresponding events via
1169 /// [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
1170 /// on-chain. This effectively re-broadcasts all channel announcements and sends our node
1171 /// announcement to ensure that the lightning P2P network is aware of the channels we have and
1172 /// our network addresses.
1173 ///
1174 /// `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
1175 /// node to humans. They carry no in-protocol meaning.
1176 ///
1177 /// `addresses` represent the set (possibly empty) of socket addresses on which this node
1178 /// accepts incoming connections. These will be included in the node_announcement, publicly
1179 /// tying these addresses together and to this node. If you wish to preserve user privacy,
1180 /// addresses should likely contain only Tor Onion addresses.
1181 ///
1182 /// Panics if `addresses` is absurdly large (more than 500).
1183 ///
1184 /// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
1185 #[no_mangle]
1186 pub extern "C" fn ChannelManager_broadcast_node_announcement(this_arg: &ChannelManager, mut rgb: crate::c_types::ThreeBytes, mut alias: crate::c_types::ThirtyTwoBytes, mut addresses: crate::c_types::derived::CVec_NetAddressZ) {
1187         let mut local_addresses = Vec::new(); for mut item in addresses.into_rust().drain(..) { local_addresses.push( { item.into_native() }); };
1188         unsafe { &*this_arg.inner }.broadcast_node_announcement(rgb.data, alias.data, local_addresses)
1189 }
1190
1191 /// Processes HTLCs which are pending waiting on random forward delay.
1192 ///
1193 /// Should only really ever be called in response to a PendingHTLCsForwardable event.
1194 /// Will likely generate further events.
1195 #[no_mangle]
1196 pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &ChannelManager) {
1197         unsafe { &*this_arg.inner }.process_pending_htlc_forwards()
1198 }
1199
1200 /// Performs actions which should happen on startup and roughly once per minute thereafter.
1201 ///
1202 /// This currently includes:
1203 ///  * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
1204 ///  * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
1205 ///    than a minute, informing the network that they should no longer attempt to route over
1206 ///    the channel.
1207 ///
1208 /// Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
1209 /// estimate fetches.
1210 #[no_mangle]
1211 pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &ChannelManager) {
1212         unsafe { &*this_arg.inner }.timer_tick_occurred()
1213 }
1214
1215 /// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
1216 /// after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
1217 /// along the path (including in our own channel on which we received it).
1218 /// Returns false if no payment was found to fail backwards, true if the process of failing the
1219 /// HTLC backwards has been started.
1220 #[must_use]
1221 #[no_mangle]
1222 pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, payment_hash: *const [u8; 32]) -> bool {
1223         let mut ret = unsafe { &*this_arg.inner }.fail_htlc_backwards(&::lightning::ln::PaymentHash(unsafe { *payment_hash }));
1224         ret
1225 }
1226
1227 /// Provides a payment preimage in response to a PaymentReceived event, returning true and
1228 /// generating message events for the net layer to claim the payment, if possible. Thus, you
1229 /// should probably kick the net layer to go send messages if this returns true!
1230 ///
1231 /// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
1232 /// [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived`
1233 /// event matches your expectation. If you fail to do so and call this method, you may provide
1234 /// the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
1235 ///
1236 /// May panic if called except in response to a PaymentReceived event.
1237 ///
1238 /// [`create_inbound_payment`]: Self::create_inbound_payment
1239 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
1240 #[must_use]
1241 #[no_mangle]
1242 pub extern "C" fn ChannelManager_claim_funds(this_arg: &ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) -> bool {
1243         let mut ret = unsafe { &*this_arg.inner }.claim_funds(::lightning::ln::PaymentPreimage(payment_preimage.data));
1244         ret
1245 }
1246
1247 /// Gets the node_id held by this ChannelManager
1248 #[must_use]
1249 #[no_mangle]
1250 pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> crate::c_types::PublicKey {
1251         let mut ret = unsafe { &*this_arg.inner }.get_our_node_id();
1252         crate::c_types::PublicKey::from_rust(&ret)
1253 }
1254
1255 /// Restores a single, given channel to normal operation after a
1256 /// ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update
1257 /// operation.
1258 ///
1259 /// All ChannelMonitor updates up to and including highest_applied_update_id must have been
1260 /// fully committed in every copy of the given channels' ChannelMonitors.
1261 ///
1262 /// Note that there is no effect to calling with a highest_applied_update_id other than the
1263 /// current latest ChannelMonitorUpdate and one call to this function after multiple
1264 /// ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field
1265 /// exists largely only to prevent races between this and concurrent update_monitor calls.
1266 ///
1267 /// Thus, the anticipated use is, at a high level:
1268 ///  1) You register a chain::Watch with this ChannelManager,
1269 ///  2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
1270 ///     said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
1271 ///     any time it cannot do so instantly,
1272 ///  3) update(s) are applied to each remote copy of a ChannelMonitor,
1273 ///  4) once all remote copies are updated, you call this function with the update_id that
1274 ///     completed, and once it is the latest the Channel will be re-enabled.
1275 #[no_mangle]
1276 pub extern "C" fn ChannelManager_channel_monitor_updated(this_arg: &ChannelManager, funding_txo: &crate::lightning::chain::transaction::OutPoint, mut highest_applied_update_id: u64) {
1277         unsafe { &*this_arg.inner }.channel_monitor_updated(unsafe { &*funding_txo.inner }, highest_applied_update_id)
1278 }
1279
1280 /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
1281 /// to pay us.
1282 ///
1283 /// This differs from [`create_inbound_payment_for_hash`] only in that it generates the
1284 /// [`PaymentHash`] and [`PaymentPreimage`] for you, returning the first and storing the second.
1285 ///
1286 /// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which
1287 /// will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be
1288 /// passed directly to [`claim_funds`].
1289 ///
1290 /// See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
1291 ///
1292 /// [`claim_funds`]: Self::claim_funds
1293 /// [`PaymentReceived`]: events::Event::PaymentReceived
1294 /// [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage
1295 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
1296 #[must_use]
1297 #[no_mangle]
1298 pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &ChannelManager, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, mut user_payment_id: u64) -> crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ {
1299         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
1300         let mut ret = unsafe { &*this_arg.inner }.create_inbound_payment(local_min_value_msat, invoice_expiry_delta_secs, user_payment_id);
1301         let (mut orig_ret_0, mut orig_ret_1) = ret; let mut local_ret = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_1.0 }).into();
1302         local_ret
1303 }
1304
1305 /// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
1306 /// stored external to LDK.
1307 ///
1308 /// A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a
1309 /// payment secret fetched via this method or [`create_inbound_payment`], and which is at least
1310 /// the `min_value_msat` provided here, if one is provided.
1311 ///
1312 /// The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This
1313 /// method may return an Err if another payment with the same payment_hash is still pending.
1314 ///
1315 /// `user_payment_id` will be provided back in [`PaymentPurpose::InvoicePayment::user_payment_id`] events to
1316 /// allow tracking of which events correspond with which calls to this and
1317 /// [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply
1318 /// copied to events and otherwise ignored. It may be used to correlate PaymentReceived events
1319 /// with invoice metadata stored elsewhere.
1320 ///
1321 /// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
1322 /// received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
1323 /// before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
1324 /// sender \"proof-of-payment\" unless they have paid the required amount.
1325 ///
1326 /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1327 /// in excess of the current time. This should roughly match the expiry time set in the invoice.
1328 /// After this many seconds, we will remove the inbound payment, resulting in any attempts to
1329 /// pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
1330 /// invoices when no timeout is set.
1331 ///
1332 /// Note that we use block header time to time-out pending inbound payments (with some margin
1333 /// to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
1334 /// accept a payment and generate a [`PaymentReceived`] event for some time after the expiry.
1335 /// If you need exact expiry semantics, you should enforce them upon receipt of
1336 /// [`PaymentReceived`].
1337 ///
1338 /// Pending inbound payments are stored in memory and in serialized versions of this
1339 /// [`ChannelManager`]. If potentially unbounded numbers of inbound payments may exist and
1340 /// space is limited, you may wish to rate-limit inbound payment creation.
1341 ///
1342 /// May panic if `invoice_expiry_delta_secs` is greater than one year.
1343 ///
1344 /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
1345 /// set to at least [`MIN_FINAL_CLTV_EXPIRY`].
1346 ///
1347 /// [`create_inbound_payment`]: Self::create_inbound_payment
1348 /// [`PaymentReceived`]: events::Event::PaymentReceived
1349 /// [`PaymentPurpose::InvoicePayment::user_payment_id`]: events::PaymentPurpose::InvoicePayment::user_payment_id
1350 #[must_use]
1351 #[no_mangle]
1352 pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, mut user_payment_id: u64) -> crate::c_types::derived::CResult_PaymentSecretAPIErrorZ {
1353         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
1354         let mut ret = unsafe { &*this_arg.inner }.create_inbound_payment_for_hash(::lightning::ln::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs, user_payment_id);
1355         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() };
1356         local_ret
1357 }
1358
1359 impl From<nativeChannelManager> for crate::lightning::util::events::MessageSendEventsProvider {
1360         fn from(obj: nativeChannelManager) -> Self {
1361                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1362                 let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj);
1363                 // 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
1364                 rust_obj.inner = std::ptr::null_mut();
1365                 ret.free = Some(ChannelManager_free_void);
1366                 ret
1367         }
1368 }
1369 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
1370 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
1371 #[no_mangle]
1372 pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::MessageSendEventsProvider {
1373         crate::lightning::util::events::MessageSendEventsProvider {
1374                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1375                 free: None,
1376                 get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
1377         }
1378 }
1379
1380 #[must_use]
1381 extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
1382         let mut ret = <nativeChannelManager as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
1383         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
1384         local_ret.into()
1385 }
1386
1387 impl From<nativeChannelManager> for crate::lightning::util::events::EventsProvider {
1388         fn from(obj: nativeChannelManager) -> Self {
1389                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1390                 let mut ret = ChannelManager_as_EventsProvider(&rust_obj);
1391                 // 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
1392                 rust_obj.inner = std::ptr::null_mut();
1393                 ret.free = Some(ChannelManager_free_void);
1394                 ret
1395         }
1396 }
1397 /// Constructs a new EventsProvider which calls the relevant methods on this_arg.
1398 /// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
1399 #[no_mangle]
1400 pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::EventsProvider {
1401         crate::lightning::util::events::EventsProvider {
1402                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1403                 free: None,
1404                 process_pending_events: ChannelManager_EventsProvider_process_pending_events,
1405         }
1406 }
1407
1408 extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::util::events::EventHandler) {
1409         <nativeChannelManager as lightning::util::events::EventsProvider<>>::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler)
1410 }
1411
1412 impl From<nativeChannelManager> for crate::lightning::chain::Listen {
1413         fn from(obj: nativeChannelManager) -> Self {
1414                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1415                 let mut ret = ChannelManager_as_Listen(&rust_obj);
1416                 // 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
1417                 rust_obj.inner = std::ptr::null_mut();
1418                 ret.free = Some(ChannelManager_free_void);
1419                 ret
1420         }
1421 }
1422 /// Constructs a new Listen which calls the relevant methods on this_arg.
1423 /// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
1424 #[no_mangle]
1425 pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate::lightning::chain::Listen {
1426         crate::lightning::chain::Listen {
1427                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1428                 free: None,
1429                 block_connected: ChannelManager_Listen_block_connected,
1430                 block_disconnected: ChannelManager_Listen_block_disconnected,
1431         }
1432 }
1433
1434 extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) {
1435         <nativeChannelManager as lightning::chain::Listen<>>::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height)
1436 }
1437 extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
1438         <nativeChannelManager as lightning::chain::Listen<>>::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
1439 }
1440
1441 impl From<nativeChannelManager> for crate::lightning::chain::Confirm {
1442         fn from(obj: nativeChannelManager) -> Self {
1443                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1444                 let mut ret = ChannelManager_as_Confirm(&rust_obj);
1445                 // 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
1446                 rust_obj.inner = std::ptr::null_mut();
1447                 ret.free = Some(ChannelManager_free_void);
1448                 ret
1449         }
1450 }
1451 /// Constructs a new Confirm which calls the relevant methods on this_arg.
1452 /// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
1453 #[no_mangle]
1454 pub extern "C" fn ChannelManager_as_Confirm(this_arg: &ChannelManager) -> crate::lightning::chain::Confirm {
1455         crate::lightning::chain::Confirm {
1456                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1457                 free: None,
1458                 transactions_confirmed: ChannelManager_Confirm_transactions_confirmed,
1459                 transaction_unconfirmed: ChannelManager_Confirm_transaction_unconfirmed,
1460                 best_block_updated: ChannelManager_Confirm_best_block_updated,
1461                 get_relevant_txids: ChannelManager_Confirm_get_relevant_txids,
1462         }
1463 }
1464
1465 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) {
1466         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 }); };
1467         <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)
1468 }
1469 extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
1470         <nativeChannelManager as lightning::chain::Confirm<>>::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
1471 }
1472 #[must_use]
1473 extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_TxidZ {
1474         let mut ret = <nativeChannelManager as lightning::chain::Confirm<>>::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
1475         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); };
1476         local_ret.into()
1477 }
1478 extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) {
1479         <nativeChannelManager as lightning::chain::Confirm<>>::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap())
1480 }
1481
1482 /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
1483 /// indicating whether persistence is necessary. Only one listener on
1484 /// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
1485 /// up.
1486 /// Note that the feature `allow_wallclock_use` must be enabled to use this function.
1487 #[must_use]
1488 #[no_mangle]
1489 pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &ChannelManager, mut max_wait: u64) -> bool {
1490         let mut ret = unsafe { &*this_arg.inner }.await_persistable_update_timeout(std::time::Duration::from_secs(max_wait));
1491         ret
1492 }
1493
1494 /// Blocks until ChannelManager needs to be persisted. Only one listener on
1495 /// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
1496 /// up.
1497 #[no_mangle]
1498 pub extern "C" fn ChannelManager_await_persistable_update(this_arg: &ChannelManager) {
1499         unsafe { &*this_arg.inner }.await_persistable_update()
1500 }
1501
1502 /// Gets the latest best block which was connected either via the [`chain::Listen`] or
1503 /// [`chain::Confirm`] interfaces.
1504 #[must_use]
1505 #[no_mangle]
1506 pub extern "C" fn ChannelManager_current_best_block(this_arg: &ChannelManager) -> crate::lightning::chain::BestBlock {
1507         let mut ret = unsafe { &*this_arg.inner }.current_best_block();
1508         crate::lightning::chain::BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1509 }
1510
1511 impl From<nativeChannelManager> for crate::lightning::ln::msgs::ChannelMessageHandler {
1512         fn from(obj: nativeChannelManager) -> Self {
1513                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1514                 let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj);
1515                 // 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
1516                 rust_obj.inner = std::ptr::null_mut();
1517                 ret.free = Some(ChannelManager_free_void);
1518                 ret
1519         }
1520 }
1521 /// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
1522 /// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
1523 #[no_mangle]
1524 pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelManager) -> crate::lightning::ln::msgs::ChannelMessageHandler {
1525         crate::lightning::ln::msgs::ChannelMessageHandler {
1526                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1527                 free: None,
1528                 handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel,
1529                 handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel,
1530                 handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created,
1531                 handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed,
1532                 handle_funding_locked: ChannelManager_ChannelMessageHandler_handle_funding_locked,
1533                 handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown,
1534                 handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed,
1535                 handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc,
1536                 handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc,
1537                 handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc,
1538                 handle_update_fail_malformed_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc,
1539                 handle_commitment_signed: ChannelManager_ChannelMessageHandler_handle_commitment_signed,
1540                 handle_revoke_and_ack: ChannelManager_ChannelMessageHandler_handle_revoke_and_ack,
1541                 handle_update_fee: ChannelManager_ChannelMessageHandler_handle_update_fee,
1542                 handle_announcement_signatures: ChannelManager_ChannelMessageHandler_handle_announcement_signatures,
1543                 peer_disconnected: ChannelManager_ChannelMessageHandler_peer_disconnected,
1544                 peer_connected: ChannelManager_ChannelMessageHandler_peer_connected,
1545                 handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish,
1546                 handle_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update,
1547                 handle_error: ChannelManager_ChannelMessageHandler_handle_error,
1548                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
1549                         this_arg: unsafe { (*this_arg).inner as *mut c_void },
1550                         free: None,
1551                         get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
1552                 },
1553         }
1554 }
1555
1556 extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::OpenChannel) {
1557         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner })
1558 }
1559 extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::AcceptChannel) {
1560         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_inner()) }, unsafe { &*msg.inner })
1561 }
1562 extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) {
1563         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1564 }
1565 extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) {
1566         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1567 }
1568 extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingLocked) {
1569         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_locked(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1570 }
1571 extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, their_features: &crate::lightning::ln::features::InitFeatures, msg: &crate::lightning::ln::msgs::Shutdown) {
1572         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*their_features.inner }, unsafe { &*msg.inner })
1573 }
1574 extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) {
1575         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1576 }
1577 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) {
1578         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1579 }
1580 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) {
1581         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1582 }
1583 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) {
1584         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1585 }
1586 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) {
1587         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1588 }
1589 extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) {
1590         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1591 }
1592 extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) {
1593         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1594 }
1595 extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) {
1596         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1597 }
1598 extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) {
1599         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1600 }
1601 extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) {
1602         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1603 }
1604 extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) {
1605         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1606 }
1607 extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
1608         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), no_connection_possible)
1609 }
1610 extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, init_msg: &crate::lightning::ln::msgs::Init) {
1611         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*init_msg.inner })
1612 }
1613 extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) {
1614         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1615 }
1616
1617 #[no_mangle]
1618 /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
1619 pub extern "C" fn ChannelManager_write(obj: &ChannelManager) -> crate::c_types::derived::CVec_u8Z {
1620         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1621 }
1622 #[no_mangle]
1623 pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1624         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) })
1625 }
1626
1627 use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport;
1628 type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::keysinterface::Sign, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::chain::keysinterface::KeysInterface, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::util::logger::Logger>;
1629
1630 /// Arguments for the creation of a ChannelManager that are not deserialized.
1631 ///
1632 /// At a high-level, the process for deserializing a ChannelManager and resuming normal operation
1633 /// is:
1634 /// 1) Deserialize all stored ChannelMonitors.
1635 /// 2) Deserialize the ChannelManager by filling in this struct and calling:
1636 ///    <(BlockHash, ChannelManager)>::read(reader, args)
1637 ///    This may result in closing some Channels if the ChannelMonitor is newer than the stored
1638 ///    ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
1639 /// 3) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same
1640 ///    way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and
1641 ///    ChannelMonitor::get_funding_txo().
1642 /// 4) Reconnect blocks on your ChannelMonitors.
1643 /// 5) Disconnect/connect blocks on the ChannelManager.
1644 /// 6) Move the ChannelMonitors into your local chain::Watch.
1645 ///
1646 /// Note that the ordering of #4-6 is not of importance, however all three must occur before you
1647 /// call any other methods on the newly-deserialized ChannelManager.
1648 ///
1649 /// Note that because some channels may be closed during deserialization, it is critical that you
1650 /// always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
1651 /// you. If you deserialize an old ChannelManager (during which force-closure transactions may be
1652 /// broadcast), and then later deserialize a newer version of the same ChannelManager (which will
1653 /// not force-close the same channels but consider them live), you may end up revoking a state for
1654 /// which you've already broadcasted the transaction.
1655 #[must_use]
1656 #[repr(C)]
1657 pub struct ChannelManagerReadArgs {
1658         /// A pointer to the opaque Rust object.
1659
1660         /// Nearly everywhere, inner must be non-null, however in places where
1661         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1662         pub inner: *mut nativeChannelManagerReadArgs,
1663         /// Indicates that this is the only struct which contains the same pointer.
1664
1665         /// Rust functions which take ownership of an object provided via an argument require
1666         /// this to be true and invalidate the object pointed to by inner.
1667         pub is_owned: bool,
1668 }
1669
1670 impl Drop for ChannelManagerReadArgs {
1671         fn drop(&mut self) {
1672                 if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) {
1673                         let _ = unsafe { Box::from_raw(self.inner) };
1674                 }
1675         }
1676 }
1677 /// Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL.
1678 #[no_mangle]
1679 pub extern "C" fn ChannelManagerReadArgs_free(this_obj: ChannelManagerReadArgs) { }
1680 #[allow(unused)]
1681 /// Used only if an object of this type is returned as a trait impl by a method
1682 extern "C" fn ChannelManagerReadArgs_free_void(this_ptr: *mut c_void) {
1683         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelManagerReadArgs); }
1684 }
1685 #[allow(unused)]
1686 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1687 impl ChannelManagerReadArgs {
1688         pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs {
1689                 assert!(self.is_owned);
1690                 let ret = self.inner;
1691                 self.inner = std::ptr::null_mut();
1692                 ret
1693         }
1694 }
1695 /// The keys provider which will give us relevant keys. Some keys will be loaded during
1696 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
1697 /// signing data.
1698 #[no_mangle]
1699 pub extern "C" fn ChannelManagerReadArgs_get_keys_manager(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::KeysInterface {
1700         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.keys_manager;
1701         inner_val
1702 }
1703 /// The keys provider which will give us relevant keys. Some keys will be loaded during
1704 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
1705 /// signing data.
1706 #[no_mangle]
1707 pub extern "C" fn ChannelManagerReadArgs_set_keys_manager(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::KeysInterface) {
1708         unsafe { &mut *this_ptr.inner }.keys_manager = val;
1709 }
1710 /// The fee_estimator for use in the ChannelManager in the future.
1711 ///
1712 /// No calls to the FeeEstimator will be made during deserialization.
1713 #[no_mangle]
1714 pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::FeeEstimator {
1715         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_estimator;
1716         inner_val
1717 }
1718 /// The fee_estimator for use in the ChannelManager in the future.
1719 ///
1720 /// No calls to the FeeEstimator will be made during deserialization.
1721 #[no_mangle]
1722 pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::FeeEstimator) {
1723         unsafe { &mut *this_ptr.inner }.fee_estimator = val;
1724 }
1725 /// The chain::Watch for use in the ChannelManager in the future.
1726 ///
1727 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
1728 /// you have deserialized ChannelMonitors separately and will add them to your
1729 /// chain::Watch after deserializing this ChannelManager.
1730 #[no_mangle]
1731 pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::Watch {
1732         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_monitor;
1733         inner_val
1734 }
1735 /// The chain::Watch for use in the ChannelManager in the future.
1736 ///
1737 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
1738 /// you have deserialized ChannelMonitors separately and will add them to your
1739 /// chain::Watch after deserializing this ChannelManager.
1740 #[no_mangle]
1741 pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::Watch) {
1742         unsafe { &mut *this_ptr.inner }.chain_monitor = val;
1743 }
1744 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
1745 /// used to broadcast the latest local commitment transactions of channels which must be
1746 /// force-closed during deserialization.
1747 #[no_mangle]
1748 pub extern "C" fn ChannelManagerReadArgs_get_tx_broadcaster(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::BroadcasterInterface {
1749         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.tx_broadcaster;
1750         inner_val
1751 }
1752 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
1753 /// used to broadcast the latest local commitment transactions of channels which must be
1754 /// force-closed during deserialization.
1755 #[no_mangle]
1756 pub extern "C" fn ChannelManagerReadArgs_set_tx_broadcaster(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::BroadcasterInterface) {
1757         unsafe { &mut *this_ptr.inner }.tx_broadcaster = val;
1758 }
1759 /// The Logger for use in the ChannelManager and which may be used to log information during
1760 /// deserialization.
1761 #[no_mangle]
1762 pub extern "C" fn ChannelManagerReadArgs_get_logger(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::util::logger::Logger {
1763         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.logger;
1764         inner_val
1765 }
1766 /// The Logger for use in the ChannelManager and which may be used to log information during
1767 /// deserialization.
1768 #[no_mangle]
1769 pub extern "C" fn ChannelManagerReadArgs_set_logger(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::logger::Logger) {
1770         unsafe { &mut *this_ptr.inner }.logger = val;
1771 }
1772 /// Default settings used for new channels. Any existing channels will continue to use the
1773 /// runtime settings which were stored when the ChannelManager was serialized.
1774 #[no_mangle]
1775 pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelManagerReadArgs) -> crate::lightning::util::config::UserConfig {
1776         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.default_config;
1777         crate::lightning::util::config::UserConfig { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
1778 }
1779 /// Default settings used for new channels. Any existing channels will continue to use the
1780 /// runtime settings which were stored when the ChannelManager was serialized.
1781 #[no_mangle]
1782 pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::config::UserConfig) {
1783         unsafe { &mut *this_ptr.inner }.default_config = *unsafe { Box::from_raw(val.take_inner()) };
1784 }
1785 /// Simple utility function to create a ChannelManagerReadArgs which creates the monitor
1786 /// HashMap for you. This is primarily useful for C bindings where it is not practical to
1787 /// populate a HashMap directly from C.
1788 #[must_use]
1789 #[no_mangle]
1790 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) -> ChannelManagerReadArgs {
1791         let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { unsafe { &mut *item.inner } }); };
1792         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);
1793         ChannelManagerReadArgs { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1794 }
1795
1796 #[no_mangle]
1797 /// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
1798 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 {
1799         let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) };
1800         let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager<crate::lightning::chain::keysinterface::Sign, 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);
1801         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: Box::into_raw(Box::new(orig_res_0_1)), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
1802         local_res
1803 }