1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Configuration we set when applicable.
14 * Default::default() provides sane defaults.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ChannelHandshakeConfig extends CommonBase {
18 ChannelHandshakeConfig(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.ChannelHandshakeConfig_free(ptr); }
26 * Confirmations we will wait for before considering the channel locked in.
27 * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
28 * equivalent limit applied to outbound channels).
30 * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment
31 * transaction before operation. If you wish to accept channels with zero confirmations, see
32 * [`UserConfig::manually_accept_inbound_channels`] and
33 * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`].
37 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
38 * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf
40 public int get_minimum_depth() {
41 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
42 Reference.reachabilityFence(this);
47 * Confirmations we will wait for before considering the channel locked in.
48 * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
49 * equivalent limit applied to outbound channels).
51 * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment
52 * transaction before operation. If you wish to accept channels with zero confirmations, see
53 * [`UserConfig::manually_accept_inbound_channels`] and
54 * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`].
58 * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
59 * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf
61 public void set_minimum_depth(int val) {
62 bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(val);
68 * Set to the number of blocks we require our counterparty to wait to claim their money (ie
69 * the number of blocks we have to punish our counterparty if they broadcast a revoked
72 * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
73 * be online to check for revoked transactions on-chain at least once every our_to_self_delay
74 * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
75 * possibly with time in between to RBF the spending transaction).
77 * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
78 * case of an honest unilateral channel close, which implicitly decrease the economic value of
81 * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
82 * can tweak config to ask for more security, not less.
84 public short get_our_to_self_delay() {
85 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
86 Reference.reachabilityFence(this);
91 * Set to the number of blocks we require our counterparty to wait to claim their money (ie
92 * the number of blocks we have to punish our counterparty if they broadcast a revoked
95 * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
96 * be online to check for revoked transactions on-chain at least once every our_to_self_delay
97 * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
98 * possibly with time in between to RBF the spending transaction).
100 * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
101 * case of an honest unilateral channel close, which implicitly decrease the economic value of
104 * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
105 * can tweak config to ask for more security, not less.
107 public void set_our_to_self_delay(short val) {
108 bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val);
109 Reference.reachabilityFence(this);
110 Reference.reachabilityFence(val);
114 * Set to the smallest value HTLC we will accept to process.
116 * This value is sent to our counterparty on channel-open and we close the channel any time
117 * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
119 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
122 public long get_our_htlc_minimum_msat() {
123 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
124 Reference.reachabilityFence(this);
129 * Set to the smallest value HTLC we will accept to process.
131 * This value is sent to our counterparty on channel-open and we close the channel any time
132 * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
134 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
137 public void set_our_htlc_minimum_msat(long val) {
138 bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val);
139 Reference.reachabilityFence(this);
140 Reference.reachabilityFence(val);
144 * Sets the percentage of the channel value we will cap the total value of outstanding inbound
147 * This can be set to a value between 1-100, where the value corresponds to the percent of the
148 * channel value in whole percentages.
151 * If configured to another value than the default value 10, any new channels created with
152 * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the
155 * This caps the total value for inbound HTLCs in-flight only, and there's currently
156 * no way to configure the cap for the total value of outbound HTLCs in-flight.
158 * The requirements for your node being online to ensure the safety of HTLC-encumbered funds
159 * are different from the non-HTLC-encumbered funds. This makes this an important knob to
160 * restrict exposure to loss due to being offline for too long.
161 * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`]
162 * for more information.
165 * Minimum value: 1, any values less than 1 will be treated as 1 instead.
166 * Maximum value: 100, any values larger than 100 will be treated as 100 instead.
168 public byte get_max_inbound_htlc_value_in_flight_percent_of_channel() {
169 byte ret = bindings.ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(this.ptr);
170 Reference.reachabilityFence(this);
175 * Sets the percentage of the channel value we will cap the total value of outstanding inbound
178 * This can be set to a value between 1-100, where the value corresponds to the percent of the
179 * channel value in whole percentages.
182 * If configured to another value than the default value 10, any new channels created with
183 * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the
186 * This caps the total value for inbound HTLCs in-flight only, and there's currently
187 * no way to configure the cap for the total value of outbound HTLCs in-flight.
189 * The requirements for your node being online to ensure the safety of HTLC-encumbered funds
190 * are different from the non-HTLC-encumbered funds. This makes this an important knob to
191 * restrict exposure to loss due to being offline for too long.
192 * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`]
193 * for more information.
196 * Minimum value: 1, any values less than 1 will be treated as 1 instead.
197 * Maximum value: 100, any values larger than 100 will be treated as 100 instead.
199 public void set_max_inbound_htlc_value_in_flight_percent_of_channel(byte val) {
200 bindings.ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(this.ptr, val);
201 Reference.reachabilityFence(this);
202 Reference.reachabilityFence(val);
206 * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
207 * BOLTs) option for outbound private channels. This provides better privacy by not including
208 * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
209 * relay HTLCs to us using the channel's SCID alias.
211 * If this option is set, channels may be created that will not be readable by LDK versions
212 * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
213 * [`DecodeError::InvalidValue`].
215 * Note that setting this to true does *not* prevent us from opening channels with
216 * counterparties that do not support the `scid_alias` option; we will simply fall back to a
217 * private channel without that option.
219 * Ignored if the channel is negotiated to be announced, see
220 * [`ChannelHandshakeConfig::announced_channel`] and
221 * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
223 * Default value: false. This value is likely to change to true in the future.
225 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
226 * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
228 public boolean get_negotiate_scid_privacy() {
229 boolean ret = bindings.ChannelHandshakeConfig_get_negotiate_scid_privacy(this.ptr);
230 Reference.reachabilityFence(this);
235 * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
236 * BOLTs) option for outbound private channels. This provides better privacy by not including
237 * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
238 * relay HTLCs to us using the channel's SCID alias.
240 * If this option is set, channels may be created that will not be readable by LDK versions
241 * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
242 * [`DecodeError::InvalidValue`].
244 * Note that setting this to true does *not* prevent us from opening channels with
245 * counterparties that do not support the `scid_alias` option; we will simply fall back to a
246 * private channel without that option.
248 * Ignored if the channel is negotiated to be announced, see
249 * [`ChannelHandshakeConfig::announced_channel`] and
250 * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
252 * Default value: false. This value is likely to change to true in the future.
254 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
255 * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
257 public void set_negotiate_scid_privacy(boolean val) {
258 bindings.ChannelHandshakeConfig_set_negotiate_scid_privacy(this.ptr, val);
259 Reference.reachabilityFence(this);
260 Reference.reachabilityFence(val);
264 * Set to announce the channel publicly and notify all nodes that they can route via this
267 * This should only be set to true for nodes which expect to be online reliably.
269 * As the node which funds a channel picks this value this will only apply for new outbound
270 * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
272 * Default value: false.
274 public boolean get_announced_channel() {
275 boolean ret = bindings.ChannelHandshakeConfig_get_announced_channel(this.ptr);
276 Reference.reachabilityFence(this);
281 * Set to announce the channel publicly and notify all nodes that they can route via this
284 * This should only be set to true for nodes which expect to be online reliably.
286 * As the node which funds a channel picks this value this will only apply for new outbound
287 * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
289 * Default value: false.
291 public void set_announced_channel(boolean val) {
292 bindings.ChannelHandshakeConfig_set_announced_channel(this.ptr, val);
293 Reference.reachabilityFence(this);
294 Reference.reachabilityFence(val);
298 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
299 * supports it, they will then enforce the mutual-close output to us matches what we provided
300 * at intialization, preventing us from closing to an alternate pubkey.
302 * This is set to true by default to provide a slight increase in security, though ultimately
303 * any attacker who is able to take control of a channel can just as easily send the funds via
304 * lightning payments, so we never require that our counterparties support this option.
306 * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
308 * Default value: true.
310 * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
312 public boolean get_commit_upfront_shutdown_pubkey() {
313 boolean ret = bindings.ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
314 Reference.reachabilityFence(this);
319 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
320 * supports it, they will then enforce the mutual-close output to us matches what we provided
321 * at intialization, preventing us from closing to an alternate pubkey.
323 * This is set to true by default to provide a slight increase in security, though ultimately
324 * any attacker who is able to take control of a channel can just as easily send the funds via
325 * lightning payments, so we never require that our counterparties support this option.
327 * The upfront key committed is provided from [`KeysInterface::get_shutdown_scriptpubkey`].
329 * Default value: true.
331 * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey
333 public void set_commit_upfront_shutdown_pubkey(boolean val) {
334 bindings.ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
335 Reference.reachabilityFence(this);
336 Reference.reachabilityFence(val);
340 * Constructs a new ChannelHandshakeConfig given each field
342 public static ChannelHandshakeConfig of(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg, byte max_inbound_htlc_value_in_flight_percent_of_channel_arg, boolean negotiate_scid_privacy_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) {
343 long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
344 Reference.reachabilityFence(minimum_depth_arg);
345 Reference.reachabilityFence(our_to_self_delay_arg);
346 Reference.reachabilityFence(our_htlc_minimum_msat_arg);
347 Reference.reachabilityFence(max_inbound_htlc_value_in_flight_percent_of_channel_arg);
348 Reference.reachabilityFence(negotiate_scid_privacy_arg);
349 Reference.reachabilityFence(announced_channel_arg);
350 Reference.reachabilityFence(commit_upfront_shutdown_pubkey_arg);
351 if (ret >= 0 && ret <= 4096) { return null; }
352 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
353 ret_hu_conv.ptrs_to.add(ret_hu_conv);
358 long ret = bindings.ChannelHandshakeConfig_clone_ptr(this.ptr);
359 Reference.reachabilityFence(this);
364 * Creates a copy of the ChannelHandshakeConfig
366 public ChannelHandshakeConfig clone() {
367 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
368 Reference.reachabilityFence(this);
369 if (ret >= 0 && ret <= 4096) { return null; }
370 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
371 ret_hu_conv.ptrs_to.add(this);
376 * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
378 public static ChannelHandshakeConfig with_default() {
379 long ret = bindings.ChannelHandshakeConfig_default();
380 if (ret >= 0 && ret <= 4096) { return null; }
381 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
382 ret_hu_conv.ptrs_to.add(ret_hu_conv);