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 std::str::FromStr;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
19 use lightning::util::config::ChannelHandshakeConfig as nativeChannelHandshakeConfigImport;
20 type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
22 /// Configuration we set when applicable.
24 /// Default::default() provides sane defaults.
27 pub struct ChannelHandshakeConfig {
28 /// A pointer to the opaque Rust object.
30 /// Nearly everywhere, inner must be non-null, however in places where
31 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
32 pub inner: *mut nativeChannelHandshakeConfig,
33 /// Indicates that this is the only struct which contains the same pointer.
35 /// Rust functions which take ownership of an object provided via an argument require
36 /// this to be true and invalidate the object pointed to by inner.
40 impl Drop for ChannelHandshakeConfig {
42 if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) {
43 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
47 /// Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL.
49 pub extern "C" fn ChannelHandshakeConfig_free(this_obj: ChannelHandshakeConfig) { }
51 /// Used only if an object of this type is returned as a trait impl by a method
52 extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
53 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeConfig); }
56 impl ChannelHandshakeConfig {
57 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeConfig {
58 unsafe { &*ObjOps::untweak_ptr(self.inner) }
60 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeConfig {
61 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
63 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
64 pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeConfig {
65 assert!(self.is_owned);
66 let ret = ObjOps::untweak_ptr(self.inner);
67 self.inner = std::ptr::null_mut();
71 /// Confirmations we will wait for before considering the channel locked in.
72 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
73 /// equivalent limit applied to outbound channels).
77 pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHandshakeConfig) -> u32 {
78 let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
81 /// Confirmations we will wait for before considering the channel locked in.
82 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
83 /// equivalent limit applied to outbound channels).
87 pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
88 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
90 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
91 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
94 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
95 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
96 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
97 /// possibly with time in between to RBF the spending transaction).
99 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
100 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
103 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
104 /// can tweak config to ask for more security, not less.
106 pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 {
107 let mut inner_val = &mut this_ptr.get_native_mut_ref().our_to_self_delay;
110 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
111 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
114 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
115 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
116 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
117 /// possibly with time in between to RBF the spending transaction).
119 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
120 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
123 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
124 /// can tweak config to ask for more security, not less.
126 pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) {
127 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_to_self_delay = val;
129 /// Set to the smallest value HTLC we will accept to process.
131 /// This value is sent to our counterparty on channel-open and we close the channel any time
132 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
134 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
137 pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 {
138 let mut inner_val = &mut this_ptr.get_native_mut_ref().our_htlc_minimum_msat;
141 /// Set to the smallest value HTLC we will accept to process.
143 /// This value is sent to our counterparty on channel-open and we close the channel any time
144 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
146 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
149 pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) {
150 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_htlc_minimum_msat = val;
152 /// Constructs a new ChannelHandshakeConfig given each field
155 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 {
156 ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig {
157 minimum_depth: minimum_depth_arg,
158 our_to_self_delay: our_to_self_delay_arg,
159 our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
162 impl Clone for ChannelHandshakeConfig {
163 fn clone(&self) -> Self {
165 inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
166 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
172 /// Used only if an object of this type is returned as a trait impl by a method
173 pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
174 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
177 /// Creates a copy of the ChannelHandshakeConfig
178 pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig {
181 /// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
184 pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
185 ChannelHandshakeConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
188 use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
189 type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
191 /// Optional channel limits which are applied during channel creation.
193 /// These limits are only applied to our counterparty's limits, not our own.
195 /// Use 0/<type>::max_value() as appropriate to skip checking.
197 /// Provides sane defaults for most configurations.
199 /// Most additional limits are disabled except those with which specify a default in individual
200 /// field documentation. Note that this may result in barely-usable channels, but since they
201 /// are applied mostly only to incoming channels that's not much of a problem.
204 pub struct ChannelHandshakeLimits {
205 /// A pointer to the opaque Rust object.
207 /// Nearly everywhere, inner must be non-null, however in places where
208 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
209 pub inner: *mut nativeChannelHandshakeLimits,
210 /// Indicates that this is the only struct which contains the same pointer.
212 /// Rust functions which take ownership of an object provided via an argument require
213 /// this to be true and invalidate the object pointed to by inner.
217 impl Drop for ChannelHandshakeLimits {
219 if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) {
220 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
224 /// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL.
226 pub extern "C" fn ChannelHandshakeLimits_free(this_obj: ChannelHandshakeLimits) { }
228 /// Used only if an object of this type is returned as a trait impl by a method
229 extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
230 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits); }
233 impl ChannelHandshakeLimits {
234 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeLimits {
235 unsafe { &*ObjOps::untweak_ptr(self.inner) }
237 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeLimits {
238 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
240 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
241 pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
242 assert!(self.is_owned);
243 let ret = ObjOps::untweak_ptr(self.inner);
244 self.inner = std::ptr::null_mut();
248 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
249 /// only applies to inbound channels.
251 /// Default value: 0.
253 pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
254 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_funding_satoshis;
257 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
258 /// only applies to inbound channels.
260 /// Default value: 0.
262 pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
263 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_funding_satoshis = val;
265 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
266 /// you to limit the maximum minimum-size they can require.
268 /// Default value: u64::max_value.
270 pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
271 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_minimum_msat;
274 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
275 /// you to limit the maximum minimum-size they can require.
277 /// Default value: u64::max_value.
279 pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
280 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_minimum_msat = val;
282 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
283 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
285 /// Default value: 0.
287 pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
288 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_htlc_value_in_flight_msat;
291 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
292 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
294 /// Default value: 0.
296 pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
297 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_htlc_value_in_flight_msat = val;
299 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
300 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
301 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
303 /// Default value: u64::max_value.
305 pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
306 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_reserve_satoshis;
309 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
310 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
311 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
313 /// Default value: u64::max_value.
315 pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
316 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_reserve_satoshis = val;
318 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
319 /// time. This allows you to set a minimum such value.
321 /// Default value: 0.
323 pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 {
324 let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_accepted_htlcs;
327 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
328 /// time. This allows you to set a minimum such value.
330 /// Default value: 0.
332 pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
333 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_accepted_htlcs = val;
335 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
336 /// certain number of blocks, specified by the node which is not the funder (as the funder can
337 /// assume they aren't going to double-spend themselves).
338 /// This config allows you to set a limit on the maximum amount of time to wait.
340 /// Default value: 144, or roughly one day and only applies to outbound channels.
342 pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 {
343 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_minimum_depth;
346 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
347 /// certain number of blocks, specified by the node which is not the funder (as the funder can
348 /// assume they aren't going to double-spend themselves).
349 /// This config allows you to set a limit on the maximum amount of time to wait.
351 /// Default value: 144, or roughly one day and only applies to outbound channels.
353 pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) {
354 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_minimum_depth = val;
356 /// Set to force an incoming channel to match our announced channel preference in
357 /// [`ChannelConfig::announced_channel`].
359 /// For a node which is not online reliably, this should be set to true and
360 /// [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
361 /// channels will ever be opened.
363 /// Default value: true.
365 pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool {
366 let mut inner_val = &mut this_ptr.get_native_mut_ref().force_announced_channel_preference;
369 /// Set to force an incoming channel to match our announced channel preference in
370 /// [`ChannelConfig::announced_channel`].
372 /// For a node which is not online reliably, this should be set to true and
373 /// [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
374 /// channels will ever be opened.
376 /// Default value: true.
378 pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
379 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_announced_channel_preference = val;
381 /// Set to the amount of time we're willing to wait to claim money back to us.
383 /// Not checking this value would be a security issue, as our peer would be able to set it to
384 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
386 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
387 /// reduce the loss of having useless locked funds (if your peer accepts)
389 pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 {
390 let mut inner_val = &mut this_ptr.get_native_mut_ref().their_to_self_delay;
393 /// Set to the amount of time we're willing to wait to claim money back to us.
395 /// Not checking this value would be a security issue, as our peer would be able to set it to
396 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
398 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
399 /// reduce the loss of having useless locked funds (if your peer accepts)
401 pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
402 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_to_self_delay = val;
404 /// Constructs a new ChannelHandshakeLimits given each field
407 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 {
408 ChannelHandshakeLimits { inner: ObjOps::heap_alloc(nativeChannelHandshakeLimits {
409 min_funding_satoshis: min_funding_satoshis_arg,
410 max_htlc_minimum_msat: max_htlc_minimum_msat_arg,
411 min_max_htlc_value_in_flight_msat: min_max_htlc_value_in_flight_msat_arg,
412 max_channel_reserve_satoshis: max_channel_reserve_satoshis_arg,
413 min_max_accepted_htlcs: min_max_accepted_htlcs_arg,
414 max_minimum_depth: max_minimum_depth_arg,
415 force_announced_channel_preference: force_announced_channel_preference_arg,
416 their_to_self_delay: their_to_self_delay_arg,
419 impl Clone for ChannelHandshakeLimits {
420 fn clone(&self) -> Self {
422 inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { std::ptr::null_mut() } else {
423 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
429 /// Used only if an object of this type is returned as a trait impl by a method
430 pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
431 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
434 /// Creates a copy of the ChannelHandshakeLimits
435 pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits {
438 /// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
441 pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
442 ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
445 use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
446 type nativeChannelConfig = nativeChannelConfigImport;
448 /// Options which apply on a per-channel basis and may change at runtime or based on negotiation
449 /// with our counterparty.
452 pub struct ChannelConfig {
453 /// A pointer to the opaque Rust object.
455 /// Nearly everywhere, inner must be non-null, however in places where
456 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
457 pub inner: *mut nativeChannelConfig,
458 /// Indicates that this is the only struct which contains the same pointer.
460 /// Rust functions which take ownership of an object provided via an argument require
461 /// this to be true and invalidate the object pointed to by inner.
465 impl Drop for ChannelConfig {
467 if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) {
468 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
472 /// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL.
474 pub extern "C" fn ChannelConfig_free(this_obj: ChannelConfig) { }
476 /// Used only if an object of this type is returned as a trait impl by a method
477 extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
478 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelConfig); }
482 pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfig {
483 unsafe { &*ObjOps::untweak_ptr(self.inner) }
485 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfig {
486 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
488 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
489 pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
490 assert!(self.is_owned);
491 let ret = ObjOps::untweak_ptr(self.inner);
492 self.inner = std::ptr::null_mut();
496 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
497 /// over the channel.
498 /// This may be allowed to change at runtime in a later update, however doing so must result in
499 /// update messages sent to notify all nodes of our updated relay fee.
501 /// Default value: 0.
503 pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 {
504 let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths;
507 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
508 /// over the channel.
509 /// This may be allowed to change at runtime in a later update, however doing so must result in
510 /// update messages sent to notify all nodes of our updated relay fee.
512 /// Default value: 0.
514 pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) {
515 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = val;
517 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
518 /// excess of [`forwarding_fee_proportional_millionths`].
519 /// This may be allowed to change at runtime in a later update, however doing so must result in
520 /// update messages sent to notify all nodes of our updated relay fee.
522 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
523 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
526 /// Default value: 1000.
528 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
530 pub extern "C" fn ChannelConfig_get_forwarding_fee_base_msat(this_ptr: &ChannelConfig) -> u32 {
531 let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_base_msat;
534 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
535 /// excess of [`forwarding_fee_proportional_millionths`].
536 /// This may be allowed to change at runtime in a later update, however doing so must result in
537 /// update messages sent to notify all nodes of our updated relay fee.
539 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
540 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
543 /// Default value: 1000.
545 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
547 pub extern "C" fn ChannelConfig_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfig, mut val: u32) {
548 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_base_msat = val;
550 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
551 /// the channel this config applies to.
553 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
554 /// HTLC balance when a channel appears on-chain whereas
555 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
556 /// (non-HTLC-encumbered) balance.
558 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
559 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
560 /// commitment transaction at least once per this many blocks (minus some margin to allow us
561 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
562 /// the spending transaction).
564 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
565 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
566 /// [`MIN_CLTV_EXPIRY_DELTA`] instead.
568 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
570 pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 {
571 let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
574 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
575 /// the channel this config applies to.
577 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
578 /// HTLC balance when a channel appears on-chain whereas
579 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
580 /// (non-HTLC-encumbered) balance.
582 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
583 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
584 /// commitment transaction at least once per this many blocks (minus some margin to allow us
585 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
586 /// the spending transaction).
588 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
589 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
590 /// [`MIN_CLTV_EXPIRY_DELTA`] instead.
592 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
594 pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) {
595 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
597 /// Set to announce the channel publicly and notify all nodes that they can route via this
600 /// This should only be set to true for nodes which expect to be online reliably.
602 /// As the node which funds a channel picks this value this will only apply for new outbound
603 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
605 /// This cannot be changed after the initial channel handshake.
607 /// Default value: false.
609 pub extern "C" fn ChannelConfig_get_announced_channel(this_ptr: &ChannelConfig) -> bool {
610 let mut inner_val = &mut this_ptr.get_native_mut_ref().announced_channel;
613 /// Set to announce the channel publicly and notify all nodes that they can route via this
616 /// This should only be set to true for nodes which expect to be online reliably.
618 /// As the node which funds a channel picks this value this will only apply for new outbound
619 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
621 /// This cannot be changed after the initial channel handshake.
623 /// Default value: false.
625 pub extern "C" fn ChannelConfig_set_announced_channel(this_ptr: &mut ChannelConfig, mut val: bool) {
626 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announced_channel = val;
628 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
629 /// supports it, they will then enforce the mutual-close output to us matches what we provided
630 /// at intialization, preventing us from closing to an alternate pubkey.
632 /// This is set to true by default to provide a slight increase in security, though ultimately
633 /// any attacker who is able to take control of a channel can just as easily send the funds via
634 /// lightning payments, so we never require that our counterparties support this option.
636 /// This cannot be changed after a channel has been initialized.
638 /// Default value: true.
640 pub extern "C" fn ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelConfig) -> bool {
641 let mut inner_val = &mut this_ptr.get_native_mut_ref().commit_upfront_shutdown_pubkey;
644 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
645 /// supports it, they will then enforce the mutual-close output to us matches what we provided
646 /// at intialization, preventing us from closing to an alternate pubkey.
648 /// This is set to true by default to provide a slight increase in security, though ultimately
649 /// any attacker who is able to take control of a channel can just as easily send the funds via
650 /// lightning payments, so we never require that our counterparties support this option.
652 /// This cannot be changed after a channel has been initialized.
654 /// Default value: true.
656 pub extern "C" fn ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelConfig, mut val: bool) {
657 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commit_upfront_shutdown_pubkey = val;
659 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
660 /// small to claim on-chain.
662 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
663 /// not be claimable on-chain, instead being turned into additional miner fees if either
664 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
665 /// to such payments may be sustantial if there are many dust HTLCs present when the
666 /// channel is force-closed.
668 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
669 /// exposure across all three types per-channel. Setting this too low may prevent the
670 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
671 /// important to prevent stealing of dust HTLCs by miners.
673 /// Default value: 5_000_000 msat.
675 pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfig) -> u64 {
676 let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat;
679 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
680 /// small to claim on-chain.
682 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
683 /// not be claimable on-chain, instead being turned into additional miner fees if either
684 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
685 /// to such payments may be sustantial if there are many dust HTLCs present when the
686 /// channel is force-closed.
688 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
689 /// exposure across all three types per-channel. Setting this too low may prevent the
690 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
691 /// important to prevent stealing of dust HTLCs by miners.
693 /// Default value: 5_000_000 msat.
695 pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfig, mut val: u64) {
696 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = val;
698 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
699 /// `to_self_delay` to reclaim funds.
701 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
702 /// closing transaction which both sides find acceptable, ultimately paid by the channel
703 /// funder/initiator.
705 /// When we are the funder, because we have to pay the channel closing fee, we bound the
706 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
707 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
708 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
709 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
712 /// When we are not the funder, we require the closing transaction fee pay at least our
713 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
714 /// Thus, this value is ignored when we are not the funder.
716 /// Default value: 1000 satoshis.
718 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
719 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
721 pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfig) -> u64 {
722 let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_avoidance_max_fee_satoshis;
725 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
726 /// `to_self_delay` to reclaim funds.
728 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
729 /// closing transaction which both sides find acceptable, ultimately paid by the channel
730 /// funder/initiator.
732 /// When we are the funder, because we have to pay the channel closing fee, we bound the
733 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
734 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
735 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
736 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
739 /// When we are not the funder, we require the closing transaction fee pay at least our
740 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
741 /// Thus, this value is ignored when we are not the funder.
743 /// Default value: 1000 satoshis.
745 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
746 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
748 pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfig, mut val: u64) {
749 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = val;
751 /// Constructs a new ChannelConfig given each field
754 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 {
755 ChannelConfig { inner: ObjOps::heap_alloc(nativeChannelConfig {
756 forwarding_fee_proportional_millionths: forwarding_fee_proportional_millionths_arg,
757 forwarding_fee_base_msat: forwarding_fee_base_msat_arg,
758 cltv_expiry_delta: cltv_expiry_delta_arg,
759 announced_channel: announced_channel_arg,
760 commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
761 max_dust_htlc_exposure_msat: max_dust_htlc_exposure_msat_arg,
762 force_close_avoidance_max_fee_satoshis: force_close_avoidance_max_fee_satoshis_arg,
765 impl Clone for ChannelConfig {
766 fn clone(&self) -> Self {
768 inner: if <*mut nativeChannelConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
769 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
775 /// Used only if an object of this type is returned as a trait impl by a method
776 pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
777 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
780 /// Creates a copy of the ChannelConfig
781 pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
784 /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
787 pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
788 ChannelConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
791 /// Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
792 pub extern "C" fn ChannelConfig_write(obj: &ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
793 crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
796 pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
797 crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) })
800 /// Read a ChannelConfig from a byte array, created by ChannelConfig_write
801 pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
802 let res = crate::c_types::deserialize_obj(ser);
803 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() };
807 use lightning::util::config::UserConfig as nativeUserConfigImport;
808 type nativeUserConfig = nativeUserConfigImport;
810 /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
812 /// Default::default() provides sane defaults for most configurations
813 /// (but currently with 0 relay fees!)
816 pub struct UserConfig {
817 /// A pointer to the opaque Rust object.
819 /// Nearly everywhere, inner must be non-null, however in places where
820 /// the Rust equivalent takes an Option, it may be set to null to indicate None.
821 pub inner: *mut nativeUserConfig,
822 /// Indicates that this is the only struct which contains the same pointer.
824 /// Rust functions which take ownership of an object provided via an argument require
825 /// this to be true and invalidate the object pointed to by inner.
829 impl Drop for UserConfig {
831 if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) {
832 let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
836 /// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL.
838 pub extern "C" fn UserConfig_free(this_obj: UserConfig) { }
840 /// Used only if an object of this type is returned as a trait impl by a method
841 extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
842 unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUserConfig); }
846 pub(crate) fn get_native_ref(&self) -> &'static nativeUserConfig {
847 unsafe { &*ObjOps::untweak_ptr(self.inner) }
849 pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUserConfig {
850 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
852 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
853 pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
854 assert!(self.is_owned);
855 let ret = ObjOps::untweak_ptr(self.inner);
856 self.inner = std::ptr::null_mut();
860 /// Channel config that we propose to our counterparty.
862 pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig {
863 let mut inner_val = &mut this_ptr.get_native_mut_ref().own_channel_config;
864 crate::lightning::util::config::ChannelHandshakeConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
866 /// Channel config that we propose to our counterparty.
868 pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeConfig) {
869 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.own_channel_config = *unsafe { Box::from_raw(val.take_inner()) };
871 /// Limits applied to our counterparty's proposed channel config settings.
873 pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeLimits {
874 let mut inner_val = &mut this_ptr.get_native_mut_ref().peer_channel_config_limits;
875 crate::lightning::util::config::ChannelHandshakeLimits { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
877 /// Limits applied to our counterparty's proposed channel config settings.
879 pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeLimits) {
880 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_inner()) };
882 /// Channel config which affects behavior during channel lifetime.
884 pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig {
885 let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_options;
886 crate::lightning::util::config::ChannelConfig { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
888 /// Channel config which affects behavior during channel lifetime.
890 pub extern "C" fn UserConfig_set_channel_options(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelConfig) {
891 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_options = *unsafe { Box::from_raw(val.take_inner()) };
893 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
894 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
895 /// node which is not online reliably.
897 /// For nodes which are not online reliably, you should set all channels to *not* be announced
898 /// (using [`ChannelConfig::announced_channel`] and
899 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
900 /// ensure you are not exposed to any forwarding risk.
902 /// Note that because you cannot change a channel's announced state after creation, there is no
903 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
904 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
905 /// all your channels and open new ones. For privacy, you should also change your node_id
906 /// (swapping all private and public key material for new ones) at that time.
908 /// Default value: false.
910 pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &UserConfig) -> bool {
911 let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_forwards_to_priv_channels;
914 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
915 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
916 /// node which is not online reliably.
918 /// For nodes which are not online reliably, you should set all channels to *not* be announced
919 /// (using [`ChannelConfig::announced_channel`] and
920 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
921 /// ensure you are not exposed to any forwarding risk.
923 /// Note that because you cannot change a channel's announced state after creation, there is no
924 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
925 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
926 /// all your channels and open new ones. For privacy, you should also change your node_id
927 /// (swapping all private and public key material for new ones) at that time.
929 /// Default value: false.
931 pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) {
932 unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_forwards_to_priv_channels = val;
934 /// Constructs a new UserConfig given each field
937 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) -> UserConfig {
938 UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig {
939 own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) },
940 peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) },
941 channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) },
942 accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
945 impl Clone for UserConfig {
946 fn clone(&self) -> Self {
948 inner: if <*mut nativeUserConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
949 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
955 /// Used only if an object of this type is returned as a trait impl by a method
956 pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
957 Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
960 /// Creates a copy of the UserConfig
961 pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig {
964 /// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
967 pub extern "C" fn UserConfig_default() -> UserConfig {
968 UserConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }