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 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
59 * you to limit the maximum minimum-size they can require.
61 * Default value: u64::max_value.
63 public long get_max_htlc_minimum_msat() {
64 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
65 Reference.reachabilityFence(this);
70 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
71 * you to limit the maximum minimum-size they can require.
73 * Default value: u64::max_value.
75 public void set_max_htlc_minimum_msat(long val) {
76 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
77 Reference.reachabilityFence(this);
78 Reference.reachabilityFence(val);
82 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
83 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
87 public long get_min_max_htlc_value_in_flight_msat() {
88 long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr);
89 Reference.reachabilityFence(this);
94 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
95 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
99 public void set_min_max_htlc_value_in_flight_msat(long val) {
100 bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val);
101 Reference.reachabilityFence(this);
102 Reference.reachabilityFence(val);
106 * The remote node will require we keep a certain amount in direct payment to ourselves at all
107 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
108 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
110 * Default value: u64::max_value.
112 public long get_max_channel_reserve_satoshis() {
113 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
114 Reference.reachabilityFence(this);
119 * The remote node will require we keep a certain amount in direct payment to ourselves at all
120 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
121 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
123 * Default value: u64::max_value.
125 public void set_max_channel_reserve_satoshis(long val) {
126 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
127 Reference.reachabilityFence(this);
128 Reference.reachabilityFence(val);
132 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
133 * time. This allows you to set a minimum such value.
137 public short get_min_max_accepted_htlcs() {
138 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
139 Reference.reachabilityFence(this);
144 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
145 * time. This allows you to set a minimum such value.
149 public void set_min_max_accepted_htlcs(short val) {
150 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
151 Reference.reachabilityFence(this);
152 Reference.reachabilityFence(val);
156 * Before a channel is usable the funding transaction will need to be confirmed by at least a
157 * certain number of blocks, specified by the node which is not the funder (as the funder can
158 * assume they aren't going to double-spend themselves).
159 * This config allows you to set a limit on the maximum amount of time to wait.
161 * Default value: 144, or roughly one day and only applies to outbound channels.
163 public int get_max_minimum_depth() {
164 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
165 Reference.reachabilityFence(this);
170 * Before a channel is usable the funding transaction will need to be confirmed by at least a
171 * certain number of blocks, specified by the node which is not the funder (as the funder can
172 * assume they aren't going to double-spend themselves).
173 * This config allows you to set a limit on the maximum amount of time to wait.
175 * Default value: 144, or roughly one day and only applies to outbound channels.
177 public void set_max_minimum_depth(int val) {
178 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
179 Reference.reachabilityFence(this);
180 Reference.reachabilityFence(val);
184 * Set to force an incoming channel to match our announced channel preference in
185 * [`ChannelConfig::announced_channel`].
187 * For a node which is not online reliably, this should be set to true and
188 * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
189 * channels will ever be opened.
191 * Default value: true.
193 public boolean get_force_announced_channel_preference() {
194 boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
195 Reference.reachabilityFence(this);
200 * Set to force an incoming channel to match our announced channel preference in
201 * [`ChannelConfig::announced_channel`].
203 * For a node which is not online reliably, this should be set to true and
204 * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public)
205 * channels will ever be opened.
207 * Default value: true.
209 public void set_force_announced_channel_preference(boolean val) {
210 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
211 Reference.reachabilityFence(this);
212 Reference.reachabilityFence(val);
216 * Set to the amount of time we're willing to wait to claim money back to us.
218 * Not checking this value would be a security issue, as our peer would be able to set it to
219 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
221 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
222 * reduce the loss of having useless locked funds (if your peer accepts)
224 public short get_their_to_self_delay() {
225 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
226 Reference.reachabilityFence(this);
231 * Set to the amount of time we're willing to wait to claim money back to us.
233 * Not checking this value would be a security issue, as our peer would be able to set it to
234 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
236 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
237 * reduce the loss of having useless locked funds (if your peer accepts)
239 public void set_their_to_self_delay(short val) {
240 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
241 Reference.reachabilityFence(this);
242 Reference.reachabilityFence(val);
246 * Constructs a new ChannelHandshakeLimits given each field
248 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) {
249 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);
250 Reference.reachabilityFence(min_funding_satoshis_arg);
251 Reference.reachabilityFence(max_htlc_minimum_msat_arg);
252 Reference.reachabilityFence(min_max_htlc_value_in_flight_msat_arg);
253 Reference.reachabilityFence(max_channel_reserve_satoshis_arg);
254 Reference.reachabilityFence(min_max_accepted_htlcs_arg);
255 Reference.reachabilityFence(max_minimum_depth_arg);
256 Reference.reachabilityFence(force_announced_channel_preference_arg);
257 Reference.reachabilityFence(their_to_self_delay_arg);
258 if (ret >= 0 && ret <= 4096) { return null; }
259 ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
260 ret_hu_conv.ptrs_to.add(ret_hu_conv);
265 long ret = bindings.ChannelHandshakeLimits_clone_ptr(this.ptr);
266 Reference.reachabilityFence(this);
271 * Creates a copy of the ChannelHandshakeLimits
273 public ChannelHandshakeLimits clone() {
274 long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
275 Reference.reachabilityFence(this);
276 if (ret >= 0 && ret <= 4096) { return null; }
277 ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
278 ret_hu_conv.ptrs_to.add(this);
283 * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
285 public static ChannelHandshakeLimits with_default() {
286 long ret = bindings.ChannelHandshakeLimits_default();
287 if (ret >= 0 && ret <= 4096) { return null; }
288 ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
289 ret_hu_conv.ptrs_to.add(ret_hu_conv);