[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / AcceptChannel.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 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * An [`accept_channel`] message to be sent to or received from a peer.
13  * 
14  * Used in V1 channel establishment
15  * 
16  * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class AcceptChannel extends CommonBase {
20         AcceptChannel(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
25         }
26
27         /**
28          * A temporary channel ID, until the funding outpoint is announced
29          */
30         public byte[] get_temporary_channel_id() {
31                 byte[] ret = bindings.AcceptChannel_get_temporary_channel_id(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * A temporary channel ID, until the funding outpoint is announced
38          */
39         public void set_temporary_channel_id(byte[] val) {
40                 bindings.AcceptChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * The threshold below which outputs on transactions broadcast by sender will be omitted
47          */
48         public long get_dust_limit_satoshis() {
49                 long ret = bindings.AcceptChannel_get_dust_limit_satoshis(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * The threshold below which outputs on transactions broadcast by sender will be omitted
56          */
57         public void set_dust_limit_satoshis(long val) {
58                 bindings.AcceptChannel_set_dust_limit_satoshis(this.ptr, val);
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61         }
62
63         /**
64          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
65          */
66         public long get_max_htlc_value_in_flight_msat() {
67                 long ret = bindings.AcceptChannel_get_max_htlc_value_in_flight_msat(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         /**
73          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
74          */
75         public void set_max_htlc_value_in_flight_msat(long val) {
76                 bindings.AcceptChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
77                 Reference.reachabilityFence(this);
78                 Reference.reachabilityFence(val);
79         }
80
81         /**
82          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
83          */
84         public long get_channel_reserve_satoshis() {
85                 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
92          */
93         public void set_channel_reserve_satoshis(long val) {
94                 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
95                 Reference.reachabilityFence(this);
96                 Reference.reachabilityFence(val);
97         }
98
99         /**
100          * The minimum HTLC size incoming to sender, in milli-satoshi
101          */
102         public long get_htlc_minimum_msat() {
103                 long ret = bindings.AcceptChannel_get_htlc_minimum_msat(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         /**
109          * The minimum HTLC size incoming to sender, in milli-satoshi
110          */
111         public void set_htlc_minimum_msat(long val) {
112                 bindings.AcceptChannel_set_htlc_minimum_msat(this.ptr, val);
113                 Reference.reachabilityFence(this);
114                 Reference.reachabilityFence(val);
115         }
116
117         /**
118          * Minimum depth of the funding transaction before the channel is considered open
119          */
120         public int get_minimum_depth() {
121                 int ret = bindings.AcceptChannel_get_minimum_depth(this.ptr);
122                 Reference.reachabilityFence(this);
123                 return ret;
124         }
125
126         /**
127          * Minimum depth of the funding transaction before the channel is considered open
128          */
129         public void set_minimum_depth(int val) {
130                 bindings.AcceptChannel_set_minimum_depth(this.ptr, val);
131                 Reference.reachabilityFence(this);
132                 Reference.reachabilityFence(val);
133         }
134
135         /**
136          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
137          */
138         public short get_to_self_delay() {
139                 short ret = bindings.AcceptChannel_get_to_self_delay(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
146          */
147         public void set_to_self_delay(short val) {
148                 bindings.AcceptChannel_set_to_self_delay(this.ptr, val);
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(val);
151         }
152
153         /**
154          * The maximum number of inbound HTLCs towards sender
155          */
156         public short get_max_accepted_htlcs() {
157                 short ret = bindings.AcceptChannel_get_max_accepted_htlcs(this.ptr);
158                 Reference.reachabilityFence(this);
159                 return ret;
160         }
161
162         /**
163          * The maximum number of inbound HTLCs towards sender
164          */
165         public void set_max_accepted_htlcs(short val) {
166                 bindings.AcceptChannel_set_max_accepted_htlcs(this.ptr, val);
167                 Reference.reachabilityFence(this);
168                 Reference.reachabilityFence(val);
169         }
170
171         /**
172          * The sender's key controlling the funding transaction
173          */
174         public byte[] get_funding_pubkey() {
175                 byte[] ret = bindings.AcceptChannel_get_funding_pubkey(this.ptr);
176                 Reference.reachabilityFence(this);
177                 return ret;
178         }
179
180         /**
181          * The sender's key controlling the funding transaction
182          */
183         public void set_funding_pubkey(byte[] val) {
184                 bindings.AcceptChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
185                 Reference.reachabilityFence(this);
186                 Reference.reachabilityFence(val);
187         }
188
189         /**
190          * Used to derive a revocation key for transactions broadcast by counterparty
191          */
192         public byte[] get_revocation_basepoint() {
193                 byte[] ret = bindings.AcceptChannel_get_revocation_basepoint(this.ptr);
194                 Reference.reachabilityFence(this);
195                 return ret;
196         }
197
198         /**
199          * Used to derive a revocation key for transactions broadcast by counterparty
200          */
201         public void set_revocation_basepoint(byte[] val) {
202                 bindings.AcceptChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
203                 Reference.reachabilityFence(this);
204                 Reference.reachabilityFence(val);
205         }
206
207         /**
208          * A payment key to sender for transactions broadcast by counterparty
209          */
210         public byte[] get_payment_point() {
211                 byte[] ret = bindings.AcceptChannel_get_payment_point(this.ptr);
212                 Reference.reachabilityFence(this);
213                 return ret;
214         }
215
216         /**
217          * A payment key to sender for transactions broadcast by counterparty
218          */
219         public void set_payment_point(byte[] val) {
220                 bindings.AcceptChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
221                 Reference.reachabilityFence(this);
222                 Reference.reachabilityFence(val);
223         }
224
225         /**
226          * Used to derive a payment key to sender for transactions broadcast by sender
227          */
228         public byte[] get_delayed_payment_basepoint() {
229                 byte[] ret = bindings.AcceptChannel_get_delayed_payment_basepoint(this.ptr);
230                 Reference.reachabilityFence(this);
231                 return ret;
232         }
233
234         /**
235          * Used to derive a payment key to sender for transactions broadcast by sender
236          */
237         public void set_delayed_payment_basepoint(byte[] val) {
238                 bindings.AcceptChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
239                 Reference.reachabilityFence(this);
240                 Reference.reachabilityFence(val);
241         }
242
243         /**
244          * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
245          */
246         public byte[] get_htlc_basepoint() {
247                 byte[] ret = bindings.AcceptChannel_get_htlc_basepoint(this.ptr);
248                 Reference.reachabilityFence(this);
249                 return ret;
250         }
251
252         /**
253          * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
254          */
255         public void set_htlc_basepoint(byte[] val) {
256                 bindings.AcceptChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
257                 Reference.reachabilityFence(this);
258                 Reference.reachabilityFence(val);
259         }
260
261         /**
262          * The first to-be-broadcast-by-sender transaction's per commitment point
263          */
264         public byte[] get_first_per_commitment_point() {
265                 byte[] ret = bindings.AcceptChannel_get_first_per_commitment_point(this.ptr);
266                 Reference.reachabilityFence(this);
267                 return ret;
268         }
269
270         /**
271          * The first to-be-broadcast-by-sender transaction's per commitment point
272          */
273         public void set_first_per_commitment_point(byte[] val) {
274                 bindings.AcceptChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
275                 Reference.reachabilityFence(this);
276                 Reference.reachabilityFence(val);
277         }
278
279         /**
280          * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
281          */
282         public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
283                 long ret = bindings.AcceptChannel_get_shutdown_scriptpubkey(this.ptr);
284                 Reference.reachabilityFence(this);
285                 if (ret >= 0 && ret <= 4096) { return null; }
286                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
287                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
288                 return ret_hu_conv;
289         }
290
291         /**
292          * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
293          */
294         public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
295                 bindings.AcceptChannel_set_shutdown_scriptpubkey(this.ptr, val.ptr);
296                 Reference.reachabilityFence(this);
297                 Reference.reachabilityFence(val);
298                 if (this != null) { this.ptrs_to.add(val); };
299         }
300
301         /**
302          * The channel type that this channel will represent.
303          * 
304          * If this is `None`, we derive the channel type from the intersection of
305          * our feature bits with our counterparty's feature bits from the [`Init`] message.
306          * This is required to match the equivalent field in [`OpenChannel::channel_type`].
307          * 
308          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
309          */
310         @Nullable
311         public ChannelTypeFeatures get_channel_type() {
312                 long ret = bindings.AcceptChannel_get_channel_type(this.ptr);
313                 Reference.reachabilityFence(this);
314                 if (ret >= 0 && ret <= 4096) { return null; }
315                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
316                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
317                 return ret_hu_conv;
318         }
319
320         /**
321          * The channel type that this channel will represent.
322          * 
323          * If this is `None`, we derive the channel type from the intersection of
324          * our feature bits with our counterparty's feature bits from the [`Init`] message.
325          * This is required to match the equivalent field in [`OpenChannel::channel_type`].
326          * 
327          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
328          */
329         public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
330                 bindings.AcceptChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
331                 Reference.reachabilityFence(this);
332                 Reference.reachabilityFence(val);
333                 if (this != null) { this.ptrs_to.add(val); };
334         }
335
336         /**
337          * Constructs a new AcceptChannel given each field
338          * 
339          * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
340          */
341         public static AcceptChannel of(byte[] temporary_channel_id_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_arg, long channel_reserve_satoshis_arg, long htlc_minimum_msat_arg, int minimum_depth_arg, short to_self_delay_arg, short max_accepted_htlcs_arg, byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_point_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg, byte[] first_per_commitment_point_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
342                 long ret = bindings.AcceptChannel_new(InternalUtils.check_arr_len(temporary_channel_id_arg, 32), dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, InternalUtils.check_arr_len(funding_pubkey_arg, 33), InternalUtils.check_arr_len(revocation_basepoint_arg, 33), InternalUtils.check_arr_len(payment_point_arg, 33), InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33), InternalUtils.check_arr_len(htlc_basepoint_arg, 33), InternalUtils.check_arr_len(first_per_commitment_point_arg, 33), shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
343                 Reference.reachabilityFence(temporary_channel_id_arg);
344                 Reference.reachabilityFence(dust_limit_satoshis_arg);
345                 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
346                 Reference.reachabilityFence(channel_reserve_satoshis_arg);
347                 Reference.reachabilityFence(htlc_minimum_msat_arg);
348                 Reference.reachabilityFence(minimum_depth_arg);
349                 Reference.reachabilityFence(to_self_delay_arg);
350                 Reference.reachabilityFence(max_accepted_htlcs_arg);
351                 Reference.reachabilityFence(funding_pubkey_arg);
352                 Reference.reachabilityFence(revocation_basepoint_arg);
353                 Reference.reachabilityFence(payment_point_arg);
354                 Reference.reachabilityFence(delayed_payment_basepoint_arg);
355                 Reference.reachabilityFence(htlc_basepoint_arg);
356                 Reference.reachabilityFence(first_per_commitment_point_arg);
357                 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
358                 Reference.reachabilityFence(channel_type_arg);
359                 if (ret >= 0 && ret <= 4096) { return null; }
360                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
361                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
362                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
363                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
364                 return ret_hu_conv;
365         }
366
367         long clone_ptr() {
368                 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
369                 Reference.reachabilityFence(this);
370                 return ret;
371         }
372
373         /**
374          * Creates a copy of the AcceptChannel
375          */
376         public AcceptChannel clone() {
377                 long ret = bindings.AcceptChannel_clone(this.ptr);
378                 Reference.reachabilityFence(this);
379                 if (ret >= 0 && ret <= 4096) { return null; }
380                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
381                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
382                 return ret_hu_conv;
383         }
384
385         /**
386          * Generates a non-cryptographic 64-bit hash of the AcceptChannel.
387          */
388         public long hash() {
389                 long ret = bindings.AcceptChannel_hash(this.ptr);
390                 Reference.reachabilityFence(this);
391                 return ret;
392         }
393
394         @Override public int hashCode() {
395                 return (int)this.hash();
396         }
397         /**
398          * Checks if two AcceptChannels contain equal inner contents.
399          * This ignores pointers and is_owned flags and looks at the values in fields.
400          * Two objects with NULL inner values will be considered "equal" here.
401          */
402         public boolean eq(org.ldk.structs.AcceptChannel b) {
403                 boolean ret = bindings.AcceptChannel_eq(this.ptr, b == null ? 0 : b.ptr);
404                 Reference.reachabilityFence(this);
405                 Reference.reachabilityFence(b);
406                 if (this != null) { this.ptrs_to.add(b); };
407                 return ret;
408         }
409
410         @Override public boolean equals(Object o) {
411                 if (!(o instanceof AcceptChannel)) return false;
412                 return this.eq((AcceptChannel)o);
413         }
414         /**
415          * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
416          */
417         public byte[] write() {
418                 byte[] ret = bindings.AcceptChannel_write(this.ptr);
419                 Reference.reachabilityFence(this);
420                 return ret;
421         }
422
423         /**
424          * Read a AcceptChannel from a byte array, created by AcceptChannel_write
425          */
426         public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
427                 long ret = bindings.AcceptChannel_read(ser);
428                 Reference.reachabilityFence(ser);
429                 if (ret >= 0 && ret <= 4096) { return null; }
430                 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
431                 return ret_hu_conv;
432         }
433
434 }