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 * Optional channel limits which are applied during channel creation.
14 * These limits are only applied to our counterparty's limits, not our own.
16 * Use 0/<type>::max_value() as appropriate to skip checking.
18 * Provides sane defaults for most configurations.
20 * Most additional limits are disabled except those with which specify a default in individual
21 * field documentation. Note that this may result in barely-usable channels, but since they
22 * are applied mostly only to incoming channels that's not much of a problem.
24 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
25 public class ChannelHandshakeLimits extends CommonBase {
26 ChannelHandshakeLimits(Object _dummy, long ptr) { super(ptr); }
27 @Override @SuppressWarnings("deprecation")
28 protected void finalize() throws Throwable {
30 if (ptr != 0) { bindings.ChannelHandshakeLimits_free(ptr); }
34 * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
35 * only applies to inbound channels.
39 public long get_min_funding_satoshis() {
40 long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr);
41 Reference.reachabilityFence(this);
46 * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
47 * only applies to inbound channels.
51 public void set_min_funding_satoshis(long val) {
52 bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val);
53 Reference.reachabilityFence(this);
54 Reference.reachabilityFence(val);
58 * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
59 * only applies to inbound channels.
61 * Default value: 2^24 - 1.
63 public long get_max_funding_satoshis() {
64 long ret = bindings.ChannelHandshakeLimits_get_max_funding_satoshis(this.ptr);
65 Reference.reachabilityFence(this);
70 * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
71 * only applies to inbound channels.
73 * Default value: 2^24 - 1.
75 public void set_max_funding_satoshis(long val) {
76 bindings.ChannelHandshakeLimits_set_max_funding_satoshis(this.ptr, val);
77 Reference.reachabilityFence(this);
78 Reference.reachabilityFence(val);
82 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
83 * you to limit the maximum minimum-size they can require.
85 * Default value: u64::max_value.
87 public long get_max_htlc_minimum_msat() {
88 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
89 Reference.reachabilityFence(this);
94 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
95 * you to limit the maximum minimum-size they can require.
97 * Default value: u64::max_value.
99 public void set_max_htlc_minimum_msat(long val) {
100 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
101 Reference.reachabilityFence(this);
102 Reference.reachabilityFence(val);
106 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
107 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
111 public long get_min_max_htlc_value_in_flight_msat() {
112 long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr);
113 Reference.reachabilityFence(this);
118 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
119 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
123 public void set_min_max_htlc_value_in_flight_msat(long val) {
124 bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val);
125 Reference.reachabilityFence(this);
126 Reference.reachabilityFence(val);
130 * The remote node will require we keep a certain amount in direct payment to ourselves at all
131 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
132 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
134 * Default value: u64::max_value.
136 public long get_max_channel_reserve_satoshis() {
137 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
138 Reference.reachabilityFence(this);
143 * The remote node will require we keep a certain amount in direct payment to ourselves at all
144 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
145 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
147 * Default value: u64::max_value.
149 public void set_max_channel_reserve_satoshis(long val) {
150 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
151 Reference.reachabilityFence(this);
152 Reference.reachabilityFence(val);
156 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
157 * time. This allows you to set a minimum such value.
161 public short get_min_max_accepted_htlcs() {
162 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
163 Reference.reachabilityFence(this);
168 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
169 * time. This allows you to set a minimum such value.
173 public void set_min_max_accepted_htlcs(short val) {
174 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
175 Reference.reachabilityFence(this);
176 Reference.reachabilityFence(val);
180 * Before a channel is usable the funding transaction will need to be confirmed by at least a
181 * certain number of blocks, specified by the node which is not the funder (as the funder can
182 * assume they aren't going to double-spend themselves).
183 * This config allows you to set a limit on the maximum amount of time to wait.
185 * Default value: 144, or roughly one day and only applies to outbound channels.
187 public int get_max_minimum_depth() {
188 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
189 Reference.reachabilityFence(this);
194 * Before a channel is usable the funding transaction will need to be confirmed by at least a
195 * certain number of blocks, specified by the node which is not the funder (as the funder can
196 * assume they aren't going to double-spend themselves).
197 * This config allows you to set a limit on the maximum amount of time to wait.
199 * Default value: 144, or roughly one day and only applies to outbound channels.
201 public void set_max_minimum_depth(int val) {
202 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
203 Reference.reachabilityFence(this);
204 Reference.reachabilityFence(val);
208 * Whether we implicitly trust funding transactions generated by us for our own outbound
209 * channels to not be double-spent.
211 * If this is set, we assume that our own funding transactions are *never* double-spent, and
212 * thus we can trust them without any confirmations. This is generally a reasonable
213 * assumption, given we're the only ones who could ever double-spend it (assuming we have sole
214 * control of the signing keys).
216 * You may wish to un-set this if you allow the user to (or do in an automated fashion)
217 * double-spend the funding transaction to RBF with an alternative channel open.
219 * This only applies if our counterparty set their confirmations-required value to 0, and we
220 * always trust our own funding transaction at 1 confirmation irrespective of this value.
221 * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
222 * `true` (0) and `false` (1).
224 * Default value: true
226 public boolean get_trust_own_funding_0conf() {
227 boolean ret = bindings.ChannelHandshakeLimits_get_trust_own_funding_0conf(this.ptr);
228 Reference.reachabilityFence(this);
233 * Whether we implicitly trust funding transactions generated by us for our own outbound
234 * channels to not be double-spent.
236 * If this is set, we assume that our own funding transactions are *never* double-spent, and
237 * thus we can trust them without any confirmations. This is generally a reasonable
238 * assumption, given we're the only ones who could ever double-spend it (assuming we have sole
239 * control of the signing keys).
241 * You may wish to un-set this if you allow the user to (or do in an automated fashion)
242 * double-spend the funding transaction to RBF with an alternative channel open.
244 * This only applies if our counterparty set their confirmations-required value to 0, and we
245 * always trust our own funding transaction at 1 confirmation irrespective of this value.
246 * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
247 * `true` (0) and `false` (1).
249 * Default value: true
251 public void set_trust_own_funding_0conf(boolean val) {
252 bindings.ChannelHandshakeLimits_set_trust_own_funding_0conf(this.ptr, val);
253 Reference.reachabilityFence(this);
254 Reference.reachabilityFence(val);
258 * Set to force an incoming channel to match our announced channel preference in
259 * [`ChannelHandshakeConfig::announced_channel`].
261 * For a node which is not online reliably, this should be set to true and
262 * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
263 * channels will ever be opened.
265 * Default value: true.
267 public boolean get_force_announced_channel_preference() {
268 boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
269 Reference.reachabilityFence(this);
274 * Set to force an incoming channel to match our announced channel preference in
275 * [`ChannelHandshakeConfig::announced_channel`].
277 * For a node which is not online reliably, this should be set to true and
278 * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
279 * channels will ever be opened.
281 * Default value: true.
283 public void set_force_announced_channel_preference(boolean val) {
284 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
285 Reference.reachabilityFence(this);
286 Reference.reachabilityFence(val);
290 * Set to the amount of time we're willing to wait to claim money back to us.
292 * Not checking this value would be a security issue, as our peer would be able to set it to
293 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
295 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
296 * reduce the loss of having useless locked funds (if your peer accepts)
298 public short get_their_to_self_delay() {
299 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
300 Reference.reachabilityFence(this);
305 * Set to the amount of time we're willing to wait to claim money back to us.
307 * Not checking this value would be a security issue, as our peer would be able to set it to
308 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
310 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
311 * reduce the loss of having useless locked funds (if your peer accepts)
313 public void set_their_to_self_delay(short val) {
314 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
315 Reference.reachabilityFence(this);
316 Reference.reachabilityFence(val);
320 * Constructs a new ChannelHandshakeLimits given each field
322 public static ChannelHandshakeLimits of(long min_funding_satoshis_arg, long max_funding_satoshis_arg, long max_htlc_minimum_msat_arg, long min_max_htlc_value_in_flight_msat_arg, long max_channel_reserve_satoshis_arg, short min_max_accepted_htlcs_arg, int max_minimum_depth_arg, boolean trust_own_funding_0conf_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) {
323 long ret = bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
324 Reference.reachabilityFence(min_funding_satoshis_arg);
325 Reference.reachabilityFence(max_funding_satoshis_arg);
326 Reference.reachabilityFence(max_htlc_minimum_msat_arg);
327 Reference.reachabilityFence(min_max_htlc_value_in_flight_msat_arg);
328 Reference.reachabilityFence(max_channel_reserve_satoshis_arg);
329 Reference.reachabilityFence(min_max_accepted_htlcs_arg);
330 Reference.reachabilityFence(max_minimum_depth_arg);
331 Reference.reachabilityFence(trust_own_funding_0conf_arg);
332 Reference.reachabilityFence(force_announced_channel_preference_arg);
333 Reference.reachabilityFence(their_to_self_delay_arg);
334 if (ret >= 0 && ret <= 4096) { return null; }
335 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
336 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
341 long ret = bindings.ChannelHandshakeLimits_clone_ptr(this.ptr);
342 Reference.reachabilityFence(this);
347 * Creates a copy of the ChannelHandshakeLimits
349 public ChannelHandshakeLimits clone() {
350 long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
351 Reference.reachabilityFence(this);
352 if (ret >= 0 && ret <= 4096) { return null; }
353 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
354 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
359 * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
361 public static ChannelHandshakeLimits with_default() {
362 long ret = bindings.ChannelHandshakeLimits_default();
363 if (ret >= 0 && ret <= 4096) { return null; }
364 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
365 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };