Merge pull request #18 from TheBlueMatt/2021-04-invoice-incl
[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::ln::channelmanager::BestBlock {
170         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.best_block;
171         crate::lightning::ln::channelmanager::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::ln::channelmanager::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::ln::channelmanager::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
190 use lightning::ln::channelmanager::BestBlock as nativeBestBlockImport;
191 type nativeBestBlock = nativeBestBlockImport;
192
193 /// The best known block as identified by its hash and height.
194 #[must_use]
195 #[repr(C)]
196 pub struct BestBlock {
197         /// A pointer to the opaque Rust object.
198
199         /// Nearly everywhere, inner must be non-null, however in places where
200         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
201         pub inner: *mut nativeBestBlock,
202         /// Indicates that this is the only struct which contains the same pointer.
203
204         /// Rust functions which take ownership of an object provided via an argument require
205         /// this to be true and invalidate the object pointed to by inner.
206         pub is_owned: bool,
207 }
208
209 impl Drop for BestBlock {
210         fn drop(&mut self) {
211                 if self.is_owned && !<*mut nativeBestBlock>::is_null(self.inner) {
212                         let _ = unsafe { Box::from_raw(self.inner) };
213                 }
214         }
215 }
216 /// Frees any resources used by the BestBlock, if is_owned is set and inner is non-NULL.
217 #[no_mangle]
218 pub extern "C" fn BestBlock_free(this_obj: BestBlock) { }
219 #[allow(unused)]
220 /// Used only if an object of this type is returned as a trait impl by a method
221 extern "C" fn BestBlock_free_void(this_ptr: *mut c_void) {
222         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBestBlock); }
223 }
224 #[allow(unused)]
225 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
226 impl BestBlock {
227         pub(crate) fn take_inner(mut self) -> *mut nativeBestBlock {
228                 assert!(self.is_owned);
229                 let ret = self.inner;
230                 self.inner = std::ptr::null_mut();
231                 ret
232         }
233 }
234 impl Clone for BestBlock {
235         fn clone(&self) -> Self {
236                 Self {
237                         inner: if <*mut nativeBestBlock>::is_null(self.inner) { std::ptr::null_mut() } else {
238                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
239                         is_owned: true,
240                 }
241         }
242 }
243 #[allow(unused)]
244 /// Used only if an object of this type is returned as a trait impl by a method
245 pub(crate) extern "C" fn BestBlock_clone_void(this_ptr: *const c_void) -> *mut c_void {
246         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeBestBlock)).clone() })) as *mut c_void
247 }
248 #[no_mangle]
249 /// Creates a copy of the BestBlock
250 pub extern "C" fn BestBlock_clone(orig: &BestBlock) -> BestBlock {
251         orig.clone()
252 }
253 /// Returns the best block from the genesis of the given network.
254 #[must_use]
255 #[no_mangle]
256 pub extern "C" fn BestBlock_from_genesis(mut network: crate::bitcoin::network::Network) -> BestBlock {
257         let mut ret = lightning::ln::channelmanager::BestBlock::from_genesis(network.into_bitcoin());
258         BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true }
259 }
260
261 /// Returns the best block as identified by the given block hash and height.
262 #[must_use]
263 #[no_mangle]
264 pub extern "C" fn BestBlock_new(mut block_hash: crate::c_types::ThirtyTwoBytes, mut height: u32) -> BestBlock {
265         let mut ret = lightning::ln::channelmanager::BestBlock::new(::bitcoin::hash_types::BlockHash::from_slice(&block_hash.data[..]).unwrap(), height);
266         BestBlock { inner: Box::into_raw(Box::new(ret)), is_owned: true }
267 }
268
269 /// Returns the best block hash.
270 #[must_use]
271 #[no_mangle]
272 pub extern "C" fn BestBlock_block_hash(this_arg: &BestBlock) -> crate::c_types::ThirtyTwoBytes {
273         let mut ret = unsafe { &*this_arg.inner }.block_hash();
274         crate::c_types::ThirtyTwoBytes { data: ret.into_inner() }
275 }
276
277 /// Returns the best block height.
278 #[must_use]
279 #[no_mangle]
280 pub extern "C" fn BestBlock_height(this_arg: &BestBlock) -> u32 {
281         let mut ret = unsafe { &*this_arg.inner }.height();
282         ret
283 }
284
285 /// The amount of time in blocks we require our counterparty wait to claim their money (ie time
286 /// between when we, or our watchtower, must check for them having broadcast a theft transaction).
287 ///
288 /// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
289 ///
290 /// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
291
292 #[no_mangle]
293 pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT;
294 /// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
295 /// HTLC's CLTV. The current default represents roughly six hours of blocks at six blocks/hour.
296 ///
297 /// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`]
298 ///
299 /// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta
300
301 #[no_mangle]
302 pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA;
303 /// Minimum CLTV difference between the current block height and received inbound payments.
304 /// Invoices generated for payment to us must set their `min_final_cltv_expiry` field to at least
305 /// this value.
306
307 #[no_mangle]
308 pub static MIN_FINAL_CLTV_EXPIRY: u32 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY;
309
310 use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport;
311 type nativeChannelDetails = nativeChannelDetailsImport;
312
313 /// Details of a channel, as returned by ChannelManager::list_channels and ChannelManager::list_usable_channels
314 #[must_use]
315 #[repr(C)]
316 pub struct ChannelDetails {
317         /// A pointer to the opaque Rust object.
318
319         /// Nearly everywhere, inner must be non-null, however in places where
320         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
321         pub inner: *mut nativeChannelDetails,
322         /// Indicates that this is the only struct which contains the same pointer.
323
324         /// Rust functions which take ownership of an object provided via an argument require
325         /// this to be true and invalidate the object pointed to by inner.
326         pub is_owned: bool,
327 }
328
329 impl Drop for ChannelDetails {
330         fn drop(&mut self) {
331                 if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) {
332                         let _ = unsafe { Box::from_raw(self.inner) };
333                 }
334         }
335 }
336 /// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
337 #[no_mangle]
338 pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
339 #[allow(unused)]
340 /// Used only if an object of this type is returned as a trait impl by a method
341 extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
342         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelDetails); }
343 }
344 #[allow(unused)]
345 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
346 impl ChannelDetails {
347         pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
348                 assert!(self.is_owned);
349                 let ret = self.inner;
350                 self.inner = std::ptr::null_mut();
351                 ret
352         }
353 }
354 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
355 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
356 /// Note that this means this value is *not* persistent - it can change once during the
357 /// lifetime of the channel.
358 #[no_mangle]
359 pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] {
360         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id;
361         inner_val
362 }
363 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
364 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
365 /// Note that this means this value is *not* persistent - it can change once during the
366 /// lifetime of the channel.
367 #[no_mangle]
368 pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
369         unsafe { &mut *this_ptr.inner }.channel_id = val.data;
370 }
371 /// The position of the funding transaction in the chain. None if the funding transaction has
372 /// not yet been confirmed and the channel fully opened.
373 #[no_mangle]
374 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
375         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id;
376         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()) } };
377         local_inner_val
378 }
379 /// The position of the funding transaction in the chain. None if the funding transaction has
380 /// not yet been confirmed and the channel fully opened.
381 #[no_mangle]
382 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
383         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
384         unsafe { &mut *this_ptr.inner }.short_channel_id = local_val;
385 }
386 /// The node_id of our counterparty
387 #[no_mangle]
388 pub extern "C" fn ChannelDetails_get_remote_network_id(this_ptr: &ChannelDetails) -> crate::c_types::PublicKey {
389         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.remote_network_id;
390         crate::c_types::PublicKey::from_rust(&inner_val)
391 }
392 /// The node_id of our counterparty
393 #[no_mangle]
394 pub extern "C" fn ChannelDetails_set_remote_network_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::PublicKey) {
395         unsafe { &mut *this_ptr.inner }.remote_network_id = val.into_rust();
396 }
397 /// The Features the channel counterparty provided upon last connection.
398 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
399 /// many routing-relevant features are present in the init context.
400 #[no_mangle]
401 pub extern "C" fn ChannelDetails_get_counterparty_features(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::InitFeatures {
402         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.counterparty_features;
403         crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
404 }
405 /// The Features the channel counterparty provided upon last connection.
406 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
407 /// many routing-relevant features are present in the init context.
408 #[no_mangle]
409 pub extern "C" fn ChannelDetails_set_counterparty_features(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::InitFeatures) {
410         unsafe { &mut *this_ptr.inner }.counterparty_features = *unsafe { Box::from_raw(val.take_inner()) };
411 }
412 /// The value, in satoshis, of this channel as appears in the funding output
413 #[no_mangle]
414 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
415         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis;
416         *inner_val
417 }
418 /// The value, in satoshis, of this channel as appears in the funding output
419 #[no_mangle]
420 pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
421         unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val;
422 }
423 /// The user_id passed in to create_channel, or 0 if the channel was inbound.
424 #[no_mangle]
425 pub extern "C" fn ChannelDetails_get_user_id(this_ptr: &ChannelDetails) -> u64 {
426         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.user_id;
427         *inner_val
428 }
429 /// The user_id passed in to create_channel, or 0 if the channel was inbound.
430 #[no_mangle]
431 pub extern "C" fn ChannelDetails_set_user_id(this_ptr: &mut ChannelDetails, mut val: u64) {
432         unsafe { &mut *this_ptr.inner }.user_id = val;
433 }
434 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
435 /// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
436 /// available for inclusion in new outbound HTLCs). This further does not include any pending
437 /// outgoing HTLCs which are awaiting some other resolution to be sent.
438 #[no_mangle]
439 pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
440         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outbound_capacity_msat;
441         *inner_val
442 }
443 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
444 /// any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
445 /// available for inclusion in new outbound HTLCs). This further does not include any pending
446 /// outgoing HTLCs which are awaiting some other resolution to be sent.
447 #[no_mangle]
448 pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
449         unsafe { &mut *this_ptr.inner }.outbound_capacity_msat = val;
450 }
451 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
452 /// include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
453 /// available for inclusion in new inbound HTLCs).
454 /// Note that there are some corner cases not fully handled here, so the actual available
455 /// inbound capacity may be slightly higher than this.
456 #[no_mangle]
457 pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
458         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.inbound_capacity_msat;
459         *inner_val
460 }
461 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
462 /// include any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not
463 /// available for inclusion in new inbound HTLCs).
464 /// Note that there are some corner cases not fully handled here, so the actual available
465 /// inbound capacity may be slightly higher than this.
466 #[no_mangle]
467 pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
468         unsafe { &mut *this_ptr.inner }.inbound_capacity_msat = val;
469 }
470 /// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
471 /// the peer is connected, and (c) no monitor update failure is pending resolution.
472 #[no_mangle]
473 pub extern "C" fn ChannelDetails_get_is_live(this_ptr: &ChannelDetails) -> bool {
474         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.is_live;
475         *inner_val
476 }
477 /// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
478 /// the peer is connected, and (c) no monitor update failure is pending resolution.
479 #[no_mangle]
480 pub extern "C" fn ChannelDetails_set_is_live(this_ptr: &mut ChannelDetails, mut val: bool) {
481         unsafe { &mut *this_ptr.inner }.is_live = val;
482 }
483 impl Clone for ChannelDetails {
484         fn clone(&self) -> Self {
485                 Self {
486                         inner: if <*mut nativeChannelDetails>::is_null(self.inner) { std::ptr::null_mut() } else {
487                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
488                         is_owned: true,
489                 }
490         }
491 }
492 #[allow(unused)]
493 /// Used only if an object of this type is returned as a trait impl by a method
494 pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
495         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDetails)).clone() })) as *mut c_void
496 }
497 #[no_mangle]
498 /// Creates a copy of the ChannelDetails
499 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
500         orig.clone()
501 }
502 /// If a payment fails to send, it can be in one of several states. This enum is returned as the
503 /// Err() type describing which state the payment is in, see the description of individual enum
504 /// states for more.
505 #[must_use]
506 #[derive(Clone)]
507 #[repr(C)]
508 pub enum PaymentSendFailure {
509         /// A parameter which was passed to send_payment was invalid, preventing us from attempting to
510         /// send the payment at all. No channel state has been changed or messages sent to peers, and
511         /// once you've changed the parameter at error, you can freely retry the payment in full.
512         ParameterError(crate::lightning::util::errors::APIError),
513         /// A parameter in a single path which was passed to send_payment was invalid, preventing us
514         /// from attempting to send the payment at all. No channel state has been changed or messages
515         /// sent to peers, and once you've changed the parameter at error, you can freely retry the
516         /// payment in full.
517         ///
518         /// The results here are ordered the same as the paths in the route object which was passed to
519         /// send_payment.
520         PathParameterError(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
521         /// All paths which were attempted failed to send, with no channel state change taking place.
522         /// You can freely retry the payment in full (though you probably want to do so over different
523         /// paths than the ones selected).
524         AllFailedRetrySafe(crate::c_types::derived::CVec_APIErrorZ),
525         /// Some paths which were attempted failed to send, though possibly not all. At least some
526         /// paths have irrevocably committed to the HTLC and retrying the payment in full would result
527         /// in over-/re-payment.
528         ///
529         /// The results here are ordered the same as the paths in the route object which was passed to
530         /// send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely
531         /// retried (though there is currently no API with which to do so).
532         ///
533         /// Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried
534         /// as they will result in over-/re-payment. These HTLCs all either successfully sent (in the
535         /// case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel
536         /// with the latest update_id.
537         PartialFailure(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
538 }
539 use lightning::ln::channelmanager::PaymentSendFailure as nativePaymentSendFailure;
540 impl PaymentSendFailure {
541         #[allow(unused)]
542         pub(crate) fn to_native(&self) -> nativePaymentSendFailure {
543                 match self {
544                         PaymentSendFailure::ParameterError (ref a, ) => {
545                                 let mut a_nonref = (*a).clone();
546                                 nativePaymentSendFailure::ParameterError (
547                                         a_nonref.into_native(),
548                                 )
549                         },
550                         PaymentSendFailure::PathParameterError (ref a, ) => {
551                                 let mut a_nonref = (*a).clone();
552                                 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 }); };
553                                 nativePaymentSendFailure::PathParameterError (
554                                         local_a_nonref,
555                                 )
556                         },
557                         PaymentSendFailure::AllFailedRetrySafe (ref a, ) => {
558                                 let mut a_nonref = (*a).clone();
559                                 let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into_native() }); };
560                                 nativePaymentSendFailure::AllFailedRetrySafe (
561                                         local_a_nonref,
562                                 )
563                         },
564                         PaymentSendFailure::PartialFailure (ref a, ) => {
565                                 let mut a_nonref = (*a).clone();
566                                 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 }); };
567                                 nativePaymentSendFailure::PartialFailure (
568                                         local_a_nonref,
569                                 )
570                         },
571                 }
572         }
573         #[allow(unused)]
574         pub(crate) fn into_native(self) -> nativePaymentSendFailure {
575                 match self {
576                         PaymentSendFailure::ParameterError (mut a, ) => {
577                                 nativePaymentSendFailure::ParameterError (
578                                         a.into_native(),
579                                 )
580                         },
581                         PaymentSendFailure::PathParameterError (mut a, ) => {
582                                 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 }); };
583                                 nativePaymentSendFailure::PathParameterError (
584                                         local_a,
585                                 )
586                         },
587                         PaymentSendFailure::AllFailedRetrySafe (mut a, ) => {
588                                 let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into_native() }); };
589                                 nativePaymentSendFailure::AllFailedRetrySafe (
590                                         local_a,
591                                 )
592                         },
593                         PaymentSendFailure::PartialFailure (mut a, ) => {
594                                 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 }); };
595                                 nativePaymentSendFailure::PartialFailure (
596                                         local_a,
597                                 )
598                         },
599                 }
600         }
601         #[allow(unused)]
602         pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self {
603                 match native {
604                         nativePaymentSendFailure::ParameterError (ref a, ) => {
605                                 let mut a_nonref = (*a).clone();
606                                 PaymentSendFailure::ParameterError (
607                                         crate::lightning::util::errors::APIError::native_into(a_nonref),
608                                 )
609                         },
610                         nativePaymentSendFailure::PathParameterError (ref a, ) => {
611                                 let mut a_nonref = (*a).clone();
612                                 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( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); };
613                                 PaymentSendFailure::PathParameterError (
614                                         local_a_nonref.into(),
615                                 )
616                         },
617                         nativePaymentSendFailure::AllFailedRetrySafe (ref a, ) => {
618                                 let mut a_nonref = (*a).clone();
619                                 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) }); };
620                                 PaymentSendFailure::AllFailedRetrySafe (
621                                         local_a_nonref.into(),
622                                 )
623                         },
624                         nativePaymentSendFailure::PartialFailure (ref a, ) => {
625                                 let mut a_nonref = (*a).clone();
626                                 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( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); };
627                                 PaymentSendFailure::PartialFailure (
628                                         local_a_nonref.into(),
629                                 )
630                         },
631                 }
632         }
633         #[allow(unused)]
634         pub(crate) fn native_into(native: nativePaymentSendFailure) -> Self {
635                 match native {
636                         nativePaymentSendFailure::ParameterError (mut a, ) => {
637                                 PaymentSendFailure::ParameterError (
638                                         crate::lightning::util::errors::APIError::native_into(a),
639                                 )
640                         },
641                         nativePaymentSendFailure::PathParameterError (mut a, ) => {
642                                 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( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); };
643                                 PaymentSendFailure::PathParameterError (
644                                         local_a.into(),
645                                 )
646                         },
647                         nativePaymentSendFailure::AllFailedRetrySafe (mut a, ) => {
648                                 let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::lightning::util::errors::APIError::native_into(item) }); };
649                                 PaymentSendFailure::AllFailedRetrySafe (
650                                         local_a.into(),
651                                 )
652                         },
653                         nativePaymentSendFailure::PartialFailure (mut a, ) => {
654                                 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( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); };
655                                 PaymentSendFailure::PartialFailure (
656                                         local_a.into(),
657                                 )
658                         },
659                 }
660         }
661 }
662 /// Frees any resources used by the PaymentSendFailure
663 #[no_mangle]
664 pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { }
665 /// Creates a copy of the PaymentSendFailure
666 #[no_mangle]
667 pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure {
668         orig.clone()
669 }
670 /// Constructs a new ChannelManager to hold several channels and route between them.
671 ///
672 /// This is the main \"logic hub\" for all channel-related actions, and implements
673 /// ChannelMessageHandler.
674 ///
675 /// Non-proportional fees are fixed according to our risk using the provided fee estimator.
676 ///
677 /// panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
678 ///
679 /// Users need to notify the new ChannelManager when a new block is connected or
680 /// disconnected using its `block_connected` and `block_disconnected` methods, starting
681 /// from after `params.latest_hash`.
682 #[must_use]
683 #[no_mangle]
684 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 {
685         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()) });
686         ChannelManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
687 }
688
689 /// Gets the current configuration applied to all new channels,  as
690 #[must_use]
691 #[no_mangle]
692 pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &ChannelManager) -> crate::lightning::util::config::UserConfig {
693         let mut ret = unsafe { &*this_arg.inner }.get_current_default_configuration();
694         crate::lightning::util::config::UserConfig { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
695 }
696
697 /// Creates a new outbound channel to the given remote node and with the given value.
698 ///
699 /// user_id will be provided back as user_channel_id in FundingGenerationReady events to allow
700 /// tracking of which events correspond with which create_channel call. Note that the
701 /// user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for
702 /// user_id here. user_id has no meaning inside of LDK, it is simply copied to events and
703 /// otherwise ignored.
704 ///
705 /// If successful, will generate a SendOpenChannel message event, so you should probably poll
706 /// PeerManager::process_events afterwards.
707 ///
708 /// Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
709 /// greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
710 #[must_use]
711 #[no_mangle]
712 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 {
713         let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) };
714         let mut ret = unsafe { &*this_arg.inner }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_id, local_override_config);
715         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
716         local_ret
717 }
718
719 /// Gets the list of open channels, in random order. See ChannelDetail field documentation for
720 /// more information.
721 #[must_use]
722 #[no_mangle]
723 pub extern "C" fn ChannelManager_list_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
724         let mut ret = unsafe { &*this_arg.inner }.list_channels();
725         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 } }); };
726         local_ret.into()
727 }
728
729 /// Gets the list of usable channels, in random order. Useful as an argument to
730 /// get_route to ensure non-announced channels are used.
731 ///
732 /// These are guaranteed to have their is_live value set to true, see the documentation for
733 /// ChannelDetails::is_live for more info on exactly what the criteria are.
734 #[must_use]
735 #[no_mangle]
736 pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
737         let mut ret = unsafe { &*this_arg.inner }.list_usable_channels();
738         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 } }); };
739         local_ret.into()
740 }
741
742 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
743 /// will be accepted on the given channel, and after additional timeout/the closing of all
744 /// pending HTLCs, the channel will be closed on chain.
745 ///
746 /// May generate a SendShutdown message event on success, which should be relayed.
747 #[must_use]
748 #[no_mangle]
749 pub extern "C" fn ChannelManager_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
750         let mut ret = unsafe { &*this_arg.inner }.close_channel(unsafe { &*channel_id});
751         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
752         local_ret
753 }
754
755 /// Force closes a channel, immediately broadcasting the latest local commitment transaction to
756 /// the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager.
757 #[must_use]
758 #[no_mangle]
759 pub extern "C" fn ChannelManager_force_close_channel(this_arg: &ChannelManager, channel_id: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
760         let mut ret = unsafe { &*this_arg.inner }.force_close_channel(unsafe { &*channel_id});
761         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
762         local_ret
763 }
764
765 /// Force close all channels, immediately broadcasting the latest local commitment transaction
766 /// for each to the chain and rejecting new HTLCs on each.
767 #[no_mangle]
768 pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: &ChannelManager) {
769         unsafe { &*this_arg.inner }.force_close_all_channels()
770 }
771
772 /// Sends a payment along a given route.
773 ///
774 /// Value parameters are provided via the last hop in route, see documentation for RouteHop
775 /// fields for more info.
776 ///
777 /// Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
778 /// payment), we don't do anything to stop you! We always try to ensure that if the provided
779 /// next hop knows the preimage to payment_hash they can claim an additional amount as
780 /// specified in the last hop in the route! Thus, you should probably do your own
781 /// payment_preimage tracking (which you should already be doing as they represent \"proof of
782 /// payment\") and prevent double-sends yourself.
783 ///
784 /// May generate SendHTLCs message(s) event on success, which should be relayed.
785 ///
786 /// Each path may have a different return value, and PaymentSendValue may return a Vec with
787 /// each entry matching the corresponding-index entry in the route paths, see
788 /// PaymentSendFailure for more info.
789 ///
790 /// In general, a path may raise:
791 ///  * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
792 ///    node public key) is specified.
793 ///  * APIError::ChannelUnavailable if the next-hop channel is not available for updates
794 ///    (including due to previous monitor update failure or new permanent monitor update
795 ///    failure).
796 ///  * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
797 ///    relevant updates.
798 ///
799 /// Note that depending on the type of the PaymentSendFailure the HTLC may have been
800 /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
801 /// different route unless you intend to pay twice!
802 ///
803 /// payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
804 /// the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
805 /// newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
806 /// must not contain multiple paths as multi-path payments require a recipient-provided
807 /// payment_secret.
808 /// If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
809 /// bit set (either as required or as available). If multiple paths are present in the Route,
810 /// we assume the invoice had the basic_mpp feature set.
811 #[must_use]
812 #[no_mangle]
813 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 {
814         let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
815         let mut ret = unsafe { &*this_arg.inner }.send_payment(unsafe { &*route.inner }, ::lightning::ln::channelmanager::PaymentHash(payment_hash.data), &local_payment_secret);
816         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
817         local_ret
818 }
819
820 /// Call this upon creation of a funding transaction for the given channel.
821 ///
822 /// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
823 /// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
824 ///
825 /// Panics if a funding transaction has already been provided for this channel.
826 ///
827 /// May panic if the output found in the funding transaction is duplicative with some other
828 /// channel (note that this should be trivially prevented by using unique funding transaction
829 /// keys per-channel).
830 ///
831 /// Do NOT broadcast the funding transaction yourself. When we have safely received our
832 /// counterparty's signature the funding transaction will automatically be broadcast via the
833 /// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
834 ///
835 /// Note that this includes RBF or similar transaction replacement strategies - lightning does
836 /// not currently support replacing a funding transaction on an existing channel. Instead,
837 /// create a new channel with a conflicting funding transaction.
838 #[must_use]
839 #[no_mangle]
840 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 {
841         let mut ret = unsafe { &*this_arg.inner }.funding_transaction_generated(unsafe { &*temporary_channel_id}, funding_transaction.into_bitcoin());
842         let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
843         local_ret
844 }
845
846 /// Generates a signed node_announcement from the given arguments and creates a
847 /// BroadcastNodeAnnouncement event. Note that such messages will be ignored unless peers have
848 /// seen a channel_announcement from us (ie unless we have public channels open).
849 ///
850 /// RGB is a node \"color\" and alias is a printable human-readable string to describe this node
851 /// to humans. They carry no in-protocol meaning.
852 ///
853 /// addresses represent the set (possibly empty) of socket addresses on which this node accepts
854 /// incoming connections. These will be broadcast to the network, publicly tying these
855 /// addresses together. If you wish to preserve user privacy, addresses should likely contain
856 /// only Tor Onion addresses.
857 ///
858 /// Panics if addresses is absurdly large (more than 500).
859 #[no_mangle]
860 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) {
861         let mut local_addresses = Vec::new(); for mut item in addresses.into_rust().drain(..) { local_addresses.push( { item.into_native() }); };
862         unsafe { &*this_arg.inner }.broadcast_node_announcement(rgb.data, alias.data, local_addresses)
863 }
864
865 /// Processes HTLCs which are pending waiting on random forward delay.
866 ///
867 /// Should only really ever be called in response to a PendingHTLCsForwardable event.
868 /// Will likely generate further events.
869 #[no_mangle]
870 pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &ChannelManager) {
871         unsafe { &*this_arg.inner }.process_pending_htlc_forwards()
872 }
873
874 /// If a peer is disconnected we mark any channels with that peer as 'disabled'.
875 /// After some time, if channels are still disabled we need to broadcast a ChannelUpdate
876 /// to inform the network about the uselessness of these channels.
877 ///
878 /// This method handles all the details, and must be called roughly once per minute.
879 ///
880 /// Note that in some rare cases this may generate a `chain::Watch::update_channel` call.
881 #[no_mangle]
882 pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &ChannelManager) {
883         unsafe { &*this_arg.inner }.timer_tick_occurred()
884 }
885
886 /// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
887 /// after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
888 /// along the path (including in our own channel on which we received it).
889 /// Returns false if no payment was found to fail backwards, true if the process of failing the
890 /// HTLC backwards has been started.
891 #[must_use]
892 #[no_mangle]
893 pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, payment_hash: *const [u8; 32]) -> bool {
894         let mut ret = unsafe { &*this_arg.inner }.fail_htlc_backwards(&::lightning::ln::channelmanager::PaymentHash(unsafe { *payment_hash }));
895         ret
896 }
897
898 /// Provides a payment preimage in response to a PaymentReceived event, returning true and
899 /// generating message events for the net layer to claim the payment, if possible. Thus, you
900 /// should probably kick the net layer to go send messages if this returns true!
901 ///
902 /// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
903 /// [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived`
904 /// event matches your expectation. If you fail to do so and call this method, you may provide
905 /// the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
906 ///
907 /// May panic if called except in response to a PaymentReceived event.
908 ///
909 /// [`create_inbound_payment`]: Self::create_inbound_payment
910 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
911 #[must_use]
912 #[no_mangle]
913 pub extern "C" fn ChannelManager_claim_funds(this_arg: &ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) -> bool {
914         let mut ret = unsafe { &*this_arg.inner }.claim_funds(::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data));
915         ret
916 }
917
918 /// Gets the node_id held by this ChannelManager
919 #[must_use]
920 #[no_mangle]
921 pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> crate::c_types::PublicKey {
922         let mut ret = unsafe { &*this_arg.inner }.get_our_node_id();
923         crate::c_types::PublicKey::from_rust(&ret)
924 }
925
926 /// Restores a single, given channel to normal operation after a
927 /// ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update
928 /// operation.
929 ///
930 /// All ChannelMonitor updates up to and including highest_applied_update_id must have been
931 /// fully committed in every copy of the given channels' ChannelMonitors.
932 ///
933 /// Note that there is no effect to calling with a highest_applied_update_id other than the
934 /// current latest ChannelMonitorUpdate and one call to this function after multiple
935 /// ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field
936 /// exists largely only to prevent races between this and concurrent update_monitor calls.
937 ///
938 /// Thus, the anticipated use is, at a high level:
939 ///  1) You register a chain::Watch with this ChannelManager,
940 ///  2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
941 ///     said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
942 ///     any time it cannot do so instantly,
943 ///  3) update(s) are applied to each remote copy of a ChannelMonitor,
944 ///  4) once all remote copies are updated, you call this function with the update_id that
945 ///     completed, and once it is the latest the Channel will be re-enabled.
946 #[no_mangle]
947 pub extern "C" fn ChannelManager_channel_monitor_updated(this_arg: &ChannelManager, funding_txo: &crate::lightning::chain::transaction::OutPoint, mut highest_applied_update_id: u64) {
948         unsafe { &*this_arg.inner }.channel_monitor_updated(unsafe { &*funding_txo.inner }, highest_applied_update_id)
949 }
950
951 /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
952 /// to pay us.
953 ///
954 /// This differs from [`create_inbound_payment_for_hash`] only in that it generates the
955 /// [`PaymentHash`] and [`PaymentPreimage`] for you, returning the first and storing the second.
956 ///
957 /// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which
958 /// will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be
959 /// passed directly to [`claim_funds`].
960 ///
961 /// See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
962 ///
963 /// [`claim_funds`]: Self::claim_funds
964 /// [`PaymentReceived`]: events::Event::PaymentReceived
965 /// [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage
966 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
967 #[must_use]
968 #[no_mangle]
969 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 {
970         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
971         let mut ret = unsafe { &*this_arg.inner }.create_inbound_payment(local_min_value_msat, invoice_expiry_delta_secs, user_payment_id);
972         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();
973         local_ret
974 }
975
976 /// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
977 /// stored external to LDK.
978 ///
979 /// A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a
980 /// payment secret fetched via this method or [`create_inbound_payment`], and which is at least
981 /// the `min_value_msat` provided here, if one is provided.
982 ///
983 /// The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This
984 /// method may return an Err if another payment with the same payment_hash is still pending.
985 ///
986 /// `user_payment_id` will be provided back in [`PaymentReceived::user_payment_id`] events to
987 /// allow tracking of which events correspond with which calls to this and
988 /// [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply
989 /// copied to events and otherwise ignored. It may be used to correlate PaymentReceived events
990 /// with invoice metadata stored elsewhere.
991 ///
992 /// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
993 /// received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
994 /// before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
995 /// sender \"proof-of-payment\" unless they have paid the required amount.
996 ///
997 /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
998 /// in excess of the current time. This should roughly match the expiry time set in the invoice.
999 /// After this many seconds, we will remove the inbound payment, resulting in any attempts to
1000 /// pay the invoice failing. The BOLT spec suggests 7,200 secs as a default validity time for
1001 /// invoices when no timeout is set.
1002 ///
1003 /// Note that we use block header time to time-out pending inbound payments (with some margin
1004 /// to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
1005 /// accept a payment and generate a [`PaymentReceived`] event for some time after the expiry.
1006 /// If you need exact expiry semantics, you should enforce them upon receipt of
1007 /// [`PaymentReceived`].
1008 ///
1009 /// May panic if `invoice_expiry_delta_secs` is greater than one year.
1010 ///
1011 /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
1012 /// set to at least [`MIN_FINAL_CLTV_EXPIRY`].
1013 ///
1014 /// [`create_inbound_payment`]: Self::create_inbound_payment
1015 /// [`PaymentReceived`]: events::Event::PaymentReceived
1016 /// [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id
1017 #[must_use]
1018 #[no_mangle]
1019 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 {
1020         let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
1021         let mut ret = unsafe { &*this_arg.inner }.create_inbound_payment_for_hash(::lightning::ln::channelmanager::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs, user_payment_id);
1022         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() };
1023         local_ret
1024 }
1025
1026 impl From<nativeChannelManager> for crate::lightning::util::events::MessageSendEventsProvider {
1027         fn from(obj: nativeChannelManager) -> Self {
1028                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1029                 let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj);
1030                 // 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
1031                 rust_obj.inner = std::ptr::null_mut();
1032                 ret.free = Some(ChannelManager_free_void);
1033                 ret
1034         }
1035 }
1036 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
1037 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
1038 #[no_mangle]
1039 pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::MessageSendEventsProvider {
1040         crate::lightning::util::events::MessageSendEventsProvider {
1041                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1042                 free: None,
1043                 get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
1044         }
1045 }
1046
1047 #[must_use]
1048 extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
1049         let mut ret = <nativeChannelManager as lightning::util::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
1050         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::MessageSendEvent::native_into(item) }); };
1051         local_ret.into()
1052 }
1053
1054 impl From<nativeChannelManager> for crate::lightning::util::events::EventsProvider {
1055         fn from(obj: nativeChannelManager) -> Self {
1056                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1057                 let mut ret = ChannelManager_as_EventsProvider(&rust_obj);
1058                 // 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
1059                 rust_obj.inner = std::ptr::null_mut();
1060                 ret.free = Some(ChannelManager_free_void);
1061                 ret
1062         }
1063 }
1064 /// Constructs a new EventsProvider which calls the relevant methods on this_arg.
1065 /// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
1066 #[no_mangle]
1067 pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> crate::lightning::util::events::EventsProvider {
1068         crate::lightning::util::events::EventsProvider {
1069                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1070                 free: None,
1071                 get_and_clear_pending_events: ChannelManager_EventsProvider_get_and_clear_pending_events,
1072         }
1073 }
1074
1075 #[must_use]
1076 extern "C" fn ChannelManager_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
1077         let mut ret = <nativeChannelManager as lightning::util::events::EventsProvider<>>::get_and_clear_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
1078         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::events::Event::native_into(item) }); };
1079         local_ret.into()
1080 }
1081
1082 impl From<nativeChannelManager> for crate::lightning::chain::Listen {
1083         fn from(obj: nativeChannelManager) -> Self {
1084                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1085                 let mut ret = ChannelManager_as_Listen(&rust_obj);
1086                 // 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
1087                 rust_obj.inner = std::ptr::null_mut();
1088                 ret.free = Some(ChannelManager_free_void);
1089                 ret
1090         }
1091 }
1092 /// Constructs a new Listen which calls the relevant methods on this_arg.
1093 /// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
1094 #[no_mangle]
1095 pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate::lightning::chain::Listen {
1096         crate::lightning::chain::Listen {
1097                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1098                 free: None,
1099                 block_connected: ChannelManager_Listen_block_connected,
1100                 block_disconnected: ChannelManager_Listen_block_disconnected,
1101         }
1102 }
1103
1104 extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) {
1105         <nativeChannelManager as lightning::chain::Listen<>>::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height)
1106 }
1107 extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
1108         <nativeChannelManager as lightning::chain::Listen<>>::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
1109 }
1110
1111 impl From<nativeChannelManager> for crate::lightning::chain::Confirm {
1112         fn from(obj: nativeChannelManager) -> Self {
1113                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1114                 let mut ret = ChannelManager_as_Confirm(&rust_obj);
1115                 // 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
1116                 rust_obj.inner = std::ptr::null_mut();
1117                 ret.free = Some(ChannelManager_free_void);
1118                 ret
1119         }
1120 }
1121 /// Constructs a new Confirm which calls the relevant methods on this_arg.
1122 /// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
1123 #[no_mangle]
1124 pub extern "C" fn ChannelManager_as_Confirm(this_arg: &ChannelManager) -> crate::lightning::chain::Confirm {
1125         crate::lightning::chain::Confirm {
1126                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1127                 free: None,
1128                 transactions_confirmed: ChannelManager_Confirm_transactions_confirmed,
1129                 transaction_unconfirmed: ChannelManager_Confirm_transaction_unconfirmed,
1130                 best_block_updated: ChannelManager_Confirm_best_block_updated,
1131                 get_relevant_txids: ChannelManager_Confirm_get_relevant_txids,
1132         }
1133 }
1134
1135 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) {
1136         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 }); };
1137         <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)
1138 }
1139 extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
1140         <nativeChannelManager as lightning::chain::Confirm<>>::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
1141 }
1142 #[must_use]
1143 extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_TxidZ {
1144         let mut ret = <nativeChannelManager as lightning::chain::Confirm<>>::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
1145         let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::ThirtyTwoBytes { data: item.into_inner() } }); };
1146         local_ret.into()
1147 }
1148 extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) {
1149         <nativeChannelManager as lightning::chain::Confirm<>>::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap())
1150 }
1151
1152 /// Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
1153 /// indicating whether persistence is necessary. Only one listener on
1154 /// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
1155 /// up.
1156 /// Note that the feature `allow_wallclock_use` must be enabled to use this function.
1157 #[must_use]
1158 #[no_mangle]
1159 pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &ChannelManager, mut max_wait: u64) -> bool {
1160         let mut ret = unsafe { &*this_arg.inner }.await_persistable_update_timeout(std::time::Duration::from_secs(max_wait));
1161         ret
1162 }
1163
1164 /// Blocks until ChannelManager needs to be persisted. Only one listener on
1165 /// `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
1166 /// up.
1167 #[no_mangle]
1168 pub extern "C" fn ChannelManager_await_persistable_update(this_arg: &ChannelManager) {
1169         unsafe { &*this_arg.inner }.await_persistable_update()
1170 }
1171
1172 impl From<nativeChannelManager> for crate::lightning::ln::msgs::ChannelMessageHandler {
1173         fn from(obj: nativeChannelManager) -> Self {
1174                 let mut rust_obj = ChannelManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
1175                 let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj);
1176                 // 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
1177                 rust_obj.inner = std::ptr::null_mut();
1178                 ret.free = Some(ChannelManager_free_void);
1179                 ret
1180         }
1181 }
1182 /// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
1183 /// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
1184 #[no_mangle]
1185 pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelManager) -> crate::lightning::ln::msgs::ChannelMessageHandler {
1186         crate::lightning::ln::msgs::ChannelMessageHandler {
1187                 this_arg: unsafe { (*this_arg).inner as *mut c_void },
1188                 free: None,
1189                 handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel,
1190                 handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel,
1191                 handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created,
1192                 handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed,
1193                 handle_funding_locked: ChannelManager_ChannelMessageHandler_handle_funding_locked,
1194                 handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown,
1195                 handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed,
1196                 handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc,
1197                 handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc,
1198                 handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc,
1199                 handle_update_fail_malformed_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc,
1200                 handle_commitment_signed: ChannelManager_ChannelMessageHandler_handle_commitment_signed,
1201                 handle_revoke_and_ack: ChannelManager_ChannelMessageHandler_handle_revoke_and_ack,
1202                 handle_update_fee: ChannelManager_ChannelMessageHandler_handle_update_fee,
1203                 handle_announcement_signatures: ChannelManager_ChannelMessageHandler_handle_announcement_signatures,
1204                 peer_disconnected: ChannelManager_ChannelMessageHandler_peer_disconnected,
1205                 peer_connected: ChannelManager_ChannelMessageHandler_peer_connected,
1206                 handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish,
1207                 handle_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update,
1208                 handle_error: ChannelManager_ChannelMessageHandler_handle_error,
1209                 MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider {
1210                         this_arg: unsafe { (*this_arg).inner as *mut c_void },
1211                         free: None,
1212                         get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
1213                 },
1214         }
1215 }
1216
1217 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) {
1218         <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 })
1219 }
1220 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) {
1221         <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 })
1222 }
1223 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) {
1224         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1225 }
1226 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) {
1227         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1228 }
1229 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) {
1230         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_funding_locked(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1231 }
1232 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) {
1233         <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 })
1234 }
1235 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) {
1236         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1237 }
1238 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) {
1239         <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 })
1240 }
1241 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) {
1242         <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 })
1243 }
1244 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) {
1245         <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 })
1246 }
1247 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) {
1248         <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 })
1249 }
1250 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) {
1251         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1252 }
1253 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) {
1254         <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 })
1255 }
1256 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) {
1257         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1258 }
1259 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) {
1260         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1261 }
1262 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) {
1263         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1264 }
1265 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) {
1266         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1267 }
1268 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) {
1269         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), no_connection_possible)
1270 }
1271 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) {
1272         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*init_msg.inner })
1273 }
1274 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) {
1275         <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &counterparty_node_id.into_rust(), unsafe { &*msg.inner })
1276 }
1277
1278 #[no_mangle]
1279 /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
1280 pub extern "C" fn ChannelManager_write(obj: &ChannelManager) -> crate::c_types::derived::CVec_u8Z {
1281         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
1282 }
1283 #[no_mangle]
1284 pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1285         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) })
1286 }
1287
1288 use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport;
1289 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>;
1290
1291 /// Arguments for the creation of a ChannelManager that are not deserialized.
1292 ///
1293 /// At a high-level, the process for deserializing a ChannelManager and resuming normal operation
1294 /// is:
1295 /// 1) Deserialize all stored ChannelMonitors.
1296 /// 2) Deserialize the ChannelManager by filling in this struct and calling:
1297 ///    <(BlockHash, ChannelManager)>::read(reader, args)
1298 ///    This may result in closing some Channels if the ChannelMonitor is newer than the stored
1299 ///    ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
1300 /// 3) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same
1301 ///    way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and
1302 ///    ChannelMonitor::get_funding_txo().
1303 /// 4) Reconnect blocks on your ChannelMonitors.
1304 /// 5) Disconnect/connect blocks on the ChannelManager.
1305 /// 6) Move the ChannelMonitors into your local chain::Watch.
1306 ///
1307 /// Note that the ordering of #4-6 is not of importance, however all three must occur before you
1308 /// call any other methods on the newly-deserialized ChannelManager.
1309 ///
1310 /// Note that because some channels may be closed during deserialization, it is critical that you
1311 /// always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
1312 /// you. If you deserialize an old ChannelManager (during which force-closure transactions may be
1313 /// broadcast), and then later deserialize a newer version of the same ChannelManager (which will
1314 /// not force-close the same channels but consider them live), you may end up revoking a state for
1315 /// which you've already broadcasted the transaction.
1316 #[must_use]
1317 #[repr(C)]
1318 pub struct ChannelManagerReadArgs {
1319         /// A pointer to the opaque Rust object.
1320
1321         /// Nearly everywhere, inner must be non-null, however in places where
1322         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1323         pub inner: *mut nativeChannelManagerReadArgs,
1324         /// Indicates that this is the only struct which contains the same pointer.
1325
1326         /// Rust functions which take ownership of an object provided via an argument require
1327         /// this to be true and invalidate the object pointed to by inner.
1328         pub is_owned: bool,
1329 }
1330
1331 impl Drop for ChannelManagerReadArgs {
1332         fn drop(&mut self) {
1333                 if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) {
1334                         let _ = unsafe { Box::from_raw(self.inner) };
1335                 }
1336         }
1337 }
1338 /// Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL.
1339 #[no_mangle]
1340 pub extern "C" fn ChannelManagerReadArgs_free(this_obj: ChannelManagerReadArgs) { }
1341 #[allow(unused)]
1342 /// Used only if an object of this type is returned as a trait impl by a method
1343 extern "C" fn ChannelManagerReadArgs_free_void(this_ptr: *mut c_void) {
1344         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelManagerReadArgs); }
1345 }
1346 #[allow(unused)]
1347 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1348 impl ChannelManagerReadArgs {
1349         pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs {
1350                 assert!(self.is_owned);
1351                 let ret = self.inner;
1352                 self.inner = std::ptr::null_mut();
1353                 ret
1354         }
1355 }
1356 /// The keys provider which will give us relevant keys. Some keys will be loaded during
1357 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
1358 /// signing data.
1359 #[no_mangle]
1360 pub extern "C" fn ChannelManagerReadArgs_get_keys_manager(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::KeysInterface {
1361         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.keys_manager;
1362         inner_val
1363 }
1364 /// The keys provider which will give us relevant keys. Some keys will be loaded during
1365 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
1366 /// signing data.
1367 #[no_mangle]
1368 pub extern "C" fn ChannelManagerReadArgs_set_keys_manager(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::KeysInterface) {
1369         unsafe { &mut *this_ptr.inner }.keys_manager = val;
1370 }
1371 /// The fee_estimator for use in the ChannelManager in the future.
1372 ///
1373 /// No calls to the FeeEstimator will be made during deserialization.
1374 #[no_mangle]
1375 pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::FeeEstimator {
1376         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_estimator;
1377         inner_val
1378 }
1379 /// The fee_estimator for use in the ChannelManager in the future.
1380 ///
1381 /// No calls to the FeeEstimator will be made during deserialization.
1382 #[no_mangle]
1383 pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::FeeEstimator) {
1384         unsafe { &mut *this_ptr.inner }.fee_estimator = val;
1385 }
1386 /// The chain::Watch for use in the ChannelManager in the future.
1387 ///
1388 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
1389 /// you have deserialized ChannelMonitors separately and will add them to your
1390 /// chain::Watch after deserializing this ChannelManager.
1391 #[no_mangle]
1392 pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::Watch {
1393         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_monitor;
1394         inner_val
1395 }
1396 /// The chain::Watch for use in the ChannelManager in the future.
1397 ///
1398 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
1399 /// you have deserialized ChannelMonitors separately and will add them to your
1400 /// chain::Watch after deserializing this ChannelManager.
1401 #[no_mangle]
1402 pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::Watch) {
1403         unsafe { &mut *this_ptr.inner }.chain_monitor = val;
1404 }
1405 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
1406 /// used to broadcast the latest local commitment transactions of channels which must be
1407 /// force-closed during deserialization.
1408 #[no_mangle]
1409 pub extern "C" fn ChannelManagerReadArgs_get_tx_broadcaster(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::BroadcasterInterface {
1410         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.tx_broadcaster;
1411         inner_val
1412 }
1413 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
1414 /// used to broadcast the latest local commitment transactions of channels which must be
1415 /// force-closed during deserialization.
1416 #[no_mangle]
1417 pub extern "C" fn ChannelManagerReadArgs_set_tx_broadcaster(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::BroadcasterInterface) {
1418         unsafe { &mut *this_ptr.inner }.tx_broadcaster = val;
1419 }
1420 /// The Logger for use in the ChannelManager and which may be used to log information during
1421 /// deserialization.
1422 #[no_mangle]
1423 pub extern "C" fn ChannelManagerReadArgs_get_logger(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::util::logger::Logger {
1424         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.logger;
1425         inner_val
1426 }
1427 /// The Logger for use in the ChannelManager and which may be used to log information during
1428 /// deserialization.
1429 #[no_mangle]
1430 pub extern "C" fn ChannelManagerReadArgs_set_logger(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::logger::Logger) {
1431         unsafe { &mut *this_ptr.inner }.logger = val;
1432 }
1433 /// Default settings used for new channels. Any existing channels will continue to use the
1434 /// runtime settings which were stored when the ChannelManager was serialized.
1435 #[no_mangle]
1436 pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelManagerReadArgs) -> crate::lightning::util::config::UserConfig {
1437         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.default_config;
1438         crate::lightning::util::config::UserConfig { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
1439 }
1440 /// Default settings used for new channels. Any existing channels will continue to use the
1441 /// runtime settings which were stored when the ChannelManager was serialized.
1442 #[no_mangle]
1443 pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::config::UserConfig) {
1444         unsafe { &mut *this_ptr.inner }.default_config = *unsafe { Box::from_raw(val.take_inner()) };
1445 }
1446 /// Simple utility function to create a ChannelManagerReadArgs which creates the monitor
1447 /// HashMap for you. This is primarily useful for C bindings where it is not practical to
1448 /// populate a HashMap directly from C.
1449 #[must_use]
1450 #[no_mangle]
1451 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 {
1452         let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { unsafe { &mut *item.inner } }); };
1453         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);
1454         ChannelManagerReadArgs { inner: Box::into_raw(Box::new(ret)), is_owned: true }
1455 }
1456
1457 #[no_mangle]
1458 /// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
1459 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 {
1460         let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) };
1461         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);
1462         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() };
1463         local_res
1464 }