Commit latest auto-generated C bindings based on 0.0.100
[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 std::str::FromStr;
13 use std::ffi::c_void;
14 use bitcoin::hashes::Hash;
15 use crate::c_types::*;
16
17
18 use lightning::util::config::ChannelHandshakeConfig as nativeChannelHandshakeConfigImport;
19 type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
20
21 /// Configuration we set when applicable.
22 ///
23 /// Default::default() provides sane defaults.
24 #[must_use]
25 #[repr(C)]
26 pub struct ChannelHandshakeConfig {
27         /// A pointer to the opaque Rust object.
28
29         /// Nearly everywhere, inner must be non-null, however in places where
30         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
31         pub inner: *mut nativeChannelHandshakeConfig,
32         /// Indicates that this is the only struct which contains the same pointer.
33
34         /// Rust functions which take ownership of an object provided via an argument require
35         /// this to be true and invalidate the object pointed to by inner.
36         pub is_owned: bool,
37 }
38
39 impl Drop for ChannelHandshakeConfig {
40         fn drop(&mut self) {
41                 if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) {
42                         let _ = unsafe { Box::from_raw(self.inner) };
43                 }
44         }
45 }
46 /// Frees any resources used by the ChannelHandshakeConfig, if is_owned is set and inner is non-NULL.
47 #[no_mangle]
48 pub extern "C" fn ChannelHandshakeConfig_free(this_obj: ChannelHandshakeConfig) { }
49 #[allow(unused)]
50 /// Used only if an object of this type is returned as a trait impl by a method
51 extern "C" fn ChannelHandshakeConfig_free_void(this_ptr: *mut c_void) {
52         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeConfig); }
53 }
54 #[allow(unused)]
55 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
56 impl ChannelHandshakeConfig {
57         pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeConfig {
58                 assert!(self.is_owned);
59                 let ret = self.inner;
60                 self.inner = std::ptr::null_mut();
61                 ret
62         }
63 }
64 /// Confirmations we will wait for before considering the channel locked in.
65 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
66 /// equivalent limit applied to outbound channels).
67 ///
68 /// Default value: 6.
69 #[no_mangle]
70 pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHandshakeConfig) -> u32 {
71         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth;
72         *inner_val
73 }
74 /// Confirmations we will wait for before considering the channel locked in.
75 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
76 /// equivalent limit applied to outbound channels).
77 ///
78 /// Default value: 6.
79 #[no_mangle]
80 pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
81         unsafe { &mut *this_ptr.inner }.minimum_depth = val;
82 }
83 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
84 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
85 /// transaction).
86 ///
87 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
88 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
89 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
90 /// possibly with time in between to RBF the spending transaction).
91 ///
92 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
93 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
94 /// our channel.
95 ///
96 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
97 /// can tweak config to ask for more security, not less.
98 #[no_mangle]
99 pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 {
100         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.our_to_self_delay;
101         *inner_val
102 }
103 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
104 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
105 /// transaction).
106 ///
107 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
108 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
109 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
110 /// possibly with time in between to RBF the spending transaction).
111 ///
112 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
113 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
114 /// our channel.
115 ///
116 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
117 /// can tweak config to ask for more security, not less.
118 #[no_mangle]
119 pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) {
120         unsafe { &mut *this_ptr.inner }.our_to_self_delay = val;
121 }
122 /// Set to the smallest value HTLC we will accept to process.
123 ///
124 /// This value is sent to our counterparty on channel-open and we close the channel any time
125 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
126 ///
127 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
128 /// by the protocol.
129 #[no_mangle]
130 pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 {
131         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.our_htlc_minimum_msat;
132         *inner_val
133 }
134 /// Set to the smallest value HTLC we will accept to process.
135 ///
136 /// This value is sent to our counterparty on channel-open and we close the channel any time
137 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
138 ///
139 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
140 /// by the protocol.
141 #[no_mangle]
142 pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) {
143         unsafe { &mut *this_ptr.inner }.our_htlc_minimum_msat = val;
144 }
145 /// Constructs a new ChannelHandshakeConfig given each field
146 #[must_use]
147 #[no_mangle]
148 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 {
149         ChannelHandshakeConfig { inner: Box::into_raw(Box::new(nativeChannelHandshakeConfig {
150                 minimum_depth: minimum_depth_arg,
151                 our_to_self_delay: our_to_self_delay_arg,
152                 our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
153         })), is_owned: true }
154 }
155 impl Clone for ChannelHandshakeConfig {
156         fn clone(&self) -> Self {
157                 Self {
158                         inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
159                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
160                         is_owned: true,
161                 }
162         }
163 }
164 #[allow(unused)]
165 /// Used only if an object of this type is returned as a trait impl by a method
166 pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
167         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
168 }
169 #[no_mangle]
170 /// Creates a copy of the ChannelHandshakeConfig
171 pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig {
172         orig.clone()
173 }
174 /// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
175 #[must_use]
176 #[no_mangle]
177 pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
178         ChannelHandshakeConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
179 }
180
181 use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
182 type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
183
184 /// Optional channel limits which are applied during channel creation.
185 ///
186 /// These limits are only applied to our counterparty's limits, not our own.
187 ///
188 /// Use 0/<type>::max_value() as appropriate to skip checking.
189 ///
190 /// Provides sane defaults for most configurations.
191 ///
192 /// Most additional limits are disabled except those with which specify a default in individual
193 /// field documentation. Note that this may result in barely-usable channels, but since they
194 /// are applied mostly only to incoming channels that's not much of a problem.
195 #[must_use]
196 #[repr(C)]
197 pub struct ChannelHandshakeLimits {
198         /// A pointer to the opaque Rust object.
199
200         /// Nearly everywhere, inner must be non-null, however in places where
201         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
202         pub inner: *mut nativeChannelHandshakeLimits,
203         /// Indicates that this is the only struct which contains the same pointer.
204
205         /// Rust functions which take ownership of an object provided via an argument require
206         /// this to be true and invalidate the object pointed to by inner.
207         pub is_owned: bool,
208 }
209
210 impl Drop for ChannelHandshakeLimits {
211         fn drop(&mut self) {
212                 if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) {
213                         let _ = unsafe { Box::from_raw(self.inner) };
214                 }
215         }
216 }
217 /// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL.
218 #[no_mangle]
219 pub extern "C" fn ChannelHandshakeLimits_free(this_obj: ChannelHandshakeLimits) { }
220 #[allow(unused)]
221 /// Used only if an object of this type is returned as a trait impl by a method
222 extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
223         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits); }
224 }
225 #[allow(unused)]
226 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
227 impl ChannelHandshakeLimits {
228         pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
229                 assert!(self.is_owned);
230                 let ret = self.inner;
231                 self.inner = std::ptr::null_mut();
232                 ret
233         }
234 }
235 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
236 /// only applies to inbound channels.
237 ///
238 /// Default value: 0.
239 #[no_mangle]
240 pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
241         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_funding_satoshis;
242         *inner_val
243 }
244 /// Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
245 /// only applies to inbound channels.
246 ///
247 /// Default value: 0.
248 #[no_mangle]
249 pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
250         unsafe { &mut *this_ptr.inner }.min_funding_satoshis = val;
251 }
252 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
253 /// you to limit the maximum minimum-size they can require.
254 ///
255 /// Default value: u64::max_value.
256 #[no_mangle]
257 pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
258         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_minimum_msat;
259         *inner_val
260 }
261 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
262 /// you to limit the maximum minimum-size they can require.
263 ///
264 /// Default value: u64::max_value.
265 #[no_mangle]
266 pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
267         unsafe { &mut *this_ptr.inner }.max_htlc_minimum_msat = val;
268 }
269 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
270 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
271 ///
272 /// Default value: 0.
273 #[no_mangle]
274 pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
275         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_max_htlc_value_in_flight_msat;
276         *inner_val
277 }
278 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
279 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
280 ///
281 /// Default value: 0.
282 #[no_mangle]
283 pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
284         unsafe { &mut *this_ptr.inner }.min_max_htlc_value_in_flight_msat = val;
285 }
286 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
287 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
288 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
289 ///
290 /// Default value: u64::max_value.
291 #[no_mangle]
292 pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
293         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_channel_reserve_satoshis;
294         *inner_val
295 }
296 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
297 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
298 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
299 ///
300 /// Default value: u64::max_value.
301 #[no_mangle]
302 pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
303         unsafe { &mut *this_ptr.inner }.max_channel_reserve_satoshis = val;
304 }
305 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
306 /// time. This allows you to set a minimum such value.
307 ///
308 /// Default value: 0.
309 #[no_mangle]
310 pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 {
311         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.min_max_accepted_htlcs;
312         *inner_val
313 }
314 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
315 /// time. This allows you to set a minimum such value.
316 ///
317 /// Default value: 0.
318 #[no_mangle]
319 pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
320         unsafe { &mut *this_ptr.inner }.min_max_accepted_htlcs = val;
321 }
322 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
323 /// certain number of blocks, specified by the node which is not the funder (as the funder can
324 /// assume they aren't going to double-spend themselves).
325 /// This config allows you to set a limit on the maximum amount of time to wait.
326 ///
327 /// Default value: 144, or roughly one day and only applies to outbound channels.
328 #[no_mangle]
329 pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 {
330         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_minimum_depth;
331         *inner_val
332 }
333 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
334 /// certain number of blocks, specified by the node which is not the funder (as the funder can
335 /// assume they aren't going to double-spend themselves).
336 /// This config allows you to set a limit on the maximum amount of time to wait.
337 ///
338 /// Default value: 144, or roughly one day and only applies to outbound channels.
339 #[no_mangle]
340 pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) {
341         unsafe { &mut *this_ptr.inner }.max_minimum_depth = val;
342 }
343 /// Set to force an incoming channel to match our announced channel preference in
344 /// [`ChannelConfig::announced_channel`].
345 ///
346 /// For a node which is not online reliably, this should be set to true and
347 /// [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
348 /// channels will ever be opened.
349 ///
350 /// Default value: true.
351 #[no_mangle]
352 pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool {
353         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.force_announced_channel_preference;
354         *inner_val
355 }
356 /// Set to force an incoming channel to match our announced channel preference in
357 /// [`ChannelConfig::announced_channel`].
358 ///
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.
362 ///
363 /// Default value: true.
364 #[no_mangle]
365 pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
366         unsafe { &mut *this_ptr.inner }.force_announced_channel_preference = val;
367 }
368 /// Set to the amount of time we're willing to wait to claim money back to us.
369 ///
370 /// Not checking this value would be a security issue, as our peer would be able to set it to
371 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
372 ///
373 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
374 /// reduce the loss of having useless locked funds (if your peer accepts)
375 #[no_mangle]
376 pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 {
377         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.their_to_self_delay;
378         *inner_val
379 }
380 /// Set to the amount of time we're willing to wait to claim money back to us.
381 ///
382 /// Not checking this value would be a security issue, as our peer would be able to set it to
383 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
384 ///
385 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
386 /// reduce the loss of having useless locked funds (if your peer accepts)
387 #[no_mangle]
388 pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
389         unsafe { &mut *this_ptr.inner }.their_to_self_delay = val;
390 }
391 /// Constructs a new ChannelHandshakeLimits given each field
392 #[must_use]
393 #[no_mangle]
394 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 {
395         ChannelHandshakeLimits { inner: Box::into_raw(Box::new(nativeChannelHandshakeLimits {
396                 min_funding_satoshis: min_funding_satoshis_arg,
397                 max_htlc_minimum_msat: max_htlc_minimum_msat_arg,
398                 min_max_htlc_value_in_flight_msat: min_max_htlc_value_in_flight_msat_arg,
399                 max_channel_reserve_satoshis: max_channel_reserve_satoshis_arg,
400                 min_max_accepted_htlcs: min_max_accepted_htlcs_arg,
401                 max_minimum_depth: max_minimum_depth_arg,
402                 force_announced_channel_preference: force_announced_channel_preference_arg,
403                 their_to_self_delay: their_to_self_delay_arg,
404         })), is_owned: true }
405 }
406 impl Clone for ChannelHandshakeLimits {
407         fn clone(&self) -> Self {
408                 Self {
409                         inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { std::ptr::null_mut() } else {
410                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
411                         is_owned: true,
412                 }
413         }
414 }
415 #[allow(unused)]
416 /// Used only if an object of this type is returned as a trait impl by a method
417 pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
418         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
419 }
420 #[no_mangle]
421 /// Creates a copy of the ChannelHandshakeLimits
422 pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits {
423         orig.clone()
424 }
425 /// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
426 #[must_use]
427 #[no_mangle]
428 pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
429         ChannelHandshakeLimits { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
430 }
431
432 use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
433 type nativeChannelConfig = nativeChannelConfigImport;
434
435 /// Options which apply on a per-channel basis and may change at runtime or based on negotiation
436 /// with our counterparty.
437 #[must_use]
438 #[repr(C)]
439 pub struct ChannelConfig {
440         /// A pointer to the opaque Rust object.
441
442         /// Nearly everywhere, inner must be non-null, however in places where
443         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
444         pub inner: *mut nativeChannelConfig,
445         /// Indicates that this is the only struct which contains the same pointer.
446
447         /// Rust functions which take ownership of an object provided via an argument require
448         /// this to be true and invalidate the object pointed to by inner.
449         pub is_owned: bool,
450 }
451
452 impl Drop for ChannelConfig {
453         fn drop(&mut self) {
454                 if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) {
455                         let _ = unsafe { Box::from_raw(self.inner) };
456                 }
457         }
458 }
459 /// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL.
460 #[no_mangle]
461 pub extern "C" fn ChannelConfig_free(this_obj: ChannelConfig) { }
462 #[allow(unused)]
463 /// Used only if an object of this type is returned as a trait impl by a method
464 extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
465         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelConfig); }
466 }
467 #[allow(unused)]
468 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
469 impl ChannelConfig {
470         pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
471                 assert!(self.is_owned);
472                 let ret = self.inner;
473                 self.inner = std::ptr::null_mut();
474                 ret
475         }
476 }
477 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
478 /// over the channel.
479 /// This may be allowed to change at runtime in a later update, however doing so must result in
480 /// update messages sent to notify all nodes of our updated relay fee.
481 ///
482 /// Default value: 0.
483 #[no_mangle]
484 pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 {
485         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.forwarding_fee_proportional_millionths;
486         *inner_val
487 }
488 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
489 /// over the channel.
490 /// This may be allowed to change at runtime in a later update, however doing so must result in
491 /// update messages sent to notify all nodes of our updated relay fee.
492 ///
493 /// Default value: 0.
494 #[no_mangle]
495 pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) {
496         unsafe { &mut *this_ptr.inner }.forwarding_fee_proportional_millionths = val;
497 }
498 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
499 /// excess of [`forwarding_fee_proportional_millionths`].
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 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
504 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
505 /// this node.
506 ///
507 /// Default value: 1000.
508 ///
509 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
510 #[no_mangle]
511 pub extern "C" fn ChannelConfig_get_forwarding_fee_base_msat(this_ptr: &ChannelConfig) -> u32 {
512         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.forwarding_fee_base_msat;
513         *inner_val
514 }
515 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
516 /// excess of [`forwarding_fee_proportional_millionths`].
517 /// This may be allowed to change at runtime in a later update, however doing so must result in
518 /// update messages sent to notify all nodes of our updated relay fee.
519 ///
520 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
521 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
522 /// this node.
523 ///
524 /// Default value: 1000.
525 ///
526 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
527 #[no_mangle]
528 pub extern "C" fn ChannelConfig_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfig, mut val: u32) {
529         unsafe { &mut *this_ptr.inner }.forwarding_fee_base_msat = val;
530 }
531 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
532 /// the channel this config applies to.
533 ///
534 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
535 /// HTLC balance when a channel appears on-chain whereas
536 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
537 /// (non-HTLC-encumbered) balance.
538 ///
539 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
540 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
541 /// commitment transaction at least once per this many blocks (minus some margin to allow us
542 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
543 /// the spending transaction).
544 ///
545 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
546 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
547 ///                [`MIN_CLTV_EXPIRY_DELTA`] instead.
548 ///
549 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
550 #[no_mangle]
551 pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 {
552         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta;
553         *inner_val
554 }
555 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
556 /// the channel this config applies to.
557 ///
558 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
559 /// HTLC balance when a channel appears on-chain whereas
560 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
561 /// (non-HTLC-encumbered) balance.
562 ///
563 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
564 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
565 /// commitment transaction at least once per this many blocks (minus some margin to allow us
566 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
567 /// the spending transaction).
568 ///
569 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
570 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
571 ///                [`MIN_CLTV_EXPIRY_DELTA`] instead.
572 ///
573 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
574 #[no_mangle]
575 pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) {
576         unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
577 }
578 /// Set to announce the channel publicly and notify all nodes that they can route via this
579 /// channel.
580 ///
581 /// This should only be set to true for nodes which expect to be online reliably.
582 ///
583 /// As the node which funds a channel picks this value this will only apply for new outbound
584 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
585 ///
586 /// This cannot be changed after the initial channel handshake.
587 ///
588 /// Default value: false.
589 #[no_mangle]
590 pub extern "C" fn ChannelConfig_get_announced_channel(this_ptr: &ChannelConfig) -> bool {
591         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.announced_channel;
592         *inner_val
593 }
594 /// Set to announce the channel publicly and notify all nodes that they can route via this
595 /// channel.
596 ///
597 /// This should only be set to true for nodes which expect to be online reliably.
598 ///
599 /// As the node which funds a channel picks this value this will only apply for new outbound
600 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
601 ///
602 /// This cannot be changed after the initial channel handshake.
603 ///
604 /// Default value: false.
605 #[no_mangle]
606 pub extern "C" fn ChannelConfig_set_announced_channel(this_ptr: &mut ChannelConfig, mut val: bool) {
607         unsafe { &mut *this_ptr.inner }.announced_channel = val;
608 }
609 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
610 /// supports it, they will then enforce the mutual-close output to us matches what we provided
611 /// at intialization, preventing us from closing to an alternate pubkey.
612 ///
613 /// This is set to true by default to provide a slight increase in security, though ultimately
614 /// any attacker who is able to take control of a channel can just as easily send the funds via
615 /// lightning payments, so we never require that our counterparties support this option.
616 ///
617 /// This cannot be changed after a channel has been initialized.
618 ///
619 /// Default value: true.
620 #[no_mangle]
621 pub extern "C" fn ChannelConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelConfig) -> bool {
622         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commit_upfront_shutdown_pubkey;
623         *inner_val
624 }
625 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
626 /// supports it, they will then enforce the mutual-close output to us matches what we provided
627 /// at intialization, preventing us from closing to an alternate pubkey.
628 ///
629 /// This is set to true by default to provide a slight increase in security, though ultimately
630 /// any attacker who is able to take control of a channel can just as easily send the funds via
631 /// lightning payments, so we never require that our counterparties support this option.
632 ///
633 /// This cannot be changed after a channel has been initialized.
634 ///
635 /// Default value: true.
636 #[no_mangle]
637 pub extern "C" fn ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelConfig, mut val: bool) {
638         unsafe { &mut *this_ptr.inner }.commit_upfront_shutdown_pubkey = val;
639 }
640 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
641 /// small to claim on-chain.
642 ///
643 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
644 /// not be claimable on-chain, instead being turned into additional miner fees if either
645 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
646 /// to such payments may be sustantial if there are many dust HTLCs present when the
647 /// channel is force-closed.
648 ///
649 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
650 /// exposure across all three types per-channel. Setting this too low may prevent the
651 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
652 /// important to prevent stealing of dust HTLCs by miners.
653 ///
654 /// Default value: 5_000_000 msat.
655 #[no_mangle]
656 pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfig) -> u64 {
657         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_dust_htlc_exposure_msat;
658         *inner_val
659 }
660 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
661 /// small to claim on-chain.
662 ///
663 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
664 /// not be claimable on-chain, instead being turned into additional miner fees if either
665 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
666 /// to such payments may be sustantial if there are many dust HTLCs present when the
667 /// channel is force-closed.
668 ///
669 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
670 /// exposure across all three types per-channel. Setting this too low may prevent the
671 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
672 /// important to prevent stealing of dust HTLCs by miners.
673 ///
674 /// Default value: 5_000_000 msat.
675 #[no_mangle]
676 pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfig, mut val: u64) {
677         unsafe { &mut *this_ptr.inner }.max_dust_htlc_exposure_msat = val;
678 }
679 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
680 /// `to_self_delay` to reclaim funds.
681 ///
682 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
683 /// closing transaction which both sides find acceptable, ultimately paid by the channel
684 /// funder/initiator.
685 ///
686 /// When we are the funder, because we have to pay the channel closing fee, we bound the
687 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
688 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
689 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
690 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
691 /// funds.
692 ///
693 /// When we are not the funder, we require the closing transaction fee pay at least our
694 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
695 /// Thus, this value is ignored when we are not the funder.
696 ///
697 /// Default value: 1000 satoshis.
698 ///
699 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
700 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
701 #[no_mangle]
702 pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfig) -> u64 {
703         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.force_close_avoidance_max_fee_satoshis;
704         *inner_val
705 }
706 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
707 /// `to_self_delay` to reclaim funds.
708 ///
709 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
710 /// closing transaction which both sides find acceptable, ultimately paid by the channel
711 /// funder/initiator.
712 ///
713 /// When we are the funder, because we have to pay the channel closing fee, we bound the
714 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
715 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
716 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
717 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
718 /// funds.
719 ///
720 /// When we are not the funder, we require the closing transaction fee pay at least our
721 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
722 /// Thus, this value is ignored when we are not the funder.
723 ///
724 /// Default value: 1000 satoshis.
725 ///
726 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
727 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
728 #[no_mangle]
729 pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfig, mut val: u64) {
730         unsafe { &mut *this_ptr.inner }.force_close_avoidance_max_fee_satoshis = val;
731 }
732 /// Constructs a new ChannelConfig given each field
733 #[must_use]
734 #[no_mangle]
735 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 {
736         ChannelConfig { inner: Box::into_raw(Box::new(nativeChannelConfig {
737                 forwarding_fee_proportional_millionths: forwarding_fee_proportional_millionths_arg,
738                 forwarding_fee_base_msat: forwarding_fee_base_msat_arg,
739                 cltv_expiry_delta: cltv_expiry_delta_arg,
740                 announced_channel: announced_channel_arg,
741                 commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
742                 max_dust_htlc_exposure_msat: max_dust_htlc_exposure_msat_arg,
743                 force_close_avoidance_max_fee_satoshis: force_close_avoidance_max_fee_satoshis_arg,
744         })), is_owned: true }
745 }
746 impl Clone for ChannelConfig {
747         fn clone(&self) -> Self {
748                 Self {
749                         inner: if <*mut nativeChannelConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
750                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
751                         is_owned: true,
752                 }
753         }
754 }
755 #[allow(unused)]
756 /// Used only if an object of this type is returned as a trait impl by a method
757 pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
758         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
759 }
760 #[no_mangle]
761 /// Creates a copy of the ChannelConfig
762 pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
763         orig.clone()
764 }
765 /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
766 #[must_use]
767 #[no_mangle]
768 pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
769         ChannelConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
770 }
771 #[no_mangle]
772 /// Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
773 pub extern "C" fn ChannelConfig_write(obj: &ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
774         crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })
775 }
776 #[no_mangle]
777 pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
778         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) })
779 }
780 #[no_mangle]
781 /// Read a ChannelConfig from a byte array, created by ChannelConfig_write
782 pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
783         let res = crate::c_types::deserialize_obj(ser);
784         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::ChannelConfig { inner: Box::into_raw(Box::new(o)), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
785         local_res
786 }
787
788 use lightning::util::config::UserConfig as nativeUserConfigImport;
789 type nativeUserConfig = nativeUserConfigImport;
790
791 /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
792 ///
793 /// Default::default() provides sane defaults for most configurations
794 /// (but currently with 0 relay fees!)
795 #[must_use]
796 #[repr(C)]
797 pub struct UserConfig {
798         /// A pointer to the opaque Rust object.
799
800         /// Nearly everywhere, inner must be non-null, however in places where
801         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
802         pub inner: *mut nativeUserConfig,
803         /// Indicates that this is the only struct which contains the same pointer.
804
805         /// Rust functions which take ownership of an object provided via an argument require
806         /// this to be true and invalidate the object pointed to by inner.
807         pub is_owned: bool,
808 }
809
810 impl Drop for UserConfig {
811         fn drop(&mut self) {
812                 if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) {
813                         let _ = unsafe { Box::from_raw(self.inner) };
814                 }
815         }
816 }
817 /// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL.
818 #[no_mangle]
819 pub extern "C" fn UserConfig_free(this_obj: UserConfig) { }
820 #[allow(unused)]
821 /// Used only if an object of this type is returned as a trait impl by a method
822 extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
823         unsafe { let _ = Box::from_raw(this_ptr as *mut nativeUserConfig); }
824 }
825 #[allow(unused)]
826 /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
827 impl UserConfig {
828         pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
829                 assert!(self.is_owned);
830                 let ret = self.inner;
831                 self.inner = std::ptr::null_mut();
832                 ret
833         }
834 }
835 /// Channel config that we propose to our counterparty.
836 #[no_mangle]
837 pub extern "C" fn UserConfig_get_own_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig {
838         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.own_channel_config;
839         crate::lightning::util::config::ChannelHandshakeConfig { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
840 }
841 /// Channel config that we propose to our counterparty.
842 #[no_mangle]
843 pub extern "C" fn UserConfig_set_own_channel_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeConfig) {
844         unsafe { &mut *this_ptr.inner }.own_channel_config = *unsafe { Box::from_raw(val.take_inner()) };
845 }
846 /// Limits applied to our counterparty's proposed channel config settings.
847 #[no_mangle]
848 pub extern "C" fn UserConfig_get_peer_channel_config_limits(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeLimits {
849         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.peer_channel_config_limits;
850         crate::lightning::util::config::ChannelHandshakeLimits { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
851 }
852 /// Limits applied to our counterparty's proposed channel config settings.
853 #[no_mangle]
854 pub extern "C" fn UserConfig_set_peer_channel_config_limits(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeLimits) {
855         unsafe { &mut *this_ptr.inner }.peer_channel_config_limits = *unsafe { Box::from_raw(val.take_inner()) };
856 }
857 /// Channel config which affects behavior during channel lifetime.
858 #[no_mangle]
859 pub extern "C" fn UserConfig_get_channel_options(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig {
860         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_options;
861         crate::lightning::util::config::ChannelConfig { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false }
862 }
863 /// Channel config which affects behavior during channel lifetime.
864 #[no_mangle]
865 pub extern "C" fn UserConfig_set_channel_options(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelConfig) {
866         unsafe { &mut *this_ptr.inner }.channel_options = *unsafe { Box::from_raw(val.take_inner()) };
867 }
868 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
869 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
870 /// node which is not online reliably.
871 ///
872 /// For nodes which are not online reliably, you should set all channels to *not* be announced
873 /// (using [`ChannelConfig::announced_channel`] and
874 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
875 /// ensure you are not exposed to any forwarding risk.
876 ///
877 /// Note that because you cannot change a channel's announced state after creation, there is no
878 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
879 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
880 /// all your channels and open new ones. For privacy, you should also change your node_id
881 /// (swapping all private and public key material for new ones) at that time.
882 ///
883 /// Default value: false.
884 #[no_mangle]
885 pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &UserConfig) -> bool {
886         let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.accept_forwards_to_priv_channels;
887         *inner_val
888 }
889 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
890 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
891 /// node which is not online reliably.
892 ///
893 /// For nodes which are not online reliably, you should set all channels to *not* be announced
894 /// (using [`ChannelConfig::announced_channel`] and
895 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
896 /// ensure you are not exposed to any forwarding risk.
897 ///
898 /// Note that because you cannot change a channel's announced state after creation, there is no
899 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
900 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
901 /// all your channels and open new ones. For privacy, you should also change your node_id
902 /// (swapping all private and public key material for new ones) at that time.
903 ///
904 /// Default value: false.
905 #[no_mangle]
906 pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) {
907         unsafe { &mut *this_ptr.inner }.accept_forwards_to_priv_channels = val;
908 }
909 /// Constructs a new UserConfig given each field
910 #[must_use]
911 #[no_mangle]
912 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 {
913         UserConfig { inner: Box::into_raw(Box::new(nativeUserConfig {
914                 own_channel_config: *unsafe { Box::from_raw(own_channel_config_arg.take_inner()) },
915                 peer_channel_config_limits: *unsafe { Box::from_raw(peer_channel_config_limits_arg.take_inner()) },
916                 channel_options: *unsafe { Box::from_raw(channel_options_arg.take_inner()) },
917                 accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
918         })), is_owned: true }
919 }
920 impl Clone for UserConfig {
921         fn clone(&self) -> Self {
922                 Self {
923                         inner: if <*mut nativeUserConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
924                                 Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) },
925                         is_owned: true,
926                 }
927         }
928 }
929 #[allow(unused)]
930 /// Used only if an object of this type is returned as a trait impl by a method
931 pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
932         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
933 }
934 #[no_mangle]
935 /// Creates a copy of the UserConfig
936 pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig {
937         orig.clone()
938 }
939 /// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
940 #[must_use]
941 #[no_mangle]
942 pub extern "C" fn UserConfig_default() -> UserConfig {
943         UserConfig { inner: Box::into_raw(Box::new(Default::default())), is_owned: true }
944 }