[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / OpenChannelV2.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 open_channel2 message to be sent by or received from the channel initiator.
13  * 
14  * Used in V2 channel establishment
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class OpenChannelV2 extends CommonBase {
18         OpenChannelV2(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.OpenChannelV2_free(ptr); }
23         }
24
25         /**
26          * The genesis hash of the blockchain where the channel is to be opened
27          */
28         public byte[] get_chain_hash() {
29                 byte[] ret = bindings.OpenChannelV2_get_chain_hash(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The genesis hash of the blockchain where the channel is to be opened
36          */
37         public void set_chain_hash(byte[] val) {
38                 bindings.OpenChannelV2_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
45          */
46         public byte[] get_temporary_channel_id() {
47                 byte[] ret = bindings.OpenChannelV2_get_temporary_channel_id(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint
54          */
55         public void set_temporary_channel_id(byte[] val) {
56                 bindings.OpenChannelV2_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * The feerate for the funding transaction set by the channel initiator
63          */
64         public int get_funding_feerate_sat_per_1000_weight() {
65                 int ret = bindings.OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The feerate for the funding transaction set by the channel initiator
72          */
73         public void set_funding_feerate_sat_per_1000_weight(int val) {
74                 bindings.OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * The feerate for the commitment transaction set by the channel initiator
81          */
82         public int get_commitment_feerate_sat_per_1000_weight() {
83                 int ret = bindings.OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * The feerate for the commitment transaction set by the channel initiator
90          */
91         public void set_commitment_feerate_sat_per_1000_weight(int val) {
92                 bindings.OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this.ptr, val);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * Part of the channel value contributed by the channel initiator
99          */
100         public long get_funding_satoshis() {
101                 long ret = bindings.OpenChannelV2_get_funding_satoshis(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * Part of the channel value contributed by the channel initiator
108          */
109         public void set_funding_satoshis(long val) {
110                 bindings.OpenChannelV2_set_funding_satoshis(this.ptr, val);
111                 Reference.reachabilityFence(this);
112                 Reference.reachabilityFence(val);
113         }
114
115         /**
116          * The threshold below which outputs on transactions broadcast by the channel initiator will be
117          * omitted
118          */
119         public long get_dust_limit_satoshis() {
120                 long ret = bindings.OpenChannelV2_get_dust_limit_satoshis(this.ptr);
121                 Reference.reachabilityFence(this);
122                 return ret;
123         }
124
125         /**
126          * The threshold below which outputs on transactions broadcast by the channel initiator will be
127          * omitted
128          */
129         public void set_dust_limit_satoshis(long val) {
130                 bindings.OpenChannelV2_set_dust_limit_satoshis(this.ptr, val);
131                 Reference.reachabilityFence(this);
132                 Reference.reachabilityFence(val);
133         }
134
135         /**
136          * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
137          */
138         public long get_max_htlc_value_in_flight_msat() {
139                 long ret = bindings.OpenChannelV2_get_max_htlc_value_in_flight_msat(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
146          */
147         public void set_max_htlc_value_in_flight_msat(long val) {
148                 bindings.OpenChannelV2_set_max_htlc_value_in_flight_msat(this.ptr, val);
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(val);
151         }
152
153         /**
154          * The minimum HTLC size incoming to channel initiator, in milli-satoshi
155          */
156         public long get_htlc_minimum_msat() {
157                 long ret = bindings.OpenChannelV2_get_htlc_minimum_msat(this.ptr);
158                 Reference.reachabilityFence(this);
159                 return ret;
160         }
161
162         /**
163          * The minimum HTLC size incoming to channel initiator, in milli-satoshi
164          */
165         public void set_htlc_minimum_msat(long val) {
166                 bindings.OpenChannelV2_set_htlc_minimum_msat(this.ptr, val);
167                 Reference.reachabilityFence(this);
168                 Reference.reachabilityFence(val);
169         }
170
171         /**
172          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
173          * broadcast a commitment transaction
174          */
175         public short get_to_self_delay() {
176                 short ret = bindings.OpenChannelV2_get_to_self_delay(this.ptr);
177                 Reference.reachabilityFence(this);
178                 return ret;
179         }
180
181         /**
182          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
183          * broadcast a commitment transaction
184          */
185         public void set_to_self_delay(short val) {
186                 bindings.OpenChannelV2_set_to_self_delay(this.ptr, val);
187                 Reference.reachabilityFence(this);
188                 Reference.reachabilityFence(val);
189         }
190
191         /**
192          * The maximum number of inbound HTLCs towards channel initiator
193          */
194         public short get_max_accepted_htlcs() {
195                 short ret = bindings.OpenChannelV2_get_max_accepted_htlcs(this.ptr);
196                 Reference.reachabilityFence(this);
197                 return ret;
198         }
199
200         /**
201          * The maximum number of inbound HTLCs towards channel initiator
202          */
203         public void set_max_accepted_htlcs(short val) {
204                 bindings.OpenChannelV2_set_max_accepted_htlcs(this.ptr, val);
205                 Reference.reachabilityFence(this);
206                 Reference.reachabilityFence(val);
207         }
208
209         /**
210          * The locktime for the funding transaction
211          */
212         public int get_locktime() {
213                 int ret = bindings.OpenChannelV2_get_locktime(this.ptr);
214                 Reference.reachabilityFence(this);
215                 return ret;
216         }
217
218         /**
219          * The locktime for the funding transaction
220          */
221         public void set_locktime(int val) {
222                 bindings.OpenChannelV2_set_locktime(this.ptr, val);
223                 Reference.reachabilityFence(this);
224                 Reference.reachabilityFence(val);
225         }
226
227         /**
228          * The channel initiator's key controlling the funding transaction
229          */
230         public byte[] get_funding_pubkey() {
231                 byte[] ret = bindings.OpenChannelV2_get_funding_pubkey(this.ptr);
232                 Reference.reachabilityFence(this);
233                 return ret;
234         }
235
236         /**
237          * The channel initiator's key controlling the funding transaction
238          */
239         public void set_funding_pubkey(byte[] val) {
240                 bindings.OpenChannelV2_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
241                 Reference.reachabilityFence(this);
242                 Reference.reachabilityFence(val);
243         }
244
245         /**
246          * Used to derive a revocation key for transactions broadcast by counterparty
247          */
248         public byte[] get_revocation_basepoint() {
249                 byte[] ret = bindings.OpenChannelV2_get_revocation_basepoint(this.ptr);
250                 Reference.reachabilityFence(this);
251                 return ret;
252         }
253
254         /**
255          * Used to derive a revocation key for transactions broadcast by counterparty
256          */
257         public void set_revocation_basepoint(byte[] val) {
258                 bindings.OpenChannelV2_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
259                 Reference.reachabilityFence(this);
260                 Reference.reachabilityFence(val);
261         }
262
263         /**
264          * A payment key to channel initiator for transactions broadcast by counterparty
265          */
266         public byte[] get_payment_basepoint() {
267                 byte[] ret = bindings.OpenChannelV2_get_payment_basepoint(this.ptr);
268                 Reference.reachabilityFence(this);
269                 return ret;
270         }
271
272         /**
273          * A payment key to channel initiator for transactions broadcast by counterparty
274          */
275         public void set_payment_basepoint(byte[] val) {
276                 bindings.OpenChannelV2_set_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
277                 Reference.reachabilityFence(this);
278                 Reference.reachabilityFence(val);
279         }
280
281         /**
282          * Used to derive a payment key to channel initiator for transactions broadcast by channel
283          * initiator
284          */
285         public byte[] get_delayed_payment_basepoint() {
286                 byte[] ret = bindings.OpenChannelV2_get_delayed_payment_basepoint(this.ptr);
287                 Reference.reachabilityFence(this);
288                 return ret;
289         }
290
291         /**
292          * Used to derive a payment key to channel initiator for transactions broadcast by channel
293          * initiator
294          */
295         public void set_delayed_payment_basepoint(byte[] val) {
296                 bindings.OpenChannelV2_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
297                 Reference.reachabilityFence(this);
298                 Reference.reachabilityFence(val);
299         }
300
301         /**
302          * Used to derive an HTLC payment key to channel initiator
303          */
304         public byte[] get_htlc_basepoint() {
305                 byte[] ret = bindings.OpenChannelV2_get_htlc_basepoint(this.ptr);
306                 Reference.reachabilityFence(this);
307                 return ret;
308         }
309
310         /**
311          * Used to derive an HTLC payment key to channel initiator
312          */
313         public void set_htlc_basepoint(byte[] val) {
314                 bindings.OpenChannelV2_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
315                 Reference.reachabilityFence(this);
316                 Reference.reachabilityFence(val);
317         }
318
319         /**
320          * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
321          */
322         public byte[] get_first_per_commitment_point() {
323                 byte[] ret = bindings.OpenChannelV2_get_first_per_commitment_point(this.ptr);
324                 Reference.reachabilityFence(this);
325                 return ret;
326         }
327
328         /**
329          * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
330          */
331         public void set_first_per_commitment_point(byte[] val) {
332                 bindings.OpenChannelV2_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
333                 Reference.reachabilityFence(this);
334                 Reference.reachabilityFence(val);
335         }
336
337         /**
338          * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
339          */
340         public byte[] get_second_per_commitment_point() {
341                 byte[] ret = bindings.OpenChannelV2_get_second_per_commitment_point(this.ptr);
342                 Reference.reachabilityFence(this);
343                 return ret;
344         }
345
346         /**
347          * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
348          */
349         public void set_second_per_commitment_point(byte[] val) {
350                 bindings.OpenChannelV2_set_second_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
351                 Reference.reachabilityFence(this);
352                 Reference.reachabilityFence(val);
353         }
354
355         /**
356          * Channel flags
357          */
358         public byte get_channel_flags() {
359                 byte ret = bindings.OpenChannelV2_get_channel_flags(this.ptr);
360                 Reference.reachabilityFence(this);
361                 return ret;
362         }
363
364         /**
365          * Channel flags
366          */
367         public void set_channel_flags(byte val) {
368                 bindings.OpenChannelV2_set_channel_flags(this.ptr, val);
369                 Reference.reachabilityFence(this);
370                 Reference.reachabilityFence(val);
371         }
372
373         /**
374          * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
375          * collaboratively close
376          */
377         public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
378                 long ret = bindings.OpenChannelV2_get_shutdown_scriptpubkey(this.ptr);
379                 Reference.reachabilityFence(this);
380                 if (ret >= 0 && ret <= 4096) { return null; }
381                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
382                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
383                 return ret_hu_conv;
384         }
385
386         /**
387          * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
388          * collaboratively close
389          */
390         public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
391                 bindings.OpenChannelV2_set_shutdown_scriptpubkey(this.ptr, val.ptr);
392                 Reference.reachabilityFence(this);
393                 Reference.reachabilityFence(val);
394                 if (this != null) { this.ptrs_to.add(val); };
395         }
396
397         /**
398          * The channel type that this channel will represent. If none is set, we derive the channel
399          * type from the intersection of our feature bits with our counterparty's feature bits from
400          * the Init message.
401          * 
402          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
403          */
404         @Nullable
405         public ChannelTypeFeatures get_channel_type() {
406                 long ret = bindings.OpenChannelV2_get_channel_type(this.ptr);
407                 Reference.reachabilityFence(this);
408                 if (ret >= 0 && ret <= 4096) { return null; }
409                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
410                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
411                 return ret_hu_conv;
412         }
413
414         /**
415          * The channel type that this channel will represent. If none is set, we derive the channel
416          * type from the intersection of our feature bits with our counterparty's feature bits from
417          * the Init message.
418          * 
419          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
420          */
421         public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
422                 bindings.OpenChannelV2_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
423                 Reference.reachabilityFence(this);
424                 Reference.reachabilityFence(val);
425                 if (this != null) { this.ptrs_to.add(val); };
426         }
427
428         /**
429          * Optionally, a requirement that only confirmed inputs can be added
430          */
431         public COption_NoneZ get_require_confirmed_inputs() {
432                 COption_NoneZ ret = bindings.OpenChannelV2_get_require_confirmed_inputs(this.ptr);
433                 Reference.reachabilityFence(this);
434                 return ret;
435         }
436
437         /**
438          * Optionally, a requirement that only confirmed inputs can be added
439          */
440         public void set_require_confirmed_inputs(org.ldk.enums.COption_NoneZ val) {
441                 bindings.OpenChannelV2_set_require_confirmed_inputs(this.ptr, val);
442                 Reference.reachabilityFence(this);
443                 Reference.reachabilityFence(val);
444         }
445
446         /**
447          * Constructs a new OpenChannelV2 given each field
448          * 
449          * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
450          */
451         public static OpenChannelV2 of(byte[] chain_hash_arg, byte[] temporary_channel_id_arg, int funding_feerate_sat_per_1000_weight_arg, int commitment_feerate_sat_per_1000_weight_arg, long funding_satoshis_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_arg, long htlc_minimum_msat_arg, short to_self_delay_arg, short max_accepted_htlcs_arg, int locktime_arg, byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_basepoint_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg, byte[] first_per_commitment_point_arg, byte[] second_per_commitment_point_arg, byte channel_flags_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg, org.ldk.enums.COption_NoneZ require_confirmed_inputs_arg) {
452                 long ret = bindings.OpenChannelV2_new(InternalUtils.check_arr_len(chain_hash_arg, 32), InternalUtils.check_arr_len(temporary_channel_id_arg, 32), funding_feerate_sat_per_1000_weight_arg, commitment_feerate_sat_per_1000_weight_arg, funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, to_self_delay_arg, max_accepted_htlcs_arg, locktime_arg, InternalUtils.check_arr_len(funding_pubkey_arg, 33), InternalUtils.check_arr_len(revocation_basepoint_arg, 33), InternalUtils.check_arr_len(payment_basepoint_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), InternalUtils.check_arr_len(second_per_commitment_point_arg, 33), channel_flags_arg, shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr, require_confirmed_inputs_arg);
453                 Reference.reachabilityFence(chain_hash_arg);
454                 Reference.reachabilityFence(temporary_channel_id_arg);
455                 Reference.reachabilityFence(funding_feerate_sat_per_1000_weight_arg);
456                 Reference.reachabilityFence(commitment_feerate_sat_per_1000_weight_arg);
457                 Reference.reachabilityFence(funding_satoshis_arg);
458                 Reference.reachabilityFence(dust_limit_satoshis_arg);
459                 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
460                 Reference.reachabilityFence(htlc_minimum_msat_arg);
461                 Reference.reachabilityFence(to_self_delay_arg);
462                 Reference.reachabilityFence(max_accepted_htlcs_arg);
463                 Reference.reachabilityFence(locktime_arg);
464                 Reference.reachabilityFence(funding_pubkey_arg);
465                 Reference.reachabilityFence(revocation_basepoint_arg);
466                 Reference.reachabilityFence(payment_basepoint_arg);
467                 Reference.reachabilityFence(delayed_payment_basepoint_arg);
468                 Reference.reachabilityFence(htlc_basepoint_arg);
469                 Reference.reachabilityFence(first_per_commitment_point_arg);
470                 Reference.reachabilityFence(second_per_commitment_point_arg);
471                 Reference.reachabilityFence(channel_flags_arg);
472                 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
473                 Reference.reachabilityFence(channel_type_arg);
474                 Reference.reachabilityFence(require_confirmed_inputs_arg);
475                 if (ret >= 0 && ret <= 4096) { return null; }
476                 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
477                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
478                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
479                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
480                 return ret_hu_conv;
481         }
482
483         long clone_ptr() {
484                 long ret = bindings.OpenChannelV2_clone_ptr(this.ptr);
485                 Reference.reachabilityFence(this);
486                 return ret;
487         }
488
489         /**
490          * Creates a copy of the OpenChannelV2
491          */
492         public OpenChannelV2 clone() {
493                 long ret = bindings.OpenChannelV2_clone(this.ptr);
494                 Reference.reachabilityFence(this);
495                 if (ret >= 0 && ret <= 4096) { return null; }
496                 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
497                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
498                 return ret_hu_conv;
499         }
500
501         /**
502          * Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
503          */
504         public long hash() {
505                 long ret = bindings.OpenChannelV2_hash(this.ptr);
506                 Reference.reachabilityFence(this);
507                 return ret;
508         }
509
510         @Override public int hashCode() {
511                 return (int)this.hash();
512         }
513         /**
514          * Checks if two OpenChannelV2s contain equal inner contents.
515          * This ignores pointers and is_owned flags and looks at the values in fields.
516          * Two objects with NULL inner values will be considered "equal" here.
517          */
518         public boolean eq(org.ldk.structs.OpenChannelV2 b) {
519                 boolean ret = bindings.OpenChannelV2_eq(this.ptr, b == null ? 0 : b.ptr);
520                 Reference.reachabilityFence(this);
521                 Reference.reachabilityFence(b);
522                 if (this != null) { this.ptrs_to.add(b); };
523                 return ret;
524         }
525
526         @Override public boolean equals(Object o) {
527                 if (!(o instanceof OpenChannelV2)) return false;
528                 return this.eq((OpenChannelV2)o);
529         }
530         /**
531          * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
532          */
533         public byte[] write() {
534                 byte[] ret = bindings.OpenChannelV2_write(this.ptr);
535                 Reference.reachabilityFence(this);
536                 return ret;
537         }
538
539         /**
540          * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
541          */
542         public static Result_OpenChannelV2DecodeErrorZ read(byte[] ser) {
543                 long ret = bindings.OpenChannelV2_read(ser);
544                 Reference.reachabilityFence(ser);
545                 if (ret >= 0 && ret <= 4096) { return null; }
546                 Result_OpenChannelV2DecodeErrorZ ret_hu_conv = Result_OpenChannelV2DecodeErrorZ.constr_from_ptr(ret);
547                 return ret_hu_conv;
548         }
549
550 }