408bc248908d4ff5a1510c8c9385c436fe02b9af
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelHandshakeLimits.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
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 public class ChannelHandshakeLimits : CommonBase {
23         internal ChannelHandshakeLimits(object _dummy, long ptr) : base(ptr) { }
24         ~ChannelHandshakeLimits() {
25                 if (ptr != 0) { bindings.ChannelHandshakeLimits_free(ptr); }
26         }
27
28         /**
29          * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
30          * only applies to inbound channels.
31          * 
32          * Default value: 0.
33          */
34         public long get_min_funding_satoshis() {
35                 long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr);
36                 GC.KeepAlive(this);
37                 return ret;
38         }
39
40         /**
41          * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so
42          * only applies to inbound channels.
43          * 
44          * Default value: 0.
45          */
46         public void set_min_funding_satoshis(long val) {
47                 bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val);
48                 GC.KeepAlive(this);
49                 GC.KeepAlive(val);
50         }
51
52         /**
53          * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
54          * only applies to inbound channels.
55          * 
56          * Default value: 2^24 - 1.
57          */
58         public long get_max_funding_satoshis() {
59                 long ret = bindings.ChannelHandshakeLimits_get_max_funding_satoshis(this.ptr);
60                 GC.KeepAlive(this);
61                 return ret;
62         }
63
64         /**
65          * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so
66          * only applies to inbound channels.
67          * 
68          * Default value: 2^24 - 1.
69          */
70         public void set_max_funding_satoshis(long val) {
71                 bindings.ChannelHandshakeLimits_set_max_funding_satoshis(this.ptr, val);
72                 GC.KeepAlive(this);
73                 GC.KeepAlive(val);
74         }
75
76         /**
77          * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
78          * you to limit the maximum minimum-size they can require.
79          * 
80          * Default value: u64::max_value.
81          */
82         public long get_max_htlc_minimum_msat() {
83                 long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr);
84                 GC.KeepAlive(this);
85                 return ret;
86         }
87
88         /**
89          * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows
90          * you to limit the maximum minimum-size they can require.
91          * 
92          * Default value: u64::max_value.
93          */
94         public void set_max_htlc_minimum_msat(long val) {
95                 bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val);
96                 GC.KeepAlive(this);
97                 GC.KeepAlive(val);
98         }
99
100         /**
101          * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
102          * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
103          * 
104          * Default value: 0.
105          */
106         public long get_min_max_htlc_value_in_flight_msat() {
107                 long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr);
108                 GC.KeepAlive(this);
109                 return ret;
110         }
111
112         /**
113          * The remote node sets a limit on the maximum value of pending HTLCs to them at any given
114          * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value.
115          * 
116          * Default value: 0.
117          */
118         public void set_min_max_htlc_value_in_flight_msat(long val) {
119                 bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val);
120                 GC.KeepAlive(this);
121                 GC.KeepAlive(val);
122         }
123
124         /**
125          * The remote node will require we keep a certain amount in direct payment to ourselves at all
126          * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
127          * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
128          * 
129          * Default value: u64::max_value.
130          */
131         public long get_max_channel_reserve_satoshis() {
132                 long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr);
133                 GC.KeepAlive(this);
134                 return ret;
135         }
136
137         /**
138          * The remote node will require we keep a certain amount in direct payment to ourselves at all
139          * time, ensuring that we are able to be punished if we broadcast an old state. This allows to
140          * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs).
141          * 
142          * Default value: u64::max_value.
143          */
144         public void set_max_channel_reserve_satoshis(long val) {
145                 bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val);
146                 GC.KeepAlive(this);
147                 GC.KeepAlive(val);
148         }
149
150         /**
151          * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
152          * time. This allows you to set a minimum such value.
153          * 
154          * Default value: 0.
155          */
156         public short get_min_max_accepted_htlcs() {
157                 short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr);
158                 GC.KeepAlive(this);
159                 return ret;
160         }
161
162         /**
163          * The remote node sets a limit on the maximum number of pending HTLCs to them at any given
164          * time. This allows you to set a minimum such value.
165          * 
166          * Default value: 0.
167          */
168         public void set_min_max_accepted_htlcs(short val) {
169                 bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val);
170                 GC.KeepAlive(this);
171                 GC.KeepAlive(val);
172         }
173
174         /**
175          * Before a channel is usable the funding transaction will need to be confirmed by at least a
176          * certain number of blocks, specified by the node which is not the funder (as the funder can
177          * assume they aren't going to double-spend themselves).
178          * This config allows you to set a limit on the maximum amount of time to wait.
179          * 
180          * Default value: 144, or roughly one day and only applies to outbound channels.
181          */
182         public int get_max_minimum_depth() {
183                 int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr);
184                 GC.KeepAlive(this);
185                 return ret;
186         }
187
188         /**
189          * Before a channel is usable the funding transaction will need to be confirmed by at least a
190          * certain number of blocks, specified by the node which is not the funder (as the funder can
191          * assume they aren't going to double-spend themselves).
192          * This config allows you to set a limit on the maximum amount of time to wait.
193          * 
194          * Default value: 144, or roughly one day and only applies to outbound channels.
195          */
196         public void set_max_minimum_depth(int val) {
197                 bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val);
198                 GC.KeepAlive(this);
199                 GC.KeepAlive(val);
200         }
201
202         /**
203          * Whether we implicitly trust funding transactions generated by us for our own outbound
204          * channels to not be double-spent.
205          * 
206          * If this is set, we assume that our own funding transactions are *never* double-spent, and
207          * thus we can trust them without any confirmations. This is generally a reasonable
208          * assumption, given we're the only ones who could ever double-spend it (assuming we have sole
209          * control of the signing keys).
210          * 
211          * You may wish to un-set this if you allow the user to (or do in an automated fashion)
212          * double-spend the funding transaction to RBF with an alternative channel open.
213          * 
214          * This only applies if our counterparty set their confirmations-required value to 0, and we
215          * always trust our own funding transaction at 1 confirmation irrespective of this value.
216          * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
217          * `true` (0) and `false` (1).
218          * 
219          * Default value: true
220          */
221         public bool get_trust_own_funding_0conf() {
222                 bool ret = bindings.ChannelHandshakeLimits_get_trust_own_funding_0conf(this.ptr);
223                 GC.KeepAlive(this);
224                 return ret;
225         }
226
227         /**
228          * Whether we implicitly trust funding transactions generated by us for our own outbound
229          * channels to not be double-spent.
230          * 
231          * If this is set, we assume that our own funding transactions are *never* double-spent, and
232          * thus we can trust them without any confirmations. This is generally a reasonable
233          * assumption, given we're the only ones who could ever double-spend it (assuming we have sole
234          * control of the signing keys).
235          * 
236          * You may wish to un-set this if you allow the user to (or do in an automated fashion)
237          * double-spend the funding transaction to RBF with an alternative channel open.
238          * 
239          * This only applies if our counterparty set their confirmations-required value to 0, and we
240          * always trust our own funding transaction at 1 confirmation irrespective of this value.
241          * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being
242          * `true` (0) and `false` (1).
243          * 
244          * Default value: true
245          */
246         public void set_trust_own_funding_0conf(bool val) {
247                 bindings.ChannelHandshakeLimits_set_trust_own_funding_0conf(this.ptr, val);
248                 GC.KeepAlive(this);
249                 GC.KeepAlive(val);
250         }
251
252         /**
253          * Set to force an incoming channel to match our announced channel preference in
254          * [`ChannelHandshakeConfig::announced_channel`].
255          * 
256          * For a node which is not online reliably, this should be set to true and
257          * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
258          * channels will ever be opened.
259          * 
260          * Default value: true.
261          */
262         public bool get_force_announced_channel_preference() {
263                 bool ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr);
264                 GC.KeepAlive(this);
265                 return ret;
266         }
267
268         /**
269          * Set to force an incoming channel to match our announced channel preference in
270          * [`ChannelHandshakeConfig::announced_channel`].
271          * 
272          * For a node which is not online reliably, this should be set to true and
273          * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public)
274          * channels will ever be opened.
275          * 
276          * Default value: true.
277          */
278         public void set_force_announced_channel_preference(bool val) {
279                 bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val);
280                 GC.KeepAlive(this);
281                 GC.KeepAlive(val);
282         }
283
284         /**
285          * Set to the amount of time we're willing to wait to claim money back to us.
286          * 
287          * Not checking this value would be a security issue, as our peer would be able to set it to
288          * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
289          * 
290          * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
291          * reduce the loss of having useless locked funds (if your peer accepts)
292          */
293         public short get_their_to_self_delay() {
294                 short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr);
295                 GC.KeepAlive(this);
296                 return ret;
297         }
298
299         /**
300          * Set to the amount of time we're willing to wait to claim money back to us.
301          * 
302          * Not checking this value would be a security issue, as our peer would be able to set it to
303          * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time.
304          * 
305          * Default value: 2016, which we also enforce as a maximum value so you can tweak config to
306          * reduce the loss of having useless locked funds (if your peer accepts)
307          */
308         public void set_their_to_self_delay(short val) {
309                 bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val);
310                 GC.KeepAlive(this);
311                 GC.KeepAlive(val);
312         }
313
314         /**
315          * Constructs a new ChannelHandshakeLimits given each field
316          */
317         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, bool trust_own_funding_0conf_arg, bool force_announced_channel_preference_arg, short their_to_self_delay_arg) {
318                 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);
319                 GC.KeepAlive(min_funding_satoshis_arg);
320                 GC.KeepAlive(max_funding_satoshis_arg);
321                 GC.KeepAlive(max_htlc_minimum_msat_arg);
322                 GC.KeepAlive(min_max_htlc_value_in_flight_msat_arg);
323                 GC.KeepAlive(max_channel_reserve_satoshis_arg);
324                 GC.KeepAlive(min_max_accepted_htlcs_arg);
325                 GC.KeepAlive(max_minimum_depth_arg);
326                 GC.KeepAlive(trust_own_funding_0conf_arg);
327                 GC.KeepAlive(force_announced_channel_preference_arg);
328                 GC.KeepAlive(their_to_self_delay_arg);
329                 if (ret >= 0 && ret <= 4096) { return null; }
330                 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
331                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
332                 return ret_hu_conv;
333         }
334
335         internal long clone_ptr() {
336                 long ret = bindings.ChannelHandshakeLimits_clone_ptr(this.ptr);
337                 GC.KeepAlive(this);
338                 return ret;
339         }
340
341         /**
342          * Creates a copy of the ChannelHandshakeLimits
343          */
344         public ChannelHandshakeLimits clone() {
345                 long ret = bindings.ChannelHandshakeLimits_clone(this.ptr);
346                 GC.KeepAlive(this);
347                 if (ret >= 0 && ret <= 4096) { return null; }
348                 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
349                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
350                 return ret_hu_conv;
351         }
352
353         /**
354          * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used.
355          */
356         public static ChannelHandshakeLimits with_default() {
357                 long ret = bindings.ChannelHandshakeLimits_default();
358                 if (ret >= 0 && ret <= 4096) { return null; }
359                 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
360                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
361                 return ret_hu_conv;
362         }
363
364 }
365 } } }