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 //! Various user-configurable channel limits and settings which ChannelManager
12 use alloc::str::FromStr;
13 use core::ffi::c_void;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17 #[cfg(feature="no-std")]
18 use alloc::{vec::Vec, boxed::Box};
21 use lightning::util::config::ChannelHandshakeConfig as nativeChannelHandshakeConfigImport;
22 pub(crate) type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
24 /// Configuration we set when applicable.
26 /// Default::default() provides sane defaults.
29 pub struct ChannelHandshakeConfig {
30 /// A pointer to the opaque Rust object.
32 /// Nearly everywhere, inner must be non-null, however in places where
33 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
34 pub inner: *mut nativeChannelHandshakeConfig,
35 /// Indicates that this is the only struct which contains the same pointer.
37 /// Rust functions which take ownership of an object provided via an argument require
38 /// this to be true and invalidate the object pointed to by inner.
42 impl Drop for ChannelHandshakeConfig {
44 if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) {
45 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
49 /// Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL.
51 pub extern "C" fn ChannelHandshakeConfig_free(this_obj: ChannelHandshakeConfig) { }
53 /// Used only if an object of this type is returned as a trait impl by a method
54 pub(crate) extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
55 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeConfig); }
58 impl ChannelHandshakeConfig {
59 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeConfig {
60 unsafe { &*ObjOps::untweak_ptr(self.inner) }
62 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeConfig {
63 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
65 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
66 pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeConfig {
67 assert!(self.is_owned);
68 let ret = ObjOps::untweak_ptr(self.inner);
69 self.inner = core::ptr::null_mut();
73 /// Confirmations we will wait for before considering the channel locked in.
74 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
75 /// equivalent limit applied to outbound channels).
79 pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHandshakeConfig) -> u32 {
80 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
83 /// Confirmations we will wait for before considering the channel locked in.
84 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
85 /// equivalent limit applied to outbound channels).
89 pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
90 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
92 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
93 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
96 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
97 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
98 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
99 /// possibly with time in between to RBF the spending transaction).
101 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
102 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
105 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
106 /// can tweak config to ask for more security, not less.
108 pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 {
109 let mut inner_val = &mut this_ptr.get_native_mut_ref().our_to_self_delay;
112 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
113 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
116 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
117 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
118 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
119 /// possibly with time in between to RBF the spending transaction).
121 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
122 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
125 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
126 /// can tweak config to ask for more security, not less.
128 pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) {
129 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_to_self_delay = val;
131 /// Set to the smallest value HTLC we will accept to process.
133 /// This value is sent to our counterparty on channel-open and we close the channel any time
134 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
136 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
139 pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 {
140 let mut inner_val = &mut this_ptr.get_native_mut_ref().our_htlc_minimum_msat;
143 /// Set to the smallest value HTLC we will accept to process.
145 /// This value is sent to our counterparty on channel-open and we close the channel any time
146 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
148 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
151 pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) {
152 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_htlc_minimum_msat = val;
154 /// Constructs a new ChannelHandshakeConfig given each field
157 pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64) -> ChannelHandshakeConfig {
158 ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig {
159 minimum_depth: minimum_depth_arg,
160 our_to_self_delay: our_to_self_delay_arg,
161 our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
164 impl Clone for ChannelHandshakeConfig {
165 fn clone(&self) -> Self {
167 inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
168 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
174 /// Used only if an object of this type is returned as a trait impl by a method
175 pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
176 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
179 /// Creates a copy of the ChannelHandshakeConfig
180 pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig {
183 /// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
186 pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
187 ChannelHandshakeConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
190 use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
191 pub(crate) type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
193 /// Optional channel limits which are applied during channel creation.
195 /// These limits are only applied to our counterparty's limits, not our own.
197 /// Use 0/<type>::max_value() as appropriate to skip checking.
199 /// Provides sane defaults for most configurations.
201 /// Most additional limits are disabled except those with which specify a default in individual
202 /// field documentation. Note that this may result in barely-usable channels, but since they
203 /// are applied mostly only to incoming channels that's not much of a problem.
206 pub struct ChannelHandshakeLimits {
207 /// A pointer to the opaque Rust object.
209 /// Nearly everywhere, inner must be non-null, however in places where
210 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
211 pub inner: *mut nativeChannelHandshakeLimits,
212 /// Indicates that this is the only struct which contains the same pointer.
214 /// Rust functions which take ownership of an object provided via an argument require
215 /// this to be true and invalidate the object pointed to by inner.
219 impl Drop for ChannelHandshakeLimits {
221 if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) {
222 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
226 /// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL.
228 pub extern "C" fn ChannelHandshakeLimits_free(this_obj: ChannelHandshakeLimits) { }
230 /// Used only if an object of this type is returned as a trait impl by a method
231 pub(crate) extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
232 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits); }
235 impl ChannelHandshakeLimits {
236 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeLimits {
237 unsafe { &*ObjOps::untweak_ptr(self.inner) }
239 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeLimits {
240 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
242 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
243 pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
244 assert!(self.is_owned);
245 let ret = ObjOps::untweak_ptr(self.inner);
246 self.inner = core::ptr::null_mut();
250 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
251 /// only applies to inbound channels.
253 /// Default value: 0.
255 pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
256 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_funding_satoshis;
259 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
260 /// only applies to inbound channels.
262 /// Default value: 0.
264 pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
265 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_funding_satoshis = val;
267 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
268 /// you to limit the maximum minimum-size they can require.
270 /// Default value: u64::max_value.
272 pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
273 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_minimum_msat;
276 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
277 /// you to limit the maximum minimum-size they can require.
279 /// Default value: u64::max_value.
281 pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
282 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_minimum_msat = val;
284 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
285 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
287 /// Default value: 0.
289 pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
290 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_htlc_value_in_flight_msat;
293 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
294 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
296 /// Default value: 0.
298 pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
299 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_htlc_value_in_flight_msat = val;
301 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
302 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
303 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
305 /// Default value: u64::max_value.
307 pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
308 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_reserve_satoshis;
311 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
312 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
313 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
315 /// Default value: u64::max_value.
317 pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
318 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_reserve_satoshis = val;
320 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
321 /// time. This allows you to set a minimum such value.
323 /// Default value: 0.
325 pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 {
326 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_accepted_htlcs;
329 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
330 /// time. This allows you to set a minimum such value.
332 /// Default value: 0.
334 pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
335 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_accepted_htlcs = val;
337 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
338 /// certain number of blocks, specified by the node which is not the funder (as the funder can
339 /// assume they aren't going to double-spend themselves).
340 /// This config allows you to set a limit on the maximum amount of time to wait.
342 /// Default value: 144, or roughly one day and only applies to outbound channels.
344 pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 {
345 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_minimum_depth;
348 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
349 /// certain number of blocks, specified by the node which is not the funder (as the funder can
350 /// assume they aren't going to double-spend themselves).
351 /// This config allows you to set a limit on the maximum amount of time to wait.
353 /// Default value: 144, or roughly one day and only applies to outbound channels.
355 pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) {
356 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_minimum_depth = val;
358 /// Set to force an incoming channel to match our announced channel preference in
359 /// [`ChannelConfig::announced_channel`].
361 /// For a node which is not online reliably, this should be set to true and
362 /// [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
363 /// channels will ever be opened.
365 /// Default value: true.
367 pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool {
368 let mut inner_val = &mut this_ptr.get_native_mut_ref().force_announced_channel_preference;
371 /// Set to force an incoming channel to match our announced channel preference in
372 /// [`ChannelConfig::announced_channel`].
374 /// For a node which is not online reliably, this should be set to true and
375 /// [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
376 /// channels will ever be opened.
378 /// Default value: true.
380 pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
381 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_announced_channel_preference = val;
383 /// Set to the amount of time we're willing to wait to claim money back to us.
385 /// Not checking this value would be a security issue, as our peer would be able to set it to
386 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
388 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
389 /// reduce the loss of having useless locked funds (if your peer accepts)
391 pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 {
392 let mut inner_val = &mut this_ptr.get_native_mut_ref().their_to_self_delay;
395 /// Set to the amount of time we're willing to wait to claim money back to us.
397 /// Not checking this value would be a security issue, as our peer would be able to set it to
398 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
400 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
401 /// reduce the loss of having useless locked funds (if your peer accepts)
403 pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
404 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_to_self_delay = val;
406 /// Constructs a new ChannelHandshakeLimits given each field
409 pub extern "C" fn ChannelHandshakeLimits_new(mut min_funding_satoshis_arg: u64, mut max_htlc_minimum_msat_arg: u64, mut min_max_htlc_value_in_flight_msat_arg: u64, mut max_channel_reserve_satoshis_arg: u64, mut min_max_accepted_htlcs_arg: u16, mut max_minimum_depth_arg: u32, mut force_announced_channel_preference_arg: bool, mut their_to_self_delay_arg: u16) -> ChannelHandshakeLimits {
410 ChannelHandshakeLimits { inner: ObjOps::heap_alloc(nativeChannelHandshakeLimits {
411 min_funding_satoshis: min_funding_satoshis_arg,
412 max_htlc_minimum_msat: max_htlc_minimum_msat_arg,
413 min_max_htlc_value_in_flight_msat: min_max_htlc_value_in_flight_msat_arg,
414 max_channel_reserve_satoshis: max_channel_reserve_satoshis_arg,
415 min_max_accepted_htlcs: min_max_accepted_htlcs_arg,
416 max_minimum_depth: max_minimum_depth_arg,
417 force_announced_channel_preference: force_announced_channel_preference_arg,
418 their_to_self_delay: their_to_self_delay_arg,
421 impl Clone for ChannelHandshakeLimits {
422 fn clone(&self) -> Self {
424 inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { core::ptr::null_mut() } else {
425 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
431 /// Used only if an object of this type is returned as a trait impl by a method
432 pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
433 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
436 /// Creates a copy of the ChannelHandshakeLimits
437 pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits {
440 /// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
443 pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
444 ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
447 use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
448 pub(crate) type nativeChannelConfig = nativeChannelConfigImport;
450 /// Options which apply on a per-channel basis and may change at runtime or based on negotiation
451 /// with our counterparty.
454 pub struct ChannelConfig {
455 /// A pointer to the opaque Rust object.
457 /// Nearly everywhere, inner must be non-null, however in places where
458 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
459 pub inner: *mut nativeChannelConfig,
460 /// Indicates that this is the only struct which contains the same pointer.
462 /// Rust functions which take ownership of an object provided via an argument require
463 /// this to be true and invalidate the object pointed to by inner.
467 impl Drop for ChannelConfig {
469 if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) {
470 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
474 /// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL.
476 pub extern "C" fn ChannelConfig_free(this_obj: ChannelConfig) { }
478 /// Used only if an object of this type is returned as a trait impl by a method
479 pub(crate) extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
480 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelConfig); }
484 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfig {
485 unsafe { &*ObjOps::untweak_ptr(self.inner) }
487 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfig {
488 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
490 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
491 pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
492 assert!(self.is_owned);
493 let ret = ObjOps::untweak_ptr(self.inner);
494 self.inner = core::ptr::null_mut();
498 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
499 /// over the channel.
500 /// This may be allowed to change at runtime in a later update, however doing so must result in
501 /// update messages sent to notify all nodes of our updated relay fee.
503 /// Default value: 0.
505 pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 {
506 let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths;
509 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
510 /// over the channel.
511 /// This may be allowed to change at runtime in a later update, however doing so must result in
512 /// update messages sent to notify all nodes of our updated relay fee.
514 /// Default value: 0.
516 pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) {
517 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = val;
519 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
520 /// excess of [`forwarding_fee_proportional_millionths`].
521 /// This may be allowed to change at runtime in a later update, however doing so must result in
522 /// update messages sent to notify all nodes of our updated relay fee.
524 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
525 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
528 /// Default value: 1000.
530 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
532 pub extern "C" fn ChannelConfig_get_forwarding_fee_base_msat(this_ptr: &ChannelConfig) -> u32 {
533 let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_base_msat;
536 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
537 /// excess of [`forwarding_fee_proportional_millionths`].
538 /// This may be allowed to change at runtime in a later update, however doing so must result in
539 /// update messages sent to notify all nodes of our updated relay fee.
541 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
542 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
545 /// Default value: 1000.
547 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
549 pub extern "C" fn ChannelConfig_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfig, mut val: u32) {
550 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_base_msat = val;
552 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
553 /// the channel this config applies to.
555 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
556 /// HTLC balance when a channel appears on-chain whereas
557 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
558 /// (non-HTLC-encumbered) balance.
560 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
561 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
562 /// commitment transaction at least once per this many blocks (minus some margin to allow us
563 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
564 /// the spending transaction).
566 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
567 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
568 /// [`MIN_CLTV_EXPIRY_DELTA`] instead.
570 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
572 pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 {
573 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
576 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
577 /// the channel this config applies to.
579 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
580 /// HTLC balance when a channel appears on-chain whereas
581 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
582 /// (non-HTLC-encumbered) balance.
584 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
585 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
586 /// commitment transaction at least once per this many blocks (minus some margin to allow us
587 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
588 /// the spending transaction).
590 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
591 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
592 /// [`MIN_CLTV_EXPIRY_DELTA`] instead.
594 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
596 pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) {
597 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
599 /// Set to announce the channel publicly and notify all nodes that they can route via this
602 /// This should only be set to true for nodes which expect to be online reliably.
604 /// As the node which funds a channel picks this value this will only apply for new outbound
605 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
607 /// This cannot be changed after the initial channel handshake.
609 /// Default value: false.
611 pub extern "C" fn ChannelConfig_get_announced_channel(this_ptr: &ChannelConfig) -> bool {
612 let mut inner_val = &mut this_ptr.get_native_mut_ref().announced_channel;
615 /// Set to announce the channel publicly and notify all nodes that they can route via this
618 /// This should only be set to true for nodes which expect to be online reliably.
620 /// As the node which funds a channel picks this value this will only apply for new outbound
621 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
623 /// This cannot be changed after the initial channel handshake.
625 /// Default value: false.
627 pub extern "C" fn ChannelConfig_set_announced_channel(this_ptr: &mut ChannelConfig, mut val: bool) {
628 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announced_channel = val;
630 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
631 /// supports it, they will then enforce the mutual-close output to us matches what we provided
632 /// at intialization, preventing us from closing to an alternate pubkey.
634 /// This is set to true by default to provide a slight increase in security, though ultimately
635 /// any attacker who is able to take control of a channel can just as easily send the funds via
636 /// lightning payments, so we never require that our counterparties support this option.
638 /// This cannot be changed after a channel has been initialized.
640 /// Default value: true.
642 pub extern "C" fn ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelConfig) -> bool {
643 let mut inner_val = &mut this_ptr.get_native_mut_ref().commit_upfront_shutdown_pubkey;
646 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
647 /// supports it, they will then enforce the mutual-close output to us matches what we provided
648 /// at intialization, preventing us from closing to an alternate pubkey.
650 /// This is set to true by default to provide a slight increase in security, though ultimately
651 /// any attacker who is able to take control of a channel can just as easily send the funds via
652 /// lightning payments, so we never require that our counterparties support this option.
654 /// This cannot be changed after a channel has been initialized.
656 /// Default value: true.
658 pub extern "C" fn ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelConfig, mut val: bool) {
659 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commit_upfront_shutdown_pubkey = val;
661 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
662 /// small to claim on-chain.
664 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
665 /// not be claimable on-chain, instead being turned into additional miner fees if either
666 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
667 /// to such payments may be sustantial if there are many dust HTLCs present when the
668 /// channel is force-closed.
670 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
671 /// exposure across all three types per-channel. Setting this too low may prevent the
672 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
673 /// important to prevent stealing of dust HTLCs by miners.
675 /// Default value: 5_000_000 msat.
677 pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfig) -> u64 {
678 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat;
681 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
682 /// small to claim on-chain.
684 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
685 /// not be claimable on-chain, instead being turned into additional miner fees if either
686 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
687 /// to such payments may be sustantial if there are many dust HTLCs present when the
688 /// channel is force-closed.
690 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
691 /// exposure across all three types per-channel. Setting this too low may prevent the
692 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
693 /// important to prevent stealing of dust HTLCs by miners.
695 /// Default value: 5_000_000 msat.
697 pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfig, mut val: u64) {
698 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = val;
700 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
701 /// `to_self_delay` to reclaim funds.
703 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
704 /// closing transaction which both sides find acceptable, ultimately paid by the channel
705 /// funder/initiator.
707 /// When we are the funder, because we have to pay the channel closing fee, we bound the
708 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
709 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
710 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
711 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
714 /// When we are not the funder, we require the closing transaction fee pay at least our
715 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
716 /// Thus, this value is ignored when we are not the funder.
718 /// Default value: 1000 satoshis.
720 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
721 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
723 pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfig) -> u64 {
724 let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_avoidance_max_fee_satoshis;
727 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
728 /// `to_self_delay` to reclaim funds.
730 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
731 /// closing transaction which both sides find acceptable, ultimately paid by the channel
732 /// funder/initiator.
734 /// When we are the funder, because we have to pay the channel closing fee, we bound the
735 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
736 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
737 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
738 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
741 /// When we are not the funder, we require the closing transaction fee pay at least our
742 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
743 /// Thus, this value is ignored when we are not the funder.
745 /// Default value: 1000 satoshis.
747 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
748 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
750 pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfig, mut val: u64) {
751 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = val;
753 /// Constructs a new ChannelConfig given each field
756 pub extern "C" fn ChannelConfig_new(mut forwarding_fee_proportional_millionths_arg: u32, mut forwarding_fee_base_msat_arg: u32, mut cltv_expiry_delta_arg: u16, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut max_dust_htlc_exposure_msat_arg: u64, mut force_close_avoidance_max_fee_satoshis_arg: u64) -> ChannelConfig {
757 ChannelConfig { inner: ObjOps::heap_alloc(nativeChannelConfig {
758 forwarding_fee_proportional_millionths: forwarding_fee_proportional_millionths_arg,
759 forwarding_fee_base_msat: forwarding_fee_base_msat_arg,
760 cltv_expiry_delta: cltv_expiry_delta_arg,
761 announced_channel: announced_channel_arg,
762 commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
763 max_dust_htlc_exposure_msat: max_dust_htlc_exposure_msat_arg,
764 force_close_avoidance_max_fee_satoshis: force_close_avoidance_max_fee_satoshis_arg,
767 impl Clone for ChannelConfig {
768 fn clone(&self) -> Self {
770 inner: if <*mut nativeChannelConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
771 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
777 /// Used only if an object of this type is returned as a trait impl by a method
778 pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
779 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
782 /// Creates a copy of the ChannelConfig
783 pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
786 /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
789 pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
790 ChannelConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
793 /// Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
794 pub extern "C" fn ChannelConfig_write(obj: &ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
795 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
798 pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
799 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) })
802 /// Read a ChannelConfig from a byte array, created by ChannelConfig_write
803 pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
804 let res: Result<lightning::util::config::ChannelConfig, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
805 let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::ChannelConfig { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
809 use lightning::util::config::UserConfig as nativeUserConfigImport;
810 pub(crate) type nativeUserConfig = nativeUserConfigImport;
812 /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
814 /// Default::default() provides sane defaults for most configurations
815 /// (but currently with 0 relay fees!)
818 pub struct UserConfig {
819 /// A pointer to the opaque Rust object.
821 /// Nearly everywhere, inner must be non-null, however in places where
822 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
823 pub inner: *mut nativeUserConfig,
824 /// Indicates that this is the only struct which contains the same pointer.
826 /// Rust functions which take ownership of an object provided via an argument require
827 /// this to be true and invalidate the object pointed to by inner.
831 impl Drop for UserConfig {
833 if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) {
834 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
838 /// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL.
840 pub extern "C" fn UserConfig_free(this_obj: UserConfig) { }
842 /// Used only if an object of this type is returned as a trait impl by a method
843 pub(crate) extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
844 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUserConfig); }
848 pub(crate) fn get_native_ref(&self) -> &'static nativeUserConfig {
849 unsafe { &*ObjOps::untweak_ptr(self.inner) }
851 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUserConfig {
852 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
854 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
855 pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
856 assert!(self.is_owned);
857 let ret = ObjOps::untweak_ptr(self.inner);
858 self.inner = core::ptr::null_mut();
862 /// Channel config that we propose to our counterparty.
864 pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig {
865 let mut inner_val = &mut this_ptr.get_native_mut_ref().own_channel_config;
866 crate::lightning::util::config::ChannelHandshakeConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::config::ChannelHandshakeConfig<>) as *mut _) }, is_owned: false }
868 /// Channel config that we propose to our counterparty.
870 pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeConfig) {
871 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.own_channel_config = *unsafe { Box::from_raw(val.take_inner()) };
873 /// Limits applied to our counterparty's proposed channel config settings.
875 pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeLimits {
876 let mut inner_val = &mut this_ptr.get_native_mut_ref().peer_channel_config_limits;
877 crate::lightning::util::config::ChannelHandshakeLimits { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::config::ChannelHandshakeLimits<>) as *mut _) }, is_owned: false }
879 /// Limits applied to our counterparty's proposed channel config settings.
881 pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeLimits) {
882 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_inner()) };
884 /// Channel config which affects behavior during channel lifetime.
886 pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig {
887 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_options;
888 crate::lightning::util::config::ChannelConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::config::ChannelConfig<>) as *mut _) }, is_owned: false }
890 /// Channel config which affects behavior during channel lifetime.
892 pub extern "C" fn UserConfig_set_channel_options(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelConfig) {
893 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_options = *unsafe { Box::from_raw(val.take_inner()) };
895 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
896 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
897 /// node which is not online reliably.
899 /// For nodes which are not online reliably, you should set all channels to *not* be announced
900 /// (using [`ChannelConfig::announced_channel`] and
901 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
902 /// ensure you are not exposed to any forwarding risk.
904 /// Note that because you cannot change a channel's announced state after creation, there is no
905 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
906 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
907 /// all your channels and open new ones. For privacy, you should also change your node_id
908 /// (swapping all private and public key material for new ones) at that time.
910 /// Default value: false.
912 pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &UserConfig) -> bool {
913 let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_forwards_to_priv_channels;
916 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
917 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
918 /// node which is not online reliably.
920 /// For nodes which are not online reliably, you should set all channels to *not* be announced
921 /// (using [`ChannelConfig::announced_channel`] and
922 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
923 /// ensure you are not exposed to any forwarding risk.
925 /// Note that because you cannot change a channel's announced state after creation, there is no
926 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
927 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
928 /// all your channels and open new ones. For privacy, you should also change your node_id
929 /// (swapping all private and public key material for new ones) at that time.
931 /// Default value: false.
933 pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) {
934 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_forwards_to_priv_channels = val;
936 /// If this is set to false, we do not accept inbound requests to open a new channel.
937 /// Default value: true.
939 pub extern "C" fn UserConfig_get_accept_inbound_channels(this_ptr: &UserConfig) -> bool {
940 let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_inbound_channels;
943 /// If this is set to false, we do not accept inbound requests to open a new channel.
944 /// Default value: true.
946 pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
947 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_inbound_channels = val;
949 /// If this is set to true, the user needs to manually accept inbound requests to open a new
952 /// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
953 /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
954 /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
955 /// user explicitly chooses to accept the request.
957 /// Default value: false.
959 /// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
960 /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
961 /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
963 pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &UserConfig) -> bool {
964 let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_accept_inbound_channels;
967 /// If this is set to true, the user needs to manually accept inbound requests to open a new
970 /// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
971 /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
972 /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
973 /// user explicitly chooses to accept the request.
975 /// Default value: false.
977 /// [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
978 /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
979 /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
981 pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
982 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_accept_inbound_channels = val;
984 /// Constructs a new UserConfig given each field
987 pub extern "C" fn UserConfig_new(mut own_channel_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut peer_channel_config_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_options_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool) -> UserConfig {
988 UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig {
989 own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) },
990 peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) },
991 channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) },
992 accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
993 accept_inbound_channels: accept_inbound_channels_arg,
994 manually_accept_inbound_channels: manually_accept_inbound_channels_arg,
997 impl Clone for UserConfig {
998 fn clone(&self) -> Self {
1000 inner: if <*mut nativeUserConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
1001 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1007 /// Used only if an object of this type is returned as a trait impl by a method
1008 pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
1009 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
1012 /// Creates a copy of the UserConfig
1013 pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig {
1016 /// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
1019 pub extern "C" fn UserConfig_default() -> UserConfig {
1020 UserConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }