Update auto-generated bindings for LDK 0.0.115
[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         let _ = unsafe { 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 /// A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment
78 /// transaction before operation. If you wish to accept channels with zero confirmations, see
79 /// [`UserConfig::manually_accept_inbound_channels`] and
80 /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`].
81 ///
82 /// Default value: 6.
83 ///
84 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
85 /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf
86 #[no_mangle]
87 pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHandshakeConfig) -> u32 {
88         let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth;
89         *inner_val
90 }
91 /// Confirmations we will wait for before considering the channel locked in.
92 /// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
93 /// equivalent limit applied to outbound channels).
94 ///
95 /// A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment
96 /// transaction before operation. If you wish to accept channels with zero confirmations, see
97 /// [`UserConfig::manually_accept_inbound_channels`] and
98 /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`].
99 ///
100 /// Default value: 6.
101 ///
102 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
103 /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf
104 #[no_mangle]
105 pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
106         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val;
107 }
108 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
109 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
110 /// transaction).
111 ///
112 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
113 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
114 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
115 /// possibly with time in between to RBF the spending transaction).
116 ///
117 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
118 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
119 /// our channel.
120 ///
121 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
122 /// can tweak config to ask for more security, not less.
123 #[no_mangle]
124 pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 {
125         let mut inner_val = &mut this_ptr.get_native_mut_ref().our_to_self_delay;
126         *inner_val
127 }
128 /// Set to the number of blocks we require our counterparty to wait to claim their money (ie
129 /// the number of blocks we have to punish our counterparty if they broadcast a revoked
130 /// transaction).
131 ///
132 /// This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
133 /// be online to check for revoked transactions on-chain at least once every our_to_self_delay
134 /// blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
135 /// possibly with time in between to RBF the spending transaction).
136 ///
137 /// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
138 /// case of an honest unilateral channel close, which implicitly decrease the economic value of
139 /// our channel.
140 ///
141 /// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
142 /// can tweak config to ask for more security, not less.
143 #[no_mangle]
144 pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) {
145         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_to_self_delay = val;
146 }
147 /// Set to the smallest value HTLC we will accept to process.
148 ///
149 /// This value is sent to our counterparty on channel-open and we close the channel any time
150 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
151 ///
152 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
153 /// by the protocol.
154 #[no_mangle]
155 pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 {
156         let mut inner_val = &mut this_ptr.get_native_mut_ref().our_htlc_minimum_msat;
157         *inner_val
158 }
159 /// Set to the smallest value HTLC we will accept to process.
160 ///
161 /// This value is sent to our counterparty on channel-open and we close the channel any time
162 /// our counterparty misbehaves by sending us an HTLC with a value smaller than this.
163 ///
164 /// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
165 /// by the protocol.
166 #[no_mangle]
167 pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) {
168         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_htlc_minimum_msat = val;
169 }
170 /// Sets the percentage of the channel value we will cap the total value of outstanding inbound
171 /// HTLCs to.
172 ///
173 /// This can be set to a value between 1-100, where the value corresponds to the percent of the
174 /// channel value in whole percentages.
175 ///
176 /// Note that:
177 /// * If configured to another value than the default value 10, any new channels created with
178 /// the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the
179 /// `ChannelManager`.
180 ///
181 /// * This caps the total value for inbound HTLCs in-flight only, and there's currently
182 /// no way to configure the cap for the total value of outbound HTLCs in-flight.
183 ///
184 /// * The requirements for your node being online to ensure the safety of HTLC-encumbered funds
185 /// are different from the non-HTLC-encumbered funds. This makes this an important knob to
186 /// restrict exposure to loss due to being offline for too long.
187 /// See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`]
188 /// for more information.
189 ///
190 /// Default value: 10.
191 /// Minimum value: 1, any values less than 1 will be treated as 1 instead.
192 /// Maximum value: 100, any values larger than 100 will be treated as 100 instead.
193 #[no_mangle]
194 pub extern "C" fn ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(this_ptr: &ChannelHandshakeConfig) -> u8 {
195         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_inbound_htlc_value_in_flight_percent_of_channel;
196         *inner_val
197 }
198 /// Sets the percentage of the channel value we will cap the total value of outstanding inbound
199 /// HTLCs to.
200 ///
201 /// This can be set to a value between 1-100, where the value corresponds to the percent of the
202 /// channel value in whole percentages.
203 ///
204 /// Note that:
205 /// * If configured to another value than the default value 10, any new channels created with
206 /// the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the
207 /// `ChannelManager`.
208 ///
209 /// * This caps the total value for inbound HTLCs in-flight only, and there's currently
210 /// no way to configure the cap for the total value of outbound HTLCs in-flight.
211 ///
212 /// * The requirements for your node being online to ensure the safety of HTLC-encumbered funds
213 /// are different from the non-HTLC-encumbered funds. This makes this an important knob to
214 /// restrict exposure to loss due to being offline for too long.
215 /// See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`]
216 /// for more information.
217 ///
218 /// Default value: 10.
219 /// Minimum value: 1, any values less than 1 will be treated as 1 instead.
220 /// Maximum value: 100, any values larger than 100 will be treated as 100 instead.
221 #[no_mangle]
222 pub extern "C" fn ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(this_ptr: &mut ChannelHandshakeConfig, mut val: u8) {
223         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_inbound_htlc_value_in_flight_percent_of_channel = val;
224 }
225 /// If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
226 /// BOLTs) option for outbound private channels. This provides better privacy by not including
227 /// our real on-chain channel UTXO in each invoice and requiring that our counterparty only
228 /// relay HTLCs to us using the channel's SCID alias.
229 ///
230 /// If this option is set, channels may be created that will not be readable by LDK versions
231 /// prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
232 /// [`DecodeError::InvalidValue`].
233 ///
234 /// Note that setting this to true does *not* prevent us from opening channels with
235 /// counterparties that do not support the `scid_alias` option; we will simply fall back to a
236 /// private channel without that option.
237 ///
238 /// Ignored if the channel is negotiated to be announced, see
239 /// [`ChannelHandshakeConfig::announced_channel`] and
240 /// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
241 ///
242 /// Default value: false. This value is likely to change to true in the future.
243 ///
244 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
245 /// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
246 #[no_mangle]
247 pub extern "C" fn ChannelHandshakeConfig_get_negotiate_scid_privacy(this_ptr: &ChannelHandshakeConfig) -> bool {
248         let mut inner_val = &mut this_ptr.get_native_mut_ref().negotiate_scid_privacy;
249         *inner_val
250 }
251 /// If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
252 /// BOLTs) option for outbound private channels. This provides better privacy by not including
253 /// our real on-chain channel UTXO in each invoice and requiring that our counterparty only
254 /// relay HTLCs to us using the channel's SCID alias.
255 ///
256 /// If this option is set, channels may be created that will not be readable by LDK versions
257 /// prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
258 /// [`DecodeError::InvalidValue`].
259 ///
260 /// Note that setting this to true does *not* prevent us from opening channels with
261 /// counterparties that do not support the `scid_alias` option; we will simply fall back to a
262 /// private channel without that option.
263 ///
264 /// Ignored if the channel is negotiated to be announced, see
265 /// [`ChannelHandshakeConfig::announced_channel`] and
266 /// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
267 ///
268 /// Default value: false. This value is likely to change to true in the future.
269 ///
270 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
271 /// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
272 #[no_mangle]
273 pub extern "C" fn ChannelHandshakeConfig_set_negotiate_scid_privacy(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) {
274         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.negotiate_scid_privacy = val;
275 }
276 /// Set to announce the channel publicly and notify all nodes that they can route via this
277 /// channel.
278 ///
279 /// This should only be set to true for nodes which expect to be online reliably.
280 ///
281 /// As the node which funds a channel picks this value this will only apply for new outbound
282 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
283 ///
284 /// Default value: false.
285 #[no_mangle]
286 pub extern "C" fn ChannelHandshakeConfig_get_announced_channel(this_ptr: &ChannelHandshakeConfig) -> bool {
287         let mut inner_val = &mut this_ptr.get_native_mut_ref().announced_channel;
288         *inner_val
289 }
290 /// Set to announce the channel publicly and notify all nodes that they can route via this
291 /// channel.
292 ///
293 /// This should only be set to true for nodes which expect to be online reliably.
294 ///
295 /// As the node which funds a channel picks this value this will only apply for new outbound
296 /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
297 ///
298 /// Default value: false.
299 #[no_mangle]
300 pub extern "C" fn ChannelHandshakeConfig_set_announced_channel(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) {
301         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announced_channel = val;
302 }
303 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
304 /// supports it, they will then enforce the mutual-close output to us matches what we provided
305 /// at intialization, preventing us from closing to an alternate pubkey.
306 ///
307 /// This is set to true by default to provide a slight increase in security, though ultimately
308 /// any attacker who is able to take control of a channel can just as easily send the funds via
309 /// lightning payments, so we never require that our counterparties support this option.
310 ///
311 /// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`].
312 ///
313 /// Default value: true.
314 ///
315 /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey
316 #[no_mangle]
317 pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this_ptr: &ChannelHandshakeConfig) -> bool {
318         let mut inner_val = &mut this_ptr.get_native_mut_ref().commit_upfront_shutdown_pubkey;
319         *inner_val
320 }
321 /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
322 /// supports it, they will then enforce the mutual-close output to us matches what we provided
323 /// at intialization, preventing us from closing to an alternate pubkey.
324 ///
325 /// This is set to true by default to provide a slight increase in security, though ultimately
326 /// any attacker who is able to take control of a channel can just as easily send the funds via
327 /// lightning payments, so we never require that our counterparties support this option.
328 ///
329 /// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`].
330 ///
331 /// Default value: true.
332 ///
333 /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey
334 #[no_mangle]
335 pub extern "C" fn ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) {
336         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commit_upfront_shutdown_pubkey = val;
337 }
338 /// The Proportion of the channel value to configure as counterparty's channel reserve,
339 /// i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
340 ///
341 /// `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
342 /// on their side, at all times.
343 /// This ensures that if our counterparty broadcasts a revoked state, we can punish them by
344 /// claiming at least this value on chain.
345 ///
346 /// Channel reserve values greater than 30% could be considered highly unreasonable, since that
347 /// amount can never be used for payments.
348 /// Also, if our selected channel reserve for counterparty and counterparty's selected
349 /// channel reserve for us sum up to equal or greater than channel value, channel negotiations
350 /// will fail.
351 ///
352 /// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
353 /// other than the default value.
354 ///
355 /// Default value: 1% of channel value, i.e., configured as 10,000 millionths.
356 /// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
357 ///                as 1000 sats instead, which is a safe implementation-specific lower bound.
358 /// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
359 ///                instead, although channel negotiations will fail in that case.
360 #[no_mangle]
361 pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this_ptr: &ChannelHandshakeConfig) -> u32 {
362         let mut inner_val = &mut this_ptr.get_native_mut_ref().their_channel_reserve_proportional_millionths;
363         *inner_val
364 }
365 /// The Proportion of the channel value to configure as counterparty's channel reserve,
366 /// i.e., `their_channel_reserve_satoshis` for both outbound and inbound channels.
367 ///
368 /// `their_channel_reserve_satoshis` is the minimum balance that the other node has to maintain
369 /// on their side, at all times.
370 /// This ensures that if our counterparty broadcasts a revoked state, we can punish them by
371 /// claiming at least this value on chain.
372 ///
373 /// Channel reserve values greater than 30% could be considered highly unreasonable, since that
374 /// amount can never be used for payments.
375 /// Also, if our selected channel reserve for counterparty and counterparty's selected
376 /// channel reserve for us sum up to equal or greater than channel value, channel negotiations
377 /// will fail.
378 ///
379 /// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve
380 /// other than the default value.
381 ///
382 /// Default value: 1% of channel value, i.e., configured as 10,000 millionths.
383 /// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated
384 ///                as 1000 sats instead, which is a safe implementation-specific lower bound.
385 /// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%)
386 ///                instead, although channel negotiations will fail in that case.
387 #[no_mangle]
388 pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) {
389         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_channel_reserve_proportional_millionths = val;
390 }
391 /// The maximum number of HTLCs in-flight from our counterparty towards us at the same time.
392 ///
393 /// Increasing the value can help improve liquidity and stability in
394 /// routing at the cost of higher long term disk / DB usage.
395 ///
396 /// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration
397 /// other than the default value.
398 ///
399 /// Default value: 50
400 /// Maximum value: 483, any values larger will be treated as 483.
401 ///                     This is the BOLT #2 spec limit on `max_accepted_htlcs`.
402 #[no_mangle]
403 pub extern "C" fn ChannelHandshakeConfig_get_our_max_accepted_htlcs(this_ptr: &ChannelHandshakeConfig) -> u16 {
404         let mut inner_val = &mut this_ptr.get_native_mut_ref().our_max_accepted_htlcs;
405         *inner_val
406 }
407 /// The maximum number of HTLCs in-flight from our counterparty towards us at the same time.
408 ///
409 /// Increasing the value can help improve liquidity and stability in
410 /// routing at the cost of higher long term disk / DB usage.
411 ///
412 /// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration
413 /// other than the default value.
414 ///
415 /// Default value: 50
416 /// Maximum value: 483, any values larger will be treated as 483.
417 ///                     This is the BOLT #2 spec limit on `max_accepted_htlcs`.
418 #[no_mangle]
419 pub extern "C" fn ChannelHandshakeConfig_set_our_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) {
420         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_max_accepted_htlcs = val;
421 }
422 /// Constructs a new ChannelHandshakeConfig given each field
423 #[must_use]
424 #[no_mangle]
425 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, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig {
426         ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig {
427                 minimum_depth: minimum_depth_arg,
428                 our_to_self_delay: our_to_self_delay_arg,
429                 our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
430                 max_inbound_htlc_value_in_flight_percent_of_channel: max_inbound_htlc_value_in_flight_percent_of_channel_arg,
431                 negotiate_scid_privacy: negotiate_scid_privacy_arg,
432                 announced_channel: announced_channel_arg,
433                 commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
434                 their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg,
435                 our_max_accepted_htlcs: our_max_accepted_htlcs_arg,
436         }), is_owned: true }
437 }
438 impl Clone for ChannelHandshakeConfig {
439         fn clone(&self) -> Self {
440                 Self {
441                         inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
442                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
443                         is_owned: true,
444                 }
445         }
446 }
447 #[allow(unused)]
448 /// Used only if an object of this type is returned as a trait impl by a method
449 pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
450         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
451 }
452 #[no_mangle]
453 /// Creates a copy of the ChannelHandshakeConfig
454 pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig {
455         orig.clone()
456 }
457 /// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
458 #[must_use]
459 #[no_mangle]
460 pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
461         ChannelHandshakeConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
462 }
463
464 use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
465 pub(crate) type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
466
467 /// Optional channel limits which are applied during channel creation.
468 ///
469 /// These limits are only applied to our counterparty's limits, not our own.
470 ///
471 /// Use 0/`<type>::max_value()` as appropriate to skip checking.
472 ///
473 /// Provides sane defaults for most configurations.
474 ///
475 /// Most additional limits are disabled except those with which specify a default in individual
476 /// field documentation. Note that this may result in barely-usable channels, but since they
477 /// are applied mostly only to incoming channels that's not much of a problem.
478 #[must_use]
479 #[repr(C)]
480 pub struct ChannelHandshakeLimits {
481         /// A pointer to the opaque Rust object.
482
483         /// Nearly everywhere, inner must be non-null, however in places where
484         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
485         pub inner: *mut nativeChannelHandshakeLimits,
486         /// Indicates that this is the only struct which contains the same pointer.
487
488         /// Rust functions which take ownership of an object provided via an argument require
489         /// this to be true and invalidate the object pointed to by inner.
490         pub is_owned: bool,
491 }
492
493 impl Drop for ChannelHandshakeLimits {
494         fn drop(&mut self) {
495                 if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) {
496                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
497                 }
498         }
499 }
500 /// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL.
501 #[no_mangle]
502 pub extern "C" fn ChannelHandshakeLimits_free(this_obj: ChannelHandshakeLimits) { }
503 #[allow(unused)]
504 /// Used only if an object of this type is returned as a trait impl by a method
505 pub(crate) extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
506         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits) };
507 }
508 #[allow(unused)]
509 impl ChannelHandshakeLimits {
510         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeLimits {
511                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
512         }
513         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeLimits {
514                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
515         }
516         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
517         pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
518                 assert!(self.is_owned);
519                 let ret = ObjOps::untweak_ptr(self.inner);
520                 self.inner = core::ptr::null_mut();
521                 ret
522         }
523 }
524 /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
525 /// only applies to inbound channels.
526 ///
527 /// Default value: 0.
528 #[no_mangle]
529 pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
530         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_funding_satoshis;
531         *inner_val
532 }
533 /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
534 /// only applies to inbound channels.
535 ///
536 /// Default value: 0.
537 #[no_mangle]
538 pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
539         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_funding_satoshis = val;
540 }
541 /// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
542 /// only applies to inbound channels.
543 ///
544 /// Default value: 2^24 - 1.
545 #[no_mangle]
546 pub extern "C" fn ChannelHandshakeLimits_get_max_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
547         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_funding_satoshis;
548         *inner_val
549 }
550 /// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
551 /// only applies to inbound channels.
552 ///
553 /// Default value: 2^24 - 1.
554 #[no_mangle]
555 pub extern "C" fn ChannelHandshakeLimits_set_max_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
556         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_funding_satoshis = val;
557 }
558 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
559 /// you to limit the maximum minimum-size they can require.
560 ///
561 /// Default value: u64::max_value.
562 #[no_mangle]
563 pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
564         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_minimum_msat;
565         *inner_val
566 }
567 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
568 /// you to limit the maximum minimum-size they can require.
569 ///
570 /// Default value: u64::max_value.
571 #[no_mangle]
572 pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
573         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_minimum_msat = val;
574 }
575 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
576 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
577 ///
578 /// Default value: 0.
579 #[no_mangle]
580 pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
581         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_htlc_value_in_flight_msat;
582         *inner_val
583 }
584 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
585 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
586 ///
587 /// Default value: 0.
588 #[no_mangle]
589 pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
590         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_htlc_value_in_flight_msat = val;
591 }
592 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
593 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
594 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
595 ///
596 /// Default value: u64::max_value.
597 #[no_mangle]
598 pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
599         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_reserve_satoshis;
600         *inner_val
601 }
602 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
603 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
604 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
605 ///
606 /// Default value: u64::max_value.
607 #[no_mangle]
608 pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
609         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_reserve_satoshis = val;
610 }
611 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
612 /// time. This allows you to set a minimum such value.
613 ///
614 /// Default value: 0.
615 #[no_mangle]
616 pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 {
617         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_accepted_htlcs;
618         *inner_val
619 }
620 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
621 /// time. This allows you to set a minimum such value.
622 ///
623 /// Default value: 0.
624 #[no_mangle]
625 pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
626         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_accepted_htlcs = val;
627 }
628 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
629 /// certain number of blocks, specified by the node which is not the funder (as the funder can
630 /// assume they aren't going to double-spend themselves).
631 /// This config allows you to set a limit on the maximum amount of time to wait.
632 ///
633 /// Default value: 144, or roughly one day and only applies to outbound channels.
634 #[no_mangle]
635 pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 {
636         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_minimum_depth;
637         *inner_val
638 }
639 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
640 /// certain number of blocks, specified by the node which is not the funder (as the funder can
641 /// assume they aren't going to double-spend themselves).
642 /// This config allows you to set a limit on the maximum amount of time to wait.
643 ///
644 /// Default value: 144, or roughly one day and only applies to outbound channels.
645 #[no_mangle]
646 pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) {
647         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_minimum_depth = val;
648 }
649 /// Whether we implicitly trust funding transactions generated by us for our own outbound
650 /// channels to not be double-spent.
651 ///
652 /// If this is set, we assume that our own funding transactions are *never* double-spent, and
653 /// thus we can trust them without any confirmations. This is generally a reasonable
654 /// assumption, given we're the only ones who could ever double-spend it (assuming we have sole
655 /// control of the signing keys).
656 ///
657 /// You may wish to un-set this if you allow the user to (or do in an automated fashion)
658 /// double-spend the funding transaction to RBF with an alternative channel open.
659 ///
660 /// This only applies if our counterparty set their confirmations-required value to 0, and we
661 /// always trust our own funding transaction at 1 confirmation irrespective of this value.
662 /// Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
663 /// `true` (0) and `false` (1).
664 ///
665 /// Default value: true
666 #[no_mangle]
667 pub extern "C" fn ChannelHandshakeLimits_get_trust_own_funding_0conf(this_ptr: &ChannelHandshakeLimits) -> bool {
668         let mut inner_val = &mut this_ptr.get_native_mut_ref().trust_own_funding_0conf;
669         *inner_val
670 }
671 /// Whether we implicitly trust funding transactions generated by us for our own outbound
672 /// channels to not be double-spent.
673 ///
674 /// If this is set, we assume that our own funding transactions are *never* double-spent, and
675 /// thus we can trust them without any confirmations. This is generally a reasonable
676 /// assumption, given we're the only ones who could ever double-spend it (assuming we have sole
677 /// control of the signing keys).
678 ///
679 /// You may wish to un-set this if you allow the user to (or do in an automated fashion)
680 /// double-spend the funding transaction to RBF with an alternative channel open.
681 ///
682 /// This only applies if our counterparty set their confirmations-required value to 0, and we
683 /// always trust our own funding transaction at 1 confirmation irrespective of this value.
684 /// Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
685 /// `true` (0) and `false` (1).
686 ///
687 /// Default value: true
688 #[no_mangle]
689 pub extern "C" fn ChannelHandshakeLimits_set_trust_own_funding_0conf(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
690         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.trust_own_funding_0conf = val;
691 }
692 /// Set to force an incoming channel to match our announced channel preference in
693 /// [`ChannelHandshakeConfig::announced_channel`].
694 ///
695 /// For a node which is not online reliably, this should be set to true and
696 /// [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
697 /// channels will ever be opened.
698 ///
699 /// Default value: true.
700 #[no_mangle]
701 pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool {
702         let mut inner_val = &mut this_ptr.get_native_mut_ref().force_announced_channel_preference;
703         *inner_val
704 }
705 /// Set to force an incoming channel to match our announced channel preference in
706 /// [`ChannelHandshakeConfig::announced_channel`].
707 ///
708 /// For a node which is not online reliably, this should be set to true and
709 /// [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
710 /// channels will ever be opened.
711 ///
712 /// Default value: true.
713 #[no_mangle]
714 pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
715         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_announced_channel_preference = val;
716 }
717 /// Set to the amount of time we're willing to wait to claim money back to us.
718 ///
719 /// Not checking this value would be a security issue, as our peer would be able to set it to
720 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
721 ///
722 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
723 /// reduce the loss of having useless locked funds (if your peer accepts)
724 #[no_mangle]
725 pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 {
726         let mut inner_val = &mut this_ptr.get_native_mut_ref().their_to_self_delay;
727         *inner_val
728 }
729 /// Set to the amount of time we're willing to wait to claim money back to us.
730 ///
731 /// Not checking this value would be a security issue, as our peer would be able to set it to
732 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
733 ///
734 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
735 /// reduce the loss of having useless locked funds (if your peer accepts)
736 #[no_mangle]
737 pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
738         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_to_self_delay = val;
739 }
740 /// Constructs a new ChannelHandshakeLimits given each field
741 #[must_use]
742 #[no_mangle]
743 pub extern "C" fn ChannelHandshakeLimits_new(mut min_funding_satoshis_arg: u64, mut max_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 trust_own_funding_0conf_arg: bool, mut force_announced_channel_preference_arg: bool, mut their_to_self_delay_arg: u16) -> ChannelHandshakeLimits {
744         ChannelHandshakeLimits { inner: ObjOps::heap_alloc(nativeChannelHandshakeLimits {
745                 min_funding_satoshis: min_funding_satoshis_arg,
746                 max_funding_satoshis: max_funding_satoshis_arg,
747                 max_htlc_minimum_msat: max_htlc_minimum_msat_arg,
748                 min_max_htlc_value_in_flight_msat: min_max_htlc_value_in_flight_msat_arg,
749                 max_channel_reserve_satoshis: max_channel_reserve_satoshis_arg,
750                 min_max_accepted_htlcs: min_max_accepted_htlcs_arg,
751                 max_minimum_depth: max_minimum_depth_arg,
752                 trust_own_funding_0conf: trust_own_funding_0conf_arg,
753                 force_announced_channel_preference: force_announced_channel_preference_arg,
754                 their_to_self_delay: their_to_self_delay_arg,
755         }), is_owned: true }
756 }
757 impl Clone for ChannelHandshakeLimits {
758         fn clone(&self) -> Self {
759                 Self {
760                         inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { core::ptr::null_mut() } else {
761                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
762                         is_owned: true,
763                 }
764         }
765 }
766 #[allow(unused)]
767 /// Used only if an object of this type is returned as a trait impl by a method
768 pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
769         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
770 }
771 #[no_mangle]
772 /// Creates a copy of the ChannelHandshakeLimits
773 pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits {
774         orig.clone()
775 }
776 /// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
777 #[must_use]
778 #[no_mangle]
779 pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
780         ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
781 }
782
783 use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
784 pub(crate) type nativeChannelConfig = nativeChannelConfigImport;
785
786 /// Options which apply on a per-channel basis and may change at runtime or based on negotiation
787 /// with our counterparty.
788 #[must_use]
789 #[repr(C)]
790 pub struct ChannelConfig {
791         /// A pointer to the opaque Rust object.
792
793         /// Nearly everywhere, inner must be non-null, however in places where
794         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
795         pub inner: *mut nativeChannelConfig,
796         /// Indicates that this is the only struct which contains the same pointer.
797
798         /// Rust functions which take ownership of an object provided via an argument require
799         /// this to be true and invalidate the object pointed to by inner.
800         pub is_owned: bool,
801 }
802
803 impl Drop for ChannelConfig {
804         fn drop(&mut self) {
805                 if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) {
806                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
807                 }
808         }
809 }
810 /// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL.
811 #[no_mangle]
812 pub extern "C" fn ChannelConfig_free(this_obj: ChannelConfig) { }
813 #[allow(unused)]
814 /// Used only if an object of this type is returned as a trait impl by a method
815 pub(crate) extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
816         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelConfig) };
817 }
818 #[allow(unused)]
819 impl ChannelConfig {
820         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfig {
821                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
822         }
823         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfig {
824                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
825         }
826         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
827         pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
828                 assert!(self.is_owned);
829                 let ret = ObjOps::untweak_ptr(self.inner);
830                 self.inner = core::ptr::null_mut();
831                 ret
832         }
833 }
834 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
835 /// over the channel.
836 /// This may be allowed to change at runtime in a later update, however doing so must result in
837 /// update messages sent to notify all nodes of our updated relay fee.
838 ///
839 /// Default value: 0.
840 #[no_mangle]
841 pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 {
842         let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths;
843         *inner_val
844 }
845 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
846 /// over the channel.
847 /// This may be allowed to change at runtime in a later update, however doing so must result in
848 /// update messages sent to notify all nodes of our updated relay fee.
849 ///
850 /// Default value: 0.
851 #[no_mangle]
852 pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) {
853         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = val;
854 }
855 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
856 /// excess of [`forwarding_fee_proportional_millionths`].
857 /// This may be allowed to change at runtime in a later update, however doing so must result in
858 /// update messages sent to notify all nodes of our updated relay fee.
859 ///
860 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
861 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
862 /// this node.
863 ///
864 /// Default value: 1000.
865 ///
866 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
867 #[no_mangle]
868 pub extern "C" fn ChannelConfig_get_forwarding_fee_base_msat(this_ptr: &ChannelConfig) -> u32 {
869         let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_base_msat;
870         *inner_val
871 }
872 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
873 /// excess of [`forwarding_fee_proportional_millionths`].
874 /// This may be allowed to change at runtime in a later update, however doing so must result in
875 /// update messages sent to notify all nodes of our updated relay fee.
876 ///
877 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
878 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
879 /// this node.
880 ///
881 /// Default value: 1000.
882 ///
883 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
884 #[no_mangle]
885 pub extern "C" fn ChannelConfig_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfig, mut val: u32) {
886         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_base_msat = val;
887 }
888 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
889 /// the channel this config applies to.
890 ///
891 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
892 /// HTLC balance when a channel appears on-chain whereas
893 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
894 /// (non-HTLC-encumbered) balance.
895 ///
896 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
897 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
898 /// commitment transaction at least once per this many blocks (minus some margin to allow us
899 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
900 /// the spending transaction).
901 ///
902 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
903 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
904 ///                [`MIN_CLTV_EXPIRY_DELTA`] instead.
905 ///
906 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
907 #[no_mangle]
908 pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 {
909         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
910         *inner_val
911 }
912 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
913 /// the channel this config applies to.
914 ///
915 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
916 /// HTLC balance when a channel appears on-chain whereas
917 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
918 /// (non-HTLC-encumbered) balance.
919 ///
920 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
921 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
922 /// commitment transaction at least once per this many blocks (minus some margin to allow us
923 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
924 /// the spending transaction).
925 ///
926 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
927 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
928 ///                [`MIN_CLTV_EXPIRY_DELTA`] instead.
929 ///
930 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
931 #[no_mangle]
932 pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) {
933         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
934 }
935 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
936 /// small to claim on-chain.
937 ///
938 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
939 /// not be claimable on-chain, instead being turned into additional miner fees if either
940 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
941 /// to such payments may be sustantial if there are many dust HTLCs present when the
942 /// channel is force-closed.
943 ///
944 /// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
945 /// channel negotiated throughout the channel open process, along with the fees required to have
946 /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs
947 /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
948 /// account the HTLC transaction fee as it is zero.
949 ///
950 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
951 /// exposure across all three types per-channel. Setting this too low may prevent the
952 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
953 /// important to prevent stealing of dust HTLCs by miners.
954 ///
955 /// Default value: 5_000_000 msat.
956 #[no_mangle]
957 pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfig) -> u64 {
958         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat;
959         *inner_val
960 }
961 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
962 /// small to claim on-chain.
963 ///
964 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
965 /// not be claimable on-chain, instead being turned into additional miner fees if either
966 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
967 /// to such payments may be sustantial if there are many dust HTLCs present when the
968 /// channel is force-closed.
969 ///
970 /// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
971 /// channel negotiated throughout the channel open process, along with the fees required to have
972 /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs
973 /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
974 /// account the HTLC transaction fee as it is zero.
975 ///
976 /// This limit is applied for sent, forwarded, and received HTLCs and limits the total
977 /// exposure across all three types per-channel. Setting this too low may prevent the
978 /// sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
979 /// important to prevent stealing of dust HTLCs by miners.
980 ///
981 /// Default value: 5_000_000 msat.
982 #[no_mangle]
983 pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfig, mut val: u64) {
984         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = val;
985 }
986 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
987 /// `to_self_delay` to reclaim funds.
988 ///
989 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
990 /// closing transaction which both sides find acceptable, ultimately paid by the channel
991 /// funder/initiator.
992 ///
993 /// When we are the funder, because we have to pay the channel closing fee, we bound the
994 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
995 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
996 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
997 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
998 /// funds.
999 ///
1000 /// When we are not the funder, we require the closing transaction fee pay at least our
1001 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
1002 /// Thus, this value is ignored when we are not the funder.
1003 ///
1004 /// Default value: 1000 satoshis.
1005 ///
1006 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1007 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1008 #[no_mangle]
1009 pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfig) -> u64 {
1010         let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_avoidance_max_fee_satoshis;
1011         *inner_val
1012 }
1013 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
1014 /// `to_self_delay` to reclaim funds.
1015 ///
1016 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
1017 /// closing transaction which both sides find acceptable, ultimately paid by the channel
1018 /// funder/initiator.
1019 ///
1020 /// When we are the funder, because we have to pay the channel closing fee, we bound the
1021 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
1022 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
1023 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
1024 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
1025 /// funds.
1026 ///
1027 /// When we are not the funder, we require the closing transaction fee pay at least our
1028 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
1029 /// Thus, this value is ignored when we are not the funder.
1030 ///
1031 /// Default value: 1000 satoshis.
1032 ///
1033 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1034 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1035 #[no_mangle]
1036 pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfig, mut val: u64) {
1037         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = val;
1038 }
1039 /// Constructs a new ChannelConfig given each field
1040 #[must_use]
1041 #[no_mangle]
1042 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 max_dust_htlc_exposure_msat_arg: u64, mut force_close_avoidance_max_fee_satoshis_arg: u64) -> ChannelConfig {
1043         ChannelConfig { inner: ObjOps::heap_alloc(nativeChannelConfig {
1044                 forwarding_fee_proportional_millionths: forwarding_fee_proportional_millionths_arg,
1045                 forwarding_fee_base_msat: forwarding_fee_base_msat_arg,
1046                 cltv_expiry_delta: cltv_expiry_delta_arg,
1047                 max_dust_htlc_exposure_msat: max_dust_htlc_exposure_msat_arg,
1048                 force_close_avoidance_max_fee_satoshis: force_close_avoidance_max_fee_satoshis_arg,
1049         }), is_owned: true }
1050 }
1051 impl Clone for ChannelConfig {
1052         fn clone(&self) -> Self {
1053                 Self {
1054                         inner: if <*mut nativeChannelConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
1055                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1056                         is_owned: true,
1057                 }
1058         }
1059 }
1060 #[allow(unused)]
1061 /// Used only if an object of this type is returned as a trait impl by a method
1062 pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
1063         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
1064 }
1065 #[no_mangle]
1066 /// Creates a copy of the ChannelConfig
1067 pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
1068         orig.clone()
1069 }
1070 /// Checks if two ChannelConfigs contain equal inner contents.
1071 /// This ignores pointers and is_owned flags and looks at the values in fields.
1072 /// Two objects with NULL inner values will be considered "equal" here.
1073 #[no_mangle]
1074 pub extern "C" fn ChannelConfig_eq(a: &ChannelConfig, b: &ChannelConfig) -> bool {
1075         if a.inner == b.inner { return true; }
1076         if a.inner.is_null() || b.inner.is_null() { return false; }
1077         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1078 }
1079 /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
1080 #[must_use]
1081 #[no_mangle]
1082 pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
1083         ChannelConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
1084 }
1085 #[no_mangle]
1086 /// Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
1087 pub extern "C" fn ChannelConfig_write(obj: &crate::lightning::util::config::ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
1088         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1089 }
1090 #[no_mangle]
1091 pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1092         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) })
1093 }
1094 #[no_mangle]
1095 /// Read a ChannelConfig from a byte array, created by ChannelConfig_write
1096 pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
1097         let res: Result<lightning::util::config::ChannelConfig, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1098         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::native_into(e) }).into() };
1099         local_res
1100 }
1101
1102 use lightning::util::config::UserConfig as nativeUserConfigImport;
1103 pub(crate) type nativeUserConfig = nativeUserConfigImport;
1104
1105 /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
1106 ///
1107 /// Default::default() provides sane defaults for most configurations
1108 /// (but currently with 0 relay fees!)
1109 #[must_use]
1110 #[repr(C)]
1111 pub struct UserConfig {
1112         /// A pointer to the opaque Rust object.
1113
1114         /// Nearly everywhere, inner must be non-null, however in places where
1115         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1116         pub inner: *mut nativeUserConfig,
1117         /// Indicates that this is the only struct which contains the same pointer.
1118
1119         /// Rust functions which take ownership of an object provided via an argument require
1120         /// this to be true and invalidate the object pointed to by inner.
1121         pub is_owned: bool,
1122 }
1123
1124 impl Drop for UserConfig {
1125         fn drop(&mut self) {
1126                 if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) {
1127                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1128                 }
1129         }
1130 }
1131 /// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL.
1132 #[no_mangle]
1133 pub extern "C" fn UserConfig_free(this_obj: UserConfig) { }
1134 #[allow(unused)]
1135 /// Used only if an object of this type is returned as a trait impl by a method
1136 pub(crate) extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
1137         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUserConfig) };
1138 }
1139 #[allow(unused)]
1140 impl UserConfig {
1141         pub(crate) fn get_native_ref(&self) -> &'static nativeUserConfig {
1142                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1143         }
1144         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUserConfig {
1145                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1146         }
1147         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1148         pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
1149                 assert!(self.is_owned);
1150                 let ret = ObjOps::untweak_ptr(self.inner);
1151                 self.inner = core::ptr::null_mut();
1152                 ret
1153         }
1154 }
1155 /// Channel handshake config that we propose to our counterparty.
1156 #[no_mangle]
1157 pub extern "C" fn UserConfig_get_channel_handshake_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig {
1158         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_handshake_config;
1159         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 }
1160 }
1161 /// Channel handshake config that we propose to our counterparty.
1162 #[no_mangle]
1163 pub extern "C" fn UserConfig_set_channel_handshake_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeConfig) {
1164         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_handshake_config = *unsafe { Box::from_raw(val.take_inner()) };
1165 }
1166 /// Limits applied to our counterparty's proposed channel handshake config settings.
1167 #[no_mangle]
1168 pub extern "C" fn UserConfig_get_channel_handshake_limits(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeLimits {
1169         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_handshake_limits;
1170         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 }
1171 }
1172 /// Limits applied to our counterparty's proposed channel handshake config settings.
1173 #[no_mangle]
1174 pub extern "C" fn UserConfig_set_channel_handshake_limits(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeLimits) {
1175         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_handshake_limits = *unsafe { Box::from_raw(val.take_inner()) };
1176 }
1177 /// Channel config which affects behavior during channel lifetime.
1178 #[no_mangle]
1179 pub extern "C" fn UserConfig_get_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig {
1180         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_config;
1181         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 }
1182 }
1183 /// Channel config which affects behavior during channel lifetime.
1184 #[no_mangle]
1185 pub extern "C" fn UserConfig_set_channel_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelConfig) {
1186         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_config = *unsafe { Box::from_raw(val.take_inner()) };
1187 }
1188 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
1189 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
1190 /// node which is not online reliably.
1191 ///
1192 /// For nodes which are not online reliably, you should set all channels to *not* be announced
1193 /// (using [`ChannelHandshakeConfig::announced_channel`] and
1194 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
1195 /// ensure you are not exposed to any forwarding risk.
1196 ///
1197 /// Note that because you cannot change a channel's announced state after creation, there is no
1198 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
1199 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
1200 /// all your channels and open new ones. For privacy, you should also change your node_id
1201 /// (swapping all private and public key material for new ones) at that time.
1202 ///
1203 /// Default value: false.
1204 #[no_mangle]
1205 pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &UserConfig) -> bool {
1206         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_forwards_to_priv_channels;
1207         *inner_val
1208 }
1209 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
1210 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
1211 /// node which is not online reliably.
1212 ///
1213 /// For nodes which are not online reliably, you should set all channels to *not* be announced
1214 /// (using [`ChannelHandshakeConfig::announced_channel`] and
1215 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
1216 /// ensure you are not exposed to any forwarding risk.
1217 ///
1218 /// Note that because you cannot change a channel's announced state after creation, there is no
1219 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
1220 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
1221 /// all your channels and open new ones. For privacy, you should also change your node_id
1222 /// (swapping all private and public key material for new ones) at that time.
1223 ///
1224 /// Default value: false.
1225 #[no_mangle]
1226 pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) {
1227         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_forwards_to_priv_channels = val;
1228 }
1229 /// If this is set to false, we do not accept inbound requests to open a new channel.
1230 /// Default value: true.
1231 #[no_mangle]
1232 pub extern "C" fn UserConfig_get_accept_inbound_channels(this_ptr: &UserConfig) -> bool {
1233         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_inbound_channels;
1234         *inner_val
1235 }
1236 /// If this is set to false, we do not accept inbound requests to open a new channel.
1237 /// Default value: true.
1238 #[no_mangle]
1239 pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
1240         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_inbound_channels = val;
1241 }
1242 /// If this is set to true, the user needs to manually accept inbound requests to open a new
1243 /// channel.
1244 ///
1245 /// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
1246 /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
1247 /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
1248 /// user explicitly chooses to accept the request.
1249 ///
1250 /// Default value: false.
1251 ///
1252 /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
1253 /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
1254 /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
1255 #[no_mangle]
1256 pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &UserConfig) -> bool {
1257         let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_accept_inbound_channels;
1258         *inner_val
1259 }
1260 /// If this is set to true, the user needs to manually accept inbound requests to open a new
1261 /// channel.
1262 ///
1263 /// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
1264 /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
1265 /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
1266 /// user explicitly chooses to accept the request.
1267 ///
1268 /// Default value: false.
1269 ///
1270 /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
1271 /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
1272 /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
1273 #[no_mangle]
1274 pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
1275         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_accept_inbound_channels = val;
1276 }
1277 ///  If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
1278 ///  fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
1279 ///  intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
1280 ///
1281 ///  Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
1282 ///
1283 ///  Default value: false.
1284 ///
1285 /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1286 /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
1287 #[no_mangle]
1288 pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) -> bool {
1289         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_intercept_htlcs;
1290         *inner_val
1291 }
1292 ///  If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
1293 ///  fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
1294 ///  intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
1295 ///
1296 ///  Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
1297 ///
1298 ///  Default value: false.
1299 ///
1300 /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1301 /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
1302 #[no_mangle]
1303 pub extern "C" fn UserConfig_set_accept_intercept_htlcs(this_ptr: &mut UserConfig, mut val: bool) {
1304         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_intercept_htlcs = val;
1305 }
1306 /// Constructs a new UserConfig given each field
1307 #[must_use]
1308 #[no_mangle]
1309 pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool) -> UserConfig {
1310         UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig {
1311                 channel_handshake_config: *unsafe { Box::from_raw(channel_handshake_config_arg.take_inner()) },
1312                 channel_handshake_limits: *unsafe { Box::from_raw(channel_handshake_limits_arg.take_inner()) },
1313                 channel_config: *unsafe { Box::from_raw(channel_config_arg.take_inner()) },
1314                 accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
1315                 accept_inbound_channels: accept_inbound_channels_arg,
1316                 manually_accept_inbound_channels: manually_accept_inbound_channels_arg,
1317                 accept_intercept_htlcs: accept_intercept_htlcs_arg,
1318         }), is_owned: true }
1319 }
1320 impl Clone for UserConfig {
1321         fn clone(&self) -> Self {
1322                 Self {
1323                         inner: if <*mut nativeUserConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
1324                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1325                         is_owned: true,
1326                 }
1327         }
1328 }
1329 #[allow(unused)]
1330 /// Used only if an object of this type is returned as a trait impl by a method
1331 pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
1332         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
1333 }
1334 #[no_mangle]
1335 /// Creates a copy of the UserConfig
1336 pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig {
1337         orig.clone()
1338 }
1339 /// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
1340 #[must_use]
1341 #[no_mangle]
1342 pub extern "C" fn UserConfig_default() -> UserConfig {
1343         UserConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
1344 }