Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning / util / config.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Various user-configurable channel limits and settings which ChannelManager
10 //! applies for you.
11
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};
19
20
21 use lightning::util::config::ChannelHandshakeConfig as nativeChannelHandshakeConfigImport;
22 pub(crate) type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
23
24 /// Configuration we set when applicable.
25 ///
26 /// Default::default() provides sane defaults.
27 #[must_use]
28 #[repr(C)]
29 pub struct ChannelHandshakeConfig {
30         /// A pointer to the opaque Rust object.
31
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.
36
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.
39         pub is_owned: bool,
40 }
41
42 impl Drop for ChannelHandshakeConfig {
43         fn drop(&mut self) {
44                 if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) {
45                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
46                 }
47         }
48 }
49 /// Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL.
50 #[no_mangle]
51 pub extern "C" fn ChannelHandshakeConfig_free(this_obj: ChannelHandshakeConfig) { }
52 #[allow(unused)]
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); }
56 }
57 #[allow(unused)]
58 impl ChannelHandshakeConfig {
59         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeConfig {
60                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
61         }
62         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeConfig {
63                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
64         }
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();
70                 ret
71         }
72 }
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).
76 ///
77 /// Default value: 6.
78 #[no_mangle]
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;
81         *inner_val
82 }
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).
86 ///
87 /// Default value: 6.
88 #[no_mangle]
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;
91 }
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
94 /// transaction).
95 ///
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).
100 ///
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
103 /// our channel.
104 ///
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.
107 #[no_mangle]
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;
110         *inner_val
111 }
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
114 /// transaction).
115 ///
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).
120 ///
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
123 /// our channel.
124 ///
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.
127 #[no_mangle]
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;
130 }
131 /// Set to the smallest value HTLC we will accept to process.
132 ///
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.
135 ///
136 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
137 /// by the protocol.
138 #[no_mangle]
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;
141         *inner_val
142 }
143 /// Set to the smallest value HTLC we will accept to process.
144 ///
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.
147 ///
148 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
149 /// by the protocol.
150 #[no_mangle]
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;
153 }
154 /// Constructs a new ChannelHandshakeConfig given each field
155 #[must_use]
156 #[no_mangle]
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,
162         }), is_owned: true }
163 }
164 impl Clone for ChannelHandshakeConfig {
165         fn clone(&self) -> Self {
166                 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()) },
169                         is_owned: true,
170                 }
171         }
172 }
173 #[allow(unused)]
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
177 }
178 #[no_mangle]
179 /// Creates a copy of the ChannelHandshakeConfig
180 pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig {
181         orig.clone()
182 }
183 /// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
184 #[must_use]
185 #[no_mangle]
186 pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
187         ChannelHandshakeConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
188 }
189
190 use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
191 pub(crate) type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
192
193 /// Optional channel limits which are applied during channel creation.
194 ///
195 /// These limits are only applied to our counterparty's limits, not our own.
196 ///
197 /// Use 0/<type>::max_value() as appropriate to skip checking.
198 ///
199 /// Provides sane defaults for most configurations.
200 ///
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.
204 #[must_use]
205 #[repr(C)]
206 pub struct ChannelHandshakeLimits {
207         /// A pointer to the opaque Rust object.
208
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.
213
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.
216         pub is_owned: bool,
217 }
218
219 impl Drop for ChannelHandshakeLimits {
220         fn drop(&mut self) {
221                 if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) {
222                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
223                 }
224         }
225 }
226 /// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL.
227 #[no_mangle]
228 pub extern "C" fn ChannelHandshakeLimits_free(this_obj: ChannelHandshakeLimits) { }
229 #[allow(unused)]
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); }
233 }
234 #[allow(unused)]
235 impl ChannelHandshakeLimits {
236         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeLimits {
237                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
238         }
239         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeLimits {
240                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
241         }
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();
247                 ret
248         }
249 }
250 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
251 /// only applies to inbound channels.
252 ///
253 /// Default value: 0.
254 #[no_mangle]
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;
257         *inner_val
258 }
259 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
260 /// only applies to inbound channels.
261 ///
262 /// Default value: 0.
263 #[no_mangle]
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;
266 }
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.
269 ///
270 /// Default value: u64::max_value.
271 #[no_mangle]
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;
274         *inner_val
275 }
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.
278 ///
279 /// Default value: u64::max_value.
280 #[no_mangle]
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;
283 }
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.
286 ///
287 /// Default value: 0.
288 #[no_mangle]
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;
291         *inner_val
292 }
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.
295 ///
296 /// Default value: 0.
297 #[no_mangle]
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;
300 }
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).
304 ///
305 /// Default value: u64::max_value.
306 #[no_mangle]
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;
309         *inner_val
310 }
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).
314 ///
315 /// Default value: u64::max_value.
316 #[no_mangle]
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;
319 }
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.
322 ///
323 /// Default value: 0.
324 #[no_mangle]
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;
327         *inner_val
328 }
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.
331 ///
332 /// Default value: 0.
333 #[no_mangle]
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;
336 }
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.
341 ///
342 /// Default value: 144, or roughly one day and only applies to outbound channels.
343 #[no_mangle]
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;
346         *inner_val
347 }
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.
352 ///
353 /// Default value: 144, or roughly one day and only applies to outbound channels.
354 #[no_mangle]
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;
357 }
358 /// Set to force an incoming channel to match our announced channel preference in
359 /// [`ChannelConfig::announced_channel`].
360 ///
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.
364 ///
365 /// Default value: true.
366 #[no_mangle]
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;
369         *inner_val
370 }
371 /// Set to force an incoming channel to match our announced channel preference in
372 /// [`ChannelConfig::announced_channel`].
373 ///
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.
377 ///
378 /// Default value: true.
379 #[no_mangle]
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;
382 }
383 /// Set to the amount of time we're willing to wait to claim money back to us.
384 ///
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.
387 ///
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)
390 #[no_mangle]
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;
393         *inner_val
394 }
395 /// Set to the amount of time we're willing to wait to claim money back to us.
396 ///
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.
399 ///
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)
402 #[no_mangle]
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;
405 }
406 /// Constructs a new ChannelHandshakeLimits given each field
407 #[must_use]
408 #[no_mangle]
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,
419         }), is_owned: true }
420 }
421 impl Clone for ChannelHandshakeLimits {
422         fn clone(&self) -> Self {
423                 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()) },
426                         is_owned: true,
427                 }
428         }
429 }
430 #[allow(unused)]
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
434 }
435 #[no_mangle]
436 /// Creates a copy of the ChannelHandshakeLimits
437 pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits {
438         orig.clone()
439 }
440 /// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
441 #[must_use]
442 #[no_mangle]
443 pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
444         ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
445 }
446
447 use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
448 pub(crate) type nativeChannelConfig = nativeChannelConfigImport;
449
450 /// Options which apply on a per-channel basis and may change at runtime or based on negotiation
451 /// with our counterparty.
452 #[must_use]
453 #[repr(C)]
454 pub struct ChannelConfig {
455         /// A pointer to the opaque Rust object.
456
457         /// Nearly everywhere, inner must be non-null, however in places where
458         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
459         pub inner: *mut nativeChannelConfig,
460         /// Indicates that this is the only struct which contains the same pointer.
461
462         /// Rust functions which take ownership of an object provided via an argument require
463         /// this to be true and invalidate the object pointed to by inner.
464         pub is_owned: bool,
465 }
466
467 impl Drop for ChannelConfig {
468         fn drop(&mut self) {
469                 if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) {
470                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
471                 }
472         }
473 }
474 /// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL.
475 #[no_mangle]
476 pub extern "C" fn ChannelConfig_free(this_obj: ChannelConfig) { }
477 #[allow(unused)]
478 /// Used only if an object of this type is returned as a trait impl by a method
479 pub(crate) extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
480         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelConfig); }
481 }
482 #[allow(unused)]
483 impl ChannelConfig {
484         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfig {
485                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
486         }
487         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfig {
488                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
489         }
490         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
491         pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
492                 assert!(self.is_owned);
493                 let ret = ObjOps::untweak_ptr(self.inner);
494                 self.inner = core::ptr::null_mut();
495                 ret
496         }
497 }
498 /// 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.
502 ///
503 /// Default value: 0.
504 #[no_mangle]
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;
507         *inner_val
508 }
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.
513 ///
514 /// Default value: 0.
515 #[no_mangle]
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;
518 }
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.
523 ///
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
526 /// this node.
527 ///
528 /// Default value: 1000.
529 ///
530 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
531 #[no_mangle]
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;
534         *inner_val
535 }
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.
540 ///
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
543 /// this node.
544 ///
545 /// Default value: 1000.
546 ///
547 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
548 #[no_mangle]
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;
551 }
552 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
553 /// the channel this config applies to.
554 ///
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.
559 ///
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).
565 ///
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.
569 ///
570 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
571 #[no_mangle]
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;
574         *inner_val
575 }
576 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
577 /// the channel this config applies to.
578 ///
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.
583 ///
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).
589 ///
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.
593 ///
594 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
595 #[no_mangle]
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;
598 }
599 /// Set to announce the channel publicly and notify all nodes that they can route via this
600 /// channel.
601 ///
602 /// This should only be set to true for nodes which expect to be online reliably.
603 ///
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.
606 ///
607 /// This cannot be changed after the initial channel handshake.
608 ///
609 /// Default value: false.
610 #[no_mangle]
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;
613         *inner_val
614 }
615 /// Set to announce the channel publicly and notify all nodes that they can route via this
616 /// channel.
617 ///
618 /// This should only be set to true for nodes which expect to be online reliably.
619 ///
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.
622 ///
623 /// This cannot be changed after the initial channel handshake.
624 ///
625 /// Default value: false.
626 #[no_mangle]
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;
629 }
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.
633 ///
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.
637 ///
638 /// This cannot be changed after a channel has been initialized.
639 ///
640 /// Default value: true.
641 #[no_mangle]
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;
644         *inner_val
645 }
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.
649 ///
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.
653 ///
654 /// This cannot be changed after a channel has been initialized.
655 ///
656 /// Default value: true.
657 #[no_mangle]
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;
660 }
661 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
662 /// small to claim on-chain.
663 ///
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.
669 ///
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.
674 ///
675 /// Default value: 5_000_000 msat.
676 #[no_mangle]
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;
679         *inner_val
680 }
681 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
682 /// small to claim on-chain.
683 ///
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.
689 ///
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.
694 ///
695 /// Default value: 5_000_000 msat.
696 #[no_mangle]
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;
699 }
700 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
701 /// `to_self_delay` to reclaim funds.
702 ///
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.
706 ///
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
712 /// funds.
713 ///
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.
717 ///
718 /// Default value: 1000 satoshis.
719 ///
720 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
721 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
722 #[no_mangle]
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;
725         *inner_val
726 }
727 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
728 /// `to_self_delay` to reclaim funds.
729 ///
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.
733 ///
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
739 /// funds.
740 ///
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.
744 ///
745 /// Default value: 1000 satoshis.
746 ///
747 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
748 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
749 #[no_mangle]
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;
752 }
753 /// Constructs a new ChannelConfig given each field
754 #[must_use]
755 #[no_mangle]
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,
765         }), is_owned: true }
766 }
767 impl Clone for ChannelConfig {
768         fn clone(&self) -> Self {
769                 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()) },
772                         is_owned: true,
773                 }
774         }
775 }
776 #[allow(unused)]
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
780 }
781 #[no_mangle]
782 /// Creates a copy of the ChannelConfig
783 pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
784         orig.clone()
785 }
786 /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
787 #[must_use]
788 #[no_mangle]
789 pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
790         ChannelConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
791 }
792 #[no_mangle]
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())
796 }
797 #[no_mangle]
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) })
800 }
801 #[no_mangle]
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() };
806         local_res
807 }
808
809 use lightning::util::config::UserConfig as nativeUserConfigImport;
810 pub(crate) type nativeUserConfig = nativeUserConfigImport;
811
812 /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
813 ///
814 /// Default::default() provides sane defaults for most configurations
815 /// (but currently with 0 relay fees!)
816 #[must_use]
817 #[repr(C)]
818 pub struct UserConfig {
819         /// A pointer to the opaque Rust object.
820
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.
825
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.
828         pub is_owned: bool,
829 }
830
831 impl Drop for UserConfig {
832         fn drop(&mut self) {
833                 if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) {
834                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
835                 }
836         }
837 }
838 /// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL.
839 #[no_mangle]
840 pub extern "C" fn UserConfig_free(this_obj: UserConfig) { }
841 #[allow(unused)]
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); }
845 }
846 #[allow(unused)]
847 impl UserConfig {
848         pub(crate) fn get_native_ref(&self) -> &'static nativeUserConfig {
849                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
850         }
851         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUserConfig {
852                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
853         }
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();
859                 ret
860         }
861 }
862 /// Channel config that we propose to our counterparty.
863 #[no_mangle]
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 }
867 }
868 /// Channel config that we propose to our counterparty.
869 #[no_mangle]
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()) };
872 }
873 /// Limits applied to our counterparty's proposed channel config settings.
874 #[no_mangle]
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 }
878 }
879 /// Limits applied to our counterparty's proposed channel config settings.
880 #[no_mangle]
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()) };
883 }
884 /// Channel config which affects behavior during channel lifetime.
885 #[no_mangle]
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 }
889 }
890 /// Channel config which affects behavior during channel lifetime.
891 #[no_mangle]
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()) };
894 }
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.
898 ///
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.
903 ///
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.
909 ///
910 /// Default value: false.
911 #[no_mangle]
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;
914         *inner_val
915 }
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.
919 ///
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.
924 ///
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.
930 ///
931 /// Default value: false.
932 #[no_mangle]
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;
935 }
936 /// If this is set to false, we do not accept inbound requests to open a new channel.
937 /// Default value: true.
938 #[no_mangle]
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;
941         *inner_val
942 }
943 /// If this is set to false, we do not accept inbound requests to open a new channel.
944 /// Default value: true.
945 #[no_mangle]
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;
948 }
949 /// Constructs a new UserConfig given each field
950 #[must_use]
951 #[no_mangle]
952 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) -> UserConfig {
953         UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig {
954                 own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) },
955                 peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) },
956                 channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) },
957                 accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
958                 accept_inbound_channels: accept_inbound_channels_arg,
959         }), is_owned: true }
960 }
961 impl Clone for UserConfig {
962         fn clone(&self) -> Self {
963                 Self {
964                         inner: if <*mut nativeUserConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
965                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
966                         is_owned: true,
967                 }
968         }
969 }
970 #[allow(unused)]
971 /// Used only if an object of this type is returned as a trait impl by a method
972 pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
973         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
974 }
975 #[no_mangle]
976 /// Creates a copy of the UserConfig
977 pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig {
978         orig.clone()
979 }
980 /// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
981 #[must_use]
982 #[no_mangle]
983 pub extern "C" fn UserConfig_default() -> UserConfig {
984         UserConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
985 }