1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
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.
9 //! The top-level channel management and payment tracking stuff lives here.
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).
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).
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};
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`].
30 /// For more info on failure codes, see <https://github.com/lightning/bolts/blob/master/04-onion-routing.md#failure-messages>.
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.
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,
47 use lightning::ln::channelmanager::FailureCode as FailureCodeImport;
48 pub(crate) type nativeFailureCode = FailureCodeImport;
52 pub(crate) fn to_native(&self) -> nativeFailureCode {
54 FailureCode::TemporaryNodeFailure => nativeFailureCode::TemporaryNodeFailure,
55 FailureCode::RequiredNodeFeatureMissing => nativeFailureCode::RequiredNodeFeatureMissing,
56 FailureCode::IncorrectOrUnknownPaymentDetails => nativeFailureCode::IncorrectOrUnknownPaymentDetails,
60 pub(crate) fn into_native(self) -> nativeFailureCode {
62 FailureCode::TemporaryNodeFailure => nativeFailureCode::TemporaryNodeFailure,
63 FailureCode::RequiredNodeFeatureMissing => nativeFailureCode::RequiredNodeFeatureMissing,
64 FailureCode::IncorrectOrUnknownPaymentDetails => nativeFailureCode::IncorrectOrUnknownPaymentDetails,
68 pub(crate) fn from_native(native: &nativeFailureCode) -> Self {
70 nativeFailureCode::TemporaryNodeFailure => FailureCode::TemporaryNodeFailure,
71 nativeFailureCode::RequiredNodeFeatureMissing => FailureCode::RequiredNodeFeatureMissing,
72 nativeFailureCode::IncorrectOrUnknownPaymentDetails => FailureCode::IncorrectOrUnknownPaymentDetails,
76 pub(crate) fn native_into(native: nativeFailureCode) -> Self {
78 nativeFailureCode::TemporaryNodeFailure => FailureCode::TemporaryNodeFailure,
79 nativeFailureCode::RequiredNodeFeatureMissing => FailureCode::RequiredNodeFeatureMissing,
80 nativeFailureCode::IncorrectOrUnknownPaymentDetails => FailureCode::IncorrectOrUnknownPaymentDetails,
84 /// Creates a copy of the FailureCode
86 pub extern "C" fn FailureCode_clone(orig: &FailureCode) -> FailureCode {
90 /// Utility method to constructs a new TemporaryNodeFailure-variant FailureCode
91 pub extern "C" fn FailureCode_temporary_node_failure() -> FailureCode {
92 FailureCode::TemporaryNodeFailure}
94 /// Utility method to constructs a new RequiredNodeFeatureMissing-variant FailureCode
95 pub extern "C" fn FailureCode_required_node_feature_missing() -> FailureCode {
96 FailureCode::RequiredNodeFeatureMissing}
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}
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>;
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.
108 /// Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through
109 /// to individual Channels.
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`] (i.e.,
114 /// called [`funding_transaction_generated`] for outbound channels) being closed.
116 /// Note that you can be a bit lazier about writing out `ChannelManager` than you can be with
117 /// [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST write each monitor update out to disk before
118 /// returning from [`chain::Watch::watch_channel`]/[`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 /// [`ChannelMonitor`] 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).
124 /// Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which
125 /// tells you the last block hash which was connected. You should get the best block tip before using the manager.
126 /// See [`chain::Listen`] and [`chain::Confirm`] for more details.
128 /// Note that `ChannelManager` is responsible for tracking liveness of its channels and generating
129 /// [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid
130 /// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
131 /// offline for a full minute. In order to track this, you must call
132 /// [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect.
134 /// To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and
135 /// inbound channels without confirmed funding transactions. This may result in nodes which we do
136 /// not have a channel with being unable to connect to us or open new channels with us if we have
137 /// many peers with unfunded channels.
139 /// Because it is an indication of trust, inbound channels which we've accepted as 0conf are
140 /// exempted from the count of unfunded channels. Similarly, outbound channels and connections are
141 /// never limited. Please ensure you limit the count of such channels yourself.
143 /// Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`]
144 /// a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but
145 /// essentially you should default to using a [`SimpleRefChannelManager`], and use a
146 /// [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when
147 /// you're using lightning-net-tokio.
149 /// [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
150 /// [`funding_created`]: msgs::FundingCreated
151 /// [`funding_transaction_generated`]: Self::funding_transaction_generated
152 /// [`BlockHash`]: bitcoin::hash_types::BlockHash
153 /// [`update_channel`]: chain::Watch::update_channel
154 /// [`ChannelUpdate`]: msgs::ChannelUpdate
155 /// [`timer_tick_occurred`]: Self::timer_tick_occurred
156 /// [`read`]: ReadableArgs::read
159 pub struct ChannelManager {
160 /// A pointer to the opaque Rust object.
162 /// Nearly everywhere, inner must be non-null, however in places where
163 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
164 pub inner: *mut nativeChannelManager,
165 /// Indicates that this is the only struct which contains the same pointer.
167 /// Rust functions which take ownership of an object provided via an argument require
168 /// this to be true and invalidate the object pointed to by inner.
172 impl Drop for ChannelManager {
174 if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) {
175 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
179 /// Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL.
181 pub extern "C" fn ChannelManager_free(this_obj: ChannelManager) { }
183 /// Used only if an object of this type is returned as a trait impl by a method
184 pub(crate) extern "C" fn ChannelManager_free_void(this_ptr: *mut c_void) {
185 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelManager) };
188 impl ChannelManager {
189 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelManager {
190 unsafe { &*ObjOps::untweak_ptr(self.inner) }
192 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelManager {
193 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
195 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
196 pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager {
197 assert!(self.is_owned);
198 let ret = ObjOps::untweak_ptr(self.inner);
199 self.inner = core::ptr::null_mut();
204 use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport;
205 pub(crate) type nativeChainParameters = nativeChainParametersImport;
207 /// Chain-related parameters used to construct a new `ChannelManager`.
209 /// Typically, the block-specific parameters are derived from the best block hash for the network,
210 /// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters
211 /// are not needed when deserializing a previously constructed `ChannelManager`.
214 pub struct ChainParameters {
215 /// A pointer to the opaque Rust object.
217 /// Nearly everywhere, inner must be non-null, however in places where
218 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
219 pub inner: *mut nativeChainParameters,
220 /// Indicates that this is the only struct which contains the same pointer.
222 /// Rust functions which take ownership of an object provided via an argument require
223 /// this to be true and invalidate the object pointed to by inner.
227 impl Drop for ChainParameters {
229 if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) {
230 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
234 /// Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL.
236 pub extern "C" fn ChainParameters_free(this_obj: ChainParameters) { }
238 /// Used only if an object of this type is returned as a trait impl by a method
239 pub(crate) extern "C" fn ChainParameters_free_void(this_ptr: *mut c_void) {
240 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChainParameters) };
243 impl ChainParameters {
244 pub(crate) fn get_native_ref(&self) -> &'static nativeChainParameters {
245 unsafe { &*ObjOps::untweak_ptr(self.inner) }
247 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChainParameters {
248 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
250 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
251 pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters {
252 assert!(self.is_owned);
253 let ret = ObjOps::untweak_ptr(self.inner);
254 self.inner = core::ptr::null_mut();
258 /// The network for determining the `chain_hash` in Lightning messages.
260 pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network {
261 let mut inner_val = &mut this_ptr.get_native_mut_ref().network;
262 crate::bitcoin::network::Network::from_bitcoin(inner_val)
264 /// The network for determining the `chain_hash` in Lightning messages.
266 pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) {
267 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network = val.into_bitcoin();
269 /// The hash and height of the latest block successfully connected.
271 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
273 pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::chain::BestBlock {
274 let mut inner_val = &mut this_ptr.get_native_mut_ref().best_block;
275 crate::lightning::chain::BestBlock { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::BestBlock<>) as *mut _) }, is_owned: false }
277 /// The hash and height of the latest block successfully connected.
279 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
281 pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::chain::BestBlock) {
282 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.best_block = *unsafe { Box::from_raw(val.take_inner()) };
284 /// Constructs a new ChainParameters given each field
287 pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::chain::BestBlock) -> ChainParameters {
288 ChainParameters { inner: ObjOps::heap_alloc(nativeChainParameters {
289 network: network_arg.into_bitcoin(),
290 best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) },
293 impl Clone for ChainParameters {
294 fn clone(&self) -> Self {
296 inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
297 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
303 /// Used only if an object of this type is returned as a trait impl by a method
304 pub(crate) extern "C" fn ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
305 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChainParameters)).clone() })) as *mut c_void
308 /// Creates a copy of the ChainParameters
309 pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters {
312 /// The amount of time in blocks we require our counterparty wait to claim their money (ie time
313 /// between when we, or our watchtower, must check for them having broadcast a theft transaction).
315 /// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
317 /// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
320 pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT;
321 /// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
322 /// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour.
324 /// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`]
326 /// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta
329 pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA;
330 /// Minimum CLTV difference between the current block height and received inbound payments.
331 /// Invoices generated for payment to us must set their `min_final_cltv_expiry_delta` field to at least
335 pub static MIN_FINAL_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA;
337 use lightning::ln::channelmanager::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport;
338 pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport;
340 /// Information needed for constructing an invoice route hint for this channel.
343 pub struct CounterpartyForwardingInfo {
344 /// A pointer to the opaque Rust object.
346 /// Nearly everywhere, inner must be non-null, however in places where
347 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
348 pub inner: *mut nativeCounterpartyForwardingInfo,
349 /// Indicates that this is the only struct which contains the same pointer.
351 /// Rust functions which take ownership of an object provided via an argument require
352 /// this to be true and invalidate the object pointed to by inner.
356 impl Drop for CounterpartyForwardingInfo {
358 if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) {
359 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
363 /// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL.
365 pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { }
367 /// Used only if an object of this type is returned as a trait impl by a method
368 pub(crate) extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) {
369 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCounterpartyForwardingInfo) };
372 impl CounterpartyForwardingInfo {
373 pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo {
374 unsafe { &*ObjOps::untweak_ptr(self.inner) }
376 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo {
377 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
379 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
380 pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo {
381 assert!(self.is_owned);
382 let ret = ObjOps::untweak_ptr(self.inner);
383 self.inner = core::ptr::null_mut();
387 /// Base routing fee in millisatoshis.
389 pub extern "C" fn CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: &CounterpartyForwardingInfo) -> u32 {
390 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
393 /// Base routing fee in millisatoshis.
395 pub extern "C" fn CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
396 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
398 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
400 pub extern "C" fn CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: &CounterpartyForwardingInfo) -> u32 {
401 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
404 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
406 pub extern "C" fn CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
407 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
409 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
410 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
411 /// `cltv_expiry_delta` for more details.
413 pub extern "C" fn CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: &CounterpartyForwardingInfo) -> u16 {
414 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
417 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
418 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
419 /// `cltv_expiry_delta` for more details.
421 pub extern "C" fn CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: &mut CounterpartyForwardingInfo, mut val: u16) {
422 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
424 /// Constructs a new CounterpartyForwardingInfo given each field
427 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 {
428 CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(nativeCounterpartyForwardingInfo {
429 fee_base_msat: fee_base_msat_arg,
430 fee_proportional_millionths: fee_proportional_millionths_arg,
431 cltv_expiry_delta: cltv_expiry_delta_arg,
434 impl Clone for CounterpartyForwardingInfo {
435 fn clone(&self) -> Self {
437 inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
438 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
444 /// Used only if an object of this type is returned as a trait impl by a method
445 pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
446 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeCounterpartyForwardingInfo)).clone() })) as *mut c_void
449 /// Creates a copy of the CounterpartyForwardingInfo
450 pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo {
454 use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport;
455 pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport;
457 /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
458 /// to better separate parameters.
461 pub struct ChannelCounterparty {
462 /// A pointer to the opaque Rust object.
464 /// Nearly everywhere, inner must be non-null, however in places where
465 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
466 pub inner: *mut nativeChannelCounterparty,
467 /// Indicates that this is the only struct which contains the same pointer.
469 /// Rust functions which take ownership of an object provided via an argument require
470 /// this to be true and invalidate the object pointed to by inner.
474 impl Drop for ChannelCounterparty {
476 if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) {
477 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
481 /// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
483 pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { }
485 /// Used only if an object of this type is returned as a trait impl by a method
486 pub(crate) extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) {
487 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelCounterparty) };
490 impl ChannelCounterparty {
491 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty {
492 unsafe { &*ObjOps::untweak_ptr(self.inner) }
494 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty {
495 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
497 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
498 pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
499 assert!(self.is_owned);
500 let ret = ObjOps::untweak_ptr(self.inner);
501 self.inner = core::ptr::null_mut();
505 /// The node_id of our counterparty
507 pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey {
508 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
509 crate::c_types::PublicKey::from_rust(&inner_val)
511 /// The node_id of our counterparty
513 pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) {
514 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
516 /// The Features the channel counterparty provided upon last connection.
517 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
518 /// many routing-relevant features are present in the init context.
520 pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures {
521 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
522 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 }
524 /// The Features the channel counterparty provided upon last connection.
525 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
526 /// many routing-relevant features are present in the init context.
528 pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) {
529 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
531 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
532 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
533 /// claiming at least this value on chain.
535 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
537 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
539 pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 {
540 let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
543 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
544 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
545 /// claiming at least this value on chain.
547 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
549 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
551 pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) {
552 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = val;
554 /// Information on the fees and requirements that the counterparty requires when forwarding
555 /// payments to us through this channel.
557 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
559 pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channelmanager::CounterpartyForwardingInfo {
560 let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info;
561 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 };
564 /// Information on the fees and requirements that the counterparty requires when forwarding
565 /// payments to us through this channel.
567 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
569 pub extern "C" fn ChannelCounterparty_set_forwarding_info(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) {
570 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
571 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_info = local_val;
573 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
574 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
575 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
577 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_minimum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
578 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_minimum_msat;
579 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() }) };
582 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
583 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
584 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
586 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_minimum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
587 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
588 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_minimum_msat = local_val;
590 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
592 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_maximum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
593 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_maximum_msat;
594 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() }) };
597 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
599 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
600 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
601 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_maximum_msat = local_val;
603 /// Constructs a new ChannelCounterparty given each field
606 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 {
607 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()) } }) };
608 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 };
609 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 };
610 ChannelCounterparty { inner: ObjOps::heap_alloc(nativeChannelCounterparty {
611 node_id: node_id_arg.into_rust(),
612 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
613 unspendable_punishment_reserve: unspendable_punishment_reserve_arg,
614 forwarding_info: local_forwarding_info_arg,
615 outbound_htlc_minimum_msat: local_outbound_htlc_minimum_msat_arg,
616 outbound_htlc_maximum_msat: local_outbound_htlc_maximum_msat_arg,
619 impl Clone for ChannelCounterparty {
620 fn clone(&self) -> Self {
622 inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else {
623 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
629 /// Used only if an object of this type is returned as a trait impl by a method
630 pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void {
631 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelCounterparty)).clone() })) as *mut c_void
634 /// Creates a copy of the ChannelCounterparty
635 pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty {
639 use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport;
640 pub(crate) type nativeChannelDetails = nativeChannelDetailsImport;
642 /// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
645 pub struct ChannelDetails {
646 /// A pointer to the opaque Rust object.
648 /// Nearly everywhere, inner must be non-null, however in places where
649 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
650 pub inner: *mut nativeChannelDetails,
651 /// Indicates that this is the only struct which contains the same pointer.
653 /// Rust functions which take ownership of an object provided via an argument require
654 /// this to be true and invalidate the object pointed to by inner.
658 impl Drop for ChannelDetails {
660 if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) {
661 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
665 /// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
667 pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
669 /// Used only if an object of this type is returned as a trait impl by a method
670 pub(crate) extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
671 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDetails) };
674 impl ChannelDetails {
675 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails {
676 unsafe { &*ObjOps::untweak_ptr(self.inner) }
678 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails {
679 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
681 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
682 pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
683 assert!(self.is_owned);
684 let ret = ObjOps::untweak_ptr(self.inner);
685 self.inner = core::ptr::null_mut();
689 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
690 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
691 /// Note that this means this value is *not* persistent - it can change once during the
692 /// lifetime of the channel.
694 pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] {
695 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
698 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
699 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
700 /// Note that this means this value is *not* persistent - it can change once during the
701 /// lifetime of the channel.
703 pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
704 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
706 /// Parameters which apply to our counterparty. See individual fields for more information.
708 pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channelmanager::ChannelCounterparty {
709 let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty;
710 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 }
712 /// Parameters which apply to our counterparty. See individual fields for more information.
714 pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channelmanager::ChannelCounterparty) {
715 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty = *unsafe { Box::from_raw(val.take_inner()) };
717 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
718 /// our counterparty already.
720 /// Note that, if this has been set, `channel_id` will be equivalent to
721 /// `funding_txo.unwrap().to_channel_id()`.
723 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
725 pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
726 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo;
727 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 };
730 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
731 /// our counterparty already.
733 /// Note that, if this has been set, `channel_id` will be equivalent to
734 /// `funding_txo.unwrap().to_channel_id()`.
736 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
738 pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) {
739 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
740 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val;
742 /// The features which this channel operates with. See individual features for more info.
744 /// `None` until negotiation completes and the channel type is finalized.
746 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
748 pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures {
749 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
750 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 };
753 /// The features which this channel operates with. See individual features for more info.
755 /// `None` until negotiation completes and the channel type is finalized.
757 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
759 pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
760 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
761 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
763 /// The position of the funding transaction in the chain. None if the funding transaction has
764 /// not yet been confirmed and the channel fully opened.
766 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
767 /// payments instead of this. See [`get_inbound_payment_scid`].
769 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
770 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
772 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
773 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
774 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
775 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
776 /// [`confirmations_required`]: Self::confirmations_required
778 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
779 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
780 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() }) };
783 /// The position of the funding transaction in the chain. None if the funding transaction has
784 /// not yet been confirmed and the channel fully opened.
786 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
787 /// payments instead of this. See [`get_inbound_payment_scid`].
789 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
790 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
792 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
793 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
794 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
795 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
796 /// [`confirmations_required`]: Self::confirmations_required
798 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
799 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
800 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val;
802 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
803 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
804 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
807 /// This will be `None` as long as the channel is not available for routing outbound payments.
809 /// [`short_channel_id`]: Self::short_channel_id
810 /// [`confirmations_required`]: Self::confirmations_required
812 pub extern "C" fn ChannelDetails_get_outbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
813 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_scid_alias;
814 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() }) };
817 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
818 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
819 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
822 /// This will be `None` as long as the channel is not available for routing outbound payments.
824 /// [`short_channel_id`]: Self::short_channel_id
825 /// [`confirmations_required`]: Self::confirmations_required
827 pub extern "C" fn ChannelDetails_set_outbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
828 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
829 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_scid_alias = local_val;
831 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
832 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
833 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
834 /// when they see a payment to be routed to us.
836 /// Our counterparty may choose to rotate this value at any time, though will always recognize
837 /// previous values for inbound payment forwarding.
839 /// [`short_channel_id`]: Self::short_channel_id
841 pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
842 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias;
843 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() }) };
846 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
847 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
848 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
849 /// when they see a payment to be routed to us.
851 /// Our counterparty may choose to rotate this value at any time, though will always recognize
852 /// previous values for inbound payment forwarding.
854 /// [`short_channel_id`]: Self::short_channel_id
856 pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
857 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
858 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val;
860 /// The value, in satoshis, of this channel as appears in the funding output
862 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
863 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis;
866 /// The value, in satoshis, of this channel as appears in the funding output
868 pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
869 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val;
871 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
872 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
873 /// this value on chain.
875 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
877 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
879 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
881 pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
882 let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
883 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() }) };
886 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
887 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
888 /// this value on chain.
890 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
892 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
894 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
896 pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
897 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
898 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = local_val;
900 /// The `user_channel_id` passed in to create_channel, or a random value if the channel was
901 /// inbound. This may be zero for inbound channels serialized with LDK versions prior to
904 pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::U128 {
905 let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
908 /// The `user_channel_id` passed in to create_channel, or a random value if the channel was
909 /// inbound. This may be zero for inbound channels serialized with LDK versions prior to
912 pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) {
913 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
915 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
916 /// which is applied to commitment and HTLC transactions.
918 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
920 pub extern "C" fn ChannelDetails_get_feerate_sat_per_1000_weight(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
921 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
922 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() }) };
925 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
926 /// which is applied to commitment and HTLC transactions.
928 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
930 pub extern "C" fn ChannelDetails_set_feerate_sat_per_1000_weight(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
931 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
932 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = local_val;
934 /// Our total balance. This is the amount we would get if we close the channel.
935 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
936 /// amount is not likely to be recoverable on close.
938 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
939 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
940 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
941 /// This does not consider any on-chain fees.
943 /// See also [`ChannelDetails::outbound_capacity_msat`]
945 pub extern "C" fn ChannelDetails_get_balance_msat(this_ptr: &ChannelDetails) -> u64 {
946 let mut inner_val = &mut this_ptr.get_native_mut_ref().balance_msat;
949 /// Our total balance. This is the amount we would get if we close the channel.
950 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
951 /// amount is not likely to be recoverable on close.
953 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
954 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
955 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
956 /// This does not consider any on-chain fees.
958 /// See also [`ChannelDetails::outbound_capacity_msat`]
960 pub extern "C" fn ChannelDetails_set_balance_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
961 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.balance_msat = val;
963 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
964 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
965 /// available for inclusion in new outbound HTLCs). This further does not include any pending
966 /// outgoing HTLCs which are awaiting some other resolution to be sent.
968 /// See also [`ChannelDetails::balance_msat`]
970 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
971 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
972 /// should be able to spend nearly this amount.
974 pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
975 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_capacity_msat;
978 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
979 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
980 /// available for inclusion in new outbound HTLCs). This further does not include any pending
981 /// outgoing HTLCs which are awaiting some other resolution to be sent.
983 /// See also [`ChannelDetails::balance_msat`]
985 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
986 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
987 /// should be able to spend nearly this amount.
989 pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
990 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_capacity_msat = val;
992 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
993 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
994 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
995 /// to use a limit as close as possible to the HTLC limit we can currently send.
997 /// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`].
999 pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 {
1000 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat;
1003 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
1004 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
1005 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
1006 /// to use a limit as close as possible to the HTLC limit we can currently send.
1008 /// See also [`ChannelDetails::balance_msat`] and [`ChannelDetails::outbound_capacity_msat`].
1010 pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1011 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val;
1013 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
1014 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1015 /// available for inclusion in new inbound HTLCs).
1016 /// Note that there are some corner cases not fully handled here, so the actual available
1017 /// inbound capacity may be slightly higher than this.
1019 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1020 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
1021 /// However, our counterparty should be able to spend nearly this amount.
1023 pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
1024 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_capacity_msat;
1027 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
1028 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1029 /// available for inclusion in new inbound HTLCs).
1030 /// Note that there are some corner cases not fully handled here, so the actual available
1031 /// inbound capacity may be slightly higher than this.
1033 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1034 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
1035 /// However, our counterparty should be able to spend nearly this amount.
1037 pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1038 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_capacity_msat = val;
1040 /// The number of required confirmations on the funding transaction before the funding will be
1041 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
1042 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
1043 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
1044 /// [`ChannelHandshakeLimits::max_minimum_depth`].
1046 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1048 /// [`is_outbound`]: ChannelDetails::is_outbound
1049 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
1050 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
1052 pub extern "C" fn ChannelDetails_get_confirmations_required(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
1053 let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations_required;
1054 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() }) };
1057 /// The number of required confirmations on the funding transaction before the funding will be
1058 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
1059 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
1060 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
1061 /// [`ChannelHandshakeLimits::max_minimum_depth`].
1063 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1065 /// [`is_outbound`]: ChannelDetails::is_outbound
1066 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
1067 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
1069 pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
1070 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1071 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations_required = local_val;
1073 /// The current number of confirmations on the funding transaction.
1075 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1077 pub extern "C" fn ChannelDetails_get_confirmations(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
1078 let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations;
1079 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() }) };
1082 /// The current number of confirmations on the funding transaction.
1084 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1086 pub extern "C" fn ChannelDetails_set_confirmations(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
1087 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1088 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations = local_val;
1090 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
1091 /// until we can claim our funds after we force-close the channel. During this time our
1092 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
1093 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
1094 /// time to claim our non-HTLC-encumbered funds.
1096 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1098 pub extern "C" fn ChannelDetails_get_force_close_spend_delay(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u16Z {
1099 let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_spend_delay;
1100 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() }) };
1103 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
1104 /// until we can claim our funds after we force-close the channel. During this time our
1105 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
1106 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
1107 /// time to claim our non-HTLC-encumbered funds.
1109 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1111 pub extern "C" fn ChannelDetails_set_force_close_spend_delay(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u16Z) {
1112 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1113 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_spend_delay = local_val;
1115 /// True if the channel was initiated (and thus funded) by us.
1117 pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool {
1118 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_outbound;
1121 /// True if the channel was initiated (and thus funded) by us.
1123 pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) {
1124 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_outbound = val;
1126 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1127 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1128 /// required confirmation count has been reached (and we were connected to the peer at some
1129 /// point after the funding transaction received enough confirmations). The required
1130 /// confirmation count is provided in [`confirmations_required`].
1132 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1134 pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) -> bool {
1135 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_channel_ready;
1138 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1139 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1140 /// required confirmation count has been reached (and we were connected to the peer at some
1141 /// point after the funding transaction received enough confirmations). The required
1142 /// confirmation count is provided in [`confirmations_required`].
1144 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1146 pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) {
1147 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val;
1149 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1150 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1152 /// This is a strict superset of `is_channel_ready`.
1154 pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool {
1155 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_usable;
1158 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1159 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1161 /// This is a strict superset of `is_channel_ready`.
1163 pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) {
1164 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_usable = val;
1166 /// True if this channel is (or will be) publicly-announced.
1168 pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool {
1169 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_public;
1172 /// True if this channel is (or will be) publicly-announced.
1174 pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) {
1175 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_public = val;
1177 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1178 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1180 pub extern "C" fn ChannelDetails_get_inbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1181 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_minimum_msat;
1182 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() }) };
1185 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1186 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1188 pub extern "C" fn ChannelDetails_set_inbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1189 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1190 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_minimum_msat = local_val;
1192 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1194 pub extern "C" fn ChannelDetails_get_inbound_htlc_maximum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1195 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_maximum_msat;
1196 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() }) };
1199 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1201 pub extern "C" fn ChannelDetails_set_inbound_htlc_maximum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1202 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1203 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_maximum_msat = local_val;
1205 /// Set of configurable parameters that affect channel operation.
1207 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1209 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1211 pub extern "C" fn ChannelDetails_get_config(this_ptr: &ChannelDetails) -> crate::lightning::util::config::ChannelConfig {
1212 let mut inner_val = &mut this_ptr.get_native_mut_ref().config;
1213 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 };
1216 /// Set of configurable parameters that affect channel operation.
1218 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1220 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1222 pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut val: crate::lightning::util::config::ChannelConfig) {
1223 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1224 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.config = local_val;
1226 /// Constructs a new ChannelDetails given each field
1229 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 feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, 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 {
1230 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()) } }) };
1231 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()) } }) };
1232 let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None };
1233 let mut local_outbound_scid_alias_arg = if outbound_scid_alias_arg.is_some() { Some( { outbound_scid_alias_arg.take() }) } else { None };
1234 let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None };
1235 let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None };
1236 let mut local_feerate_sat_per_1000_weight_arg = if feerate_sat_per_1000_weight_arg.is_some() { Some( { feerate_sat_per_1000_weight_arg.take() }) } else { None };
1237 let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None };
1238 let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None };
1239 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 };
1240 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 };
1241 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 };
1242 let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) };
1243 ChannelDetails { inner: ObjOps::heap_alloc(nativeChannelDetails {
1244 channel_id: channel_id_arg.data,
1245 counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) },
1246 funding_txo: local_funding_txo_arg,
1247 channel_type: local_channel_type_arg,
1248 short_channel_id: local_short_channel_id_arg,
1249 outbound_scid_alias: local_outbound_scid_alias_arg,
1250 inbound_scid_alias: local_inbound_scid_alias_arg,
1251 channel_value_satoshis: channel_value_satoshis_arg,
1252 unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg,
1253 user_channel_id: user_channel_id_arg.into(),
1254 feerate_sat_per_1000_weight: local_feerate_sat_per_1000_weight_arg,
1255 balance_msat: balance_msat_arg,
1256 outbound_capacity_msat: outbound_capacity_msat_arg,
1257 next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg,
1258 inbound_capacity_msat: inbound_capacity_msat_arg,
1259 confirmations_required: local_confirmations_required_arg,
1260 confirmations: local_confirmations_arg,
1261 force_close_spend_delay: local_force_close_spend_delay_arg,
1262 is_outbound: is_outbound_arg,
1263 is_channel_ready: is_channel_ready_arg,
1264 is_usable: is_usable_arg,
1265 is_public: is_public_arg,
1266 inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg,
1267 inbound_htlc_maximum_msat: local_inbound_htlc_maximum_msat_arg,
1268 config: local_config_arg,
1269 }), is_owned: true }
1271 impl Clone for ChannelDetails {
1272 fn clone(&self) -> Self {
1274 inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
1275 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1281 /// Used only if an object of this type is returned as a trait impl by a method
1282 pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
1283 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelDetails)).clone() })) as *mut c_void
1286 /// Creates a copy of the ChannelDetails
1287 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
1290 /// Gets the current SCID which should be used to identify this channel for inbound payments.
1291 /// This should be used for providing invoice hints or in any other context where our
1292 /// counterparty will forward a payment to us.
1294 /// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
1295 /// [`ChannelDetails::short_channel_id`]. See those for more information.
1298 pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1299 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid();
1300 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() }) };
1304 /// Gets the current SCID which should be used to identify this channel for outbound payments.
1305 /// This should be used in [`Route`]s to describe the first hop or in other contexts where
1306 /// we're sending or forwarding a payment outbound over this channel.
1308 /// This is either the [`ChannelDetails::short_channel_id`], if set, or the
1309 /// [`ChannelDetails::outbound_scid_alias`]. See those for more information.
1312 pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1313 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_outbound_payment_scid();
1314 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() }) };
1318 /// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
1319 /// These include payments that have yet to find a successful path, or have unresolved HTLCs.
1323 pub enum RecentPaymentDetails {
1324 /// When a payment is still being sent and awaiting successful delivery.
1326 /// Hash of the payment that is currently being sent but has yet to be fulfilled or
1328 payment_hash: crate::c_types::ThirtyTwoBytes,
1329 /// Total amount (in msat, excluding fees) across all paths for this payment,
1330 /// not just the amount currently inflight.
1333 /// When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have
1334 /// been resolved. Upon receiving [`Event::PaymentSent`], we delay for a few minutes before the
1335 /// payment is removed from tracking.
1337 /// Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`]
1338 /// made before LDK version 0.0.104.
1340 /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
1341 payment_hash: crate::c_types::ThirtyTwoBytes,
1343 /// After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly
1344 /// abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all
1345 /// pending HTLCs for this payment resolve and an [`Event::PaymentFailed`] is generated.
1347 /// Hash of the payment that we have given up trying to send.
1348 payment_hash: crate::c_types::ThirtyTwoBytes,
1351 use lightning::ln::channelmanager::RecentPaymentDetails as RecentPaymentDetailsImport;
1352 pub(crate) type nativeRecentPaymentDetails = RecentPaymentDetailsImport;
1354 impl RecentPaymentDetails {
1356 pub(crate) fn to_native(&self) -> nativeRecentPaymentDetails {
1358 RecentPaymentDetails::Pending {ref payment_hash, ref total_msat, } => {
1359 let mut payment_hash_nonref = Clone::clone(payment_hash);
1360 let mut total_msat_nonref = Clone::clone(total_msat);
1361 nativeRecentPaymentDetails::Pending {
1362 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1363 total_msat: total_msat_nonref,
1366 RecentPaymentDetails::Fulfilled {ref payment_hash, } => {
1367 let mut payment_hash_nonref = Clone::clone(payment_hash);
1368 let mut local_payment_hash_nonref = if payment_hash_nonref.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash_nonref.data) }) };
1369 nativeRecentPaymentDetails::Fulfilled {
1370 payment_hash: local_payment_hash_nonref,
1373 RecentPaymentDetails::Abandoned {ref payment_hash, } => {
1374 let mut payment_hash_nonref = Clone::clone(payment_hash);
1375 nativeRecentPaymentDetails::Abandoned {
1376 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1382 pub(crate) fn into_native(self) -> nativeRecentPaymentDetails {
1384 RecentPaymentDetails::Pending {mut payment_hash, mut total_msat, } => {
1385 nativeRecentPaymentDetails::Pending {
1386 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1387 total_msat: total_msat,
1390 RecentPaymentDetails::Fulfilled {mut payment_hash, } => {
1391 let mut local_payment_hash = if payment_hash.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentHash(payment_hash.data) }) };
1392 nativeRecentPaymentDetails::Fulfilled {
1393 payment_hash: local_payment_hash,
1396 RecentPaymentDetails::Abandoned {mut payment_hash, } => {
1397 nativeRecentPaymentDetails::Abandoned {
1398 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1404 pub(crate) fn from_native(native: &nativeRecentPaymentDetails) -> Self {
1406 nativeRecentPaymentDetails::Pending {ref payment_hash, ref total_msat, } => {
1407 let mut payment_hash_nonref = Clone::clone(payment_hash);
1408 let mut total_msat_nonref = Clone::clone(total_msat);
1409 RecentPaymentDetails::Pending {
1410 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1411 total_msat: total_msat_nonref,
1414 nativeRecentPaymentDetails::Fulfilled {ref payment_hash, } => {
1415 let mut payment_hash_nonref = Clone::clone(payment_hash);
1416 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 } } };
1417 RecentPaymentDetails::Fulfilled {
1418 payment_hash: local_payment_hash_nonref,
1421 nativeRecentPaymentDetails::Abandoned {ref payment_hash, } => {
1422 let mut payment_hash_nonref = Clone::clone(payment_hash);
1423 RecentPaymentDetails::Abandoned {
1424 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1430 pub(crate) fn native_into(native: nativeRecentPaymentDetails) -> Self {
1432 nativeRecentPaymentDetails::Pending {mut payment_hash, mut total_msat, } => {
1433 RecentPaymentDetails::Pending {
1434 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1435 total_msat: total_msat,
1438 nativeRecentPaymentDetails::Fulfilled {mut payment_hash, } => {
1439 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 } } };
1440 RecentPaymentDetails::Fulfilled {
1441 payment_hash: local_payment_hash,
1444 nativeRecentPaymentDetails::Abandoned {mut payment_hash, } => {
1445 RecentPaymentDetails::Abandoned {
1446 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1452 /// Frees any resources used by the RecentPaymentDetails
1454 pub extern "C" fn RecentPaymentDetails_free(this_ptr: RecentPaymentDetails) { }
1455 /// Creates a copy of the RecentPaymentDetails
1457 pub extern "C" fn RecentPaymentDetails_clone(orig: &RecentPaymentDetails) -> RecentPaymentDetails {
1461 /// Utility method to constructs a new Pending-variant RecentPaymentDetails
1462 pub extern "C" fn RecentPaymentDetails_pending(payment_hash: crate::c_types::ThirtyTwoBytes, total_msat: u64) -> RecentPaymentDetails {
1463 RecentPaymentDetails::Pending {
1469 /// Utility method to constructs a new Fulfilled-variant RecentPaymentDetails
1470 pub extern "C" fn RecentPaymentDetails_fulfilled(payment_hash: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails {
1471 RecentPaymentDetails::Fulfilled {
1476 /// Utility method to constructs a new Abandoned-variant RecentPaymentDetails
1477 pub extern "C" fn RecentPaymentDetails_abandoned(payment_hash: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails {
1478 RecentPaymentDetails::Abandoned {
1483 use lightning::ln::channelmanager::PhantomRouteHints as nativePhantomRouteHintsImport;
1484 pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport;
1486 /// Route hints used in constructing invoices for [phantom node payents].
1488 /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
1491 pub struct PhantomRouteHints {
1492 /// A pointer to the opaque Rust object.
1494 /// Nearly everywhere, inner must be non-null, however in places where
1495 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1496 pub inner: *mut nativePhantomRouteHints,
1497 /// Indicates that this is the only struct which contains the same pointer.
1499 /// Rust functions which take ownership of an object provided via an argument require
1500 /// this to be true and invalidate the object pointed to by inner.
1504 impl Drop for PhantomRouteHints {
1505 fn drop(&mut self) {
1506 if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) {
1507 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1511 /// Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL.
1513 pub extern "C" fn PhantomRouteHints_free(this_obj: PhantomRouteHints) { }
1515 /// Used only if an object of this type is returned as a trait impl by a method
1516 pub(crate) extern "C" fn PhantomRouteHints_free_void(this_ptr: *mut c_void) {
1517 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomRouteHints) };
1520 impl PhantomRouteHints {
1521 pub(crate) fn get_native_ref(&self) -> &'static nativePhantomRouteHints {
1522 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1524 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomRouteHints {
1525 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1527 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1528 pub(crate) fn take_inner(mut self) -> *mut nativePhantomRouteHints {
1529 assert!(self.is_owned);
1530 let ret = ObjOps::untweak_ptr(self.inner);
1531 self.inner = core::ptr::null_mut();
1535 /// The list of channels to be included in the invoice route hints.
1537 pub extern "C" fn PhantomRouteHints_get_channels(this_ptr: &PhantomRouteHints) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1538 let mut inner_val = &mut this_ptr.get_native_mut_ref().channels;
1539 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 } }); };
1540 local_inner_val.into()
1542 /// The list of channels to be included in the invoice route hints.
1544 pub extern "C" fn PhantomRouteHints_set_channels(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::derived::CVec_ChannelDetailsZ) {
1545 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1546 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
1548 /// A fake scid used for representing the phantom node's fake channel in generating the invoice
1551 pub extern "C" fn PhantomRouteHints_get_phantom_scid(this_ptr: &PhantomRouteHints) -> u64 {
1552 let mut inner_val = &mut this_ptr.get_native_mut_ref().phantom_scid;
1555 /// A fake scid used for representing the phantom node's fake channel in generating the invoice
1558 pub extern "C" fn PhantomRouteHints_set_phantom_scid(this_ptr: &mut PhantomRouteHints, mut val: u64) {
1559 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.phantom_scid = val;
1561 /// The pubkey of the real backing node that would ultimately receive the payment.
1563 pub extern "C" fn PhantomRouteHints_get_real_node_pubkey(this_ptr: &PhantomRouteHints) -> crate::c_types::PublicKey {
1564 let mut inner_val = &mut this_ptr.get_native_mut_ref().real_node_pubkey;
1565 crate::c_types::PublicKey::from_rust(&inner_val)
1567 /// The pubkey of the real backing node that would ultimately receive the payment.
1569 pub extern "C" fn PhantomRouteHints_set_real_node_pubkey(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::PublicKey) {
1570 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.real_node_pubkey = val.into_rust();
1572 /// Constructs a new PhantomRouteHints given each field
1575 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 {
1576 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()) } }); };
1577 PhantomRouteHints { inner: ObjOps::heap_alloc(nativePhantomRouteHints {
1578 channels: local_channels_arg,
1579 phantom_scid: phantom_scid_arg,
1580 real_node_pubkey: real_node_pubkey_arg.into_rust(),
1581 }), is_owned: true }
1583 impl Clone for PhantomRouteHints {
1584 fn clone(&self) -> Self {
1586 inner: if <*mut nativePhantomRouteHints>::is_null(self.inner) { core::ptr::null_mut() } else {
1587 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1593 /// Used only if an object of this type is returned as a trait impl by a method
1594 pub(crate) extern "C" fn PhantomRouteHints_clone_void(this_ptr: *const c_void) -> *mut c_void {
1595 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePhantomRouteHints)).clone() })) as *mut c_void
1598 /// Creates a copy of the PhantomRouteHints
1599 pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRouteHints {
1602 /// Constructs a new `ChannelManager` to hold several channels and route between them.
1604 /// This is the main \"logic hub\" for all channel-related actions, and implements
1605 /// [`ChannelMessageHandler`].
1607 /// Non-proportional fees are fixed according to our risk using the provided fee estimator.
1609 /// Users need to notify the new `ChannelManager` when a new block is connected or
1610 /// disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting
1611 /// from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for
1614 /// [`block_connected`]: chain::Listen::block_connected
1615 /// [`block_disconnected`]: chain::Listen::block_disconnected
1616 /// [`params.best_block.block_hash`]: chain::BestBlock::block_hash
1619 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 {
1620 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()) });
1621 crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
1624 /// Gets the current configuration applied to all new channels.
1627 pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::config::UserConfig {
1628 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_current_default_configuration();
1629 crate::lightning::util::config::UserConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::util::config::UserConfig<>) as *mut _) }, is_owned: false }
1632 /// Creates a new outbound channel to the given remote node and with the given value.
1634 /// `user_channel_id` will be provided back as in
1635 /// [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
1636 /// correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
1637 /// randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
1638 /// is simply copied to events and otherwise ignored.
1640 /// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
1641 /// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
1643 /// Note that we do not check if you are currently connected to the given peer. If no
1644 /// connection is available, the outbound `open_channel` message may fail to send, resulting in
1645 /// the channel eventually being silently forgotten (dropped on reload).
1647 /// Returns the new Channel's temporary `channel_id`. This ID will appear as
1648 /// [`Event::FundingGenerationReady::temporary_channel_id`] and in
1649 /// [`ChannelDetails::channel_id`] until after
1650 /// [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
1651 /// one derived from the funding transaction's TXID. If the counterparty rejects the channel
1652 /// immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
1654 /// [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
1655 /// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
1656 /// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
1658 /// Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
1661 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 {
1662 let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) };
1663 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);
1664 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() };
1668 /// Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
1669 /// more information.
1672 pub extern "C" fn ChannelManager_list_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1673 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels();
1674 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 } }); };
1678 /// Gets the list of usable channels, in random order. Useful as an argument to
1679 /// [`Router::find_route`] to ensure non-announced channels are used.
1681 /// These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
1682 /// documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
1686 pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1687 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_usable_channels();
1688 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 } }); };
1692 /// Gets the list of channels we have with a given counterparty, in random order.
1695 pub extern "C" fn ChannelManager_list_channels_with_counterparty(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1696 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels_with_counterparty(&counterparty_node_id.into_rust());
1697 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 } }); };
1701 /// Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
1702 /// successful path, or have unresolved HTLCs.
1704 /// This can be useful for payments that may have been prepared, but ultimately not sent, as a
1705 /// result of a crash. If such a payment exists, is not listed here, and an
1706 /// [`Event::PaymentSent`] has not been received, you may consider resending the payment.
1708 /// [`Event::PaymentSent`]: events::Event::PaymentSent
1711 pub extern "C" fn ChannelManager_list_recent_payments(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_RecentPaymentDetailsZ {
1712 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_recent_payments();
1713 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::RecentPaymentDetails::native_into(item) }); };
1717 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
1718 /// will be accepted on the given channel, and after additional timeout/the closing of all
1719 /// pending HTLCs, the channel will be closed on chain.
1721 /// * If we are the channel initiator, we will pay between our [`Background`] and
1722 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
1724 /// * If our counterparty is the channel initiator, we will require a channel closing
1725 /// transaction feerate of at least our [`Background`] feerate or the feerate which
1726 /// would appear on a force-closure transaction, whichever is lower. We will allow our
1727 /// counterparty to pay as much fee as they'd like, however.
1729 /// May generate a [`SendShutdown`] message event on success, which should be relayed.
1731 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1732 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1733 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1734 /// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
1737 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 {
1738 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel(unsafe { &*channel_id}, &counterparty_node_id.into_rust());
1739 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() };
1743 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
1744 /// will be accepted on the given channel, and after additional timeout/the closing of all
1745 /// pending HTLCs, the channel will be closed on chain.
1747 /// `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
1748 /// the channel being closed or not:
1749 /// * If we are the channel initiator, we will pay at least this feerate on the closing
1750 /// transaction. The upper-bound is set by
1751 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
1752 /// estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
1753 /// * If our counterparty is the channel initiator, we will refuse to accept a channel closure
1754 /// transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
1755 /// will appear on a force-closure transaction, whichever is lower).
1757 /// May generate a [`SendShutdown`] message event on success, which should be relayed.
1759 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
1760 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1761 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1762 /// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
1765 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 {
1766 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);
1767 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() };
1771 /// Force closes a channel, immediately broadcasting the latest local transaction(s) and
1772 /// rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
1773 /// the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
1777 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 {
1778 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(unsafe { &*channel_id}, &counterparty_node_id.into_rust());
1779 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() };
1783 /// Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
1784 /// the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
1785 /// `counterparty_node_id` isn't the counterparty of the corresponding channel.
1787 /// You can always get the latest local transaction(s) to broadcast from
1788 /// [`ChannelMonitor::get_latest_holder_commitment_txn`].
1791 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 {
1792 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(unsafe { &*channel_id}, &counterparty_node_id.into_rust());
1793 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() };
1797 /// Force close all channels, immediately broadcasting the latest local commitment transaction
1798 /// for each to the chain and rejecting new HTLCs on each.
1800 pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
1801 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn()
1804 /// Force close all channels rejecting new HTLCs on each but without broadcasting the latest
1805 /// local transaction(s).
1807 pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
1808 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn()
1811 /// Sends a payment along a given route.
1813 /// Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
1814 /// fields for more info.
1816 /// May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
1817 /// [`PeerManager::process_events`]).
1819 /// # Avoiding Duplicate Payments
1821 /// If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
1822 /// method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
1823 /// is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
1824 /// [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
1825 /// second payment with the same [`PaymentId`].
1827 /// Thus, in order to ensure duplicate payments are not sent, you should implement your own
1828 /// tracking of payments, including state to indicate once a payment has completed. Because you
1829 /// should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
1830 /// consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
1831 /// [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
1833 /// Additionally, in the scenario where we begin the process of sending a payment, but crash
1834 /// before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
1835 /// using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
1836 /// [`ChannelManager::list_recent_payments`] for more information.
1838 /// # Possible Error States on [`PaymentSendFailure`]
1840 /// Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
1841 /// each entry matching the corresponding-index entry in the route paths, see
1842 /// [`PaymentSendFailure`] for more info.
1844 /// In general, a path may raise:
1845 /// * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
1846 /// node public key) is specified.
1847 /// * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates
1848 /// (including due to previous monitor update failure or new permanent monitor update
1850 /// * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
1851 /// relevant updates.
1853 /// Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
1854 /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
1855 /// different route unless you intend to pay twice!
1857 /// [`Event::PaymentSent`]: events::Event::PaymentSent
1858 /// [`Event::PaymentFailed`]: events::Event::PaymentFailed
1859 /// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
1860 /// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
1861 /// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
1864 pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
1865 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment_with_route(route.get_native_ref(), ::lightning::ln::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data));
1866 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() };
1870 /// Similar to [`ChannelManager::send_payment`], but will automatically find a route based on
1871 /// `route_params` and retry failed payment paths based on `retry_strategy`.
1874 pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, 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 {
1875 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment(::lightning::ln::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native());
1876 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() };
1880 /// Signals that no further retries for the given payment should occur. Useful if you have a
1881 /// pending outbound payment with retries remaining, but wish to stop retrying the payment before
1882 /// retries are exhausted.
1884 /// If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
1885 /// as there are no remaining pending HTLCs for this payment.
1887 /// Note that calling this method does *not* prevent a payment from succeeding. You must still
1888 /// wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
1889 /// determine the ultimate status of a payment.
1891 /// If an [`Event::PaymentFailed`] event is generated and we restart without this
1892 /// [`ChannelManager`] having been persisted, another [`Event::PaymentFailed`] may be generated.
1894 /// [`Event::PaymentFailed`]: events::Event::PaymentFailed
1895 /// [`Event::PaymentSent`]: events::Event::PaymentSent
1897 pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_id: crate::c_types::ThirtyTwoBytes) {
1898 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.abandon_payment(::lightning::ln::channelmanager::PaymentId(payment_id.data))
1901 /// Send a spontaneous payment, which is a payment that does not require the recipient to have
1902 /// generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
1903 /// the preimage, it must be a cryptographically secure random value that no intermediate node
1904 /// would be able to guess -- otherwise, an intermediate node may claim the payment and it will
1905 /// never reach the recipient.
1907 /// See [`send_payment`] documentation for more details on the return value of this function
1908 /// and idempotency guarantees provided by the [`PaymentId`] key.
1910 /// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
1911 /// [`send_payment`] for more information about the risks of duplicate preimage usage.
1913 /// Note that `route` must have exactly one path.
1915 /// [`send_payment`]: Self::send_payment
1917 /// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
1920 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 recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_PaymentHashPaymentSendFailureZ {
1921 let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) };
1922 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data));
1923 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() };
1927 /// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
1928 /// based on `route_params` and retry failed payment paths based on `retry_strategy`.
1930 /// See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
1933 /// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
1935 /// Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
1938 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 recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, 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 {
1939 let mut local_payment_preimage = if payment_preimage.data == [0; 32] { None } else { Some( { ::lightning::ln::PaymentPreimage(payment_preimage.data) }) };
1940 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment_with_retry(local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native());
1941 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() };
1945 /// Send a payment that is probing the given route for liquidity. We calculate the
1946 /// [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
1947 /// us to easily discern them from real payments.
1950 pub extern "C" fn ChannelManager_send_probe(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut path: crate::lightning::routing::router::Path) -> crate::c_types::derived::CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ {
1951 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_probe(*unsafe { Box::from_raw(path.take_inner()) });
1952 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() };
1956 /// Call this upon creation of a funding transaction for the given channel.
1958 /// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
1959 /// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
1961 /// Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
1962 /// across the p2p network.
1964 /// Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
1965 /// for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
1967 /// May panic if the output found in the funding transaction is duplicative with some other
1968 /// channel (note that this should be trivially prevented by using unique funding transaction
1969 /// keys per-channel).
1971 /// Do NOT broadcast the funding transaction yourself. When we have safely received our
1972 /// counterparty's signature the funding transaction will automatically be broadcast via the
1973 /// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
1975 /// Note that this includes RBF or similar transaction replacement strategies - lightning does
1976 /// not currently support replacing a funding transaction on an existing channel. Instead,
1977 /// create a new channel with a conflicting funding transaction.
1979 /// Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
1980 /// the wallet software generating the funding transaction to apply anti-fee sniping as
1981 /// implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
1982 /// for more details.
1984 /// [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
1985 /// [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
1988 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 {
1989 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());
1990 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() };
1994 /// Atomically updates the [`ChannelConfig`] for the given channels.
1996 /// Once the updates are applied, each eligible channel (advertised with a known short channel
1997 /// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
1998 /// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
1999 /// containing the new [`ChannelUpdate`] message which should be broadcast to the network.
2001 /// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
2002 /// `counterparty_node_id` is provided.
2004 /// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
2005 /// below [`MIN_CLTV_EXPIRY_DELTA`].
2007 /// If an error is returned, none of the updates should be considered applied.
2009 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
2010 /// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
2011 /// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
2012 /// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
2013 /// [`ChannelUpdate`]: msgs::ChannelUpdate
2014 /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
2015 /// [`APIMisuseError`]: APIError::APIMisuseError
2018 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 {
2019 let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { item.data }); };
2020 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());
2021 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() };
2025 /// Attempts to forward an intercepted HTLC over the provided channel id and with the provided
2026 /// amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
2028 /// Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
2029 /// channel to a receiving node if the node lacks sufficient inbound liquidity.
2031 /// To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
2032 /// [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
2033 /// receiver's invoice route hints. These route hints will signal to LDK to generate an
2034 /// [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
2035 /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
2037 /// Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
2038 /// you from forwarding more than you received.
2040 /// Errors if the event was not handled in time, in which case the HTLC was automatically failed
2043 /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
2044 /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
2047 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 {
2048 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);
2049 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() };
2053 /// Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
2054 /// an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
2056 /// Errors if the event was not handled in time, in which case the HTLC was automatically failed
2059 /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
2062 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 {
2063 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data));
2064 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() };
2068 /// Processes HTLCs which are pending waiting on random forward delay.
2070 /// Should only really ever be called in response to a PendingHTLCsForwardable event.
2071 /// Will likely generate further events.
2073 pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2074 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_htlc_forwards()
2077 /// Performs actions which should happen on startup and roughly once per minute thereafter.
2079 /// This currently includes:
2080 /// * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
2081 /// * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more
2082 /// than a minute, informing the network that they should no longer attempt to route over
2084 /// * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs
2085 /// with the current [`ChannelConfig`].
2086 /// * Removing peers which have disconnected but and no longer have any channels.
2088 /// Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate
2089 /// estimate fetches.
2091 /// [`ChannelUpdate`]: msgs::ChannelUpdate
2092 /// [`ChannelConfig`]: crate::util::config::ChannelConfig
2094 pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2095 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timer_tick_occurred()
2098 /// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
2099 /// after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
2100 /// along the path (including in our own channel on which we received it).
2102 /// Note that in some cases around unclean shutdown, it is possible the payment may have
2103 /// already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
2104 /// second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
2105 /// may have already been failed automatically by LDK if it was nearing its expiration time.
2107 /// While LDK will never claim a payment automatically on your behalf (i.e. without you calling
2108 /// [`ChannelManager::claim_funds`]), you should still monitor for
2109 /// [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
2110 /// startup during which time claims that were in-progress at shutdown may be replayed.
2112 pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, payment_hash: *const [u8; 32]) {
2113 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards(&::lightning::ln::PaymentHash(unsafe { *payment_hash }))
2116 /// This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
2117 /// reason for the failure.
2119 /// See [`FailureCode`] for valid failure codes.
2121 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) {
2122 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards_with_reason(&::lightning::ln::PaymentHash(unsafe { *payment_hash }), failure_code.into_native())
2125 /// Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
2126 /// [`MessageSendEvent`]s needed to claim the payment.
2128 /// This method is guaranteed to ensure the payment has been claimed but only if the current
2129 /// height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race
2130 /// conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment
2131 /// successful. It will generally be available in the next [`process_pending_events`] call.
2133 /// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
2134 /// [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
2135 /// event matches your expectation. If you fail to do so and call this method, you may provide
2136 /// the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
2138 /// [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
2139 /// [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline
2140 /// [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed
2141 /// [`process_pending_events`]: EventsProvider::process_pending_events
2142 /// [`create_inbound_payment`]: Self::create_inbound_payment
2143 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2145 pub extern "C" fn ChannelManager_claim_funds(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) {
2146 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds(::lightning::ln::PaymentPreimage(payment_preimage.data))
2149 /// Gets the node_id held by this ChannelManager
2152 pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::PublicKey {
2153 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_our_node_id();
2154 crate::c_types::PublicKey::from_rust(&ret)
2157 /// Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
2159 /// The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
2160 /// and the `counterparty_node_id` parameter is the id of the peer which has requested to open
2163 /// The `user_channel_id` parameter will be provided back in
2164 /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2165 /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2167 /// Note that this method will return an error and reject the channel, if it requires support
2168 /// for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
2169 /// used to accept such channels.
2171 /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2172 /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2175 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 {
2176 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());
2177 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() };
2181 /// Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
2182 /// it as confirmed immediately.
2184 /// The `user_channel_id` parameter will be provided back in
2185 /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2186 /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2188 /// Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
2189 /// and (if the counterparty agrees), enables forwarding of payments immediately.
2191 /// This fully trusts that the counterparty has honestly and correctly constructed the funding
2192 /// transaction and blindly assumes that it will eventually confirm.
2194 /// If it does not confirm before we decide to close the channel, or if the funding transaction
2195 /// does not pay to the correct script the correct amount, *you will lose funds*.
2197 /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2198 /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2201 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 {
2202 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());
2203 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() };
2207 /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
2210 /// This differs from [`create_inbound_payment_for_hash`] only in that it generates the
2211 /// [`PaymentHash`] and [`PaymentPreimage`] for you.
2213 /// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which
2214 /// will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with
2215 /// its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be
2216 /// passed directly to [`claim_funds`].
2218 /// See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
2220 /// Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2221 /// `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2225 /// If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2226 /// deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2228 /// Errors if `min_value_msat` is greater than total bitcoin supply.
2230 /// If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
2231 /// on versions of LDK prior to 0.0.114.
2233 /// [`claim_funds`]: Self::claim_funds
2234 /// [`PaymentClaimable`]: events::Event::PaymentClaimable
2235 /// [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose
2236 /// [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment
2237 /// [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage
2238 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2241 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 {
2242 let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2243 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 };
2244 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);
2245 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() };
2249 /// Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
2250 /// serialized state with LDK node(s) running 0.0.103 and earlier.
2252 /// May panic if `invoice_expiry_delta_secs` is greater than one year.
2255 /// This method is deprecated and will be removed soon.
2257 /// [`create_inbound_payment`]: Self::create_inbound_payment
2260 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 {
2261 let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2262 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_legacy(local_min_value_msat, invoice_expiry_delta_secs);
2263 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() };
2267 /// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
2268 /// stored external to LDK.
2270 /// A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
2271 /// payment secret fetched via this method or [`create_inbound_payment`], and which is at least
2272 /// the `min_value_msat` provided here, if one is provided.
2274 /// The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
2275 /// note that LDK will not stop you from registering duplicate payment hashes for inbound
2278 /// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
2279 /// received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
2280 /// before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
2281 /// sender \"proof-of-payment\" unless they have paid the required amount.
2283 /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
2284 /// in excess of the current time. This should roughly match the expiry time set in the invoice.
2285 /// After this many seconds, we will remove the inbound payment, resulting in any attempts to
2286 /// pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
2287 /// invoices when no timeout is set.
2289 /// Note that we use block header time to time-out pending inbound payments (with some margin
2290 /// to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
2291 /// accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
2292 /// If you need exact expiry semantics, you should enforce them upon receipt of
2293 /// [`PaymentClaimable`].
2295 /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta`
2296 /// set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
2298 /// Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2299 /// `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2303 /// If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2304 /// deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2306 /// Errors if `min_value_msat` is greater than total bitcoin supply.
2308 /// If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
2309 /// on versions of LDK prior to 0.0.114.
2311 /// [`create_inbound_payment`]: Self::create_inbound_payment
2312 /// [`PaymentClaimable`]: events::Event::PaymentClaimable
2315 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 {
2316 let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2317 let mut local_min_final_cltv_expiry = if min_final_cltv_expiry.is_some() { Some( { min_final_cltv_expiry.take() }) } else { None };
2318 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);
2319 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() };
2323 /// Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
2324 /// serialized state with LDK node(s) running 0.0.103 and earlier.
2326 /// May panic if `invoice_expiry_delta_secs` is greater than one year.
2329 /// This method is deprecated and will be removed soon.
2331 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2334 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 {
2335 let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2336 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);
2337 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() };
2341 /// Gets an LDK-generated payment preimage from a payment hash and payment secret that were
2342 /// previously returned from [`create_inbound_payment`].
2344 /// [`create_inbound_payment`]: Self::create_inbound_payment
2347 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 {
2348 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));
2349 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() };
2353 /// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
2354 /// are used when constructing the phantom invoice's route hints.
2356 /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
2359 pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 {
2360 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_scid();
2364 /// Gets route hints for use in receiving [phantom node payments].
2366 /// [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
2369 pub extern "C" fn ChannelManager_get_phantom_route_hints(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::channelmanager::PhantomRouteHints {
2370 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_route_hints();
2371 crate::lightning::ln::channelmanager::PhantomRouteHints { inner: ObjOps::heap_alloc(ret), is_owned: true }
2374 /// Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
2375 /// used when constructing the route hints for HTLCs intended to be intercepted. See
2376 /// [`ChannelManager::forward_intercepted_htlc`].
2378 /// Note that this method is not guaranteed to return unique values, you may need to call it a few
2379 /// times to get a unique scid.
2382 pub extern "C" fn ChannelManager_get_intercept_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 {
2383 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_intercept_scid();
2387 /// Gets inflight HTLC information by processing pending outbound payments that are in
2388 /// our channels. May be used during pathfinding to account for in-use channel liquidity.
2391 pub extern "C" fn ChannelManager_compute_inflight_htlcs(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::routing::router::InFlightHtlcs {
2392 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.compute_inflight_htlcs();
2393 crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(ret), is_owned: true }
2396 impl From<nativeChannelManager> for crate::lightning::events::MessageSendEventsProvider {
2397 fn from(obj: nativeChannelManager) -> Self {
2398 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2399 let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj);
2400 // 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
2401 rust_obj.inner = core::ptr::null_mut();
2402 ret.free = Some(ChannelManager_free_void);
2406 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
2407 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
2409 pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::events::MessageSendEventsProvider {
2410 crate::lightning::events::MessageSendEventsProvider {
2411 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2413 get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
2418 extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
2419 let mut ret = <nativeChannelManager as lightning::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
2420 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); };
2424 impl From<nativeChannelManager> for crate::lightning::events::EventsProvider {
2425 fn from(obj: nativeChannelManager) -> Self {
2426 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2427 let mut ret = ChannelManager_as_EventsProvider(&rust_obj);
2428 // 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
2429 rust_obj.inner = core::ptr::null_mut();
2430 ret.free = Some(ChannelManager_free_void);
2434 /// Constructs a new EventsProvider which calls the relevant methods on this_arg.
2435 /// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
2437 pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> crate::lightning::events::EventsProvider {
2438 crate::lightning::events::EventsProvider {
2439 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2441 process_pending_events: ChannelManager_EventsProvider_process_pending_events,
2445 extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) {
2446 <nativeChannelManager as lightning::events::EventsProvider<>>::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler)
2449 impl From<nativeChannelManager> for crate::lightning::chain::Listen {
2450 fn from(obj: nativeChannelManager) -> Self {
2451 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2452 let mut ret = ChannelManager_as_Listen(&rust_obj);
2453 // 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
2454 rust_obj.inner = core::ptr::null_mut();
2455 ret.free = Some(ChannelManager_free_void);
2459 /// Constructs a new Listen which calls the relevant methods on this_arg.
2460 /// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
2462 pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate::lightning::chain::Listen {
2463 crate::lightning::chain::Listen {
2464 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2466 filtered_block_connected: ChannelManager_Listen_filtered_block_connected,
2467 block_connected: ChannelManager_Listen_block_connected,
2468 block_disconnected: ChannelManager_Listen_block_disconnected,
2472 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) {
2473 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 }); };
2474 <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)
2476 extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) {
2477 <nativeChannelManager as lightning::chain::Listen<>>::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height)
2479 extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
2480 <nativeChannelManager as lightning::chain::Listen<>>::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
2483 impl From<nativeChannelManager> for crate::lightning::chain::Confirm {
2484 fn from(obj: nativeChannelManager) -> Self {
2485 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2486 let mut ret = ChannelManager_as_Confirm(&rust_obj);
2487 // 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
2488 rust_obj.inner = core::ptr::null_mut();
2489 ret.free = Some(ChannelManager_free_void);
2493 /// Constructs a new Confirm which calls the relevant methods on this_arg.
2494 /// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
2496 pub extern "C" fn ChannelManager_as_Confirm(this_arg: &ChannelManager) -> crate::lightning::chain::Confirm {
2497 crate::lightning::chain::Confirm {
2498 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2500 transactions_confirmed: ChannelManager_Confirm_transactions_confirmed,
2501 transaction_unconfirmed: ChannelManager_Confirm_transaction_unconfirmed,
2502 best_block_updated: ChannelManager_Confirm_best_block_updated,
2503 get_relevant_txids: ChannelManager_Confirm_get_relevant_txids,
2507 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) {
2508 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 }); };
2509 <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)
2511 extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) {
2512 <nativeChannelManager as lightning::chain::Confirm<>>::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap())
2514 extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
2515 <nativeChannelManager as lightning::chain::Confirm<>>::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
2518 extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_TxidBlockHashZZ {
2519 let mut ret = <nativeChannelManager as lightning::chain::Confirm<>>::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
2520 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 }); };
2524 /// Gets a [`Future`] that completes when this [`ChannelManager`] needs to be persisted.
2526 /// Note that callbacks registered on the [`Future`] MUST NOT call back into this
2527 /// [`ChannelManager`] and should instead register actions to be taken later.
2531 pub extern "C" fn ChannelManager_get_persistable_update_future(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::wakers::Future {
2532 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_persistable_update_future();
2533 crate::lightning::util::wakers::Future { inner: ObjOps::heap_alloc(ret), is_owned: true }
2536 /// Gets the latest best block which was connected either via the [`chain::Listen`] or
2537 /// [`chain::Confirm`] interfaces.
2540 pub extern "C" fn ChannelManager_current_best_block(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::chain::BestBlock {
2541 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.current_best_block();
2542 crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true }
2545 /// Fetches the set of [`NodeFeatures`] flags which are provided by or required by
2546 /// [`ChannelManager`].
2549 pub extern "C" fn ChannelManager_node_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::NodeFeatures {
2550 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node_features();
2551 crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2554 /// Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
2555 /// [`ChannelManager`].
2558 pub extern "C" fn ChannelManager_channel_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelFeatures {
2559 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_features();
2560 crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2563 /// Fetches the set of [`ChannelTypeFeatures`] flags which are provided by or required by
2564 /// [`ChannelManager`].
2567 pub extern "C" fn ChannelManager_channel_type_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelTypeFeatures {
2568 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features();
2569 crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2572 /// Fetches the set of [`InitFeatures`] flags which are provided by or required by
2573 /// [`ChannelManager`].
2576 pub extern "C" fn ChannelManager_init_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::InitFeatures {
2577 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.init_features();
2578 crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2581 impl From<nativeChannelManager> for crate::lightning::ln::msgs::ChannelMessageHandler {
2582 fn from(obj: nativeChannelManager) -> Self {
2583 let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2584 let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj);
2585 // 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
2586 rust_obj.inner = core::ptr::null_mut();
2587 ret.free = Some(ChannelManager_free_void);
2591 /// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
2592 /// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
2594 pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelManager) -> crate::lightning::ln::msgs::ChannelMessageHandler {
2595 crate::lightning::ln::msgs::ChannelMessageHandler {
2596 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2598 handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel,
2599 handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel,
2600 handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created,
2601 handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed,
2602 handle_channel_ready: ChannelManager_ChannelMessageHandler_handle_channel_ready,
2603 handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown,
2604 handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed,
2605 handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc,
2606 handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc,
2607 handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc,
2608 handle_update_fail_malformed_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc,
2609 handle_commitment_signed: ChannelManager_ChannelMessageHandler_handle_commitment_signed,
2610 handle_revoke_and_ack: ChannelManager_ChannelMessageHandler_handle_revoke_and_ack,
2611 handle_update_fee: ChannelManager_ChannelMessageHandler_handle_update_fee,
2612 handle_announcement_signatures: ChannelManager_ChannelMessageHandler_handle_announcement_signatures,
2613 peer_disconnected: ChannelManager_ChannelMessageHandler_peer_disconnected,
2614 peer_connected: ChannelManager_ChannelMessageHandler_peer_connected,
2615 handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish,
2616 handle_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update,
2617 handle_error: ChannelManager_ChannelMessageHandler_handle_error,
2618 provided_node_features: ChannelManager_ChannelMessageHandler_provided_node_features,
2619 provided_init_features: ChannelManager_ChannelMessageHandler_provided_init_features,
2620 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider {
2621 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2623 get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
2628 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) {
2629 <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())
2631 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) {
2632 <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())
2634 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) {
2635 <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())
2637 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) {
2638 <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())
2640 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) {
2641 <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())
2643 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) {
2644 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2646 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) {
2647 <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())
2649 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) {
2650 <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())
2652 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) {
2653 <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())
2655 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) {
2656 <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())
2658 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) {
2659 <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())
2661 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) {
2662 <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())
2664 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) {
2665 <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())
2667 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) {
2668 <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())
2670 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) {
2671 <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())
2673 extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) {
2674 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust())
2677 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 {
2678 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);
2679 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() };
2682 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) {
2683 <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())
2685 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) {
2686 <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())
2688 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) {
2689 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
2692 extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
2693 let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
2694 crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2697 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 {
2698 let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust());
2699 crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2702 /// Fetches the set of [`InitFeatures`] flags which are provided by or required by
2703 /// [`ChannelManager`].
2705 pub extern "C" fn provided_init_features(_config: &crate::lightning::util::config::UserConfig) -> crate::lightning::ln::features::InitFeatures {
2706 let mut ret = lightning::ln::channelmanager::provided_init_features(_config.get_native_ref());
2707 crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
2711 /// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read
2712 pub extern "C" fn CounterpartyForwardingInfo_write(obj: &crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z {
2713 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2716 pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2717 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) })
2720 /// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write
2721 pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ {
2722 let res: Result<lightning::ln::channelmanager::CounterpartyForwardingInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2723 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() };
2727 /// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
2728 pub extern "C" fn ChannelCounterparty_write(obj: &crate::lightning::ln::channelmanager::ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z {
2729 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2732 pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2733 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) })
2736 /// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
2737 pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ {
2738 let res: Result<lightning::ln::channelmanager::ChannelCounterparty, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2739 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() };
2743 /// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read
2744 pub extern "C" fn ChannelDetails_write(obj: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::CVec_u8Z {
2745 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2748 pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2749 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) })
2752 /// Read a ChannelDetails from a byte array, created by ChannelDetails_write
2753 pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ {
2754 let res: Result<lightning::ln::channelmanager::ChannelDetails, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2755 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() };
2759 /// Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
2760 pub extern "C" fn PhantomRouteHints_write(obj: &crate::lightning::ln::channelmanager::PhantomRouteHints) -> crate::c_types::derived::CVec_u8Z {
2761 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2764 pub(crate) extern "C" fn PhantomRouteHints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2765 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePhantomRouteHints) })
2768 /// Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
2769 pub extern "C" fn PhantomRouteHints_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PhantomRouteHintsDecodeErrorZ {
2770 let res: Result<lightning::ln::channelmanager::PhantomRouteHints, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
2771 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() };
2775 /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
2776 pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_u8Z {
2777 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
2780 pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
2781 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) })
2784 use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport;
2785 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>;
2787 /// Arguments for the creation of a ChannelManager that are not deserialized.
2789 /// At a high-level, the process for deserializing a ChannelManager and resuming normal operation
2791 /// 1) Deserialize all stored [`ChannelMonitor`]s.
2792 /// 2) Deserialize the [`ChannelManager`] by filling in this struct and calling:
2793 /// `<(BlockHash, ChannelManager)>::read(reader, args)`
2794 /// This may result in closing some channels if the [`ChannelMonitor`] is newer than the stored
2795 /// [`ChannelManager`] state to ensure no loss of funds. Thus, transactions may be broadcasted.
2796 /// 3) If you are not fetching full blocks, register all relevant [`ChannelMonitor`] outpoints the
2797 /// same way you would handle a [`chain::Filter`] call using
2798 /// [`ChannelMonitor::get_outputs_to_watch`] and [`ChannelMonitor::get_funding_txo`].
2799 /// 4) Reconnect blocks on your [`ChannelMonitor`]s.
2800 /// 5) Disconnect/connect blocks on the [`ChannelManager`].
2801 /// 6) Re-persist the [`ChannelMonitor`]s to ensure the latest state is on disk.
2802 /// Note that if you're using a [`ChainMonitor`] for your [`chain::Watch`] implementation, you
2803 /// will likely accomplish this as a side-effect of calling [`chain::Watch::watch_channel`] in
2805 /// 7) Move the [`ChannelMonitor`]s into your local [`chain::Watch`]. If you're using a
2806 /// [`ChainMonitor`], this is done by calling [`chain::Watch::watch_channel`].
2808 /// Note that the ordering of #4-7 is not of importance, however all four must occur before you
2809 /// call any other methods on the newly-deserialized [`ChannelManager`].
2811 /// Note that because some channels may be closed during deserialization, it is critical that you
2812 /// always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
2813 /// you. If you deserialize an old ChannelManager (during which force-closure transactions may be
2814 /// broadcast), and then later deserialize a newer version of the same ChannelManager (which will
2815 /// not force-close the same channels but consider them live), you may end up revoking a state for
2816 /// which you've already broadcasted the transaction.
2818 /// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
2821 pub struct ChannelManagerReadArgs {
2822 /// A pointer to the opaque Rust object.
2824 /// Nearly everywhere, inner must be non-null, however in places where
2825 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
2826 pub inner: *mut nativeChannelManagerReadArgs,
2827 /// Indicates that this is the only struct which contains the same pointer.
2829 /// Rust functions which take ownership of an object provided via an argument require
2830 /// this to be true and invalidate the object pointed to by inner.
2834 impl Drop for ChannelManagerReadArgs {
2835 fn drop(&mut self) {
2836 if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) {
2837 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
2841 /// Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL.
2843 pub extern "C" fn ChannelManagerReadArgs_free(this_obj: ChannelManagerReadArgs) { }
2845 /// Used only if an object of this type is returned as a trait impl by a method
2846 pub(crate) extern "C" fn ChannelManagerReadArgs_free_void(this_ptr: *mut c_void) {
2847 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelManagerReadArgs) };
2850 impl ChannelManagerReadArgs {
2851 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelManagerReadArgs {
2852 unsafe { &*ObjOps::untweak_ptr(self.inner) }
2854 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelManagerReadArgs {
2855 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
2857 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
2858 pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs {
2859 assert!(self.is_owned);
2860 let ret = ObjOps::untweak_ptr(self.inner);
2861 self.inner = core::ptr::null_mut();
2865 /// A cryptographically secure source of entropy.
2867 pub extern "C" fn ChannelManagerReadArgs_get_entropy_source(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::EntropySource {
2868 let mut inner_val = &mut this_ptr.get_native_mut_ref().entropy_source;
2871 /// A cryptographically secure source of entropy.
2873 pub extern "C" fn ChannelManagerReadArgs_set_entropy_source(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::EntropySource) {
2874 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.entropy_source = val;
2876 /// A signer that is able to perform node-scoped cryptographic operations.
2878 pub extern "C" fn ChannelManagerReadArgs_get_node_signer(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::NodeSigner {
2879 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signer;
2882 /// A signer that is able to perform node-scoped cryptographic operations.
2884 pub extern "C" fn ChannelManagerReadArgs_set_node_signer(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::NodeSigner) {
2885 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signer = val;
2887 /// The keys provider which will give us relevant keys. Some keys will be loaded during
2888 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
2891 pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::keysinterface::SignerProvider {
2892 let mut inner_val = &mut this_ptr.get_native_mut_ref().signer_provider;
2895 /// The keys provider which will give us relevant keys. Some keys will be loaded during
2896 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
2899 pub extern "C" fn ChannelManagerReadArgs_set_signer_provider(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::keysinterface::SignerProvider) {
2900 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signer_provider = val;
2902 /// The fee_estimator for use in the ChannelManager in the future.
2904 /// No calls to the FeeEstimator will be made during deserialization.
2906 pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::FeeEstimator {
2907 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_estimator;
2910 /// The fee_estimator for use in the ChannelManager in the future.
2912 /// No calls to the FeeEstimator will be made during deserialization.
2914 pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::FeeEstimator) {
2915 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_estimator = val;
2917 /// The chain::Watch for use in the ChannelManager in the future.
2919 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
2920 /// you have deserialized ChannelMonitors separately and will add them to your
2921 /// chain::Watch after deserializing this ChannelManager.
2923 pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::Watch {
2924 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_monitor;
2927 /// The chain::Watch for use in the ChannelManager in the future.
2929 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
2930 /// you have deserialized ChannelMonitors separately and will add them to your
2931 /// chain::Watch after deserializing this ChannelManager.
2933 pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::Watch) {
2934 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_monitor = val;
2936 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
2937 /// used to broadcast the latest local commitment transactions of channels which must be
2938 /// force-closed during deserialization.
2940 pub extern "C" fn ChannelManagerReadArgs_get_tx_broadcaster(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::BroadcasterInterface {
2941 let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_broadcaster;
2944 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
2945 /// used to broadcast the latest local commitment transactions of channels which must be
2946 /// force-closed during deserialization.
2948 pub extern "C" fn ChannelManagerReadArgs_set_tx_broadcaster(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::BroadcasterInterface) {
2949 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_broadcaster = val;
2951 /// The router which will be used in the ChannelManager in the future for finding routes
2952 /// on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding.
2954 /// No calls to the router will be made during deserialization.
2956 pub extern "C" fn ChannelManagerReadArgs_get_router(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::routing::router::Router {
2957 let mut inner_val = &mut this_ptr.get_native_mut_ref().router;
2960 /// The router which will be used in the ChannelManager in the future for finding routes
2961 /// on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding.
2963 /// No calls to the router will be made during deserialization.
2965 pub extern "C" fn ChannelManagerReadArgs_set_router(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::routing::router::Router) {
2966 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.router = val;
2968 /// The Logger for use in the ChannelManager and which may be used to log information during
2969 /// deserialization.
2971 pub extern "C" fn ChannelManagerReadArgs_get_logger(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::util::logger::Logger {
2972 let mut inner_val = &mut this_ptr.get_native_mut_ref().logger;
2975 /// The Logger for use in the ChannelManager and which may be used to log information during
2976 /// deserialization.
2978 pub extern "C" fn ChannelManagerReadArgs_set_logger(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::logger::Logger) {
2979 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.logger = val;
2981 /// Default settings used for new channels. Any existing channels will continue to use the
2982 /// runtime settings which were stored when the ChannelManager was serialized.
2984 pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelManagerReadArgs) -> crate::lightning::util::config::UserConfig {
2985 let mut inner_val = &mut this_ptr.get_native_mut_ref().default_config;
2986 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 }
2988 /// Default settings used for new channels. Any existing channels will continue to use the
2989 /// runtime settings which were stored when the ChannelManager was serialized.
2991 pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::config::UserConfig) {
2992 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.default_config = *unsafe { Box::from_raw(val.take_inner()) };
2994 /// Simple utility function to create a ChannelManagerReadArgs which creates the monitor
2995 /// HashMap for you. This is primarily useful for C bindings where it is not practical to
2996 /// populate a HashMap directly from C.
2999 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 {
3000 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() }); };
3001 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);
3002 crate::lightning::ln::channelmanager::ChannelManagerReadArgs { inner: ObjOps::heap_alloc(ret), is_owned: true }
3006 /// Read a C2Tuple_BlockHashChannelManagerZ from a byte array, created by C2Tuple_BlockHashChannelManagerZ_write
3007 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 {
3008 let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) };
3009 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);
3010 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() };