1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Optional channel limits which are applied during channel creation.
13 * These limits are only applied to our counterparty's limits, not our own.
15 * Use 0/<type>::max_value() as appropriate to skip checking.
17 * Provides sane defaults for most configurations.
19 * Most additional limits are disabled except those with which specify a default in individual
20 * field documentation. Note that this may result in barely-usable channels, but since they
21 * are applied mostly only to incoming channels that's not much of a problem.
23 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
24 public class ChannelHandshakeLimits extends CommonBase {
25 ChannelHandshakeLimits(Object _dummy, long ptr) { super(ptr); }
26 @Override @SuppressWarnings("deprecation")
27 protected void finalize() throws Throwable {
29 if (ptr != 0) { bindings.ChannelHandshakeLimits_free(ptr); }
33 * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
34 * only applies to inbound channels.
38 public long get_min_funding_satoshis() {
39 long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr);
44 * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
45 * only applies to inbound channels.
49 public void set_min_funding_satoshis(long val) {
50 bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val);
54 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
55 * you to limit the maximum minimum-size they can require.
57 * Default value: u64::max_value.
59 public long get_max_htlc_minimum_msat() {
60 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
65 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
66 * you to limit the maximum minimum-size they can require.
68 * Default value: u64::max_value.
70 public void set_max_htlc_minimum_msat(long val) {
71 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
75 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
76 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
80 public long get_min_max_htlc_value_in_flight_msat() {
81 long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr);
86 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
87 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
91 public void set_min_max_htlc_value_in_flight_msat(long val) {
92 bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val);
96 * The remote node will require we keep a certain amount in direct payment to ourselves at all
97 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
98 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
100 * Default value: u64::max_value.
102 public long get_max_channel_reserve_satoshis() {
103 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
108 * The remote node will require we keep a certain amount in direct payment to ourselves at all
109 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
110 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
112 * Default value: u64::max_value.
114 public void set_max_channel_reserve_satoshis(long val) {
115 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
119 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
120 * time. This allows you to set a minimum such value.
124 public short get_min_max_accepted_htlcs() {
125 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
130 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
131 * time. This allows you to set a minimum such value.
135 public void set_min_max_accepted_htlcs(short val) {
136 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
140 * Before a channel is usable the funding transaction will need to be confirmed by at least a
141 * certain number of blocks, specified by the node which is not the funder (as the funder can
142 * assume they aren't going to double-spend themselves).
143 * This config allows you to set a limit on the maximum amount of time to wait.
145 * Default value: 144, or roughly one day and only applies to outbound channels.
147 public int get_max_minimum_depth() {
148 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
153 * Before a channel is usable the funding transaction will need to be confirmed by at least a
154 * certain number of blocks, specified by the node which is not the funder (as the funder can
155 * assume they aren't going to double-spend themselves).
156 * This config allows you to set a limit on the maximum amount of time to wait.
158 * Default value: 144, or roughly one day and only applies to outbound channels.
160 public void set_max_minimum_depth(int val) {
161 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
165 * Set to force an incoming channel to match our announced channel preference in
166 * [`ChannelConfig::announced_channel`].
168 * For a node which is not online reliably, this should be set to true and
169 * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
170 * channels will ever be opened.
172 * Default value: true.
174 public boolean get_force_announced_channel_preference() {
175 boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
180 * Set to force an incoming channel to match our announced channel preference in
181 * [`ChannelConfig::announced_channel`].
183 * For a node which is not online reliably, this should be set to true and
184 * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
185 * channels will ever be opened.
187 * Default value: true.
189 public void set_force_announced_channel_preference(boolean val) {
190 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
194 * Set to the amount of time we're willing to wait to claim money back to us.
196 * Not checking this value would be a security issue, as our peer would be able to set it to
197 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
199 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
200 * reduce the loss of having useless locked funds (if your peer accepts)
202 public short get_their_to_self_delay() {
203 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
208 * Set to the amount of time we're willing to wait to claim money back to us.
210 * Not checking this value would be a security issue, as our peer would be able to set it to
211 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
213 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
214 * reduce the loss of having useless locked funds (if your peer accepts)
216 public void set_their_to_self_delay(short val) {
217 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
221 * Constructs a new ChannelHandshakeLimits given each field
223 public static ChannelHandshakeLimits of(long min_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 force_announced_channel_preference_arg, short their_to_self_delay_arg) {
224 long ret = bindings.ChannelHandshakeLimits_new(min_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, force_announced_channel_preference_arg, their_to_self_delay_arg);
225 if (ret < 1024) { return null; }
226 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
227 ret_hu_conv.ptrs_to.add(ret_hu_conv);
232 * Creates a copy of the ChannelHandshakeLimits
234 public ChannelHandshakeLimits clone() {
235 long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
236 if (ret < 1024) { return null; }
237 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
238 ret_hu_conv.ptrs_to.add(this);
243 * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
245 public static ChannelHandshakeLimits with_default() {
246 long ret = bindings.ChannelHandshakeLimits_default();
247 if (ret < 1024) { return null; }
248 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
249 ret_hu_conv.ptrs_to.add(ret_hu_conv);