39f6fd4eed685a7dcb46a0207a37f7c30309895a
[ldk-java] / src / main / java / org / ldk / structs / ChannelHandshakeLimits.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8
9 /**
10  * Optional channel limits which are applied during channel creation.
11  * 
12  * These limits are only applied to our counterparty's limits, not our own.
13  * 
14  * Use 0/<type>::max_value() as appropriate to skip checking.
15  * 
16  * Provides sane defaults for most configurations.
17  * 
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.
21  */
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 {
27                 super.finalize();
28                 if (ptr != 0) { bindings.ChannelHandshakeLimits_free(ptr); }
29         }
30
31         /**
32          * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
33          * only applies to inbound channels.
34          * 
35          * Default value: 0.
36          */
37         public long get_min_funding_satoshis() {
38                 long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr);
39                 return ret;
40         }
41
42         /**
43          * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so
44          * only applies to inbound channels.
45          * 
46          * Default value: 0.
47          */
48         public void set_min_funding_satoshis(long val) {
49                 bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val);
50         }
51
52         /**
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.
55          * 
56          * Default value: u64::max_value.
57          */
58         public long get_max_htlc_minimum_msat() {
59                 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
60                 return ret;
61         }
62
63         /**
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.
66          * 
67          * Default value: u64::max_value.
68          */
69         public void set_max_htlc_minimum_msat(long val) {
70                 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
71         }
72
73         /**
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.
76          * 
77          * Default value: 0.
78          */
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);
81                 return ret;
82         }
83
84         /**
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.
87          * 
88          * Default value: 0.
89          */
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);
92         }
93
94         /**
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).
98          * 
99          * Default value: u64::max_value.
100          */
101         public long get_max_channel_reserve_satoshis() {
102                 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
103                 return ret;
104         }
105
106         /**
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).
110          * 
111          * Default value: u64::max_value.
112          */
113         public void set_max_channel_reserve_satoshis(long val) {
114                 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
115         }
116
117         /**
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.
120          * 
121          * Default value: 0.
122          */
123         public short get_min_max_accepted_htlcs() {
124                 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
125                 return ret;
126         }
127
128         /**
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.
131          * 
132          * Default value: 0.
133          */
134         public void set_min_max_accepted_htlcs(short val) {
135                 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
136         }
137
138         /**
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.
143          * 
144          * Default value: 144, or roughly one day and only applies to outbound channels.
145          */
146         public int get_max_minimum_depth() {
147                 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
148                 return ret;
149         }
150
151         /**
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.
156          * 
157          * Default value: 144, or roughly one day and only applies to outbound channels.
158          */
159         public void set_max_minimum_depth(int val) {
160                 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
161         }
162
163         /**
164          * Set to force the incoming channel to match our announced channel preference in
165          * ChannelConfig.
166          * 
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).
169          */
170         public boolean get_force_announced_channel_preference() {
171                 boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
172                 return ret;
173         }
174
175         /**
176          * Set to force the incoming channel to match our announced channel preference in
177          * ChannelConfig.
178          * 
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).
181          */
182         public void set_force_announced_channel_preference(boolean val) {
183                 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
184         }
185
186         /**
187          * Set to the amount of time we're willing to wait to claim money back to us.
188          * 
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.
191          * 
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)
194          */
195         public short get_their_to_self_delay() {
196                 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
197                 return ret;
198         }
199
200         /**
201          * Set to the amount of time we're willing to wait to claim money back to us.
202          * 
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.
205          * 
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)
208          */
209         public void set_their_to_self_delay(short val) {
210                 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
211         }
212
213         /**
214          * Constructs a new ChannelHandshakeLimits given each field
215          */
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);
220                 return ret_hu_conv;
221         }
222
223         /**
224          * Creates a copy of the ChannelHandshakeLimits
225          */
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);
230                 return ret_hu_conv;
231         }
232
233         /**
234          * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
235          */
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);
240                 return ret_hu_conv;
241         }
242
243 }