1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * Optional channel limits which are applied during channel creation.
12 * These limits are only applied to our counterparty's limits, not our own.
14 * Use 0/<type>::max_value() as appropriate to skip checking.
16 * Provides sane defaults for most configurations.
18 * Most additional limits are disabled except those with which specify a default in individual
19 * field documentation. Note that this may result in barely-usable channels, but since they
20 * are applied mostly only to incoming channels that's not much of a problem.
22 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
23 public class ChannelHandshakeLimits extends CommonBase {
24 ChannelHandshakeLimits(Object _dummy, long ptr) { super(ptr); }
25 @Override @SuppressWarnings("deprecation")
26 protected void finalize() throws Throwable {
28 if (ptr != 0) { bindings.ChannelHandshakeLimits_free(ptr); }
32 * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
33 * only applies to inbound channels.
37 public long get_min_funding_satoshis() {
38 long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr);
43 * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
44 * only applies to inbound channels.
48 public void set_min_funding_satoshis(long val) {
49 bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val);
53 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
54 * you to limit the maximum minimum-size they can require.
56 * Default value: u64::max_value.
58 public long get_max_htlc_minimum_msat() {
59 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
64 * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
65 * you to limit the maximum minimum-size they can require.
67 * Default value: u64::max_value.
69 public void set_max_htlc_minimum_msat(long val) {
70 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
74 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
75 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
79 public long get_min_max_htlc_value_in_flight_msat() {
80 long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr);
85 * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
86 * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
90 public void set_min_max_htlc_value_in_flight_msat(long val) {
91 bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val);
95 * The remote node will require we keep a certain amount in direct payment to ourselves at all
96 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
97 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
99 * Default value: u64::max_value.
101 public long get_max_channel_reserve_satoshis() {
102 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
107 * The remote node will require we keep a certain amount in direct payment to ourselves at all
108 * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
109 * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
111 * Default value: u64::max_value.
113 public void set_max_channel_reserve_satoshis(long val) {
114 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
118 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
119 * time. This allows you to set a minimum such value.
123 public short get_min_max_accepted_htlcs() {
124 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
129 * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
130 * time. This allows you to set a minimum such value.
134 public void set_min_max_accepted_htlcs(short val) {
135 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
139 * Before a channel is usable the funding transaction will need to be confirmed by at least a
140 * certain number of blocks, specified by the node which is not the funder (as the funder can
141 * assume they aren't going to double-spend themselves).
142 * This config allows you to set a limit on the maximum amount of time to wait.
144 * Default value: 144, or roughly one day and only applies to outbound channels.
146 public int get_max_minimum_depth() {
147 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
152 * Before a channel is usable the funding transaction will need to be confirmed by at least a
153 * certain number of blocks, specified by the node which is not the funder (as the funder can
154 * assume they aren't going to double-spend themselves).
155 * This config allows you to set a limit on the maximum amount of time to wait.
157 * Default value: 144, or roughly one day and only applies to outbound channels.
159 public void set_max_minimum_depth(int val) {
160 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
164 * Set to force the incoming channel to match our announced channel preference in
167 * Default value: true, to make the default that no announced channels are possible (which is
168 * appropriate for any nodes which are not online very reliably).
170 public boolean get_force_announced_channel_preference() {
171 boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
176 * Set to force the incoming channel to match our announced channel preference in
179 * Default value: true, to make the default that no announced channels are possible (which is
180 * appropriate for any nodes which are not online very reliably).
182 public void set_force_announced_channel_preference(boolean val) {
183 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
187 * Set to the amount of time we're willing to wait to claim money back to us.
189 * Not checking this value would be a security issue, as our peer would be able to set it to
190 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
192 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
193 * reduce the loss of having useless locked funds (if your peer accepts)
195 public short get_their_to_self_delay() {
196 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
201 * Set to the amount of time we're willing to wait to claim money back to us.
203 * Not checking this value would be a security issue, as our peer would be able to set it to
204 * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
206 * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
207 * reduce the loss of having useless locked funds (if your peer accepts)
209 public void set_their_to_self_delay(short val) {
210 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
214 * Constructs a new ChannelHandshakeLimits given each field
216 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) {
217 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);
218 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
219 ret_hu_conv.ptrs_to.add(ret_hu_conv);
224 * Creates a copy of the ChannelHandshakeLimits
226 public ChannelHandshakeLimits clone() {
227 long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
228 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
229 ret_hu_conv.ptrs_to.add(this);
234 * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
236 public static ChannelHandshakeLimits with_default() {
237 long ret = bindings.ChannelHandshakeLimits_default();
238 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
239 ret_hu_conv.ptrs_to.add(ret_hu_conv);