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