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).
32 public int get_minimum_depth() {
33 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
34 Reference.reachabilityFence(this);
39 * Confirmations we will wait for before considering the channel locked in.
40 * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
41 * equivalent limit applied to outbound channels).
45 public void set_minimum_depth(int val) {
46 bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val);
47 Reference.reachabilityFence(this);
48 Reference.reachabilityFence(val);
52 * Set to the number of blocks we require our counterparty to wait to claim their money (ie
53 * the number of blocks we have to punish our counterparty if they broadcast a revoked
56 * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
57 * be online to check for revoked transactions on-chain at least once every our_to_self_delay
58 * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
59 * possibly with time in between to RBF the spending transaction).
61 * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
62 * case of an honest unilateral channel close, which implicitly decrease the economic value of
65 * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
66 * can tweak config to ask for more security, not less.
68 public short get_our_to_self_delay() {
69 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
70 Reference.reachabilityFence(this);
75 * Set to the number of blocks we require our counterparty to wait to claim their money (ie
76 * the number of blocks we have to punish our counterparty if they broadcast a revoked
79 * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
80 * be online to check for revoked transactions on-chain at least once every our_to_self_delay
81 * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
82 * possibly with time in between to RBF the spending transaction).
84 * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
85 * case of an honest unilateral channel close, which implicitly decrease the economic value of
88 * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
89 * can tweak config to ask for more security, not less.
91 public void set_our_to_self_delay(short val) {
92 bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * Set to the smallest value HTLC we will accept to process.
100 * This value is sent to our counterparty on channel-open and we close the channel any time
101 * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
103 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
106 public long get_our_htlc_minimum_msat() {
107 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
108 Reference.reachabilityFence(this);
113 * Set to the smallest value HTLC we will accept to process.
115 * This value is sent to our counterparty on channel-open and we close the channel any time
116 * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
118 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
121 public void set_our_htlc_minimum_msat(long val) {
122 bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val);
123 Reference.reachabilityFence(this);
124 Reference.reachabilityFence(val);
128 * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
129 * BOLTs) option for outbound private channels. This provides better privacy by not including
130 * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
131 * relay HTLCs to us using the channel's SCID alias.
133 * If this option is set, channels may be created that will not be readable by LDK versions
134 * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
135 * [`DecodeError:InvalidValue`].
137 * Note that setting this to true does *not* prevent us from opening channels with
138 * counterparties that do not support the `scid_alias` option; we will simply fall back to a
139 * private channel without that option.
141 * Ignored if the channel is negotiated to be announced, see
142 * [`ChannelConfig::announced_channel`] and
143 * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
145 * Default value: false. This value is likely to change to true in the future.
147 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
148 * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
150 public boolean get_negotiate_scid_privacy() {
151 boolean ret = bindings.ChannelHandshakeConfig_get_negotiate_scid_privacy(this.ptr);
152 Reference.reachabilityFence(this);
157 * If set, we attempt to negotiate the `scid_privacy` (referred to as `scid_alias` in the
158 * BOLTs) option for outbound private channels. This provides better privacy by not including
159 * our real on-chain channel UTXO in each invoice and requiring that our counterparty only
160 * relay HTLCs to us using the channel's SCID alias.
162 * If this option is set, channels may be created that will not be readable by LDK versions
163 * prior to 0.0.106, causing [`ChannelManager`]'s read method to return a
164 * [`DecodeError:InvalidValue`].
166 * Note that setting this to true does *not* prevent us from opening channels with
167 * counterparties that do not support the `scid_alias` option; we will simply fall back to a
168 * private channel without that option.
170 * Ignored if the channel is negotiated to be announced, see
171 * [`ChannelConfig::announced_channel`] and
172 * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more.
174 * Default value: false. This value is likely to change to true in the future.
176 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
177 * [`DecodeError:InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue
179 public void set_negotiate_scid_privacy(boolean val) {
180 bindings.ChannelHandshakeConfig_set_negotiate_scid_privacy(this.ptr, val);
181 Reference.reachabilityFence(this);
182 Reference.reachabilityFence(val);
186 * Constructs a new ChannelHandshakeConfig given each field
188 public static ChannelHandshakeConfig of(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg, boolean negotiate_scid_privacy_arg) {
189 long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
190 Reference.reachabilityFence(minimum_depth_arg);
191 Reference.reachabilityFence(our_to_self_delay_arg);
192 Reference.reachabilityFence(our_htlc_minimum_msat_arg);
193 Reference.reachabilityFence(negotiate_scid_privacy_arg);
194 if (ret >= 0 && ret <= 4096) { return null; }
195 ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
196 ret_hu_conv.ptrs_to.add(ret_hu_conv);
201 long ret = bindings.ChannelHandshakeConfig_clone_ptr(this.ptr);
202 Reference.reachabilityFence(this);
207 * Creates a copy of the ChannelHandshakeConfig
209 public ChannelHandshakeConfig clone() {
210 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
211 Reference.reachabilityFence(this);
212 if (ret >= 0 && ret <= 4096) { return null; }
213 ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
214 ret_hu_conv.ptrs_to.add(this);
219 * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
221 public static ChannelHandshakeConfig with_default() {
222 long ret = bindings.ChannelHandshakeConfig_default();
223 if (ret >= 0 && ret <= 4096) { return null; }
224 ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
225 ret_hu_conv.ptrs_to.add(ret_hu_conv);