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