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 alloc::string::String;
21 use core::ffi::c_void;
22 use core::convert::Infallible;
23 use bitcoin::hashes::Hash;
24 use crate::c_types::*;
25 #[cfg(feature="no-std")]
26 use alloc::{vec::Vec, boxed::Box};
28 /// This enum is used to specify which error data to send to peers when failing back an HTLC
29 /// using [`ChannelManager::fail_htlc_backwards_with_reason`].
31 /// For more info on failure codes, see <https://github.com/lightning/bolts/blob/master/04-onion-routing.md#failure-messages>.
35 pub enum FailureCode {
36 /// We had a temporary error processing the payment. Useful if no other error codes fit
37 /// and you want to indicate that the payer may want to retry.
39 /// We have a required feature which was not in this onion. For example, you may require
40 /// some additional metadata that was not provided with this payment.
41 RequiredNodeFeatureMissing,
42 /// You may wish to use this when a `payment_preimage` is unknown, or the CLTV expiry of
43 /// the HTLC is too close to the current block height for safe handling.
44 /// Using this failure code in [`ChannelManager::fail_htlc_backwards_with_reason`] is
45 /// equivalent to calling [`ChannelManager::fail_htlc_backwards`].
46 IncorrectOrUnknownPaymentDetails,
47 /// We failed to process the payload after the onion was decrypted. You may wish to
48 /// use this when receiving custom HTLC TLVs with even type numbers that you don't recognize.
50 /// If available, the tuple data may include the type number and byte offset in the
51 /// decrypted byte stream where the failure occurred.
53 crate::c_types::derived::COption_C2Tuple_u64u16ZZ),
55 use lightning::ln::channelmanager::FailureCode as FailureCodeImport;
56 pub(crate) type nativeFailureCode = FailureCodeImport;
60 pub(crate) fn to_native(&self) -> nativeFailureCode {
62 FailureCode::TemporaryNodeFailure => nativeFailureCode::TemporaryNodeFailure,
63 FailureCode::RequiredNodeFeatureMissing => nativeFailureCode::RequiredNodeFeatureMissing,
64 FailureCode::IncorrectOrUnknownPaymentDetails => nativeFailureCode::IncorrectOrUnknownPaymentDetails,
65 FailureCode::InvalidOnionPayload (ref a, ) => {
66 let mut a_nonref = Clone::clone(a);
67 let mut local_a_nonref = if a_nonref.is_some() { Some( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = a_nonref.take().to_rust(); let mut local_a_nonref_0 = (orig_a_nonref_0_0, orig_a_nonref_0_1); local_a_nonref_0 }) } else { None };
68 nativeFailureCode::InvalidOnionPayload (
75 pub(crate) fn into_native(self) -> nativeFailureCode {
77 FailureCode::TemporaryNodeFailure => nativeFailureCode::TemporaryNodeFailure,
78 FailureCode::RequiredNodeFeatureMissing => nativeFailureCode::RequiredNodeFeatureMissing,
79 FailureCode::IncorrectOrUnknownPaymentDetails => nativeFailureCode::IncorrectOrUnknownPaymentDetails,
80 FailureCode::InvalidOnionPayload (mut a, ) => {
81 let mut local_a = if a.is_some() { Some( { let (mut orig_a_0_0, mut orig_a_0_1) = a.take().to_rust(); let mut local_a_0 = (orig_a_0_0, orig_a_0_1); local_a_0 }) } else { None };
82 nativeFailureCode::InvalidOnionPayload (
89 pub(crate) fn from_native(native: &nativeFailureCode) -> Self {
91 nativeFailureCode::TemporaryNodeFailure => FailureCode::TemporaryNodeFailure,
92 nativeFailureCode::RequiredNodeFeatureMissing => FailureCode::RequiredNodeFeatureMissing,
93 nativeFailureCode::IncorrectOrUnknownPaymentDetails => FailureCode::IncorrectOrUnknownPaymentDetails,
94 nativeFailureCode::InvalidOnionPayload (ref a, ) => {
95 let mut a_nonref = Clone::clone(a);
96 let mut local_a_nonref = if a_nonref.is_none() { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::None } else { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::Some( { let (mut orig_a_nonref_0_0, mut orig_a_nonref_0_1) = (a_nonref.unwrap()); let mut local_a_nonref_0 = (orig_a_nonref_0_0, orig_a_nonref_0_1).into(); local_a_nonref_0 }) };
97 FailureCode::InvalidOnionPayload (
104 pub(crate) fn native_into(native: nativeFailureCode) -> Self {
106 nativeFailureCode::TemporaryNodeFailure => FailureCode::TemporaryNodeFailure,
107 nativeFailureCode::RequiredNodeFeatureMissing => FailureCode::RequiredNodeFeatureMissing,
108 nativeFailureCode::IncorrectOrUnknownPaymentDetails => FailureCode::IncorrectOrUnknownPaymentDetails,
109 nativeFailureCode::InvalidOnionPayload (mut a, ) => {
110 let mut local_a = if a.is_none() { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::None } else { crate::c_types::derived::COption_C2Tuple_u64u16ZZ::Some( { let (mut orig_a_0_0, mut orig_a_0_1) = (a.unwrap()); let mut local_a_0 = (orig_a_0_0, orig_a_0_1).into(); local_a_0 }) };
111 FailureCode::InvalidOnionPayload (
118 /// Frees any resources used by the FailureCode
120 pub extern "C" fn FailureCode_free(this_ptr: FailureCode) { }
121 /// Creates a copy of the FailureCode
123 pub extern "C" fn FailureCode_clone(orig: &FailureCode) -> FailureCode {
127 /// Used only if an object of this type is returned as a trait impl by a method
128 pub(crate) extern "C" fn FailureCode_clone_void(this_ptr: *const c_void) -> *mut c_void {
129 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const FailureCode)).clone() })) as *mut c_void
132 /// Used only if an object of this type is returned as a trait impl by a method
133 pub(crate) extern "C" fn FailureCode_free_void(this_ptr: *mut c_void) {
134 let _ = unsafe { Box::from_raw(this_ptr as *mut FailureCode) };
137 /// Utility method to constructs a new TemporaryNodeFailure-variant FailureCode
138 pub extern "C" fn FailureCode_temporary_node_failure() -> FailureCode {
139 FailureCode::TemporaryNodeFailure}
141 /// Utility method to constructs a new RequiredNodeFeatureMissing-variant FailureCode
142 pub extern "C" fn FailureCode_required_node_feature_missing() -> FailureCode {
143 FailureCode::RequiredNodeFeatureMissing}
145 /// Utility method to constructs a new IncorrectOrUnknownPaymentDetails-variant FailureCode
146 pub extern "C" fn FailureCode_incorrect_or_unknown_payment_details() -> FailureCode {
147 FailureCode::IncorrectOrUnknownPaymentDetails}
149 /// Utility method to constructs a new InvalidOnionPayload-variant FailureCode
150 pub extern "C" fn FailureCode_invalid_onion_payload(a: crate::c_types::derived::COption_C2Tuple_u64u16ZZ) -> FailureCode {
151 FailureCode::InvalidOnionPayload(a, )
154 use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport;
155 pub(crate) type nativeChannelManager = nativeChannelManagerImport<crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>;
157 /// Manager which keeps track of a number of channels and sends messages to the appropriate
158 /// channel, also tracking HTLC preimages and forwarding onion packets appropriately.
160 /// Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through
161 /// to individual Channels.
163 /// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
164 /// all peers during write/read (though does not modify this instance, only the instance being
165 /// serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e.,
166 /// called [`funding_transaction_generated`] for outbound channels) being closed.
168 /// Note that you can be a bit lazier about writing out `ChannelManager` than you can be with
169 /// [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST durably write each
170 /// [`ChannelMonitorUpdate`] before returning from
171 /// [`chain::Watch::watch_channel`]/[`update_channel`] or before completing async writes. With
172 /// `ChannelManager`s, writing updates happens out-of-band (and will prevent any other
173 /// `ChannelManager` operations from occurring during the serialization process). If the
174 /// deserialized version is out-of-date compared to the [`ChannelMonitor`] passed by reference to
175 /// [`read`], those channels will be force-closed based on the `ChannelMonitor` state and no funds
176 /// will be lost (modulo on-chain transaction fees).
178 /// Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which
179 /// tells you the last block hash which was connected. You should get the best block tip before using the manager.
180 /// See [`chain::Listen`] and [`chain::Confirm`] for more details.
182 /// Note that `ChannelManager` is responsible for tracking liveness of its channels and generating
183 /// [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid
184 /// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
185 /// offline for a full minute. In order to track this, you must call
186 /// [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect.
188 /// To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and
189 /// inbound channels without confirmed funding transactions. This may result in nodes which we do
190 /// not have a channel with being unable to connect to us or open new channels with us if we have
191 /// many peers with unfunded channels.
193 /// Because it is an indication of trust, inbound channels which we've accepted as 0conf are
194 /// exempted from the count of unfunded channels. Similarly, outbound channels and connections are
195 /// never limited. Please ensure you limit the count of such channels yourself.
197 /// Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`]
198 /// a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but
199 /// essentially you should default to using a [`SimpleRefChannelManager`], and use a
200 /// [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when
201 /// you're using lightning-net-tokio.
203 /// [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
204 /// [`funding_created`]: msgs::FundingCreated
205 /// [`funding_transaction_generated`]: Self::funding_transaction_generated
206 /// [`BlockHash`]: bitcoin::hash_types::BlockHash
207 /// [`update_channel`]: chain::Watch::update_channel
208 /// [`ChannelUpdate`]: msgs::ChannelUpdate
209 /// [`timer_tick_occurred`]: Self::timer_tick_occurred
210 /// [`read`]: ReadableArgs::read
213 pub struct ChannelManager {
214 /// A pointer to the opaque Rust object.
216 /// Nearly everywhere, inner must be non-null, however in places where
217 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
218 pub inner: *mut nativeChannelManager,
219 /// Indicates that this is the only struct which contains the same pointer.
221 /// Rust functions which take ownership of an object provided via an argument require
222 /// this to be true and invalidate the object pointed to by inner.
226 impl Drop for ChannelManager {
228 if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) {
229 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
233 /// Frees any resources used by the ChannelManager, if is_owned is set and inner is non-NULL.
235 pub extern "C" fn ChannelManager_free(this_obj: ChannelManager) { }
237 /// Used only if an object of this type is returned as a trait impl by a method
238 pub(crate) extern "C" fn ChannelManager_free_void(this_ptr: *mut c_void) {
239 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelManager) };
242 impl ChannelManager {
243 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelManager {
244 unsafe { &*ObjOps::untweak_ptr(self.inner) }
246 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelManager {
247 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
249 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
250 pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager {
251 assert!(self.is_owned);
252 let ret = ObjOps::untweak_ptr(self.inner);
253 self.inner = core::ptr::null_mut();
258 use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport;
259 pub(crate) type nativeChainParameters = nativeChainParametersImport;
261 /// Chain-related parameters used to construct a new `ChannelManager`.
263 /// Typically, the block-specific parameters are derived from the best block hash for the network,
264 /// as a newly constructed `ChannelManager` will not have created any channels yet. These parameters
265 /// are not needed when deserializing a previously constructed `ChannelManager`.
268 pub struct ChainParameters {
269 /// A pointer to the opaque Rust object.
271 /// Nearly everywhere, inner must be non-null, however in places where
272 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
273 pub inner: *mut nativeChainParameters,
274 /// Indicates that this is the only struct which contains the same pointer.
276 /// Rust functions which take ownership of an object provided via an argument require
277 /// this to be true and invalidate the object pointed to by inner.
281 impl Drop for ChainParameters {
283 if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) {
284 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
288 /// Frees any resources used by the ChainParameters, if is_owned is set and inner is non-NULL.
290 pub extern "C" fn ChainParameters_free(this_obj: ChainParameters) { }
292 /// Used only if an object of this type is returned as a trait impl by a method
293 pub(crate) extern "C" fn ChainParameters_free_void(this_ptr: *mut c_void) {
294 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChainParameters) };
297 impl ChainParameters {
298 pub(crate) fn get_native_ref(&self) -> &'static nativeChainParameters {
299 unsafe { &*ObjOps::untweak_ptr(self.inner) }
301 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChainParameters {
302 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
304 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
305 pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters {
306 assert!(self.is_owned);
307 let ret = ObjOps::untweak_ptr(self.inner);
308 self.inner = core::ptr::null_mut();
312 /// The network for determining the `chain_hash` in Lightning messages.
314 pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network {
315 let mut inner_val = &mut this_ptr.get_native_mut_ref().network;
316 crate::bitcoin::network::Network::from_bitcoin(inner_val)
318 /// The network for determining the `chain_hash` in Lightning messages.
320 pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) {
321 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network = val.into_bitcoin();
323 /// The hash and height of the latest block successfully connected.
325 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
327 pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::chain::BestBlock {
328 let mut inner_val = &mut this_ptr.get_native_mut_ref().best_block;
329 crate::lightning::chain::BestBlock { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::BestBlock<>) as *mut _) }, is_owned: false }
331 /// The hash and height of the latest block successfully connected.
333 /// Used to track on-chain channel funding outputs and send payments with reliable timelocks.
335 pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::chain::BestBlock) {
336 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.best_block = *unsafe { Box::from_raw(val.take_inner()) };
338 /// Constructs a new ChainParameters given each field
341 pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::chain::BestBlock) -> ChainParameters {
342 ChainParameters { inner: ObjOps::heap_alloc(nativeChainParameters {
343 network: network_arg.into_bitcoin(),
344 best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) },
347 impl Clone for ChainParameters {
348 fn clone(&self) -> Self {
350 inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
351 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
357 /// Used only if an object of this type is returned as a trait impl by a method
358 pub(crate) extern "C" fn ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void {
359 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChainParameters)).clone() })) as *mut c_void
362 /// Creates a copy of the ChainParameters
363 pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters {
366 /// The amount of time in blocks we require our counterparty wait to claim their money (ie time
367 /// between when we, or our watchtower, must check for them having broadcast a theft transaction).
369 /// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
371 /// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
374 pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT;
375 /// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
376 /// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour.
378 /// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`]
380 /// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta
383 pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA;
384 /// Minimum CLTV difference between the current block height and received inbound payments.
385 /// Invoices generated for payment to us must set their `min_final_cltv_expiry_delta` field to at least
389 pub static MIN_FINAL_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA;
391 use lightning::ln::channelmanager::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport;
392 pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport;
394 /// Information needed for constructing an invoice route hint for this channel.
397 pub struct CounterpartyForwardingInfo {
398 /// A pointer to the opaque Rust object.
400 /// Nearly everywhere, inner must be non-null, however in places where
401 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
402 pub inner: *mut nativeCounterpartyForwardingInfo,
403 /// Indicates that this is the only struct which contains the same pointer.
405 /// Rust functions which take ownership of an object provided via an argument require
406 /// this to be true and invalidate the object pointed to by inner.
410 impl Drop for CounterpartyForwardingInfo {
412 if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) {
413 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
417 /// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL.
419 pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { }
421 /// Used only if an object of this type is returned as a trait impl by a method
422 pub(crate) extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) {
423 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCounterpartyForwardingInfo) };
426 impl CounterpartyForwardingInfo {
427 pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo {
428 unsafe { &*ObjOps::untweak_ptr(self.inner) }
430 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo {
431 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
433 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
434 pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo {
435 assert!(self.is_owned);
436 let ret = ObjOps::untweak_ptr(self.inner);
437 self.inner = core::ptr::null_mut();
441 /// Base routing fee in millisatoshis.
443 pub extern "C" fn CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: &CounterpartyForwardingInfo) -> u32 {
444 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat;
447 /// Base routing fee in millisatoshis.
449 pub extern "C" fn CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
450 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val;
452 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
454 pub extern "C" fn CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: &CounterpartyForwardingInfo) -> u32 {
455 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths;
458 /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
460 pub extern "C" fn CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) {
461 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val;
463 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
464 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
465 /// `cltv_expiry_delta` for more details.
467 pub extern "C" fn CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: &CounterpartyForwardingInfo) -> u16 {
468 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
471 /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
472 /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
473 /// `cltv_expiry_delta` for more details.
475 pub extern "C" fn CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: &mut CounterpartyForwardingInfo, mut val: u16) {
476 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
478 /// Constructs a new CounterpartyForwardingInfo given each field
481 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 {
482 CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(nativeCounterpartyForwardingInfo {
483 fee_base_msat: fee_base_msat_arg,
484 fee_proportional_millionths: fee_proportional_millionths_arg,
485 cltv_expiry_delta: cltv_expiry_delta_arg,
488 impl Clone for CounterpartyForwardingInfo {
489 fn clone(&self) -> Self {
491 inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
492 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
498 /// Used only if an object of this type is returned as a trait impl by a method
499 pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void {
500 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCounterpartyForwardingInfo)).clone() })) as *mut c_void
503 /// Creates a copy of the CounterpartyForwardingInfo
504 pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo {
508 use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport;
509 pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport;
511 /// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
512 /// to better separate parameters.
515 pub struct ChannelCounterparty {
516 /// A pointer to the opaque Rust object.
518 /// Nearly everywhere, inner must be non-null, however in places where
519 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
520 pub inner: *mut nativeChannelCounterparty,
521 /// Indicates that this is the only struct which contains the same pointer.
523 /// Rust functions which take ownership of an object provided via an argument require
524 /// this to be true and invalidate the object pointed to by inner.
528 impl Drop for ChannelCounterparty {
530 if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) {
531 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
535 /// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
537 pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { }
539 /// Used only if an object of this type is returned as a trait impl by a method
540 pub(crate) extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) {
541 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelCounterparty) };
544 impl ChannelCounterparty {
545 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty {
546 unsafe { &*ObjOps::untweak_ptr(self.inner) }
548 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty {
549 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
551 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
552 pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
553 assert!(self.is_owned);
554 let ret = ObjOps::untweak_ptr(self.inner);
555 self.inner = core::ptr::null_mut();
559 /// The node_id of our counterparty
561 pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey {
562 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id;
563 crate::c_types::PublicKey::from_rust(&inner_val)
565 /// The node_id of our counterparty
567 pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) {
568 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust();
570 /// The Features the channel counterparty provided upon last connection.
571 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
572 /// many routing-relevant features are present in the init context.
574 pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures {
575 let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
576 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 }
578 /// The Features the channel counterparty provided upon last connection.
579 /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
580 /// many routing-relevant features are present in the init context.
582 pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) {
583 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) };
585 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
586 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
587 /// claiming at least this value on chain.
589 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
591 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
593 pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 {
594 let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
597 /// The value, in satoshis, that must always be held in the channel for our counterparty. This
598 /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
599 /// claiming at least this value on chain.
601 /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
603 /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
605 pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) {
606 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = val;
608 /// Information on the fees and requirements that the counterparty requires when forwarding
609 /// payments to us through this channel.
611 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
613 pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channelmanager::CounterpartyForwardingInfo {
614 let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info;
615 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 };
618 /// Information on the fees and requirements that the counterparty requires when forwarding
619 /// payments to us through this channel.
621 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
623 pub extern "C" fn ChannelCounterparty_set_forwarding_info(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) {
624 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
625 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_info = local_val;
627 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
628 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
629 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
631 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_minimum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
632 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_minimum_msat;
633 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() }) };
636 /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
637 /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
638 /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
640 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_minimum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
641 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
642 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_minimum_msat = local_val;
644 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
646 pub extern "C" fn ChannelCounterparty_get_outbound_htlc_maximum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z {
647 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_maximum_msat;
648 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() }) };
651 /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
653 pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) {
654 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
655 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_maximum_msat = local_val;
657 /// Constructs a new ChannelCounterparty given each field
659 /// Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
662 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 {
663 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()) } }) };
664 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 };
665 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 };
666 ChannelCounterparty { inner: ObjOps::heap_alloc(nativeChannelCounterparty {
667 node_id: node_id_arg.into_rust(),
668 features: *unsafe { Box::from_raw(features_arg.take_inner()) },
669 unspendable_punishment_reserve: unspendable_punishment_reserve_arg,
670 forwarding_info: local_forwarding_info_arg,
671 outbound_htlc_minimum_msat: local_outbound_htlc_minimum_msat_arg,
672 outbound_htlc_maximum_msat: local_outbound_htlc_maximum_msat_arg,
675 impl Clone for ChannelCounterparty {
676 fn clone(&self) -> Self {
678 inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else {
679 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
685 /// Used only if an object of this type is returned as a trait impl by a method
686 pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void {
687 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelCounterparty)).clone() })) as *mut c_void
690 /// Creates a copy of the ChannelCounterparty
691 pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty {
695 use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport;
696 pub(crate) type nativeChannelDetails = nativeChannelDetailsImport;
698 /// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
701 pub struct ChannelDetails {
702 /// A pointer to the opaque Rust object.
704 /// Nearly everywhere, inner must be non-null, however in places where
705 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
706 pub inner: *mut nativeChannelDetails,
707 /// Indicates that this is the only struct which contains the same pointer.
709 /// Rust functions which take ownership of an object provided via an argument require
710 /// this to be true and invalidate the object pointed to by inner.
714 impl Drop for ChannelDetails {
716 if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) {
717 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
721 /// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL.
723 pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { }
725 /// Used only if an object of this type is returned as a trait impl by a method
726 pub(crate) extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) {
727 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDetails) };
730 impl ChannelDetails {
731 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails {
732 unsafe { &*ObjOps::untweak_ptr(self.inner) }
734 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails {
735 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
737 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
738 pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
739 assert!(self.is_owned);
740 let ret = ObjOps::untweak_ptr(self.inner);
741 self.inner = core::ptr::null_mut();
745 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
746 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
747 /// Note that this means this value is *not* persistent - it can change once during the
748 /// lifetime of the channel.
750 pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] {
751 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
754 /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
755 /// thereafter this is the txid of the funding transaction xor the funding transaction output).
756 /// Note that this means this value is *not* persistent - it can change once during the
757 /// lifetime of the channel.
759 pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) {
760 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data);
762 /// Parameters which apply to our counterparty. See individual fields for more information.
764 pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channelmanager::ChannelCounterparty {
765 let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty;
766 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 }
768 /// Parameters which apply to our counterparty. See individual fields for more information.
770 pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channelmanager::ChannelCounterparty) {
771 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty = *unsafe { Box::from_raw(val.take_inner()) };
773 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
774 /// our counterparty already.
776 /// Note that, if this has been set, `channel_id` will be equivalent to
777 /// `funding_txo.unwrap().to_channel_id()`.
779 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
781 pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
782 let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo;
783 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 };
786 /// The Channel's funding transaction output, if we've negotiated the funding transaction with
787 /// our counterparty already.
789 /// Note that, if this has been set, `channel_id` will be equivalent to
790 /// `funding_txo.unwrap().to_channel_id()`.
792 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
794 pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) {
795 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
796 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val;
798 /// The features which this channel operates with. See individual features for more info.
800 /// `None` until negotiation completes and the channel type is finalized.
802 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
804 pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures {
805 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
806 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 };
809 /// The features which this channel operates with. See individual features for more info.
811 /// `None` until negotiation completes and the channel type is finalized.
813 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
815 pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
816 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
817 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
819 /// The position of the funding transaction in the chain. None if the funding transaction has
820 /// not yet been confirmed and the channel fully opened.
822 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
823 /// payments instead of this. See [`get_inbound_payment_scid`].
825 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
826 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
828 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
829 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
830 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
831 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
832 /// [`confirmations_required`]: Self::confirmations_required
834 pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
835 let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id;
836 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
839 /// The position of the funding transaction in the chain. None if the funding transaction has
840 /// not yet been confirmed and the channel fully opened.
842 /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
843 /// payments instead of this. See [`get_inbound_payment_scid`].
845 /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
846 /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
848 /// [`inbound_scid_alias`]: Self::inbound_scid_alias
849 /// [`outbound_scid_alias`]: Self::outbound_scid_alias
850 /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
851 /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
852 /// [`confirmations_required`]: Self::confirmations_required
854 pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
855 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
856 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val;
858 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
859 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
860 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
863 /// This will be `None` as long as the channel is not available for routing outbound payments.
865 /// [`short_channel_id`]: Self::short_channel_id
866 /// [`confirmations_required`]: Self::confirmations_required
868 pub extern "C" fn ChannelDetails_get_outbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
869 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_scid_alias;
870 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() }) };
873 /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
874 /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
875 /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
878 /// This will be `None` as long as the channel is not available for routing outbound payments.
880 /// [`short_channel_id`]: Self::short_channel_id
881 /// [`confirmations_required`]: Self::confirmations_required
883 pub extern "C" fn ChannelDetails_set_outbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
884 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
885 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_scid_alias = local_val;
887 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
888 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
889 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
890 /// when they see a payment to be routed to us.
892 /// Our counterparty may choose to rotate this value at any time, though will always recognize
893 /// previous values for inbound payment forwarding.
895 /// [`short_channel_id`]: Self::short_channel_id
897 pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
898 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias;
899 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() }) };
902 /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
903 /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
904 /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
905 /// when they see a payment to be routed to us.
907 /// Our counterparty may choose to rotate this value at any time, though will always recognize
908 /// previous values for inbound payment forwarding.
910 /// [`short_channel_id`]: Self::short_channel_id
912 pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
913 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
914 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val;
916 /// The value, in satoshis, of this channel as appears in the funding output
918 pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 {
919 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis;
922 /// The value, in satoshis, of this channel as appears in the funding output
924 pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) {
925 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val;
927 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
928 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
929 /// this value on chain.
931 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
933 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
935 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
937 pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
938 let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve;
939 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() }) };
942 /// The value, in satoshis, that must always be held in the channel for us. This value ensures
943 /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
944 /// this value on chain.
946 /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
948 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
950 /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
952 pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
953 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
954 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = local_val;
956 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
957 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
958 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
959 /// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
960 /// serialized with LDK versions prior to 0.0.113.
962 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
963 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
964 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
966 pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::U128 {
967 let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id;
970 /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
971 /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
972 /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
973 /// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects
974 /// serialized with LDK versions prior to 0.0.113.
976 /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
977 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
978 /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
980 pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) {
981 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into();
983 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
984 /// which is applied to commitment and HTLC transactions.
986 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
988 pub extern "C" fn ChannelDetails_get_feerate_sat_per_1000_weight(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
989 let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight;
990 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() }) };
993 /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
994 /// which is applied to commitment and HTLC transactions.
996 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
998 pub extern "C" fn ChannelDetails_set_feerate_sat_per_1000_weight(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
999 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1000 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = local_val;
1002 /// Our total balance. This is the amount we would get if we close the channel.
1003 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
1004 /// amount is not likely to be recoverable on close.
1006 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
1007 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
1008 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
1009 /// This does not consider any on-chain fees.
1011 /// See also [`ChannelDetails::outbound_capacity_msat`]
1013 pub extern "C" fn ChannelDetails_get_balance_msat(this_ptr: &ChannelDetails) -> u64 {
1014 let mut inner_val = &mut this_ptr.get_native_mut_ref().balance_msat;
1017 /// Our total balance. This is the amount we would get if we close the channel.
1018 /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
1019 /// amount is not likely to be recoverable on close.
1021 /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
1022 /// balance is not available for inclusion in new outbound HTLCs). This further does not include
1023 /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
1024 /// This does not consider any on-chain fees.
1026 /// See also [`ChannelDetails::outbound_capacity_msat`]
1028 pub extern "C" fn ChannelDetails_set_balance_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1029 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.balance_msat = val;
1031 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
1032 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1033 /// available for inclusion in new outbound HTLCs). This further does not include any pending
1034 /// outgoing HTLCs which are awaiting some other resolution to be sent.
1036 /// See also [`ChannelDetails::balance_msat`]
1038 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1039 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
1040 /// should be able to spend nearly this amount.
1042 pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
1043 let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_capacity_msat;
1046 /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
1047 /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1048 /// available for inclusion in new outbound HTLCs). This further does not include any pending
1049 /// outgoing HTLCs which are awaiting some other resolution to be sent.
1051 /// See also [`ChannelDetails::balance_msat`]
1053 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1054 /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
1055 /// should be able to spend nearly this amount.
1057 pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1058 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_capacity_msat = val;
1060 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
1061 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
1062 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
1063 /// to use a limit as close as possible to the HTLC limit we can currently send.
1065 /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1066 /// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
1068 pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 {
1069 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat;
1072 /// The available outbound capacity for sending a single HTLC to the remote peer. This is
1073 /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
1074 /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
1075 /// to use a limit as close as possible to the HTLC limit we can currently send.
1077 /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
1078 /// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
1080 pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1081 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val;
1083 /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
1084 /// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
1085 /// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
1086 /// route which is valid.
1088 pub extern "C" fn ChannelDetails_get_next_outbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> u64 {
1089 let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_minimum_msat;
1092 /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
1093 /// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
1094 /// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
1095 /// route which is valid.
1097 pub extern "C" fn ChannelDetails_set_next_outbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1098 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_minimum_msat = val;
1100 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
1101 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1102 /// available for inclusion in new inbound HTLCs).
1103 /// Note that there are some corner cases not fully handled here, so the actual available
1104 /// inbound capacity may be slightly higher than this.
1106 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1107 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
1108 /// However, our counterparty should be able to spend nearly this amount.
1110 pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 {
1111 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_capacity_msat;
1114 /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
1115 /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
1116 /// available for inclusion in new inbound HTLCs).
1117 /// Note that there are some corner cases not fully handled here, so the actual available
1118 /// inbound capacity may be slightly higher than this.
1120 /// This value is not exact. Due to various in-flight changes, feerate changes, and our
1121 /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
1122 /// However, our counterparty should be able to spend nearly this amount.
1124 pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) {
1125 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_capacity_msat = val;
1127 /// The number of required confirmations on the funding transaction before the funding will be
1128 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
1129 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
1130 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
1131 /// [`ChannelHandshakeLimits::max_minimum_depth`].
1133 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1135 /// [`is_outbound`]: ChannelDetails::is_outbound
1136 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
1137 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
1139 pub extern "C" fn ChannelDetails_get_confirmations_required(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
1140 let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations_required;
1141 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() }) };
1144 /// The number of required confirmations on the funding transaction before the funding will be
1145 /// considered \"locked\". This number is selected by the channel fundee (i.e. us if
1146 /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
1147 /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
1148 /// [`ChannelHandshakeLimits::max_minimum_depth`].
1150 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1152 /// [`is_outbound`]: ChannelDetails::is_outbound
1153 /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
1154 /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
1156 pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
1157 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1158 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations_required = local_val;
1160 /// The current number of confirmations on the funding transaction.
1162 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1164 pub extern "C" fn ChannelDetails_get_confirmations(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z {
1165 let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations;
1166 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() }) };
1169 /// The current number of confirmations on the funding transaction.
1171 /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
1173 pub extern "C" fn ChannelDetails_set_confirmations(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) {
1174 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1175 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations = local_val;
1177 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
1178 /// until we can claim our funds after we force-close the channel. During this time our
1179 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
1180 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
1181 /// time to claim our non-HTLC-encumbered funds.
1183 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1185 pub extern "C" fn ChannelDetails_get_force_close_spend_delay(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u16Z {
1186 let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_spend_delay;
1187 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() }) };
1190 /// The number of blocks (after our commitment transaction confirms) that we will need to wait
1191 /// until we can claim our funds after we force-close the channel. During this time our
1192 /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
1193 /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
1194 /// time to claim our non-HTLC-encumbered funds.
1196 /// This value will be `None` for outbound channels until the counterparty accepts the channel.
1198 pub extern "C" fn ChannelDetails_set_force_close_spend_delay(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u16Z) {
1199 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1200 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_spend_delay = local_val;
1202 /// True if the channel was initiated (and thus funded) by us.
1204 pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool {
1205 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_outbound;
1208 /// True if the channel was initiated (and thus funded) by us.
1210 pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) {
1211 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_outbound = val;
1213 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1214 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1215 /// required confirmation count has been reached (and we were connected to the peer at some
1216 /// point after the funding transaction received enough confirmations). The required
1217 /// confirmation count is provided in [`confirmations_required`].
1219 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1221 pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) -> bool {
1222 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_channel_ready;
1225 /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
1226 /// channel is not currently being shut down. `channel_ready` message exchange implies the
1227 /// required confirmation count has been reached (and we were connected to the peer at some
1228 /// point after the funding transaction received enough confirmations). The required
1229 /// confirmation count is provided in [`confirmations_required`].
1231 /// [`confirmations_required`]: ChannelDetails::confirmations_required
1233 pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) {
1234 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val;
1236 /// The stage of the channel's shutdown.
1237 /// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
1239 /// Returns a copy of the field.
1241 pub extern "C" fn ChannelDetails_get_channel_shutdown_state(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_ChannelShutdownStateZ {
1242 let mut inner_val = this_ptr.get_native_mut_ref().channel_shutdown_state.clone();
1243 let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ChannelShutdownStateZ::None } else { crate::c_types::derived::COption_ChannelShutdownStateZ::Some( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(inner_val.unwrap()) }) };
1246 /// The stage of the channel's shutdown.
1247 /// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
1249 pub extern "C" fn ChannelDetails_set_channel_shutdown_state(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_ChannelShutdownStateZ) {
1250 let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
1251 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_shutdown_state = local_val;
1253 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1254 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1256 /// This is a strict superset of `is_channel_ready`.
1258 pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool {
1259 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_usable;
1262 /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
1263 /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
1265 /// This is a strict superset of `is_channel_ready`.
1267 pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) {
1268 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_usable = val;
1270 /// True if this channel is (or will be) publicly-announced.
1272 pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool {
1273 let mut inner_val = &mut this_ptr.get_native_mut_ref().is_public;
1276 /// True if this channel is (or will be) publicly-announced.
1278 pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) {
1279 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_public = val;
1281 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1282 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1284 pub extern "C" fn ChannelDetails_get_inbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1285 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_minimum_msat;
1286 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() }) };
1289 /// The smallest value HTLC (in msat) we will accept, for this channel. This field
1290 /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
1292 pub extern "C" fn ChannelDetails_set_inbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1293 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1294 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_minimum_msat = local_val;
1296 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1298 pub extern "C" fn ChannelDetails_get_inbound_htlc_maximum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1299 let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_maximum_msat;
1300 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() }) };
1303 /// The largest value HTLC (in msat) we currently will accept, for this channel.
1305 pub extern "C" fn ChannelDetails_set_inbound_htlc_maximum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) {
1306 let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1307 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_maximum_msat = local_val;
1309 /// Set of configurable parameters that affect channel operation.
1311 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1313 /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
1315 pub extern "C" fn ChannelDetails_get_config(this_ptr: &ChannelDetails) -> crate::lightning::util::config::ChannelConfig {
1316 let mut inner_val = &mut this_ptr.get_native_mut_ref().config;
1317 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 };
1320 /// Set of configurable parameters that affect channel operation.
1322 /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
1324 /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
1326 pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut val: crate::lightning::util::config::ChannelConfig) {
1327 let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
1328 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.config = local_val;
1330 /// Constructs a new ChannelDetails given each field
1332 /// Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1333 /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1334 /// Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
1337 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 next_outbound_htlc_minimum_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 channel_shutdown_state_arg: crate::c_types::derived::COption_ChannelShutdownStateZ, 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 {
1338 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()) } }) };
1339 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()) } }) };
1340 let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None };
1341 let mut local_outbound_scid_alias_arg = if outbound_scid_alias_arg.is_some() { Some( { outbound_scid_alias_arg.take() }) } else { None };
1342 let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None };
1343 let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None };
1344 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 };
1345 let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None };
1346 let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None };
1347 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 };
1348 let mut local_channel_shutdown_state_arg = { /*channel_shutdown_state_arg*/ let channel_shutdown_state_arg_opt = channel_shutdown_state_arg; if channel_shutdown_state_arg_opt.is_none() { None } else { Some({ { { channel_shutdown_state_arg_opt.take() }.into_native() }})} };
1349 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 };
1350 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 };
1351 let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) };
1352 ChannelDetails { inner: ObjOps::heap_alloc(nativeChannelDetails {
1353 channel_id: ::lightning::ln::ChannelId(channel_id_arg.data),
1354 counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) },
1355 funding_txo: local_funding_txo_arg,
1356 channel_type: local_channel_type_arg,
1357 short_channel_id: local_short_channel_id_arg,
1358 outbound_scid_alias: local_outbound_scid_alias_arg,
1359 inbound_scid_alias: local_inbound_scid_alias_arg,
1360 channel_value_satoshis: channel_value_satoshis_arg,
1361 unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg,
1362 user_channel_id: user_channel_id_arg.into(),
1363 feerate_sat_per_1000_weight: local_feerate_sat_per_1000_weight_arg,
1364 balance_msat: balance_msat_arg,
1365 outbound_capacity_msat: outbound_capacity_msat_arg,
1366 next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg,
1367 next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat_arg,
1368 inbound_capacity_msat: inbound_capacity_msat_arg,
1369 confirmations_required: local_confirmations_required_arg,
1370 confirmations: local_confirmations_arg,
1371 force_close_spend_delay: local_force_close_spend_delay_arg,
1372 is_outbound: is_outbound_arg,
1373 is_channel_ready: is_channel_ready_arg,
1374 channel_shutdown_state: local_channel_shutdown_state_arg,
1375 is_usable: is_usable_arg,
1376 is_public: is_public_arg,
1377 inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg,
1378 inbound_htlc_maximum_msat: local_inbound_htlc_maximum_msat_arg,
1379 config: local_config_arg,
1380 }), is_owned: true }
1382 impl Clone for ChannelDetails {
1383 fn clone(&self) -> Self {
1385 inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
1386 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1392 /// Used only if an object of this type is returned as a trait impl by a method
1393 pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
1394 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelDetails)).clone() })) as *mut c_void
1397 /// Creates a copy of the ChannelDetails
1398 pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
1401 /// Gets the current SCID which should be used to identify this channel for inbound payments.
1402 /// This should be used for providing invoice hints or in any other context where our
1403 /// counterparty will forward a payment to us.
1405 /// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
1406 /// [`ChannelDetails::short_channel_id`]. See those for more information.
1409 pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1410 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid();
1411 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() }) };
1415 /// Gets the current SCID which should be used to identify this channel for outbound payments.
1416 /// This should be used in [`Route`]s to describe the first hop or in other contexts where
1417 /// we're sending or forwarding a payment outbound over this channel.
1419 /// This is either the [`ChannelDetails::short_channel_id`], if set, or the
1420 /// [`ChannelDetails::outbound_scid_alias`]. See those for more information.
1423 pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z {
1424 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_outbound_payment_scid();
1425 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() }) };
1429 /// Further information on the details of the channel shutdown.
1430 /// Upon channels being forced closed (i.e. commitment transaction confirmation detected
1431 /// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or
1432 /// the channel will be removed shortly.
1433 /// Also note, that in normal operation, peers could disconnect at any of these states
1434 /// and require peer re-connection before making progress onto other states
1438 pub enum ChannelShutdownState {
1439 /// Channel has not sent or received a shutdown message.
1441 /// Local node has sent a shutdown message for this channel.
1443 /// Shutdown message exchanges have concluded and the channels are in the midst of
1444 /// resolving all existing open HTLCs before closing can continue.
1446 /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates.
1447 NegotiatingClosingFee,
1448 /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about
1449 /// to drop the channel.
1452 use lightning::ln::channelmanager::ChannelShutdownState as ChannelShutdownStateImport;
1453 pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport;
1455 impl ChannelShutdownState {
1457 pub(crate) fn to_native(&self) -> nativeChannelShutdownState {
1459 ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown,
1460 ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated,
1461 ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs,
1462 ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee,
1463 ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete,
1467 pub(crate) fn into_native(self) -> nativeChannelShutdownState {
1469 ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown,
1470 ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated,
1471 ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs,
1472 ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee,
1473 ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete,
1477 pub(crate) fn from_native(native: &nativeChannelShutdownState) -> Self {
1479 nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown,
1480 nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated,
1481 nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs,
1482 nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee,
1483 nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete,
1487 pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self {
1489 nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown,
1490 nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated,
1491 nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs,
1492 nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee,
1493 nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete,
1497 /// Creates a copy of the ChannelShutdownState
1499 pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState {
1503 /// Used only if an object of this type is returned as a trait impl by a method
1504 pub(crate) extern "C" fn ChannelShutdownState_clone_void(this_ptr: *const c_void) -> *mut c_void {
1505 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ChannelShutdownState)).clone() })) as *mut c_void
1508 /// Used only if an object of this type is returned as a trait impl by a method
1509 pub(crate) extern "C" fn ChannelShutdownState_free_void(this_ptr: *mut c_void) {
1510 let _ = unsafe { Box::from_raw(this_ptr as *mut ChannelShutdownState) };
1513 /// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState
1514 pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState {
1515 ChannelShutdownState::NotShuttingDown}
1517 /// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState
1518 pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState {
1519 ChannelShutdownState::ShutdownInitiated}
1521 /// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState
1522 pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState {
1523 ChannelShutdownState::ResolvingHTLCs}
1525 /// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState
1526 pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState {
1527 ChannelShutdownState::NegotiatingClosingFee}
1529 /// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState
1530 pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState {
1531 ChannelShutdownState::ShutdownComplete}
1532 /// Checks if two ChannelShutdownStates contain equal inner contents.
1533 /// This ignores pointers and is_owned flags and looks at the values in fields.
1535 pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool {
1536 if &a.to_native() == &b.to_native() { true } else { false }
1538 /// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
1539 /// These include payments that have yet to find a successful path, or have unresolved HTLCs.
1543 pub enum RecentPaymentDetails {
1544 /// When an invoice was requested and thus a payment has not yet been sent.
1546 /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
1547 /// a payment and ensure idempotency in LDK.
1548 payment_id: crate::c_types::ThirtyTwoBytes,
1550 /// When a payment is still being sent and awaiting successful delivery.
1552 /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
1553 /// a payment and ensure idempotency in LDK.
1554 payment_id: crate::c_types::ThirtyTwoBytes,
1555 /// Hash of the payment that is currently being sent but has yet to be fulfilled or
1557 payment_hash: crate::c_types::ThirtyTwoBytes,
1558 /// Total amount (in msat, excluding fees) across all paths for this payment,
1559 /// not just the amount currently inflight.
1562 /// When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have
1563 /// been resolved. Upon receiving [`Event::PaymentSent`], we delay for a few minutes before the
1564 /// payment is removed from tracking.
1566 /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
1567 /// a payment and ensure idempotency in LDK.
1568 payment_id: crate::c_types::ThirtyTwoBytes,
1569 /// Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`]
1570 /// made before LDK version 0.0.104.
1571 payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ,
1573 /// After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly
1574 /// abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all
1575 /// pending HTLCs for this payment resolve and an [`Event::PaymentFailed`] is generated.
1577 /// A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
1578 /// a payment and ensure idempotency in LDK.
1579 payment_id: crate::c_types::ThirtyTwoBytes,
1580 /// Hash of the payment that we have given up trying to send.
1581 payment_hash: crate::c_types::ThirtyTwoBytes,
1584 use lightning::ln::channelmanager::RecentPaymentDetails as RecentPaymentDetailsImport;
1585 pub(crate) type nativeRecentPaymentDetails = RecentPaymentDetailsImport;
1587 impl RecentPaymentDetails {
1589 pub(crate) fn to_native(&self) -> nativeRecentPaymentDetails {
1591 RecentPaymentDetails::AwaitingInvoice {ref payment_id, } => {
1592 let mut payment_id_nonref = Clone::clone(payment_id);
1593 nativeRecentPaymentDetails::AwaitingInvoice {
1594 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1597 RecentPaymentDetails::Pending {ref payment_id, ref payment_hash, ref total_msat, } => {
1598 let mut payment_id_nonref = Clone::clone(payment_id);
1599 let mut payment_hash_nonref = Clone::clone(payment_hash);
1600 let mut total_msat_nonref = Clone::clone(total_msat);
1601 nativeRecentPaymentDetails::Pending {
1602 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1603 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1604 total_msat: total_msat_nonref,
1607 RecentPaymentDetails::Fulfilled {ref payment_id, ref payment_hash, } => {
1608 let mut payment_id_nonref = Clone::clone(payment_id);
1609 let mut payment_hash_nonref = Clone::clone(payment_hash);
1610 let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} };
1611 nativeRecentPaymentDetails::Fulfilled {
1612 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1613 payment_hash: local_payment_hash_nonref,
1616 RecentPaymentDetails::Abandoned {ref payment_id, ref payment_hash, } => {
1617 let mut payment_id_nonref = Clone::clone(payment_id);
1618 let mut payment_hash_nonref = Clone::clone(payment_hash);
1619 nativeRecentPaymentDetails::Abandoned {
1620 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data),
1621 payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
1627 pub(crate) fn into_native(self) -> nativeRecentPaymentDetails {
1629 RecentPaymentDetails::AwaitingInvoice {mut payment_id, } => {
1630 nativeRecentPaymentDetails::AwaitingInvoice {
1631 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1634 RecentPaymentDetails::Pending {mut payment_id, mut payment_hash, mut total_msat, } => {
1635 nativeRecentPaymentDetails::Pending {
1636 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1637 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1638 total_msat: total_msat,
1641 RecentPaymentDetails::Fulfilled {mut payment_id, mut payment_hash, } => {
1642 let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} };
1643 nativeRecentPaymentDetails::Fulfilled {
1644 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1645 payment_hash: local_payment_hash,
1648 RecentPaymentDetails::Abandoned {mut payment_id, mut payment_hash, } => {
1649 nativeRecentPaymentDetails::Abandoned {
1650 payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data),
1651 payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
1657 pub(crate) fn from_native(native: &nativeRecentPaymentDetails) -> Self {
1659 nativeRecentPaymentDetails::AwaitingInvoice {ref payment_id, } => {
1660 let mut payment_id_nonref = Clone::clone(payment_id);
1661 RecentPaymentDetails::AwaitingInvoice {
1662 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1665 nativeRecentPaymentDetails::Pending {ref payment_id, ref payment_hash, ref total_msat, } => {
1666 let mut payment_id_nonref = Clone::clone(payment_id);
1667 let mut payment_hash_nonref = Clone::clone(payment_hash);
1668 let mut total_msat_nonref = Clone::clone(total_msat);
1669 RecentPaymentDetails::Pending {
1670 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1671 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1672 total_msat: total_msat_nonref,
1675 nativeRecentPaymentDetails::Fulfilled {ref payment_id, ref payment_hash, } => {
1676 let mut payment_id_nonref = Clone::clone(payment_id);
1677 let mut payment_hash_nonref = Clone::clone(payment_hash);
1678 let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) };
1679 RecentPaymentDetails::Fulfilled {
1680 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1681 payment_hash: local_payment_hash_nonref,
1684 nativeRecentPaymentDetails::Abandoned {ref payment_id, ref payment_hash, } => {
1685 let mut payment_id_nonref = Clone::clone(payment_id);
1686 let mut payment_hash_nonref = Clone::clone(payment_hash);
1687 RecentPaymentDetails::Abandoned {
1688 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 },
1689 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
1695 pub(crate) fn native_into(native: nativeRecentPaymentDetails) -> Self {
1697 nativeRecentPaymentDetails::AwaitingInvoice {mut payment_id, } => {
1698 RecentPaymentDetails::AwaitingInvoice {
1699 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1702 nativeRecentPaymentDetails::Pending {mut payment_id, mut payment_hash, mut total_msat, } => {
1703 RecentPaymentDetails::Pending {
1704 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1705 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1706 total_msat: total_msat,
1709 nativeRecentPaymentDetails::Fulfilled {mut payment_id, mut payment_hash, } => {
1710 let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) };
1711 RecentPaymentDetails::Fulfilled {
1712 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1713 payment_hash: local_payment_hash,
1716 nativeRecentPaymentDetails::Abandoned {mut payment_id, mut payment_hash, } => {
1717 RecentPaymentDetails::Abandoned {
1718 payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 },
1719 payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
1725 /// Frees any resources used by the RecentPaymentDetails
1727 pub extern "C" fn RecentPaymentDetails_free(this_ptr: RecentPaymentDetails) { }
1728 /// Creates a copy of the RecentPaymentDetails
1730 pub extern "C" fn RecentPaymentDetails_clone(orig: &RecentPaymentDetails) -> RecentPaymentDetails {
1734 /// Used only if an object of this type is returned as a trait impl by a method
1735 pub(crate) extern "C" fn RecentPaymentDetails_clone_void(this_ptr: *const c_void) -> *mut c_void {
1736 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const RecentPaymentDetails)).clone() })) as *mut c_void
1739 /// Used only if an object of this type is returned as a trait impl by a method
1740 pub(crate) extern "C" fn RecentPaymentDetails_free_void(this_ptr: *mut c_void) {
1741 let _ = unsafe { Box::from_raw(this_ptr as *mut RecentPaymentDetails) };
1744 /// Utility method to constructs a new AwaitingInvoice-variant RecentPaymentDetails
1745 pub extern "C" fn RecentPaymentDetails_awaiting_invoice(payment_id: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails {
1746 RecentPaymentDetails::AwaitingInvoice {
1751 /// Utility method to constructs a new Pending-variant RecentPaymentDetails
1752 pub extern "C" fn RecentPaymentDetails_pending(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, total_msat: u64) -> RecentPaymentDetails {
1753 RecentPaymentDetails::Pending {
1760 /// Utility method to constructs a new Fulfilled-variant RecentPaymentDetails
1761 pub extern "C" fn RecentPaymentDetails_fulfilled(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> RecentPaymentDetails {
1762 RecentPaymentDetails::Fulfilled {
1768 /// Utility method to constructs a new Abandoned-variant RecentPaymentDetails
1769 pub extern "C" fn RecentPaymentDetails_abandoned(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes) -> RecentPaymentDetails {
1770 RecentPaymentDetails::Abandoned {
1776 use lightning::ln::channelmanager::PhantomRouteHints as nativePhantomRouteHintsImport;
1777 pub(crate) type nativePhantomRouteHints = nativePhantomRouteHintsImport;
1779 /// Route hints used in constructing invoices for [phantom node payents].
1781 /// [phantom node payments]: crate::sign::PhantomKeysManager
1784 pub struct PhantomRouteHints {
1785 /// A pointer to the opaque Rust object.
1787 /// Nearly everywhere, inner must be non-null, however in places where
1788 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1789 pub inner: *mut nativePhantomRouteHints,
1790 /// Indicates that this is the only struct which contains the same pointer.
1792 /// Rust functions which take ownership of an object provided via an argument require
1793 /// this to be true and invalidate the object pointed to by inner.
1797 impl Drop for PhantomRouteHints {
1798 fn drop(&mut self) {
1799 if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) {
1800 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1804 /// Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL.
1806 pub extern "C" fn PhantomRouteHints_free(this_obj: PhantomRouteHints) { }
1808 /// Used only if an object of this type is returned as a trait impl by a method
1809 pub(crate) extern "C" fn PhantomRouteHints_free_void(this_ptr: *mut c_void) {
1810 let _ = unsafe { Box::from_raw(this_ptr as *mut nativePhantomRouteHints) };
1813 impl PhantomRouteHints {
1814 pub(crate) fn get_native_ref(&self) -> &'static nativePhantomRouteHints {
1815 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1817 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePhantomRouteHints {
1818 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1820 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1821 pub(crate) fn take_inner(mut self) -> *mut nativePhantomRouteHints {
1822 assert!(self.is_owned);
1823 let ret = ObjOps::untweak_ptr(self.inner);
1824 self.inner = core::ptr::null_mut();
1828 /// The list of channels to be included in the invoice route hints.
1830 pub extern "C" fn PhantomRouteHints_get_channels(this_ptr: &PhantomRouteHints) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1831 let mut inner_val = &mut this_ptr.get_native_mut_ref().channels;
1832 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 } }); };
1833 local_inner_val.into()
1835 /// The list of channels to be included in the invoice route hints.
1837 pub extern "C" fn PhantomRouteHints_set_channels(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::derived::CVec_ChannelDetailsZ) {
1838 let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
1839 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channels = local_val;
1841 /// A fake scid used for representing the phantom node's fake channel in generating the invoice
1844 pub extern "C" fn PhantomRouteHints_get_phantom_scid(this_ptr: &PhantomRouteHints) -> u64 {
1845 let mut inner_val = &mut this_ptr.get_native_mut_ref().phantom_scid;
1848 /// A fake scid used for representing the phantom node's fake channel in generating the invoice
1851 pub extern "C" fn PhantomRouteHints_set_phantom_scid(this_ptr: &mut PhantomRouteHints, mut val: u64) {
1852 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.phantom_scid = val;
1854 /// The pubkey of the real backing node that would ultimately receive the payment.
1856 pub extern "C" fn PhantomRouteHints_get_real_node_pubkey(this_ptr: &PhantomRouteHints) -> crate::c_types::PublicKey {
1857 let mut inner_val = &mut this_ptr.get_native_mut_ref().real_node_pubkey;
1858 crate::c_types::PublicKey::from_rust(&inner_val)
1860 /// The pubkey of the real backing node that would ultimately receive the payment.
1862 pub extern "C" fn PhantomRouteHints_set_real_node_pubkey(this_ptr: &mut PhantomRouteHints, mut val: crate::c_types::PublicKey) {
1863 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.real_node_pubkey = val.into_rust();
1865 /// Constructs a new PhantomRouteHints given each field
1868 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 {
1869 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()) } }); };
1870 PhantomRouteHints { inner: ObjOps::heap_alloc(nativePhantomRouteHints {
1871 channels: local_channels_arg,
1872 phantom_scid: phantom_scid_arg,
1873 real_node_pubkey: real_node_pubkey_arg.into_rust(),
1874 }), is_owned: true }
1876 impl Clone for PhantomRouteHints {
1877 fn clone(&self) -> Self {
1879 inner: if <*mut nativePhantomRouteHints>::is_null(self.inner) { core::ptr::null_mut() } else {
1880 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1886 /// Used only if an object of this type is returned as a trait impl by a method
1887 pub(crate) extern "C" fn PhantomRouteHints_clone_void(this_ptr: *const c_void) -> *mut c_void {
1888 Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePhantomRouteHints)).clone() })) as *mut c_void
1891 /// Creates a copy of the PhantomRouteHints
1892 pub extern "C" fn PhantomRouteHints_clone(orig: &PhantomRouteHints) -> PhantomRouteHints {
1895 /// Constructs a new `ChannelManager` to hold several channels and route between them.
1897 /// The current time or latest block header time can be provided as the `current_timestamp`.
1899 /// This is the main \"logic hub\" for all channel-related actions, and implements
1900 /// [`ChannelMessageHandler`].
1902 /// Non-proportional fees are fixed according to our risk using the provided fee estimator.
1904 /// Users need to notify the new `ChannelManager` when a new block is connected or
1905 /// disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting
1906 /// from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for
1909 /// [`block_connected`]: chain::Listen::block_connected
1910 /// [`block_disconnected`]: chain::Listen::block_disconnected
1911 /// [`params.best_block.block_hash`]: chain::BestBlock::block_hash
1914 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::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut signer_provider: crate::lightning::sign::SignerProvider, mut config: crate::lightning::util::config::UserConfig, mut params: crate::lightning::ln::channelmanager::ChainParameters, mut current_timestamp: u32) -> crate::lightning::ln::channelmanager::ChannelManager {
1915 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()) }, current_timestamp);
1916 crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
1919 /// Gets the current configuration applied to all new channels.
1922 pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::config::UserConfig {
1923 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_current_default_configuration();
1924 crate::lightning::util::config::UserConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::util::config::UserConfig<>) as *mut _) }, is_owned: false }
1927 /// Creates a new outbound channel to the given remote node and with the given value.
1929 /// `user_channel_id` will be provided back as in
1930 /// [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
1931 /// correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
1932 /// randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
1933 /// is simply copied to events and otherwise ignored.
1935 /// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
1936 /// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
1938 /// Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to
1939 /// generate a shutdown scriptpubkey or destination script set by
1940 /// [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`].
1942 /// Note that we do not check if you are currently connected to the given peer. If no
1943 /// connection is available, the outbound `open_channel` message may fail to send, resulting in
1944 /// the channel eventually being silently forgotten (dropped on reload).
1946 /// Returns the new Channel's temporary `channel_id`. This ID will appear as
1947 /// [`Event::FundingGenerationReady::temporary_channel_id`] and in
1948 /// [`ChannelDetails::channel_id`] until after
1949 /// [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
1950 /// one derived from the funding transaction's TXID. If the counterparty rejects the channel
1951 /// immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
1953 /// [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
1954 /// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
1955 /// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
1957 /// Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
1960 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_ThirtyTwoBytesAPIErrorZ {
1961 let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) };
1962 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);
1963 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() };
1967 /// Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
1968 /// more information.
1971 pub extern "C" fn ChannelManager_list_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1972 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels();
1973 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 } }); };
1977 /// Gets the list of usable channels, in random order. Useful as an argument to
1978 /// [`Router::find_route`] to ensure non-announced channels are used.
1980 /// These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
1981 /// documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
1985 pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
1986 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_usable_channels();
1987 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 } }); };
1991 /// Gets the list of channels we have with a given counterparty, in random order.
1994 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 {
1995 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels_with_counterparty(&counterparty_node_id.into_rust());
1996 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 } }); };
2000 /// Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
2001 /// successful path, or have unresolved HTLCs.
2003 /// This can be useful for payments that may have been prepared, but ultimately not sent, as a
2004 /// result of a crash. If such a payment exists, is not listed here, and an
2005 /// [`Event::PaymentSent`] has not been received, you may consider resending the payment.
2007 /// [`Event::PaymentSent`]: events::Event::PaymentSent
2010 pub extern "C" fn ChannelManager_list_recent_payments(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_RecentPaymentDetailsZ {
2011 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_recent_payments();
2012 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::RecentPaymentDetails::native_into(item) }); };
2016 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
2017 /// will be accepted on the given channel, and after additional timeout/the closing of all
2018 /// pending HTLCs, the channel will be closed on chain.
2020 /// * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and
2021 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
2023 /// * If our counterparty is the channel initiator, we will require a channel closing
2024 /// transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which
2025 /// would appear on a force-closure transaction, whichever is lower. We will allow our
2026 /// counterparty to pay as much fee as they'd like, however.
2028 /// May generate a [`SendShutdown`] message event on success, which should be relayed.
2030 /// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
2031 /// generate a shutdown scriptpubkey or destination script set by
2032 /// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
2035 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
2036 /// [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
2037 /// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
2038 /// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
2041 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 {
2042 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust());
2043 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() };
2047 /// Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
2048 /// will be accepted on the given channel, and after additional timeout/the closing of all
2049 /// pending HTLCs, the channel will be closed on chain.
2051 /// `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
2052 /// the channel being closed or not:
2053 /// * If we are the channel initiator, we will pay at least this feerate on the closing
2054 /// transaction. The upper-bound is set by
2055 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
2056 /// fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
2057 /// * If our counterparty is the channel initiator, we will refuse to accept a channel closure
2058 /// transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
2059 /// will appear on a force-closure transaction, whichever is lower).
2061 /// The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction.
2062 /// Will fail if a shutdown script has already been set for this channel by
2063 /// ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must
2064 /// also be compatible with our and the counterparty's features.
2066 /// May generate a [`SendShutdown`] message event on success, which should be relayed.
2068 /// Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
2069 /// generate a shutdown scriptpubkey or destination script set by
2070 /// [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
2073 /// [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
2074 /// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
2075 /// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
2077 /// Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None
2080 pub extern "C" fn ChannelManager_close_channel_with_feerate_and_script(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: crate::c_types::derived::COption_u32Z, mut shutdown_script: crate::lightning::ln::script::ShutdownScript) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
2081 let mut local_target_feerate_sats_per_1000_weight = if target_feerate_sats_per_1000_weight.is_some() { Some( { target_feerate_sats_per_1000_weight.take() }) } else { None };
2082 let mut local_shutdown_script = if shutdown_script.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(shutdown_script.take_inner()) } }) };
2083 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_feerate_and_script(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust(), local_target_feerate_sats_per_1000_weight, local_shutdown_script);
2084 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() };
2088 /// Force closes a channel, immediately broadcasting the latest local transaction(s) and
2089 /// rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
2090 /// the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
2094 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 {
2095 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust());
2096 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() };
2100 /// Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
2101 /// the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
2102 /// `counterparty_node_id` isn't the counterparty of the corresponding channel.
2104 /// You can always get the latest local transaction(s) to broadcast from
2105 /// [`ChannelMonitor::get_latest_holder_commitment_txn`].
2108 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 {
2109 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust());
2110 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() };
2114 /// Force close all channels, immediately broadcasting the latest local commitment transaction
2115 /// for each to the chain and rejecting new HTLCs on each.
2117 pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2118 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn()
2121 /// Force close all channels rejecting new HTLCs on each but without broadcasting the latest
2122 /// local transaction(s).
2124 pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2125 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn()
2128 /// Sends a payment along a given route.
2130 /// Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
2131 /// fields for more info.
2133 /// May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
2134 /// [`PeerManager::process_events`]).
2136 /// # Avoiding Duplicate Payments
2138 /// If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
2139 /// method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
2140 /// is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
2141 /// [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
2142 /// second payment with the same [`PaymentId`].
2144 /// Thus, in order to ensure duplicate payments are not sent, you should implement your own
2145 /// tracking of payments, including state to indicate once a payment has completed. Because you
2146 /// should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
2147 /// consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
2148 /// [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
2150 /// Additionally, in the scenario where we begin the process of sending a payment, but crash
2151 /// before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
2152 /// using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
2153 /// [`ChannelManager::list_recent_payments`] for more information.
2155 /// # Possible Error States on [`PaymentSendFailure`]
2157 /// Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
2158 /// each entry matching the corresponding-index entry in the route paths, see
2159 /// [`PaymentSendFailure`] for more info.
2161 /// In general, a path may raise:
2162 /// * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
2163 /// node public key) is specified.
2164 /// * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
2165 /// closed, doesn't exist, or the peer is currently disconnected.
2166 /// * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
2167 /// relevant updates.
2169 /// Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
2170 /// irrevocably committed to on our end. In such a case, do NOT retry the payment with a
2171 /// different route unless you intend to pay twice!
2173 /// [`RouteHop`]: crate::routing::router::RouteHop
2174 /// [`Event::PaymentSent`]: events::Event::PaymentSent
2175 /// [`Event::PaymentFailed`]: events::Event::PaymentFailed
2176 /// [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
2177 /// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
2178 /// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
2181 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 {
2182 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));
2183 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() };
2187 /// Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
2188 /// `route_params` and retry failed payment paths based on `retry_strategy`.
2191 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 {
2192 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());
2193 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() };
2197 /// Signals that no further attempts for the given payment should occur. Useful if you have a
2198 /// pending outbound payment with retries remaining, but wish to stop retrying the payment before
2199 /// retries are exhausted.
2201 /// # Event Generation
2203 /// If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
2204 /// as there are no remaining pending HTLCs for this payment.
2206 /// Note that calling this method does *not* prevent a payment from succeeding. You must still
2207 /// wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
2208 /// determine the ultimate status of a payment.
2210 /// # Requested Invoices
2212 /// In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning
2213 /// the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`]
2214 /// and prevent any attempts at paying it once received. The other events may only be generated
2215 /// once the invoice has been received.
2217 /// # Restart Behavior
2219 /// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
2220 /// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
2221 /// [`Event::InvoiceRequestFailed`].
2223 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
2225 pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_id: crate::c_types::ThirtyTwoBytes) {
2226 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.abandon_payment(::lightning::ln::channelmanager::PaymentId(payment_id.data))
2229 /// Send a spontaneous payment, which is a payment that does not require the recipient to have
2230 /// generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
2231 /// the preimage, it must be a cryptographically secure random value that no intermediate node
2232 /// would be able to guess -- otherwise, an intermediate node may claim the payment and it will
2233 /// never reach the recipient.
2235 /// See [`send_payment`] documentation for more details on the return value of this function
2236 /// and idempotency guarantees provided by the [`PaymentId`] key.
2238 /// Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
2239 /// [`send_payment`] for more information about the risks of duplicate preimage usage.
2241 /// [`send_payment`]: Self::send_payment
2244 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::derived::COption_ThirtyTwoBytesZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_ThirtyTwoBytesPaymentSendFailureZ {
2245 let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} };
2246 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));
2247 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() };
2251 /// Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
2252 /// based on `route_params` and retry failed payment paths based on `retry_strategy`.
2254 /// See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
2257 /// [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
2260 pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, 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_ThirtyTwoBytesRetryableSendFailureZ {
2261 let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} };
2262 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());
2263 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() };
2267 /// Send a payment that is probing the given route for liquidity. We calculate the
2268 /// [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
2269 /// us to easily discern them from real payments.
2272 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_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ {
2273 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_probe(*unsafe { Box::from_raw(path.take_inner()) });
2274 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() };
2278 /// Sends payment probes over all paths of a route that would be used to pay the given
2279 /// amount to the given `node_id`.
2281 /// See [`ChannelManager::send_preflight_probes`] for more information.
2284 pub extern "C" fn ChannelManager_send_spontaneous_preflight_probes(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut node_id: crate::c_types::PublicKey, mut amount_msat: u64, mut final_cltv_expiry_delta: u32, mut liquidity_limit_multiplier: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ {
2285 let mut local_liquidity_limit_multiplier = if liquidity_limit_multiplier.is_some() { Some( { liquidity_limit_multiplier.take() }) } else { None };
2286 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_preflight_probes(node_id.into_rust(), amount_msat, final_cltv_expiry_delta, local_liquidity_limit_multiplier);
2287 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_1.0 }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::ProbeSendFailure::native_into(e) }).into() };
2291 /// Sends payment probes over all paths of a route that would be used to pay a route found
2292 /// according to the given [`RouteParameters`].
2294 /// This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting
2295 /// the actual payment. Note this is only useful if there likely is sufficient time for the
2296 /// probe to settle before sending out the actual payment, e.g., when waiting for user
2297 /// confirmation in a wallet UI.
2299 /// Otherwise, there is a chance the probe could take up some liquidity needed to complete the
2300 /// actual payment. Users should therefore be cautious and might avoid sending probes if
2301 /// liquidity is scarce and/or they don't expect the probe to return before they send the
2302 /// payment. To mitigate this issue, channels with available liquidity less than the required
2303 /// amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight
2304 /// probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`.
2307 pub extern "C" fn ChannelManager_send_preflight_probes(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut route_params: crate::lightning::routing::router::RouteParameters, mut liquidity_limit_multiplier: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ {
2308 let mut local_liquidity_limit_multiplier = if liquidity_limit_multiplier.is_some() { Some( { liquidity_limit_multiplier.take() }) } else { None };
2309 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_preflight_probes(*unsafe { Box::from_raw(route_params.take_inner()) }, local_liquidity_limit_multiplier);
2310 let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0_1.0 }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::ProbeSendFailure::native_into(e) }).into() };
2314 /// Call this upon creation of a funding transaction for the given channel.
2316 /// Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
2317 /// or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
2319 /// Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
2320 /// across the p2p network.
2322 /// Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
2323 /// for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
2325 /// May panic if the output found in the funding transaction is duplicative with some other
2326 /// channel (note that this should be trivially prevented by using unique funding transaction
2327 /// keys per-channel).
2329 /// Do NOT broadcast the funding transaction yourself. When we have safely received our
2330 /// counterparty's signature the funding transaction will automatically be broadcast via the
2331 /// [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
2333 /// Note that this includes RBF or similar transaction replacement strategies - lightning does
2334 /// not currently support replacing a funding transaction on an existing channel. Instead,
2335 /// create a new channel with a conflicting funding transaction.
2337 /// Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
2338 /// the wallet software generating the funding transaction to apply anti-fee sniping as
2339 /// implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
2340 /// for more details.
2342 /// [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
2343 /// [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
2346 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 {
2347 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_transaction_generated(&::lightning::ln::ChannelId(unsafe { *temporary_channel_id }), &counterparty_node_id.into_rust(), funding_transaction.into_bitcoin());
2348 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() };
2352 /// Call this upon creation of a batch funding transaction for the given channels.
2354 /// Return values are identical to [`Self::funding_transaction_generated`], respective to
2355 /// each individual channel and transaction output.
2357 /// Do NOT broadcast the funding transaction yourself. This batch funding transcaction
2358 /// will only be broadcast when we have safely received and persisted the counterparty's
2359 /// signature for each channel.
2361 /// If there is an error, all channels in the batch are to be considered closed.
2364 pub extern "C" fn ChannelManager_batch_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channels: crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
2365 let mut local_temporary_channels = Vec::new(); for mut item in temporary_channels.into_rust().drain(..) { local_temporary_channels.push( { let (mut orig_temporary_channels_0_0, mut orig_temporary_channels_0_1) = item.to_rust(); let mut local_temporary_channels_0 = (::lightning::ln::ChannelId(orig_temporary_channels_0_0.data), orig_temporary_channels_0_1.into_rust()); local_temporary_channels_0 }); };
2366 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.batch_funding_transaction_generated(&local_temporary_channels.iter().map(|(a, b)| (a, b)).collect::<Vec<_>>()[..], funding_transaction.into_bitcoin());
2367 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() };
2371 /// Atomically applies partial updates to the [`ChannelConfig`] of the given channels.
2373 /// Once the updates are applied, each eligible channel (advertised with a known short channel
2374 /// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
2375 /// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
2376 /// containing the new [`ChannelUpdate`] message which should be broadcast to the network.
2378 /// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
2379 /// `counterparty_node_id` is provided.
2381 /// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
2382 /// below [`MIN_CLTV_EXPIRY_DELTA`].
2384 /// If an error is returned, none of the updates should be considered applied.
2386 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
2387 /// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
2388 /// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
2389 /// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
2390 /// [`ChannelUpdate`]: msgs::ChannelUpdate
2391 /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
2392 /// [`APIMisuseError`]: APIError::APIMisuseError
2395 pub extern "C" fn ChannelManager_update_partial_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_update: &crate::lightning::util::config::ChannelConfigUpdate) -> crate::c_types::derived::CResult_NoneAPIErrorZ {
2396 let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { ::lightning::ln::ChannelId(item.data) }); };
2397 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_partial_channel_config(&counterparty_node_id.into_rust(), local_channel_ids, config_update.get_native_ref());
2398 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() };
2402 /// Atomically updates the [`ChannelConfig`] for the given channels.
2404 /// Once the updates are applied, each eligible channel (advertised with a known short channel
2405 /// ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
2406 /// or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
2407 /// containing the new [`ChannelUpdate`] message which should be broadcast to the network.
2409 /// Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
2410 /// `counterparty_node_id` is provided.
2412 /// Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
2413 /// below [`MIN_CLTV_EXPIRY_DELTA`].
2415 /// If an error is returned, none of the updates should be considered applied.
2417 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
2418 /// [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
2419 /// [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
2420 /// [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
2421 /// [`ChannelUpdate`]: msgs::ChannelUpdate
2422 /// [`ChannelUnavailable`]: APIError::ChannelUnavailable
2423 /// [`APIMisuseError`]: APIError::APIMisuseError
2426 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 {
2427 let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { ::lightning::ln::ChannelId(item.data) }); };
2428 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_config(&counterparty_node_id.into_rust(), local_channel_ids, config.get_native_ref());
2429 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() };
2433 /// Attempts to forward an intercepted HTLC over the provided channel id and with the provided
2434 /// amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
2436 /// Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
2437 /// channel to a receiving node if the node lacks sufficient inbound liquidity.
2439 /// To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
2440 /// [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
2441 /// receiver's invoice route hints. These route hints will signal to LDK to generate an
2442 /// [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
2443 /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
2445 /// Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
2446 /// you from forwarding more than you received. See
2447 /// [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount
2450 /// Errors if the event was not handled in time, in which case the HTLC was automatically failed
2453 /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
2454 /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
2455 /// [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat
2458 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 {
2459 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.forward_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data), &::lightning::ln::ChannelId(unsafe { *next_hop_channel_id }), next_node_id.into_rust(), amt_to_forward_msat);
2460 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() };
2464 /// Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
2465 /// an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
2467 /// Errors if the event was not handled in time, in which case the HTLC was automatically failed
2470 /// [`HTLCIntercepted`]: events::Event::HTLCIntercepted
2473 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 {
2474 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data));
2475 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() };
2479 /// Processes HTLCs which are pending waiting on random forward delay.
2481 /// Should only really ever be called in response to a PendingHTLCsForwardable event.
2482 /// Will likely generate further events.
2484 pub extern "C" fn ChannelManager_process_pending_htlc_forwards(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2485 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_htlc_forwards()
2488 /// Performs actions which should happen on startup and roughly once per minute thereafter.
2490 /// This currently includes:
2491 /// * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
2492 /// * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more
2493 /// than a minute, informing the network that they should no longer attempt to route over
2495 /// * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs
2496 /// with the current [`ChannelConfig`].
2497 /// * Removing peers which have disconnected but and no longer have any channels.
2498 /// * Force-closing and removing channels which have not completed establishment in a timely manner.
2499 /// * Forgetting about stale outbound payments, either those that have already been fulfilled
2500 /// or those awaiting an invoice that hasn't been delivered in the necessary amount of time.
2501 /// The latter is determined using the system clock in `std` and the highest seen block time
2502 /// minus two hours in `no-std`.
2504 /// Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate
2505 /// estimate fetches.
2507 /// [`ChannelUpdate`]: msgs::ChannelUpdate
2508 /// [`ChannelConfig`]: crate::util::config::ChannelConfig
2510 pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) {
2511 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.timer_tick_occurred()
2514 /// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
2515 /// after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
2516 /// along the path (including in our own channel on which we received it).
2518 /// Note that in some cases around unclean shutdown, it is possible the payment may have
2519 /// already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
2520 /// second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
2521 /// may have already been failed automatically by LDK if it was nearing its expiration time.
2523 /// While LDK will never claim a payment automatically on your behalf (i.e. without you calling
2524 /// [`ChannelManager::claim_funds`]), you should still monitor for
2525 /// [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
2526 /// startup during which time claims that were in-progress at shutdown may be replayed.
2528 pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, payment_hash: *const [u8; 32]) {
2529 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards(&::lightning::ln::PaymentHash(unsafe { *payment_hash }))
2532 /// This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
2533 /// reason for the failure.
2535 /// See [`FailureCode`] for valid failure codes.
2537 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) {
2538 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards_with_reason(&::lightning::ln::PaymentHash(unsafe { *payment_hash }), failure_code.into_native())
2541 /// Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
2542 /// [`MessageSendEvent`]s needed to claim the payment.
2544 /// This method is guaranteed to ensure the payment has been claimed but only if the current
2545 /// height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race
2546 /// conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment
2547 /// successful. It will generally be available in the next [`process_pending_events`] call.
2549 /// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
2550 /// [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
2551 /// event matches your expectation. If you fail to do so and call this method, you may provide
2552 /// the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
2554 /// This function will fail the payment if it has custom TLVs with even type numbers, as we
2555 /// will assume they are unknown. If you intend to accept even custom TLVs, you should use
2556 /// [`claim_funds_with_known_custom_tlvs`].
2558 /// [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
2559 /// [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline
2560 /// [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed
2561 /// [`process_pending_events`]: EventsProvider::process_pending_events
2562 /// [`create_inbound_payment`]: Self::create_inbound_payment
2563 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2564 /// [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs
2566 pub extern "C" fn ChannelManager_claim_funds(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) {
2567 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds(::lightning::ln::PaymentPreimage(payment_preimage.data))
2570 /// This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with
2571 /// even type numbers.
2575 /// You MUST check you've understood all even TLVs before using this to
2576 /// claim, otherwise you may unintentionally agree to some protocol you do not understand.
2578 /// [`claim_funds`]: Self::claim_funds
2580 pub extern "C" fn ChannelManager_claim_funds_with_known_custom_tlvs(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) {
2581 unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds_with_known_custom_tlvs(::lightning::ln::PaymentPreimage(payment_preimage.data))
2584 /// Gets the node_id held by this ChannelManager
2587 pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::PublicKey {
2588 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_our_node_id();
2589 crate::c_types::PublicKey::from_rust(&ret)
2592 /// Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
2594 /// The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
2595 /// and the `counterparty_node_id` parameter is the id of the peer which has requested to open
2598 /// The `user_channel_id` parameter will be provided back in
2599 /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2600 /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2602 /// Note that this method will return an error and reject the channel, if it requires support
2603 /// for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
2604 /// used to accept such channels.
2606 /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2607 /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2610 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 {
2611 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(&::lightning::ln::ChannelId(unsafe { *temporary_channel_id }), &counterparty_node_id.into_rust(), user_channel_id.into());
2612 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() };
2616 /// Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
2617 /// it as confirmed immediately.
2619 /// The `user_channel_id` parameter will be provided back in
2620 /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
2621 /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
2623 /// Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
2624 /// and (if the counterparty agrees), enables forwarding of payments immediately.
2626 /// This fully trusts that the counterparty has honestly and correctly constructed the funding
2627 /// transaction and blindly assumes that it will eventually confirm.
2629 /// If it does not confirm before we decide to close the channel, or if the funding transaction
2630 /// does not pay to the correct script the correct amount, *you will lose funds*.
2632 /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
2633 /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
2636 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 {
2637 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel_from_trusted_peer_0conf(&::lightning::ln::ChannelId(unsafe { *temporary_channel_id }), &counterparty_node_id.into_rust(), user_channel_id.into());
2638 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() };
2642 /// Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and
2643 /// enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual
2644 /// [`Bolt12Invoice`] once it is received.
2646 /// Uses [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is recognized by
2647 /// the [`ChannelManager`] when handling a [`Bolt12Invoice`] message in response to the request.
2648 /// The optional parameters are used in the builder, if `Some`:
2649 /// - `quantity` for [`InvoiceRequest::quantity`] which must be set if
2650 /// [`Offer::expects_quantity`] is `true`.
2651 /// - `amount_msats` if overpaying what is required for the given `quantity` is desired, and
2652 /// - `payer_note` for [`InvoiceRequest::payer_note`].
2654 /// If `max_total_routing_fee_msat` is not specified, The default from
2655 /// [`RouteParameters::from_payment_params_and_value`] is applied.
2659 /// The provided `payment_id` is used to ensure that only one invoice is paid for the request
2660 /// when received. See [Avoiding Duplicate Payments] for other requirements once the payment has
2663 /// To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the
2664 /// invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the
2665 /// payment will fail with an [`Event::InvoiceRequestFailed`].
2669 /// Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`]
2670 /// as the introduction node and a derived payer id for payer privacy. As such, currently, the
2671 /// node must be announced. Otherwise, there is no way to find a path to the introduction node
2672 /// in order to send the [`Bolt12Invoice`].
2676 /// Requires a direct connection to an introduction node in [`Offer::paths`] or to
2677 /// [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding
2678 /// [`Bolt12Invoice::payment_paths`].
2682 /// Errors if a duplicate `payment_id` is provided given the caveats in the aforementioned link
2683 /// or if the provided parameters are invalid for the offer.
2685 /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
2686 /// [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
2687 /// [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note
2688 /// [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder
2689 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
2690 /// [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
2691 /// [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
2694 pub extern "C" fn ChannelManager_pay_for_offer(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, offer: &crate::lightning::offers::offer::Offer, mut quantity: crate::c_types::derived::COption_u64Z, mut amount_msats: crate::c_types::derived::COption_u64Z, mut payer_note: crate::c_types::derived::COption_StrZ, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, mut max_total_routing_fee_msat: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
2695 let mut local_quantity = if quantity.is_some() { Some( { quantity.take() }) } else { None };
2696 let mut local_amount_msats = if amount_msats.is_some() { Some( { amount_msats.take() }) } else { None };
2697 let mut local_payer_note = { /*payer_note*/ let payer_note_opt = payer_note; if payer_note_opt.is_none() { None } else { Some({ { { payer_note_opt.take() }.into_string() }})} };
2698 let mut local_max_total_routing_fee_msat = if max_total_routing_fee_msat.is_some() { Some( { max_total_routing_fee_msat.take() }) } else { None };
2699 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.pay_for_offer(offer.get_native_ref(), local_quantity, local_amount_msats, local_payer_note, ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), local_max_total_routing_fee_msat);
2700 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::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
2704 /// Creates a [`Bolt12Invoice`] for a [`Refund`] and enqueues it to be sent via an onion
2707 /// The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a
2708 /// [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding
2709 /// [`PaymentPreimage`].
2713 /// Requires a direct connection to an introduction node in [`Refund::paths`] or to
2714 /// [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
2715 /// node meeting the aforementioned criteria, but there's no guarantee that they will be
2716 /// received and no retries will be made.
2718 /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
2721 pub extern "C" fn ChannelManager_request_refund_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, refund: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ {
2722 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_refund_payment(refund.get_native_ref());
2723 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::offers::parse::Bolt12SemanticError::native_into(e) }).into() };
2727 /// Gets a payment secret and payment hash for use in an invoice given to a third party wishing
2730 /// This differs from [`create_inbound_payment_for_hash`] only in that it generates the
2731 /// [`PaymentHash`] and [`PaymentPreimage`] for you.
2733 /// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which
2734 /// will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with
2735 /// its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be
2736 /// passed directly to [`claim_funds`].
2738 /// See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
2740 /// Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2741 /// `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2745 /// If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2746 /// deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2748 /// Errors if `min_value_msat` is greater than total bitcoin supply.
2750 /// If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
2751 /// on versions of LDK prior to 0.0.114.
2753 /// [`claim_funds`]: Self::claim_funds
2754 /// [`PaymentClaimable`]: events::Event::PaymentClaimable
2755 /// [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose
2756 /// [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment
2757 /// [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage
2758 /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
2761 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_ThirtyTwoBytesThirtyTwoBytesZNoneZ {
2762 let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2763 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 };
2764 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);
2765 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() };
2769 /// Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
2770 /// stored external to LDK.
2772 /// A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
2773 /// payment secret fetched via this method or [`create_inbound_payment`], and which is at least
2774 /// the `min_value_msat` provided here, if one is provided.
2776 /// The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
2777 /// note that LDK will not stop you from registering duplicate payment hashes for inbound
2780 /// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
2781 /// received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
2782 /// before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
2783 /// sender \"proof-of-payment\" unless they have paid the required amount.
2785 /// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
2786 /// in excess of the current time. This should roughly match the expiry time set in the invoice.
2787 /// After this many seconds, we will remove the inbound payment, resulting in any attempts to
2788 /// pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
2789 /// invoices when no timeout is set.
2791 /// Note that we use block header time to time-out pending inbound payments (with some margin
2792 /// to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
2793 /// accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
2794 /// If you need exact expiry semantics, you should enforce them upon receipt of
2795 /// [`PaymentClaimable`].
2797 /// Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta`
2798 /// set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
2800 /// Note that a malicious eavesdropper can intuit whether an inbound payment was created by
2801 /// `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
2805 /// If you register an inbound payment with this method, then serialize the `ChannelManager`, then
2806 /// deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
2808 /// Errors if `min_value_msat` is greater than total bitcoin supply.
2810 /// If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
2811 /// on versions of LDK prior to 0.0.114.
2813 /// [`create_inbound_payment`]: Self::create_inbound_payment
2814 /// [`PaymentClaimable`]: events::Event::PaymentClaimable
2817 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_ThirtyTwoBytesNoneZ {
2818 let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None };
2819 let mut local_min_final_cltv_expiry = if min_final_cltv_expiry.is_some() { Some( { min_final_cltv_expiry.take() }) } else { None };
2820 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);
2821 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() };
2825 /// Gets an LDK-generated payment preimage from a payment hash and payment secret that were
2826 /// previously returned from [`create_inbound_payment`].
2828 /// [`create_inbound_payment`]: Self::create_inbound_payment
2831 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_ThirtyTwoBytesAPIErrorZ {
2832 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));
2833 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() };
2837 /// Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
2838 /// are used when constructing the phantom invoice's route hints.
2840 /// [phantom node payments]: crate::sign::PhantomKeysManager
2843 pub extern "C" fn ChannelManager_get_phantom_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 {
2844 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_scid();
2848 /// Gets route hints for use in receiving [phantom node payments].
2850 /// [phantom node payments]: crate::sign::PhantomKeysManager
2853 pub extern "C" fn ChannelManager_get_phantom_route_hints(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::channelmanager::PhantomRouteHints {
2854 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_phantom_route_hints();
2855 crate::lightning::ln::channelmanager::PhantomRouteHints { inner: ObjOps::heap_alloc(ret), is_owned: true }
2858 /// Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
2859 /// used when constructing the route hints for HTLCs intended to be intercepted. See
2860 /// [`ChannelManager::forward_intercepted_htlc`].
2862 /// Note that this method is not guaranteed to return unique values, you may need to call it a few
2863 /// times to get a unique scid.
2866 pub extern "C" fn ChannelManager_get_intercept_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> u64 {
2867 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_intercept_scid();
2871 /// Gets inflight HTLC information by processing pending outbound payments that are in
2872 /// our channels. May be used during pathfinding to account for in-use channel liquidity.
2875 pub extern "C" fn ChannelManager_compute_inflight_htlcs(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::routing::router::InFlightHtlcs {
2876 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.compute_inflight_htlcs();
2877 crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(ret), is_owned: true }
2880 impl From<nativeChannelManager> for crate::lightning::events::MessageSendEventsProvider {
2881 fn from(obj: nativeChannelManager) -> Self {
2882 let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2883 let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj);
2884 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
2885 core::mem::forget(rust_obj);
2886 ret.free = Some(ChannelManager_free_void);
2890 /// Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
2891 /// This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
2893 pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &ChannelManager) -> crate::lightning::events::MessageSendEventsProvider {
2894 crate::lightning::events::MessageSendEventsProvider {
2895 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2897 get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
2902 extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
2903 let mut ret = <nativeChannelManager as lightning::events::MessageSendEventsProvider<>>::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
2904 let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); };
2908 impl From<nativeChannelManager> for crate::lightning::events::EventsProvider {
2909 fn from(obj: nativeChannelManager) -> Self {
2910 let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2911 let mut ret = ChannelManager_as_EventsProvider(&rust_obj);
2912 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
2913 core::mem::forget(rust_obj);
2914 ret.free = Some(ChannelManager_free_void);
2918 /// Constructs a new EventsProvider which calls the relevant methods on this_arg.
2919 /// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
2921 pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> crate::lightning::events::EventsProvider {
2922 crate::lightning::events::EventsProvider {
2923 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2925 process_pending_events: ChannelManager_EventsProvider_process_pending_events,
2929 extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) {
2930 <nativeChannelManager as lightning::events::EventsProvider<>>::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler)
2933 impl From<nativeChannelManager> for crate::lightning::chain::Listen {
2934 fn from(obj: nativeChannelManager) -> Self {
2935 let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2936 let mut ret = ChannelManager_as_Listen(&rust_obj);
2937 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
2938 core::mem::forget(rust_obj);
2939 ret.free = Some(ChannelManager_free_void);
2943 /// Constructs a new Listen which calls the relevant methods on this_arg.
2944 /// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
2946 pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate::lightning::chain::Listen {
2947 crate::lightning::chain::Listen {
2948 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2950 filtered_block_connected: ChannelManager_Listen_filtered_block_connected,
2951 block_connected: ChannelManager_Listen_block_connected,
2952 block_disconnected: ChannelManager_Listen_block_disconnected,
2956 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) {
2957 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 }); };
2958 <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)
2960 extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) {
2961 <nativeChannelManager as lightning::chain::Listen<>>::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height)
2963 extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
2964 <nativeChannelManager as lightning::chain::Listen<>>::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
2967 impl From<nativeChannelManager> for crate::lightning::chain::Confirm {
2968 fn from(obj: nativeChannelManager) -> Self {
2969 let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
2970 let mut ret = ChannelManager_as_Confirm(&rust_obj);
2971 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
2972 core::mem::forget(rust_obj);
2973 ret.free = Some(ChannelManager_free_void);
2977 /// Constructs a new Confirm which calls the relevant methods on this_arg.
2978 /// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
2980 pub extern "C" fn ChannelManager_as_Confirm(this_arg: &ChannelManager) -> crate::lightning::chain::Confirm {
2981 crate::lightning::chain::Confirm {
2982 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
2984 transactions_confirmed: ChannelManager_Confirm_transactions_confirmed,
2985 transaction_unconfirmed: ChannelManager_Confirm_transaction_unconfirmed,
2986 best_block_updated: ChannelManager_Confirm_best_block_updated,
2987 get_relevant_txids: ChannelManager_Confirm_get_relevant_txids,
2991 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) {
2992 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 }); };
2993 <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)
2995 extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) {
2996 <nativeChannelManager as lightning::chain::Confirm<>>::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap())
2998 extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) {
2999 <nativeChannelManager as lightning::chain::Confirm<>>::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height)
3002 extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ {
3003 let mut ret = <nativeChannelManager as lightning::chain::Confirm<>>::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
3004 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::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { 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 }); };
3008 /// Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or
3009 /// may have events that need processing.
3011 /// In order to check if this [`ChannelManager`] needs persisting, call
3012 /// [`Self::get_and_clear_needs_persistence`].
3014 /// Note that callbacks registered on the [`Future`] MUST NOT call back into this
3015 /// [`ChannelManager`] and should instead register actions to be taken later.
3018 pub extern "C" fn ChannelManager_get_event_or_persistence_needed_future(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::util::wakers::Future {
3019 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_event_or_persistence_needed_future();
3020 crate::lightning::util::wakers::Future { inner: ObjOps::heap_alloc(ret), is_owned: true }
3023 /// Returns true if this [`ChannelManager`] needs to be persisted.
3026 pub extern "C" fn ChannelManager_get_and_clear_needs_persistence(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> bool {
3027 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_and_clear_needs_persistence();
3031 /// Gets the latest best block which was connected either via the [`chain::Listen`] or
3032 /// [`chain::Confirm`] interfaces.
3035 pub extern "C" fn ChannelManager_current_best_block(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::chain::BestBlock {
3036 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.current_best_block();
3037 crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true }
3040 /// Fetches the set of [`NodeFeatures`] flags that are provided by or required by
3041 /// [`ChannelManager`].
3044 pub extern "C" fn ChannelManager_node_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::NodeFeatures {
3045 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node_features();
3046 crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
3049 /// Fetches the set of [`ChannelFeatures`] flags that are provided by or required by
3050 /// [`ChannelManager`].
3053 pub extern "C" fn ChannelManager_channel_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelFeatures {
3054 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_features();
3055 crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
3058 /// Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by
3059 /// [`ChannelManager`].
3062 pub extern "C" fn ChannelManager_channel_type_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelTypeFeatures {
3063 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features();
3064 crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
3067 /// Fetches the set of [`InitFeatures`] flags that are provided by or required by
3068 /// [`ChannelManager`].
3071 pub extern "C" fn ChannelManager_init_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::InitFeatures {
3072 let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.init_features();
3073 crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
3076 impl From<nativeChannelManager> for crate::lightning::ln::msgs::ChannelMessageHandler {
3077 fn from(obj: nativeChannelManager) -> Self {
3078 let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
3079 let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj);
3080 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
3081 core::mem::forget(rust_obj);
3082 ret.free = Some(ChannelManager_free_void);
3086 /// Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
3087 /// This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
3089 pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelManager) -> crate::lightning::ln::msgs::ChannelMessageHandler {
3090 crate::lightning::ln::msgs::ChannelMessageHandler {
3091 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
3093 handle_open_channel: ChannelManager_ChannelMessageHandler_handle_open_channel,
3094 handle_open_channel_v2: ChannelManager_ChannelMessageHandler_handle_open_channel_v2,
3095 handle_accept_channel: ChannelManager_ChannelMessageHandler_handle_accept_channel,
3096 handle_accept_channel_v2: ChannelManager_ChannelMessageHandler_handle_accept_channel_v2,
3097 handle_funding_created: ChannelManager_ChannelMessageHandler_handle_funding_created,
3098 handle_funding_signed: ChannelManager_ChannelMessageHandler_handle_funding_signed,
3099 handle_channel_ready: ChannelManager_ChannelMessageHandler_handle_channel_ready,
3100 handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown,
3101 handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed,
3102 handle_tx_add_input: ChannelManager_ChannelMessageHandler_handle_tx_add_input,
3103 handle_tx_add_output: ChannelManager_ChannelMessageHandler_handle_tx_add_output,
3104 handle_tx_remove_input: ChannelManager_ChannelMessageHandler_handle_tx_remove_input,
3105 handle_tx_remove_output: ChannelManager_ChannelMessageHandler_handle_tx_remove_output,
3106 handle_tx_complete: ChannelManager_ChannelMessageHandler_handle_tx_complete,
3107 handle_tx_signatures: ChannelManager_ChannelMessageHandler_handle_tx_signatures,
3108 handle_tx_init_rbf: ChannelManager_ChannelMessageHandler_handle_tx_init_rbf,
3109 handle_tx_ack_rbf: ChannelManager_ChannelMessageHandler_handle_tx_ack_rbf,
3110 handle_tx_abort: ChannelManager_ChannelMessageHandler_handle_tx_abort,
3111 handle_update_add_htlc: ChannelManager_ChannelMessageHandler_handle_update_add_htlc,
3112 handle_update_fulfill_htlc: ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc,
3113 handle_update_fail_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_htlc,
3114 handle_update_fail_malformed_htlc: ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc,
3115 handle_commitment_signed: ChannelManager_ChannelMessageHandler_handle_commitment_signed,
3116 handle_revoke_and_ack: ChannelManager_ChannelMessageHandler_handle_revoke_and_ack,
3117 handle_update_fee: ChannelManager_ChannelMessageHandler_handle_update_fee,
3118 handle_announcement_signatures: ChannelManager_ChannelMessageHandler_handle_announcement_signatures,
3119 peer_disconnected: ChannelManager_ChannelMessageHandler_peer_disconnected,
3120 peer_connected: ChannelManager_ChannelMessageHandler_peer_connected,
3121 handle_channel_reestablish: ChannelManager_ChannelMessageHandler_handle_channel_reestablish,
3122 handle_channel_update: ChannelManager_ChannelMessageHandler_handle_channel_update,
3123 handle_error: ChannelManager_ChannelMessageHandler_handle_error,
3124 provided_node_features: ChannelManager_ChannelMessageHandler_provided_node_features,
3125 provided_init_features: ChannelManager_ChannelMessageHandler_provided_init_features,
3126 get_chain_hashes: ChannelManager_ChannelMessageHandler_get_chain_hashes,
3127 MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider {
3128 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
3130 get_and_clear_pending_msg_events: ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events,
3135 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) {
3136 <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())
3138 extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2) {
3139 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3141 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) {
3142 <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())
3144 extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2) {
3145 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3147 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) {
3148 <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())
3150 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) {
3151 <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())
3153 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) {
3154 <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())
3156 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) {
3157 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3159 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) {
3160 <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())
3162 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) {
3163 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3165 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput) {
3166 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3168 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput) {
3169 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3171 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput) {
3172 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3174 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_complete(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete) {
3175 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3177 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures) {
3178 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3180 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_init_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf) {
3181 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3183 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_ack_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf) {
3184 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3186 extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_abort(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort) {
3187 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3189 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) {
3190 <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())
3192 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) {
3193 <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())
3195 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) {
3196 <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())
3198 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) {
3199 <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())
3201 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) {
3202 <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())
3204 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) {
3205 <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())
3207 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) {
3208 <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())
3210 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) {
3211 <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())
3213 extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) {
3214 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust())
3217 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 {
3218 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);
3219 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() };
3222 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) {
3223 <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())
3225 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) {
3226 <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())
3228 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) {
3229 <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref())
3232 extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures {
3233 let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_node_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
3234 crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
3237 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 {
3238 let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust());
3239 crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
3242 extern "C" fn ChannelManager_ChannelMessageHandler_get_chain_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ {
3243 let mut ret = <nativeChannelManager as lightning::ln::msgs::ChannelMessageHandler<>>::get_chain_hashes(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
3244 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: item.to_bytes() } }); }; local_ret_0.into() }) };
3248 impl From<nativeChannelManager> for crate::lightning::onion_message::offers::OffersMessageHandler {
3249 fn from(obj: nativeChannelManager) -> Self {
3250 let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
3251 let mut ret = ChannelManager_as_OffersMessageHandler(&rust_obj);
3252 // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn
3253 core::mem::forget(rust_obj);
3254 ret.free = Some(ChannelManager_free_void);
3258 /// Constructs a new OffersMessageHandler which calls the relevant methods on this_arg.
3259 /// This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is
3261 pub extern "C" fn ChannelManager_as_OffersMessageHandler(this_arg: &ChannelManager) -> crate::lightning::onion_message::offers::OffersMessageHandler {
3262 crate::lightning::onion_message::offers::OffersMessageHandler {
3263 this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
3265 handle_message: ChannelManager_OffersMessageHandler_handle_message,
3266 release_pending_messages: ChannelManager_OffersMessageHandler_release_pending_messages,
3271 extern "C" fn ChannelManager_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ {
3272 let mut ret = <nativeChannelManager as lightning::onion_message::offers::OffersMessageHandler<>>::handle_message(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, message.into_native());
3273 let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_OffersMessageZ::None } else { crate::c_types::derived::COption_OffersMessageZ::Some( { crate::lightning::onion_message::offers::OffersMessage::native_into(ret.unwrap()) }) };
3277 extern "C" fn ChannelManager_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ {
3278 let mut ret = <nativeChannelManager as lightning::onion_message::offers::OffersMessageHandler<>>::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, );
3279 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, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = crate::lightning::blinded_path::BlindedPath { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::Destination::native_into(orig_ret_0_1), local_orig_ret_0_2).into(); local_ret_0 }); };
3283 /// Fetches the set of [`InitFeatures`] flags that are provided by or required by
3284 /// [`ChannelManager`].
3286 pub extern "C" fn provided_init_features(config: &crate::lightning::util::config::UserConfig) -> crate::lightning::ln::features::InitFeatures {
3287 let mut ret = lightning::ln::channelmanager::provided_init_features(config.get_native_ref());
3288 crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
3292 /// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read
3293 pub extern "C" fn CounterpartyForwardingInfo_write(obj: &crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z {
3294 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
3297 pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
3298 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) })
3301 /// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write
3302 pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ {
3303 let res: Result<lightning::ln::channelmanager::CounterpartyForwardingInfo, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3304 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() };
3308 /// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read
3309 pub extern "C" fn ChannelCounterparty_write(obj: &crate::lightning::ln::channelmanager::ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z {
3310 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
3313 pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
3314 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) })
3317 /// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write
3318 pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ {
3319 let res: Result<lightning::ln::channelmanager::ChannelCounterparty, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3320 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() };
3324 /// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read
3325 pub extern "C" fn ChannelDetails_write(obj: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::CVec_u8Z {
3326 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
3329 pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
3330 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) })
3333 /// Read a ChannelDetails from a byte array, created by ChannelDetails_write
3334 pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ {
3335 let res: Result<lightning::ln::channelmanager::ChannelDetails, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3336 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() };
3340 /// Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read
3341 pub extern "C" fn PhantomRouteHints_write(obj: &crate::lightning::ln::channelmanager::PhantomRouteHints) -> crate::c_types::derived::CVec_u8Z {
3342 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
3345 pub(crate) extern "C" fn PhantomRouteHints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
3346 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePhantomRouteHints) })
3349 /// Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write
3350 pub extern "C" fn PhantomRouteHints_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PhantomRouteHintsDecodeErrorZ {
3351 let res: Result<lightning::ln::channelmanager::PhantomRouteHints, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3352 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() };
3356 /// Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
3357 pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_u8Z {
3358 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
3361 pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
3362 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) })
3365 /// Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read
3366 pub extern "C" fn ChannelShutdownState_write(obj: &crate::lightning::ln::channelmanager::ChannelShutdownState) -> crate::c_types::derived::CVec_u8Z {
3367 crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
3370 pub(crate) extern "C" fn ChannelShutdownState_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
3371 ChannelShutdownState_write(unsafe { &*(obj as *const ChannelShutdownState) })
3374 /// Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write
3375 pub extern "C" fn ChannelShutdownState_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelShutdownStateDecodeErrorZ {
3376 let res: Result<lightning::ln::channelmanager::ChannelShutdownState, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
3377 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
3381 use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport;
3382 pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>;
3384 /// Arguments for the creation of a ChannelManager that are not deserialized.
3386 /// At a high-level, the process for deserializing a ChannelManager and resuming normal operation
3388 /// 1) Deserialize all stored [`ChannelMonitor`]s.
3389 /// 2) Deserialize the [`ChannelManager`] by filling in this struct and calling:
3390 /// `<(BlockHash, ChannelManager)>::read(reader, args)`
3391 /// This may result in closing some channels if the [`ChannelMonitor`] is newer than the stored
3392 /// [`ChannelManager`] state to ensure no loss of funds. Thus, transactions may be broadcasted.
3393 /// 3) If you are not fetching full blocks, register all relevant [`ChannelMonitor`] outpoints the
3394 /// same way you would handle a [`chain::Filter`] call using
3395 /// [`ChannelMonitor::get_outputs_to_watch`] and [`ChannelMonitor::get_funding_txo`].
3396 /// 4) Reconnect blocks on your [`ChannelMonitor`]s.
3397 /// 5) Disconnect/connect blocks on the [`ChannelManager`].
3398 /// 6) Re-persist the [`ChannelMonitor`]s to ensure the latest state is on disk.
3399 /// Note that if you're using a [`ChainMonitor`] for your [`chain::Watch`] implementation, you
3400 /// will likely accomplish this as a side-effect of calling [`chain::Watch::watch_channel`] in
3402 /// 7) Move the [`ChannelMonitor`]s into your local [`chain::Watch`]. If you're using a
3403 /// [`ChainMonitor`], this is done by calling [`chain::Watch::watch_channel`].
3405 /// Note that the ordering of #4-7 is not of importance, however all four must occur before you
3406 /// call any other methods on the newly-deserialized [`ChannelManager`].
3408 /// Note that because some channels may be closed during deserialization, it is critical that you
3409 /// always deserialize only the latest version of a ChannelManager and ChannelMonitors available to
3410 /// you. If you deserialize an old ChannelManager (during which force-closure transactions may be
3411 /// broadcast), and then later deserialize a newer version of the same ChannelManager (which will
3412 /// not force-close the same channels but consider them live), you may end up revoking a state for
3413 /// which you've already broadcasted the transaction.
3415 /// [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
3418 pub struct ChannelManagerReadArgs {
3419 /// A pointer to the opaque Rust object.
3421 /// Nearly everywhere, inner must be non-null, however in places where
3422 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
3423 pub inner: *mut nativeChannelManagerReadArgs,
3424 /// Indicates that this is the only struct which contains the same pointer.
3426 /// Rust functions which take ownership of an object provided via an argument require
3427 /// this to be true and invalidate the object pointed to by inner.
3431 impl Drop for ChannelManagerReadArgs {
3432 fn drop(&mut self) {
3433 if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) {
3434 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
3438 /// Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL.
3440 pub extern "C" fn ChannelManagerReadArgs_free(this_obj: ChannelManagerReadArgs) { }
3442 /// Used only if an object of this type is returned as a trait impl by a method
3443 pub(crate) extern "C" fn ChannelManagerReadArgs_free_void(this_ptr: *mut c_void) {
3444 let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelManagerReadArgs) };
3447 impl ChannelManagerReadArgs {
3448 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelManagerReadArgs {
3449 unsafe { &*ObjOps::untweak_ptr(self.inner) }
3451 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelManagerReadArgs {
3452 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
3454 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
3455 pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs {
3456 assert!(self.is_owned);
3457 let ret = ObjOps::untweak_ptr(self.inner);
3458 self.inner = core::ptr::null_mut();
3462 /// A cryptographically secure source of entropy.
3464 pub extern "C" fn ChannelManagerReadArgs_get_entropy_source(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::EntropySource {
3465 let mut inner_val = &mut this_ptr.get_native_mut_ref().entropy_source;
3468 /// A cryptographically secure source of entropy.
3470 pub extern "C" fn ChannelManagerReadArgs_set_entropy_source(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::EntropySource) {
3471 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.entropy_source = val;
3473 /// A signer that is able to perform node-scoped cryptographic operations.
3475 pub extern "C" fn ChannelManagerReadArgs_get_node_signer(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::NodeSigner {
3476 let mut inner_val = &mut this_ptr.get_native_mut_ref().node_signer;
3479 /// A signer that is able to perform node-scoped cryptographic operations.
3481 pub extern "C" fn ChannelManagerReadArgs_set_node_signer(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::NodeSigner) {
3482 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_signer = val;
3484 /// The keys provider which will give us relevant keys. Some keys will be loaded during
3485 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
3488 pub extern "C" fn ChannelManagerReadArgs_get_signer_provider(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::sign::SignerProvider {
3489 let mut inner_val = &mut this_ptr.get_native_mut_ref().signer_provider;
3492 /// The keys provider which will give us relevant keys. Some keys will be loaded during
3493 /// deserialization and KeysInterface::read_chan_signer will be used to read per-Channel
3496 pub extern "C" fn ChannelManagerReadArgs_set_signer_provider(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::sign::SignerProvider) {
3497 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signer_provider = val;
3499 /// The fee_estimator for use in the ChannelManager in the future.
3501 /// No calls to the FeeEstimator will be made during deserialization.
3503 pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::FeeEstimator {
3504 let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_estimator;
3507 /// The fee_estimator for use in the ChannelManager in the future.
3509 /// No calls to the FeeEstimator will be made during deserialization.
3511 pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::FeeEstimator) {
3512 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_estimator = val;
3514 /// The chain::Watch for use in the ChannelManager in the future.
3516 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
3517 /// you have deserialized ChannelMonitors separately and will add them to your
3518 /// chain::Watch after deserializing this ChannelManager.
3520 pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::Watch {
3521 let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_monitor;
3524 /// The chain::Watch for use in the ChannelManager in the future.
3526 /// No calls to the chain::Watch will be made during deserialization. It is assumed that
3527 /// you have deserialized ChannelMonitors separately and will add them to your
3528 /// chain::Watch after deserializing this ChannelManager.
3530 pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::Watch) {
3531 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_monitor = val;
3533 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
3534 /// used to broadcast the latest local commitment transactions of channels which must be
3535 /// force-closed during deserialization.
3537 pub extern "C" fn ChannelManagerReadArgs_get_tx_broadcaster(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::chain::chaininterface::BroadcasterInterface {
3538 let mut inner_val = &mut this_ptr.get_native_mut_ref().tx_broadcaster;
3541 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
3542 /// used to broadcast the latest local commitment transactions of channels which must be
3543 /// force-closed during deserialization.
3545 pub extern "C" fn ChannelManagerReadArgs_set_tx_broadcaster(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::chain::chaininterface::BroadcasterInterface) {
3546 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tx_broadcaster = val;
3548 /// The router which will be used in the ChannelManager in the future for finding routes
3549 /// on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding.
3551 /// No calls to the router will be made during deserialization.
3553 pub extern "C" fn ChannelManagerReadArgs_get_router(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::routing::router::Router {
3554 let mut inner_val = &mut this_ptr.get_native_mut_ref().router;
3557 /// The router which will be used in the ChannelManager in the future for finding routes
3558 /// on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding.
3560 /// No calls to the router will be made during deserialization.
3562 pub extern "C" fn ChannelManagerReadArgs_set_router(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::routing::router::Router) {
3563 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.router = val;
3565 /// The Logger for use in the ChannelManager and which may be used to log information during
3566 /// deserialization.
3568 pub extern "C" fn ChannelManagerReadArgs_get_logger(this_ptr: &ChannelManagerReadArgs) -> *const crate::lightning::util::logger::Logger {
3569 let mut inner_val = &mut this_ptr.get_native_mut_ref().logger;
3572 /// The Logger for use in the ChannelManager and which may be used to log information during
3573 /// deserialization.
3575 pub extern "C" fn ChannelManagerReadArgs_set_logger(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::logger::Logger) {
3576 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.logger = val;
3578 /// Default settings used for new channels. Any existing channels will continue to use the
3579 /// runtime settings which were stored when the ChannelManager was serialized.
3581 pub extern "C" fn ChannelManagerReadArgs_get_default_config(this_ptr: &ChannelManagerReadArgs) -> crate::lightning::util::config::UserConfig {
3582 let mut inner_val = &mut this_ptr.get_native_mut_ref().default_config;
3583 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 }
3585 /// Default settings used for new channels. Any existing channels will continue to use the
3586 /// runtime settings which were stored when the ChannelManager was serialized.
3588 pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::lightning::util::config::UserConfig) {
3589 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.default_config = *unsafe { Box::from_raw(val.take_inner()) };
3591 /// Simple utility function to create a ChannelManagerReadArgs which creates the monitor
3592 /// HashMap for you. This is primarily useful for C bindings where it is not practical to
3593 /// populate a HashMap directly from C.
3596 pub extern "C" fn ChannelManagerReadArgs_new(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut signer_provider: crate::lightning::sign::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 {
3597 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() }); };
3598 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);
3599 crate::lightning::ln::channelmanager::ChannelManagerReadArgs { inner: ObjOps::heap_alloc(ret), is_owned: true }
3603 /// Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write
3604 pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelManagerZ_read(ser: crate::c_types::u8slice, arg: crate::lightning::ln::channelmanager::ChannelManagerReadArgs) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ {
3605 let arg_conv = *unsafe { Box::from_raw(arg.take_inner()) };
3606 let res: Result<(bitcoin::hash_types::BlockHash, lightning::ln::channelmanager::ChannelManager<crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::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);
3607 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() };