Update auto-generated bindings to LDK 0.0.116
[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::sign::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::sign::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 /// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future
392 /// channels. This feature requires having a reserve of onchain funds readily available to bump
393 /// transactions in the event of a channel force close to avoid the possibility of losing funds.
394 ///
395 /// Note that if you wish accept inbound channels with anchor outputs, you must enable
396 /// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with
397 /// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check
398 /// whether your reserve of onchain funds is enough to cover the fees for all existing and new
399 /// channels featuring anchor outputs in the event of a force close.
400 ///
401 /// If this option is set, channels may be created that will not be readable by LDK versions
402 /// prior to 0.0.116, causing [`ChannelManager`]'s read method to return a
403 /// [`DecodeError::InvalidValue`].
404 ///
405 /// Note that setting this to true does *not* prevent us from opening channels with
406 /// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply
407 /// fall back to a `static_remote_key` channel.
408 ///
409 /// LDK will not support the legacy `option_anchors` commitment version due to a discovered
410 /// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee
411 /// Considered Harmful`] mailing list post.
412 ///
413 /// Default value: false. This value is likely to change to true in the future.
414 ///
415 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
416 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
417 /// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
418 /// [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html
419 #[no_mangle]
420 pub extern "C" fn ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(this_ptr: &ChannelHandshakeConfig) -> bool {
421         let mut inner_val = &mut this_ptr.get_native_mut_ref().negotiate_anchors_zero_fee_htlc_tx;
422         *inner_val
423 }
424 /// If set, we attempt to negotiate the `anchors_zero_fee_htlc_tx`option for all future
425 /// channels. This feature requires having a reserve of onchain funds readily available to bump
426 /// transactions in the event of a channel force close to avoid the possibility of losing funds.
427 ///
428 /// Note that if you wish accept inbound channels with anchor outputs, you must enable
429 /// [`UserConfig::manually_accept_inbound_channels`] and manually accept them with
430 /// [`ChannelManager::accept_inbound_channel`]. This is done to give you the chance to check
431 /// whether your reserve of onchain funds is enough to cover the fees for all existing and new
432 /// channels featuring anchor outputs in the event of a force close.
433 ///
434 /// If this option is set, channels may be created that will not be readable by LDK versions
435 /// prior to 0.0.116, causing [`ChannelManager`]'s read method to return a
436 /// [`DecodeError::InvalidValue`].
437 ///
438 /// Note that setting this to true does *not* prevent us from opening channels with
439 /// counterparties that do not support the `anchors_zero_fee_htlc_tx` option; we will simply
440 /// fall back to a `static_remote_key` channel.
441 ///
442 /// LDK will not support the legacy `option_anchors` commitment version due to a discovered
443 /// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee
444 /// Considered Harmful`] mailing list post.
445 ///
446 /// Default value: false. This value is likely to change to true in the future.
447 ///
448 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
449 /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
450 /// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
451 /// [`SIGHASH_SINGLE + update_fee Considered Harmful`]: https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html
452 #[no_mangle]
453 pub extern "C" fn ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) {
454         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.negotiate_anchors_zero_fee_htlc_tx = val;
455 }
456 /// The maximum number of HTLCs in-flight from our counterparty towards us at the same time.
457 ///
458 /// Increasing the value can help improve liquidity and stability in
459 /// routing at the cost of higher long term disk / DB usage.
460 ///
461 /// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration
462 /// other than the default value.
463 ///
464 /// Default value: 50
465 /// Maximum value: 483, any values larger will be treated as 483.
466 ///                     This is the BOLT #2 spec limit on `max_accepted_htlcs`.
467 #[no_mangle]
468 pub extern "C" fn ChannelHandshakeConfig_get_our_max_accepted_htlcs(this_ptr: &ChannelHandshakeConfig) -> u16 {
469         let mut inner_val = &mut this_ptr.get_native_mut_ref().our_max_accepted_htlcs;
470         *inner_val
471 }
472 /// The maximum number of HTLCs in-flight from our counterparty towards us at the same time.
473 ///
474 /// Increasing the value can help improve liquidity and stability in
475 /// routing at the cost of higher long term disk / DB usage.
476 ///
477 /// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration
478 /// other than the default value.
479 ///
480 /// Default value: 50
481 /// Maximum value: 483, any values larger will be treated as 483.
482 ///                     This is the BOLT #2 spec limit on `max_accepted_htlcs`.
483 #[no_mangle]
484 pub extern "C" fn ChannelHandshakeConfig_set_our_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) {
485         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_max_accepted_htlcs = val;
486 }
487 /// Constructs a new ChannelHandshakeConfig given each field
488 #[must_use]
489 #[no_mangle]
490 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 negotiate_anchors_zero_fee_htlc_tx_arg: bool, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig {
491         ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig {
492                 minimum_depth: minimum_depth_arg,
493                 our_to_self_delay: our_to_self_delay_arg,
494                 our_htlc_minimum_msat: our_htlc_minimum_msat_arg,
495                 max_inbound_htlc_value_in_flight_percent_of_channel: max_inbound_htlc_value_in_flight_percent_of_channel_arg,
496                 negotiate_scid_privacy: negotiate_scid_privacy_arg,
497                 announced_channel: announced_channel_arg,
498                 commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg,
499                 their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg,
500                 negotiate_anchors_zero_fee_htlc_tx: negotiate_anchors_zero_fee_htlc_tx_arg,
501                 our_max_accepted_htlcs: our_max_accepted_htlcs_arg,
502         }), is_owned: true }
503 }
504 impl Clone for ChannelHandshakeConfig {
505         fn clone(&self) -> Self {
506                 Self {
507                         inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
508                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
509                         is_owned: true,
510                 }
511         }
512 }
513 #[allow(unused)]
514 /// Used only if an object of this type is returned as a trait impl by a method
515 pub(crate) extern "C" fn ChannelHandshakeConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
516         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeConfig)).clone() })) as *mut c_void
517 }
518 #[no_mangle]
519 /// Creates a copy of the ChannelHandshakeConfig
520 pub extern "C" fn ChannelHandshakeConfig_clone(orig: &ChannelHandshakeConfig) -> ChannelHandshakeConfig {
521         orig.clone()
522 }
523 /// Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
524 #[must_use]
525 #[no_mangle]
526 pub extern "C" fn ChannelHandshakeConfig_default() -> ChannelHandshakeConfig {
527         ChannelHandshakeConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
528 }
529
530 use lightning::util::config::ChannelHandshakeLimits as nativeChannelHandshakeLimitsImport;
531 pub(crate) type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
532
533 /// Optional channel limits which are applied during channel creation.
534 ///
535 /// These limits are only applied to our counterparty's limits, not our own.
536 ///
537 /// Use 0/`<type>::max_value()` as appropriate to skip checking.
538 ///
539 /// Provides sane defaults for most configurations.
540 ///
541 /// Most additional limits are disabled except those with which specify a default in individual
542 /// field documentation. Note that this may result in barely-usable channels, but since they
543 /// are applied mostly only to incoming channels that's not much of a problem.
544 #[must_use]
545 #[repr(C)]
546 pub struct ChannelHandshakeLimits {
547         /// A pointer to the opaque Rust object.
548
549         /// Nearly everywhere, inner must be non-null, however in places where
550         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
551         pub inner: *mut nativeChannelHandshakeLimits,
552         /// Indicates that this is the only struct which contains the same pointer.
553
554         /// Rust functions which take ownership of an object provided via an argument require
555         /// this to be true and invalidate the object pointed to by inner.
556         pub is_owned: bool,
557 }
558
559 impl Drop for ChannelHandshakeLimits {
560         fn drop(&mut self) {
561                 if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) {
562                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
563                 }
564         }
565 }
566 /// Frees any resources used by the ChannelHandshakeLimits, if is_owned is set and inner is non-NULL.
567 #[no_mangle]
568 pub extern "C" fn ChannelHandshakeLimits_free(this_obj: ChannelHandshakeLimits) { }
569 #[allow(unused)]
570 /// Used only if an object of this type is returned as a trait impl by a method
571 pub(crate) extern "C" fn ChannelHandshakeLimits_free_void(this_ptr: *mut c_void) {
572         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelHandshakeLimits) };
573 }
574 #[allow(unused)]
575 impl ChannelHandshakeLimits {
576         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelHandshakeLimits {
577                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
578         }
579         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelHandshakeLimits {
580                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
581         }
582         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
583         pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
584                 assert!(self.is_owned);
585                 let ret = ObjOps::untweak_ptr(self.inner);
586                 self.inner = core::ptr::null_mut();
587                 ret
588         }
589 }
590 /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
591 /// only applies to inbound channels.
592 ///
593 /// Default value: 0.
594 #[no_mangle]
595 pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
596         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_funding_satoshis;
597         *inner_val
598 }
599 /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
600 /// only applies to inbound channels.
601 ///
602 /// Default value: 0.
603 #[no_mangle]
604 pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
605         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_funding_satoshis = val;
606 }
607 /// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
608 /// only applies to inbound channels.
609 ///
610 /// Default value: 2^24 - 1.
611 #[no_mangle]
612 pub extern "C" fn ChannelHandshakeLimits_get_max_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
613         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_funding_satoshis;
614         *inner_val
615 }
616 /// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
617 /// only applies to inbound channels.
618 ///
619 /// Default value: 2^24 - 1.
620 #[no_mangle]
621 pub extern "C" fn ChannelHandshakeLimits_set_max_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
622         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_funding_satoshis = val;
623 }
624 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
625 /// you to limit the maximum minimum-size they can require.
626 ///
627 /// Default value: u64::max_value.
628 #[no_mangle]
629 pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
630         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_minimum_msat;
631         *inner_val
632 }
633 /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
634 /// you to limit the maximum minimum-size they can require.
635 ///
636 /// Default value: u64::max_value.
637 #[no_mangle]
638 pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
639         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_minimum_msat = val;
640 }
641 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
642 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
643 ///
644 /// Default value: 0.
645 #[no_mangle]
646 pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 {
647         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_htlc_value_in_flight_msat;
648         *inner_val
649 }
650 /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given
651 /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
652 ///
653 /// Default value: 0.
654 #[no_mangle]
655 pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
656         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_htlc_value_in_flight_msat = val;
657 }
658 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
659 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
660 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
661 ///
662 /// Default value: u64::max_value.
663 #[no_mangle]
664 pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 {
665         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_reserve_satoshis;
666         *inner_val
667 }
668 /// The remote node will require we keep a certain amount in direct payment to ourselves at all
669 /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to
670 /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
671 ///
672 /// Default value: u64::max_value.
673 #[no_mangle]
674 pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) {
675         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_reserve_satoshis = val;
676 }
677 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
678 /// time. This allows you to set a minimum such value.
679 ///
680 /// Default value: 0.
681 #[no_mangle]
682 pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 {
683         let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_accepted_htlcs;
684         *inner_val
685 }
686 /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given
687 /// time. This allows you to set a minimum such value.
688 ///
689 /// Default value: 0.
690 #[no_mangle]
691 pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
692         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_accepted_htlcs = val;
693 }
694 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
695 /// certain number of blocks, specified by the node which is not the funder (as the funder can
696 /// assume they aren't going to double-spend themselves).
697 /// This config allows you to set a limit on the maximum amount of time to wait.
698 ///
699 /// Default value: 144, or roughly one day and only applies to outbound channels.
700 #[no_mangle]
701 pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 {
702         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_minimum_depth;
703         *inner_val
704 }
705 /// Before a channel is usable the funding transaction will need to be confirmed by at least a
706 /// certain number of blocks, specified by the node which is not the funder (as the funder can
707 /// assume they aren't going to double-spend themselves).
708 /// This config allows you to set a limit on the maximum amount of time to wait.
709 ///
710 /// Default value: 144, or roughly one day and only applies to outbound channels.
711 #[no_mangle]
712 pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) {
713         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_minimum_depth = val;
714 }
715 /// Whether we implicitly trust funding transactions generated by us for our own outbound
716 /// channels to not be double-spent.
717 ///
718 /// If this is set, we assume that our own funding transactions are *never* double-spent, and
719 /// thus we can trust them without any confirmations. This is generally a reasonable
720 /// assumption, given we're the only ones who could ever double-spend it (assuming we have sole
721 /// control of the signing keys).
722 ///
723 /// You may wish to un-set this if you allow the user to (or do in an automated fashion)
724 /// double-spend the funding transaction to RBF with an alternative channel open.
725 ///
726 /// This only applies if our counterparty set their confirmations-required value to 0, and we
727 /// always trust our own funding transaction at 1 confirmation irrespective of this value.
728 /// Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
729 /// `true` (0) and `false` (1).
730 ///
731 /// Default value: true
732 #[no_mangle]
733 pub extern "C" fn ChannelHandshakeLimits_get_trust_own_funding_0conf(this_ptr: &ChannelHandshakeLimits) -> bool {
734         let mut inner_val = &mut this_ptr.get_native_mut_ref().trust_own_funding_0conf;
735         *inner_val
736 }
737 /// Whether we implicitly trust funding transactions generated by us for our own outbound
738 /// channels to not be double-spent.
739 ///
740 /// If this is set, we assume that our own funding transactions are *never* double-spent, and
741 /// thus we can trust them without any confirmations. This is generally a reasonable
742 /// assumption, given we're the only ones who could ever double-spend it (assuming we have sole
743 /// control of the signing keys).
744 ///
745 /// You may wish to un-set this if you allow the user to (or do in an automated fashion)
746 /// double-spend the funding transaction to RBF with an alternative channel open.
747 ///
748 /// This only applies if our counterparty set their confirmations-required value to 0, and we
749 /// always trust our own funding transaction at 1 confirmation irrespective of this value.
750 /// Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
751 /// `true` (0) and `false` (1).
752 ///
753 /// Default value: true
754 #[no_mangle]
755 pub extern "C" fn ChannelHandshakeLimits_set_trust_own_funding_0conf(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
756         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.trust_own_funding_0conf = val;
757 }
758 /// Set to force an incoming channel to match our announced channel preference in
759 /// [`ChannelHandshakeConfig::announced_channel`].
760 ///
761 /// For a node which is not online reliably, this should be set to true and
762 /// [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
763 /// channels will ever be opened.
764 ///
765 /// Default value: true.
766 #[no_mangle]
767 pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool {
768         let mut inner_val = &mut this_ptr.get_native_mut_ref().force_announced_channel_preference;
769         *inner_val
770 }
771 /// Set to force an incoming channel to match our announced channel preference in
772 /// [`ChannelHandshakeConfig::announced_channel`].
773 ///
774 /// For a node which is not online reliably, this should be set to true and
775 /// [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
776 /// channels will ever be opened.
777 ///
778 /// Default value: true.
779 #[no_mangle]
780 pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) {
781         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_announced_channel_preference = val;
782 }
783 /// Set to the amount of time we're willing to wait to claim money back to us.
784 ///
785 /// Not checking this value would be a security issue, as our peer would be able to set it to
786 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
787 ///
788 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
789 /// reduce the loss of having useless locked funds (if your peer accepts)
790 #[no_mangle]
791 pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 {
792         let mut inner_val = &mut this_ptr.get_native_mut_ref().their_to_self_delay;
793         *inner_val
794 }
795 /// Set to the amount of time we're willing to wait to claim money back to us.
796 ///
797 /// Not checking this value would be a security issue, as our peer would be able to set it to
798 /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
799 ///
800 /// Default value: 2016, which we also enforce as a maximum value so you can tweak config to
801 /// reduce the loss of having useless locked funds (if your peer accepts)
802 #[no_mangle]
803 pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) {
804         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_to_self_delay = val;
805 }
806 /// Constructs a new ChannelHandshakeLimits given each field
807 #[must_use]
808 #[no_mangle]
809 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 {
810         ChannelHandshakeLimits { inner: ObjOps::heap_alloc(nativeChannelHandshakeLimits {
811                 min_funding_satoshis: min_funding_satoshis_arg,
812                 max_funding_satoshis: max_funding_satoshis_arg,
813                 max_htlc_minimum_msat: max_htlc_minimum_msat_arg,
814                 min_max_htlc_value_in_flight_msat: min_max_htlc_value_in_flight_msat_arg,
815                 max_channel_reserve_satoshis: max_channel_reserve_satoshis_arg,
816                 min_max_accepted_htlcs: min_max_accepted_htlcs_arg,
817                 max_minimum_depth: max_minimum_depth_arg,
818                 trust_own_funding_0conf: trust_own_funding_0conf_arg,
819                 force_announced_channel_preference: force_announced_channel_preference_arg,
820                 their_to_self_delay: their_to_self_delay_arg,
821         }), is_owned: true }
822 }
823 impl Clone for ChannelHandshakeLimits {
824         fn clone(&self) -> Self {
825                 Self {
826                         inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { core::ptr::null_mut() } else {
827                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
828                         is_owned: true,
829                 }
830         }
831 }
832 #[allow(unused)]
833 /// Used only if an object of this type is returned as a trait impl by a method
834 pub(crate) extern "C" fn ChannelHandshakeLimits_clone_void(this_ptr: *const c_void) -> *mut c_void {
835         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelHandshakeLimits)).clone() })) as *mut c_void
836 }
837 #[no_mangle]
838 /// Creates a copy of the ChannelHandshakeLimits
839 pub extern "C" fn ChannelHandshakeLimits_clone(orig: &ChannelHandshakeLimits) -> ChannelHandshakeLimits {
840         orig.clone()
841 }
842 /// Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
843 #[must_use]
844 #[no_mangle]
845 pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits {
846         ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
847 }
848 /// Options for how to set the max dust HTLC exposure allowed on a channel. See
849 /// [`ChannelConfig::max_dust_htlc_exposure`] for details.
850 #[derive(Clone)]
851 #[must_use]
852 #[repr(C)]
853 pub enum MaxDustHTLCExposure {
854         /// This sets a fixed limit on the total dust exposure in millisatoshis. Setting this too low
855         /// may prevent the sending or receipt of low-value HTLCs on high-traffic nodes, however this
856         /// limit is very important to prevent stealing of large amounts of dust HTLCs by miners
857         /// through [fee griefing
858         /// attacks](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html).
859         ///
860         /// Note that if the feerate increases significantly, without a manual increase
861         /// to this maximum the channel may be unable to send/receive HTLCs between the maximum dust
862         /// exposure and the new minimum value for HTLCs to be economically viable to claim.
863         FixedLimitMsat(
864                 u64),
865         /// This sets a multiplier on the estimated high priority feerate (sats/KW, as obtained from
866         /// [`FeeEstimator`]) to determine the maximum allowed dust exposure. If this variant is used
867         /// then the maximum dust exposure in millisatoshis is calculated as:
868         /// `high_priority_feerate_per_kw * value`. For example, with our default value
869         /// `FeeRateMultiplier(5000)`:
870         ///
871         /// - For the minimum fee rate of 1 sat/vByte (250 sat/KW, although the minimum
872         /// defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would
873         /// be 253 * 5000 = 1,265,000 msats.
874         /// - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be
875         /// 7500 * 5000 = 37,500,000 msats.
876         ///
877         /// This allows the maximum dust exposure to automatically scale with fee rate changes.
878         ///
879         /// Note, if you're using a third-party fee estimator, this may leave you more exposed to a
880         /// fee griefing attack, where your fee estimator may purposely overestimate the fee rate,
881         /// causing you to accept more dust HTLCs than you would otherwise.
882         ///
883         /// This variant is primarily meant to serve pre-anchor channels, as HTLC fees being included
884         /// on HTLC outputs means your channel may be subject to more dust exposure in the event of
885         /// increases in fee rate.
886         ///
887         /// # Backwards Compatibility
888         /// This variant only became available in LDK 0.0.116, so if you downgrade to a prior version
889         /// by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat.
890         ///
891         /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator
892         FeeRateMultiplier(
893                 u64),
894 }
895 use lightning::util::config::MaxDustHTLCExposure as MaxDustHTLCExposureImport;
896 pub(crate) type nativeMaxDustHTLCExposure = MaxDustHTLCExposureImport;
897
898 impl MaxDustHTLCExposure {
899         #[allow(unused)]
900         pub(crate) fn to_native(&self) -> nativeMaxDustHTLCExposure {
901                 match self {
902                         MaxDustHTLCExposure::FixedLimitMsat (ref a, ) => {
903                                 let mut a_nonref = Clone::clone(a);
904                                 nativeMaxDustHTLCExposure::FixedLimitMsat (
905                                         a_nonref,
906                                 )
907                         },
908                         MaxDustHTLCExposure::FeeRateMultiplier (ref a, ) => {
909                                 let mut a_nonref = Clone::clone(a);
910                                 nativeMaxDustHTLCExposure::FeeRateMultiplier (
911                                         a_nonref,
912                                 )
913                         },
914                 }
915         }
916         #[allow(unused)]
917         pub(crate) fn into_native(self) -> nativeMaxDustHTLCExposure {
918                 match self {
919                         MaxDustHTLCExposure::FixedLimitMsat (mut a, ) => {
920                                 nativeMaxDustHTLCExposure::FixedLimitMsat (
921                                         a,
922                                 )
923                         },
924                         MaxDustHTLCExposure::FeeRateMultiplier (mut a, ) => {
925                                 nativeMaxDustHTLCExposure::FeeRateMultiplier (
926                                         a,
927                                 )
928                         },
929                 }
930         }
931         #[allow(unused)]
932         pub(crate) fn from_native(native: &nativeMaxDustHTLCExposure) -> Self {
933                 match native {
934                         nativeMaxDustHTLCExposure::FixedLimitMsat (ref a, ) => {
935                                 let mut a_nonref = Clone::clone(a);
936                                 MaxDustHTLCExposure::FixedLimitMsat (
937                                         a_nonref,
938                                 )
939                         },
940                         nativeMaxDustHTLCExposure::FeeRateMultiplier (ref a, ) => {
941                                 let mut a_nonref = Clone::clone(a);
942                                 MaxDustHTLCExposure::FeeRateMultiplier (
943                                         a_nonref,
944                                 )
945                         },
946                 }
947         }
948         #[allow(unused)]
949         pub(crate) fn native_into(native: nativeMaxDustHTLCExposure) -> Self {
950                 match native {
951                         nativeMaxDustHTLCExposure::FixedLimitMsat (mut a, ) => {
952                                 MaxDustHTLCExposure::FixedLimitMsat (
953                                         a,
954                                 )
955                         },
956                         nativeMaxDustHTLCExposure::FeeRateMultiplier (mut a, ) => {
957                                 MaxDustHTLCExposure::FeeRateMultiplier (
958                                         a,
959                                 )
960                         },
961                 }
962         }
963 }
964 /// Frees any resources used by the MaxDustHTLCExposure
965 #[no_mangle]
966 pub extern "C" fn MaxDustHTLCExposure_free(this_ptr: MaxDustHTLCExposure) { }
967 /// Creates a copy of the MaxDustHTLCExposure
968 #[no_mangle]
969 pub extern "C" fn MaxDustHTLCExposure_clone(orig: &MaxDustHTLCExposure) -> MaxDustHTLCExposure {
970         orig.clone()
971 }
972 #[no_mangle]
973 /// Utility method to constructs a new FixedLimitMsat-variant MaxDustHTLCExposure
974 pub extern "C" fn MaxDustHTLCExposure_fixed_limit_msat(a: u64) -> MaxDustHTLCExposure {
975         MaxDustHTLCExposure::FixedLimitMsat(a, )
976 }
977 #[no_mangle]
978 /// Utility method to constructs a new FeeRateMultiplier-variant MaxDustHTLCExposure
979 pub extern "C" fn MaxDustHTLCExposure_fee_rate_multiplier(a: u64) -> MaxDustHTLCExposure {
980         MaxDustHTLCExposure::FeeRateMultiplier(a, )
981 }
982 /// Checks if two MaxDustHTLCExposures contain equal inner contents.
983 /// This ignores pointers and is_owned flags and looks at the values in fields.
984 #[no_mangle]
985 pub extern "C" fn MaxDustHTLCExposure_eq(a: &MaxDustHTLCExposure, b: &MaxDustHTLCExposure) -> bool {
986         if &a.to_native() == &b.to_native() { true } else { false }
987 }
988 #[no_mangle]
989 /// Serialize the MaxDustHTLCExposure object into a byte array which can be read by MaxDustHTLCExposure_read
990 pub extern "C" fn MaxDustHTLCExposure_write(obj: &crate::lightning::util::config::MaxDustHTLCExposure) -> crate::c_types::derived::CVec_u8Z {
991         crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
992 }
993 #[no_mangle]
994 /// Read a MaxDustHTLCExposure from a byte array, created by MaxDustHTLCExposure_write
995 pub extern "C" fn MaxDustHTLCExposure_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_MaxDustHTLCExposureDecodeErrorZ {
996         let res: Result<lightning::util::config::MaxDustHTLCExposure, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
997         let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::config::MaxDustHTLCExposure::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() };
998         local_res
999 }
1000
1001 use lightning::util::config::ChannelConfig as nativeChannelConfigImport;
1002 pub(crate) type nativeChannelConfig = nativeChannelConfigImport;
1003
1004 /// Options which apply on a per-channel basis and may change at runtime or based on negotiation
1005 /// with our counterparty.
1006 #[must_use]
1007 #[repr(C)]
1008 pub struct ChannelConfig {
1009         /// A pointer to the opaque Rust object.
1010
1011         /// Nearly everywhere, inner must be non-null, however in places where
1012         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1013         pub inner: *mut nativeChannelConfig,
1014         /// Indicates that this is the only struct which contains the same pointer.
1015
1016         /// Rust functions which take ownership of an object provided via an argument require
1017         /// this to be true and invalidate the object pointed to by inner.
1018         pub is_owned: bool,
1019 }
1020
1021 impl Drop for ChannelConfig {
1022         fn drop(&mut self) {
1023                 if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) {
1024                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1025                 }
1026         }
1027 }
1028 /// Frees any resources used by the ChannelConfig, if is_owned is set and inner is non-NULL.
1029 #[no_mangle]
1030 pub extern "C" fn ChannelConfig_free(this_obj: ChannelConfig) { }
1031 #[allow(unused)]
1032 /// Used only if an object of this type is returned as a trait impl by a method
1033 pub(crate) extern "C" fn ChannelConfig_free_void(this_ptr: *mut c_void) {
1034         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelConfig) };
1035 }
1036 #[allow(unused)]
1037 impl ChannelConfig {
1038         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfig {
1039                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1040         }
1041         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfig {
1042                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1043         }
1044         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1045         pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
1046                 assert!(self.is_owned);
1047                 let ret = ObjOps::untweak_ptr(self.inner);
1048                 self.inner = core::ptr::null_mut();
1049                 ret
1050         }
1051 }
1052 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
1053 /// over the channel.
1054 /// This may be allowed to change at runtime in a later update, however doing so must result in
1055 /// update messages sent to notify all nodes of our updated relay fee.
1056 ///
1057 /// Default value: 0.
1058 #[no_mangle]
1059 pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 {
1060         let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths;
1061         *inner_val
1062 }
1063 /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
1064 /// over the channel.
1065 /// This may be allowed to change at runtime in a later update, however doing so must result in
1066 /// update messages sent to notify all nodes of our updated relay fee.
1067 ///
1068 /// Default value: 0.
1069 #[no_mangle]
1070 pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) {
1071         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = val;
1072 }
1073 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
1074 /// excess of [`forwarding_fee_proportional_millionths`].
1075 /// This may be allowed to change at runtime in a later update, however doing so must result in
1076 /// update messages sent to notify all nodes of our updated relay fee.
1077 ///
1078 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
1079 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
1080 /// this node.
1081 ///
1082 /// Default value: 1000.
1083 ///
1084 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
1085 #[no_mangle]
1086 pub extern "C" fn ChannelConfig_get_forwarding_fee_base_msat(this_ptr: &ChannelConfig) -> u32 {
1087         let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_base_msat;
1088         *inner_val
1089 }
1090 /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
1091 /// excess of [`forwarding_fee_proportional_millionths`].
1092 /// This may be allowed to change at runtime in a later update, however doing so must result in
1093 /// update messages sent to notify all nodes of our updated relay fee.
1094 ///
1095 /// The default value of a single satoshi roughly matches the market rate on many routing nodes
1096 /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
1097 /// this node.
1098 ///
1099 /// Default value: 1000.
1100 ///
1101 /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
1102 #[no_mangle]
1103 pub extern "C" fn ChannelConfig_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfig, mut val: u32) {
1104         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_base_msat = val;
1105 }
1106 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
1107 /// the channel this config applies to.
1108 ///
1109 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
1110 /// HTLC balance when a channel appears on-chain whereas
1111 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
1112 /// (non-HTLC-encumbered) balance.
1113 ///
1114 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
1115 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
1116 /// commitment transaction at least once per this many blocks (minus some margin to allow us
1117 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
1118 /// the spending transaction).
1119 ///
1120 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
1121 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
1122 ///                [`MIN_CLTV_EXPIRY_DELTA`] instead.
1123 ///
1124 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
1125 #[no_mangle]
1126 pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) -> u16 {
1127         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
1128         *inner_val
1129 }
1130 /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
1131 /// the channel this config applies to.
1132 ///
1133 /// This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
1134 /// HTLC balance when a channel appears on-chain whereas
1135 /// [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
1136 /// (non-HTLC-encumbered) balance.
1137 ///
1138 /// Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
1139 /// we (or one of our watchtowers) MUST be online to check for broadcast of the current
1140 /// commitment transaction at least once per this many blocks (minus some margin to allow us
1141 /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF
1142 /// the spending transaction).
1143 ///
1144 /// Default value: 72 (12 hours at an average of 6 blocks/hour).
1145 /// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
1146 ///                [`MIN_CLTV_EXPIRY_DELTA`] instead.
1147 ///
1148 /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
1149 #[no_mangle]
1150 pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) {
1151         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val;
1152 }
1153 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
1154 /// small to claim on-chain.
1155 ///
1156 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
1157 /// not be claimable on-chain, instead being turned into additional miner fees if either
1158 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
1159 /// to such payments may be sustantial if there are many dust HTLCs present when the
1160 /// channel is force-closed.
1161 ///
1162 /// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
1163 /// channel negotiated throughout the channel open process, along with the fees required to have
1164 /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs
1165 /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
1166 /// account the HTLC transaction fee as it is zero. Because of this, you may want to set this
1167 /// value to a fixed limit for channels using anchor outputs, while the fee rate multiplier
1168 /// variant is primarily intended for use with pre-anchor channels.
1169 ///
1170 /// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total
1171 /// exposure across all three types per-channel.
1172 ///
1173 /// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000.
1174 #[no_mangle]
1175 pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure(this_ptr: &ChannelConfig) -> crate::lightning::util::config::MaxDustHTLCExposure {
1176         let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure;
1177         crate::lightning::util::config::MaxDustHTLCExposure::from_native(inner_val)
1178 }
1179 /// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
1180 /// small to claim on-chain.
1181 ///
1182 /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
1183 /// not be claimable on-chain, instead being turned into additional miner fees if either
1184 /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure
1185 /// to such payments may be sustantial if there are many dust HTLCs present when the
1186 /// channel is force-closed.
1187 ///
1188 /// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
1189 /// channel negotiated throughout the channel open process, along with the fees required to have
1190 /// a broadcastable HTLC spending transaction. When a channel supports anchor outputs
1191 /// (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
1192 /// account the HTLC transaction fee as it is zero. Because of this, you may want to set this
1193 /// value to a fixed limit for channels using anchor outputs, while the fee rate multiplier
1194 /// variant is primarily intended for use with pre-anchor channels.
1195 ///
1196 /// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total
1197 /// exposure across all three types per-channel.
1198 ///
1199 /// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000.
1200 #[no_mangle]
1201 pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure(this_ptr: &mut ChannelConfig, mut val: crate::lightning::util::config::MaxDustHTLCExposure) {
1202         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure = val.into_native();
1203 }
1204 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
1205 /// `to_self_delay` to reclaim funds.
1206 ///
1207 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
1208 /// closing transaction which both sides find acceptable, ultimately paid by the channel
1209 /// funder/initiator.
1210 ///
1211 /// When we are the funder, because we have to pay the channel closing fee, we bound the
1212 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
1213 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
1214 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
1215 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
1216 /// funds.
1217 ///
1218 /// When we are not the funder, we require the closing transaction fee pay at least our
1219 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
1220 /// Thus, this value is ignored when we are not the funder.
1221 ///
1222 /// Default value: 1000 satoshis.
1223 ///
1224 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1225 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1226 #[no_mangle]
1227 pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfig) -> u64 {
1228         let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_avoidance_max_fee_satoshis;
1229         *inner_val
1230 }
1231 /// The additional fee we're willing to pay to avoid waiting for the counterparty's
1232 /// `to_self_delay` to reclaim funds.
1233 ///
1234 /// When we close a channel cooperatively with our counterparty, we negotiate a fee for the
1235 /// closing transaction which both sides find acceptable, ultimately paid by the channel
1236 /// funder/initiator.
1237 ///
1238 /// When we are the funder, because we have to pay the channel closing fee, we bound the
1239 /// acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
1240 /// this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
1241 /// [`Normal`] feerate during normal operation, this value represents the additional fee we're
1242 /// willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
1243 /// funds.
1244 ///
1245 /// When we are not the funder, we require the closing transaction fee pay at least our
1246 /// [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
1247 /// Thus, this value is ignored when we are not the funder.
1248 ///
1249 /// Default value: 1000 satoshis.
1250 ///
1251 /// [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
1252 /// [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
1253 #[no_mangle]
1254 pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfig, mut val: u64) {
1255         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = val;
1256 }
1257 /// If set, allows this channel's counterparty to skim an additional fee off this node's inbound
1258 /// HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users.
1259 ///
1260 /// Usage:
1261 /// - The payee will set this option and set its invoice route hints to use [intercept scids]
1262 ///   generated by this channel's counterparty.
1263 /// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
1264 ///   [`forward_intercepted_htlc`] with less than the amount provided in
1265 ///   [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
1266 ///   actual forward amounts is their fee.
1267 ///
1268 /// # Note
1269 /// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is
1270 /// as-expected if this feature is activated, otherwise they may lose money!
1271 /// [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the
1272 /// counterparty.
1273 ///
1274 /// # Note
1275 /// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116.
1276 /// Unsetting this flag between restarts may lead to payment receive failures.
1277 ///
1278 /// Default value: false.
1279 ///
1280 /// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1281 /// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
1282 /// [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
1283 /// [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat
1284 /// [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat
1285 /// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat
1286 #[no_mangle]
1287 pub extern "C" fn ChannelConfig_get_accept_underpaying_htlcs(this_ptr: &ChannelConfig) -> bool {
1288         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_underpaying_htlcs;
1289         *inner_val
1290 }
1291 /// If set, allows this channel's counterparty to skim an additional fee off this node's inbound
1292 /// HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users.
1293 ///
1294 /// Usage:
1295 /// - The payee will set this option and set its invoice route hints to use [intercept scids]
1296 ///   generated by this channel's counterparty.
1297 /// - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
1298 ///   [`forward_intercepted_htlc`] with less than the amount provided in
1299 ///   [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
1300 ///   actual forward amounts is their fee.
1301 ///
1302 /// # Note
1303 /// It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is
1304 /// as-expected if this feature is activated, otherwise they may lose money!
1305 /// [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the
1306 /// counterparty.
1307 ///
1308 /// # Note
1309 /// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116.
1310 /// Unsetting this flag between restarts may lead to payment receive failures.
1311 ///
1312 /// Default value: false.
1313 ///
1314 /// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1315 /// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
1316 /// [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
1317 /// [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat
1318 /// [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat
1319 /// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat
1320 #[no_mangle]
1321 pub extern "C" fn ChannelConfig_set_accept_underpaying_htlcs(this_ptr: &mut ChannelConfig, mut val: bool) {
1322         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_underpaying_htlcs = val;
1323 }
1324 /// Constructs a new ChannelConfig given each field
1325 #[must_use]
1326 #[no_mangle]
1327 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_arg: crate::lightning::util::config::MaxDustHTLCExposure, mut force_close_avoidance_max_fee_satoshis_arg: u64, mut accept_underpaying_htlcs_arg: bool) -> ChannelConfig {
1328         ChannelConfig { inner: ObjOps::heap_alloc(nativeChannelConfig {
1329                 forwarding_fee_proportional_millionths: forwarding_fee_proportional_millionths_arg,
1330                 forwarding_fee_base_msat: forwarding_fee_base_msat_arg,
1331                 cltv_expiry_delta: cltv_expiry_delta_arg,
1332                 max_dust_htlc_exposure: max_dust_htlc_exposure_arg.into_native(),
1333                 force_close_avoidance_max_fee_satoshis: force_close_avoidance_max_fee_satoshis_arg,
1334                 accept_underpaying_htlcs: accept_underpaying_htlcs_arg,
1335         }), is_owned: true }
1336 }
1337 impl Clone for ChannelConfig {
1338         fn clone(&self) -> Self {
1339                 Self {
1340                         inner: if <*mut nativeChannelConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
1341                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1342                         is_owned: true,
1343                 }
1344         }
1345 }
1346 #[allow(unused)]
1347 /// Used only if an object of this type is returned as a trait impl by a method
1348 pub(crate) extern "C" fn ChannelConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
1349         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelConfig)).clone() })) as *mut c_void
1350 }
1351 #[no_mangle]
1352 /// Creates a copy of the ChannelConfig
1353 pub extern "C" fn ChannelConfig_clone(orig: &ChannelConfig) -> ChannelConfig {
1354         orig.clone()
1355 }
1356 /// Checks if two ChannelConfigs contain equal inner contents.
1357 /// This ignores pointers and is_owned flags and looks at the values in fields.
1358 /// Two objects with NULL inner values will be considered "equal" here.
1359 #[no_mangle]
1360 pub extern "C" fn ChannelConfig_eq(a: &ChannelConfig, b: &ChannelConfig) -> bool {
1361         if a.inner == b.inner { return true; }
1362         if a.inner.is_null() || b.inner.is_null() { return false; }
1363         if a.get_native_ref() == b.get_native_ref() { true } else { false }
1364 }
1365 /// Applies the given [`ChannelConfigUpdate`] as a partial update to the [`ChannelConfig`].
1366 #[no_mangle]
1367 pub extern "C" fn ChannelConfig_apply(this_arg: &mut crate::lightning::util::config::ChannelConfig, update: &crate::lightning::util::config::ChannelConfigUpdate) {
1368         unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::util::config::nativeChannelConfig)) }.apply(update.get_native_ref())
1369 }
1370
1371 /// Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
1372 #[must_use]
1373 #[no_mangle]
1374 pub extern "C" fn ChannelConfig_default() -> ChannelConfig {
1375         ChannelConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
1376 }
1377 #[no_mangle]
1378 /// Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
1379 pub extern "C" fn ChannelConfig_write(obj: &crate::lightning::util::config::ChannelConfig) -> crate::c_types::derived::CVec_u8Z {
1380         crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
1381 }
1382 #[no_mangle]
1383 pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
1384         crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) })
1385 }
1386 #[no_mangle]
1387 /// Read a ChannelConfig from a byte array, created by ChannelConfig_write
1388 pub extern "C" fn ChannelConfig_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelConfigDecodeErrorZ {
1389         let res: Result<lightning::util::config::ChannelConfig, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
1390         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() };
1391         local_res
1392 }
1393
1394 use lightning::util::config::ChannelConfigUpdate as nativeChannelConfigUpdateImport;
1395 pub(crate) type nativeChannelConfigUpdate = nativeChannelConfigUpdateImport;
1396
1397 /// A parallel struct to [`ChannelConfig`] to define partial updates.
1398 #[must_use]
1399 #[repr(C)]
1400 pub struct ChannelConfigUpdate {
1401         /// A pointer to the opaque Rust object.
1402
1403         /// Nearly everywhere, inner must be non-null, however in places where
1404         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1405         pub inner: *mut nativeChannelConfigUpdate,
1406         /// Indicates that this is the only struct which contains the same pointer.
1407
1408         /// Rust functions which take ownership of an object provided via an argument require
1409         /// this to be true and invalidate the object pointed to by inner.
1410         pub is_owned: bool,
1411 }
1412
1413 impl Drop for ChannelConfigUpdate {
1414         fn drop(&mut self) {
1415                 if self.is_owned && !<*mut nativeChannelConfigUpdate>::is_null(self.inner) {
1416                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1417                 }
1418         }
1419 }
1420 /// Frees any resources used by the ChannelConfigUpdate, if is_owned is set and inner is non-NULL.
1421 #[no_mangle]
1422 pub extern "C" fn ChannelConfigUpdate_free(this_obj: ChannelConfigUpdate) { }
1423 #[allow(unused)]
1424 /// Used only if an object of this type is returned as a trait impl by a method
1425 pub(crate) extern "C" fn ChannelConfigUpdate_free_void(this_ptr: *mut c_void) {
1426         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelConfigUpdate) };
1427 }
1428 #[allow(unused)]
1429 impl ChannelConfigUpdate {
1430         pub(crate) fn get_native_ref(&self) -> &'static nativeChannelConfigUpdate {
1431                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1432         }
1433         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelConfigUpdate {
1434                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1435         }
1436         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1437         pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfigUpdate {
1438                 assert!(self.is_owned);
1439                 let ret = ObjOps::untweak_ptr(self.inner);
1440                 self.inner = core::ptr::null_mut();
1441                 ret
1442         }
1443 }
1444 #[no_mangle]
1445 pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z {
1446         let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths;
1447         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) };
1448         local_inner_val
1449 }
1450 #[no_mangle]
1451 pub extern "C" fn ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u32Z) {
1452         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1453         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = local_val;
1454 }
1455 #[no_mangle]
1456 pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_base_msat(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z {
1457         let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_base_msat;
1458         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) };
1459         local_inner_val
1460 }
1461 #[no_mangle]
1462 pub extern "C" fn ChannelConfigUpdate_set_forwarding_fee_base_msat(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u32Z) {
1463         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1464         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_base_msat = local_val;
1465 }
1466 #[no_mangle]
1467 pub extern "C" fn ChannelConfigUpdate_get_cltv_expiry_delta(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u16Z {
1468         let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta;
1469         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { inner_val.unwrap() }) };
1470         local_inner_val
1471 }
1472 #[no_mangle]
1473 pub extern "C" fn ChannelConfigUpdate_set_cltv_expiry_delta(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u16Z) {
1474         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1475         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = local_val;
1476 }
1477 ///
1478 /// Returns a copy of the field.
1479 #[no_mangle]
1480 pub extern "C" fn ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_MaxDustHTLCExposureZ {
1481         let mut inner_val = this_ptr.get_native_mut_ref().max_dust_htlc_exposure_msat.clone();
1482         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_MaxDustHTLCExposureZ::None } else { crate::c_types::derived::COption_MaxDustHTLCExposureZ::Some( { crate::lightning::util::config::MaxDustHTLCExposure::native_into(inner_val.unwrap()) }) };
1483         local_inner_val
1484 }
1485 #[no_mangle]
1486 pub extern "C" fn ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_MaxDustHTLCExposureZ) {
1487         let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} };
1488         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure_msat = local_val;
1489 }
1490 #[no_mangle]
1491 pub extern "C" fn ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u64Z {
1492         let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_avoidance_max_fee_satoshis;
1493         let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) };
1494         local_inner_val
1495 }
1496 #[no_mangle]
1497 pub extern "C" fn ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(this_ptr: &mut ChannelConfigUpdate, mut val: crate::c_types::derived::COption_u64Z) {
1498         let mut local_val = if val.is_some() { Some( { val.take() }) } else { None };
1499         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_avoidance_max_fee_satoshis = local_val;
1500 }
1501 /// Constructs a new ChannelConfigUpdate given each field
1502 #[must_use]
1503 #[no_mangle]
1504 pub extern "C" fn ChannelConfigUpdate_new(mut forwarding_fee_proportional_millionths_arg: crate::c_types::derived::COption_u32Z, mut forwarding_fee_base_msat_arg: crate::c_types::derived::COption_u32Z, mut cltv_expiry_delta_arg: crate::c_types::derived::COption_u16Z, mut max_dust_htlc_exposure_msat_arg: crate::c_types::derived::COption_MaxDustHTLCExposureZ, mut force_close_avoidance_max_fee_satoshis_arg: crate::c_types::derived::COption_u64Z) -> ChannelConfigUpdate {
1505         let mut local_forwarding_fee_proportional_millionths_arg = if forwarding_fee_proportional_millionths_arg.is_some() { Some( { forwarding_fee_proportional_millionths_arg.take() }) } else { None };
1506         let mut local_forwarding_fee_base_msat_arg = if forwarding_fee_base_msat_arg.is_some() { Some( { forwarding_fee_base_msat_arg.take() }) } else { None };
1507         let mut local_cltv_expiry_delta_arg = if cltv_expiry_delta_arg.is_some() { Some( { cltv_expiry_delta_arg.take() }) } else { None };
1508         let mut local_max_dust_htlc_exposure_msat_arg = { /*max_dust_htlc_exposure_msat_arg*/ let max_dust_htlc_exposure_msat_arg_opt = max_dust_htlc_exposure_msat_arg; if max_dust_htlc_exposure_msat_arg_opt.is_none() { None } else { Some({ { { max_dust_htlc_exposure_msat_arg_opt.take() }.into_native() }})} };
1509         let mut local_force_close_avoidance_max_fee_satoshis_arg = if force_close_avoidance_max_fee_satoshis_arg.is_some() { Some( { force_close_avoidance_max_fee_satoshis_arg.take() }) } else { None };
1510         ChannelConfigUpdate { inner: ObjOps::heap_alloc(nativeChannelConfigUpdate {
1511                 forwarding_fee_proportional_millionths: local_forwarding_fee_proportional_millionths_arg,
1512                 forwarding_fee_base_msat: local_forwarding_fee_base_msat_arg,
1513                 cltv_expiry_delta: local_cltv_expiry_delta_arg,
1514                 max_dust_htlc_exposure_msat: local_max_dust_htlc_exposure_msat_arg,
1515                 force_close_avoidance_max_fee_satoshis: local_force_close_avoidance_max_fee_satoshis_arg,
1516         }), is_owned: true }
1517 }
1518 /// Creates a "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used.
1519 #[must_use]
1520 #[no_mangle]
1521 pub extern "C" fn ChannelConfigUpdate_default() -> ChannelConfigUpdate {
1522         ChannelConfigUpdate { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
1523 }
1524
1525 use lightning::util::config::UserConfig as nativeUserConfigImport;
1526 pub(crate) type nativeUserConfig = nativeUserConfigImport;
1527
1528 /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
1529 ///
1530 /// Default::default() provides sane defaults for most configurations
1531 /// (but currently with 0 relay fees!)
1532 #[must_use]
1533 #[repr(C)]
1534 pub struct UserConfig {
1535         /// A pointer to the opaque Rust object.
1536
1537         /// Nearly everywhere, inner must be non-null, however in places where
1538         /// the Rust equivalent takes an Option, it may be set to null to indicate None.
1539         pub inner: *mut nativeUserConfig,
1540         /// Indicates that this is the only struct which contains the same pointer.
1541
1542         /// Rust functions which take ownership of an object provided via an argument require
1543         /// this to be true and invalidate the object pointed to by inner.
1544         pub is_owned: bool,
1545 }
1546
1547 impl Drop for UserConfig {
1548         fn drop(&mut self) {
1549                 if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) {
1550                         let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
1551                 }
1552         }
1553 }
1554 /// Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL.
1555 #[no_mangle]
1556 pub extern "C" fn UserConfig_free(this_obj: UserConfig) { }
1557 #[allow(unused)]
1558 /// Used only if an object of this type is returned as a trait impl by a method
1559 pub(crate) extern "C" fn UserConfig_free_void(this_ptr: *mut c_void) {
1560         let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUserConfig) };
1561 }
1562 #[allow(unused)]
1563 impl UserConfig {
1564         pub(crate) fn get_native_ref(&self) -> &'static nativeUserConfig {
1565                 unsafe { &*ObjOps::untweak_ptr(self.inner) }
1566         }
1567         pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUserConfig {
1568                 unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
1569         }
1570         /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
1571         pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
1572                 assert!(self.is_owned);
1573                 let ret = ObjOps::untweak_ptr(self.inner);
1574                 self.inner = core::ptr::null_mut();
1575                 ret
1576         }
1577 }
1578 /// Channel handshake config that we propose to our counterparty.
1579 #[no_mangle]
1580 pub extern "C" fn UserConfig_get_channel_handshake_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeConfig {
1581         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_handshake_config;
1582         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 }
1583 }
1584 /// Channel handshake config that we propose to our counterparty.
1585 #[no_mangle]
1586 pub extern "C" fn UserConfig_set_channel_handshake_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeConfig) {
1587         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_handshake_config = *unsafe { Box::from_raw(val.take_inner()) };
1588 }
1589 /// Limits applied to our counterparty's proposed channel handshake config settings.
1590 #[no_mangle]
1591 pub extern "C" fn UserConfig_get_channel_handshake_limits(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelHandshakeLimits {
1592         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_handshake_limits;
1593         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 }
1594 }
1595 /// Limits applied to our counterparty's proposed channel handshake config settings.
1596 #[no_mangle]
1597 pub extern "C" fn UserConfig_set_channel_handshake_limits(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelHandshakeLimits) {
1598         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_handshake_limits = *unsafe { Box::from_raw(val.take_inner()) };
1599 }
1600 /// Channel config which affects behavior during channel lifetime.
1601 #[no_mangle]
1602 pub extern "C" fn UserConfig_get_channel_config(this_ptr: &UserConfig) -> crate::lightning::util::config::ChannelConfig {
1603         let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_config;
1604         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 }
1605 }
1606 /// Channel config which affects behavior during channel lifetime.
1607 #[no_mangle]
1608 pub extern "C" fn UserConfig_set_channel_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelConfig) {
1609         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_config = *unsafe { Box::from_raw(val.take_inner()) };
1610 }
1611 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
1612 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
1613 /// node which is not online reliably.
1614 ///
1615 /// For nodes which are not online reliably, you should set all channels to *not* be announced
1616 /// (using [`ChannelHandshakeConfig::announced_channel`] and
1617 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
1618 /// ensure you are not exposed to any forwarding risk.
1619 ///
1620 /// Note that because you cannot change a channel's announced state after creation, there is no
1621 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
1622 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
1623 /// all your channels and open new ones. For privacy, you should also change your node_id
1624 /// (swapping all private and public key material for new ones) at that time.
1625 ///
1626 /// Default value: false.
1627 #[no_mangle]
1628 pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &UserConfig) -> bool {
1629         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_forwards_to_priv_channels;
1630         *inner_val
1631 }
1632 /// If this is set to false, we will reject any HTLCs which were to be forwarded over private
1633 /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
1634 /// node which is not online reliably.
1635 ///
1636 /// For nodes which are not online reliably, you should set all channels to *not* be announced
1637 /// (using [`ChannelHandshakeConfig::announced_channel`] and
1638 /// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
1639 /// ensure you are not exposed to any forwarding risk.
1640 ///
1641 /// Note that because you cannot change a channel's announced state after creation, there is no
1642 /// way to disable forwarding on public channels retroactively. Thus, in order to change a node
1643 /// from a publicly-announced forwarding node to a private non-forwarding node you must close
1644 /// all your channels and open new ones. For privacy, you should also change your node_id
1645 /// (swapping all private and public key material for new ones) at that time.
1646 ///
1647 /// Default value: false.
1648 #[no_mangle]
1649 pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) {
1650         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_forwards_to_priv_channels = val;
1651 }
1652 /// If this is set to false, we do not accept inbound requests to open a new channel.
1653 /// Default value: true.
1654 #[no_mangle]
1655 pub extern "C" fn UserConfig_get_accept_inbound_channels(this_ptr: &UserConfig) -> bool {
1656         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_inbound_channels;
1657         *inner_val
1658 }
1659 /// If this is set to false, we do not accept inbound requests to open a new channel.
1660 /// Default value: true.
1661 #[no_mangle]
1662 pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
1663         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_inbound_channels = val;
1664 }
1665 /// If this is set to true, the user needs to manually accept inbound requests to open a new
1666 /// channel.
1667 ///
1668 /// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
1669 /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
1670 /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
1671 /// user explicitly chooses to accept the request.
1672 ///
1673 /// Default value: false.
1674 ///
1675 /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
1676 /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
1677 /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
1678 #[no_mangle]
1679 pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &UserConfig) -> bool {
1680         let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_accept_inbound_channels;
1681         *inner_val
1682 }
1683 /// If this is set to true, the user needs to manually accept inbound requests to open a new
1684 /// channel.
1685 ///
1686 /// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
1687 /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
1688 /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
1689 /// user explicitly chooses to accept the request.
1690 ///
1691 /// Default value: false.
1692 ///
1693 /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest
1694 /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
1695 /// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
1696 #[no_mangle]
1697 pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) {
1698         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_accept_inbound_channels = val;
1699 }
1700 ///  If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
1701 ///  fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
1702 ///  intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
1703 ///
1704 ///  Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
1705 ///
1706 ///  Default value: false.
1707 ///
1708 /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1709 /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
1710 #[no_mangle]
1711 pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) -> bool {
1712         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_intercept_htlcs;
1713         *inner_val
1714 }
1715 ///  If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
1716 ///  fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
1717 ///  intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
1718 ///
1719 ///  Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
1720 ///
1721 ///  Default value: false.
1722 ///
1723 /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
1724 /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
1725 #[no_mangle]
1726 pub extern "C" fn UserConfig_set_accept_intercept_htlcs(this_ptr: &mut UserConfig, mut val: bool) {
1727         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_intercept_htlcs = val;
1728 }
1729 /// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple
1730 /// parts. If this is set to true, we'll accept the payment.
1731 ///
1732 /// Setting this to true will break backwards compatibility upon downgrading to an LDK
1733 /// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP
1734 /// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`].
1735 ///
1736 /// Default value: false.
1737 ///
1738 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1739 #[no_mangle]
1740 pub extern "C" fn UserConfig_get_accept_mpp_keysend(this_ptr: &UserConfig) -> bool {
1741         let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_mpp_keysend;
1742         *inner_val
1743 }
1744 /// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple
1745 /// parts. If this is set to true, we'll accept the payment.
1746 ///
1747 /// Setting this to true will break backwards compatibility upon downgrading to an LDK
1748 /// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP
1749 /// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`].
1750 ///
1751 /// Default value: false.
1752 ///
1753 /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
1754 #[no_mangle]
1755 pub extern "C" fn UserConfig_set_accept_mpp_keysend(this_ptr: &mut UserConfig, mut val: bool) {
1756         unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_mpp_keysend = val;
1757 }
1758 /// Constructs a new UserConfig given each field
1759 #[must_use]
1760 #[no_mangle]
1761 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, mut accept_mpp_keysend_arg: bool) -> UserConfig {
1762         UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig {
1763                 channel_handshake_config: *unsafe { Box::from_raw(channel_handshake_config_arg.take_inner()) },
1764                 channel_handshake_limits: *unsafe { Box::from_raw(channel_handshake_limits_arg.take_inner()) },
1765                 channel_config: *unsafe { Box::from_raw(channel_config_arg.take_inner()) },
1766                 accept_forwards_to_priv_channels: accept_forwards_to_priv_channels_arg,
1767                 accept_inbound_channels: accept_inbound_channels_arg,
1768                 manually_accept_inbound_channels: manually_accept_inbound_channels_arg,
1769                 accept_intercept_htlcs: accept_intercept_htlcs_arg,
1770                 accept_mpp_keysend: accept_mpp_keysend_arg,
1771         }), is_owned: true }
1772 }
1773 impl Clone for UserConfig {
1774         fn clone(&self) -> Self {
1775                 Self {
1776                         inner: if <*mut nativeUserConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
1777                                 ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
1778                         is_owned: true,
1779                 }
1780         }
1781 }
1782 #[allow(unused)]
1783 /// Used only if an object of this type is returned as a trait impl by a method
1784 pub(crate) extern "C" fn UserConfig_clone_void(this_ptr: *const c_void) -> *mut c_void {
1785         Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUserConfig)).clone() })) as *mut c_void
1786 }
1787 #[no_mangle]
1788 /// Creates a copy of the UserConfig
1789 pub extern "C" fn UserConfig_clone(orig: &UserConfig) -> UserConfig {
1790         orig.clone()
1791 }
1792 /// Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
1793 #[must_use]
1794 #[no_mangle]
1795 pub extern "C" fn UserConfig_default() -> UserConfig {
1796         UserConfig { inner: ObjOps::heap_alloc(Default::default()), is_owned: true }
1797 }