[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / CommonOpenChannelFields.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  * Contains fields that are both common to [`open_channel`] and `open_channel2` messages.
13  * 
14  * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class CommonOpenChannelFields extends CommonBase {
18         CommonOpenChannelFields(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.CommonOpenChannelFields_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.CommonOpenChannelFields_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.CommonOpenChannelFields_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
45          * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
46          * For V1 channels: a temporary channel ID, until the funding outpoint is announced
47          */
48         public ChannelId get_temporary_channel_id() {
49                 long ret = bindings.CommonOpenChannelFields_get_temporary_channel_id(this.ptr);
50                 Reference.reachabilityFence(this);
51                 if (ret >= 0 && ret <= 4096) { return null; }
52                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
53                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
54                 return ret_hu_conv;
55         }
56
57         /**
58          * A temporary channel ID
59          * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
60          * For V1 channels: a temporary channel ID, until the funding outpoint is announced
61          */
62         public void set_temporary_channel_id(org.ldk.structs.ChannelId val) {
63                 bindings.CommonOpenChannelFields_set_temporary_channel_id(this.ptr, val.ptr);
64                 Reference.reachabilityFence(this);
65                 Reference.reachabilityFence(val);
66                 if (this != null) { this.ptrs_to.add(val); };
67         }
68
69         /**
70          * For V1 channels: The channel value
71          * For V2 channels: Part of the channel value contributed by the channel initiator
72          */
73         public long get_funding_satoshis() {
74                 long ret = bindings.CommonOpenChannelFields_get_funding_satoshis(this.ptr);
75                 Reference.reachabilityFence(this);
76                 return ret;
77         }
78
79         /**
80          * For V1 channels: The channel value
81          * For V2 channels: Part of the channel value contributed by the channel initiator
82          */
83         public void set_funding_satoshis(long val) {
84                 bindings.CommonOpenChannelFields_set_funding_satoshis(this.ptr, val);
85                 Reference.reachabilityFence(this);
86                 Reference.reachabilityFence(val);
87         }
88
89         /**
90          * The threshold below which outputs on transactions broadcast by the channel initiator will be
91          * omitted
92          */
93         public long get_dust_limit_satoshis() {
94                 long ret = bindings.CommonOpenChannelFields_get_dust_limit_satoshis(this.ptr);
95                 Reference.reachabilityFence(this);
96                 return ret;
97         }
98
99         /**
100          * The threshold below which outputs on transactions broadcast by the channel initiator will be
101          * omitted
102          */
103         public void set_dust_limit_satoshis(long val) {
104                 bindings.CommonOpenChannelFields_set_dust_limit_satoshis(this.ptr, val);
105                 Reference.reachabilityFence(this);
106                 Reference.reachabilityFence(val);
107         }
108
109         /**
110          * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
111          */
112         public long get_max_htlc_value_in_flight_msat() {
113                 long ret = bindings.CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(this.ptr);
114                 Reference.reachabilityFence(this);
115                 return ret;
116         }
117
118         /**
119          * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
120          */
121         public void set_max_htlc_value_in_flight_msat(long val) {
122                 bindings.CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(this.ptr, val);
123                 Reference.reachabilityFence(this);
124                 Reference.reachabilityFence(val);
125         }
126
127         /**
128          * The minimum HTLC size incoming to channel initiator, in milli-satoshi
129          */
130         public long get_htlc_minimum_msat() {
131                 long ret = bindings.CommonOpenChannelFields_get_htlc_minimum_msat(this.ptr);
132                 Reference.reachabilityFence(this);
133                 return ret;
134         }
135
136         /**
137          * The minimum HTLC size incoming to channel initiator, in milli-satoshi
138          */
139         public void set_htlc_minimum_msat(long val) {
140                 bindings.CommonOpenChannelFields_set_htlc_minimum_msat(this.ptr, val);
141                 Reference.reachabilityFence(this);
142                 Reference.reachabilityFence(val);
143         }
144
145         /**
146          * The feerate for the commitment transaction set by the channel initiator until updated by
147          * [`UpdateFee`]
148          */
149         public int get_commitment_feerate_sat_per_1000_weight() {
150                 int ret = bindings.CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(this.ptr);
151                 Reference.reachabilityFence(this);
152                 return ret;
153         }
154
155         /**
156          * The feerate for the commitment transaction set by the channel initiator until updated by
157          * [`UpdateFee`]
158          */
159         public void set_commitment_feerate_sat_per_1000_weight(int val) {
160                 bindings.CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(this.ptr, val);
161                 Reference.reachabilityFence(this);
162                 Reference.reachabilityFence(val);
163         }
164
165         /**
166          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
167          * broadcast a commitment transaction
168          */
169         public short get_to_self_delay() {
170                 short ret = bindings.CommonOpenChannelFields_get_to_self_delay(this.ptr);
171                 Reference.reachabilityFence(this);
172                 return ret;
173         }
174
175         /**
176          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
177          * broadcast a commitment transaction
178          */
179         public void set_to_self_delay(short val) {
180                 bindings.CommonOpenChannelFields_set_to_self_delay(this.ptr, val);
181                 Reference.reachabilityFence(this);
182                 Reference.reachabilityFence(val);
183         }
184
185         /**
186          * The maximum number of inbound HTLCs towards channel initiator
187          */
188         public short get_max_accepted_htlcs() {
189                 short ret = bindings.CommonOpenChannelFields_get_max_accepted_htlcs(this.ptr);
190                 Reference.reachabilityFence(this);
191                 return ret;
192         }
193
194         /**
195          * The maximum number of inbound HTLCs towards channel initiator
196          */
197         public void set_max_accepted_htlcs(short val) {
198                 bindings.CommonOpenChannelFields_set_max_accepted_htlcs(this.ptr, val);
199                 Reference.reachabilityFence(this);
200                 Reference.reachabilityFence(val);
201         }
202
203         /**
204          * The channel initiator's key controlling the funding transaction
205          */
206         public byte[] get_funding_pubkey() {
207                 byte[] ret = bindings.CommonOpenChannelFields_get_funding_pubkey(this.ptr);
208                 Reference.reachabilityFence(this);
209                 return ret;
210         }
211
212         /**
213          * The channel initiator's key controlling the funding transaction
214          */
215         public void set_funding_pubkey(byte[] val) {
216                 bindings.CommonOpenChannelFields_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
217                 Reference.reachabilityFence(this);
218                 Reference.reachabilityFence(val);
219         }
220
221         /**
222          * Used to derive a revocation key for transactions broadcast by counterparty
223          */
224         public byte[] get_revocation_basepoint() {
225                 byte[] ret = bindings.CommonOpenChannelFields_get_revocation_basepoint(this.ptr);
226                 Reference.reachabilityFence(this);
227                 return ret;
228         }
229
230         /**
231          * Used to derive a revocation key for transactions broadcast by counterparty
232          */
233         public void set_revocation_basepoint(byte[] val) {
234                 bindings.CommonOpenChannelFields_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
235                 Reference.reachabilityFence(this);
236                 Reference.reachabilityFence(val);
237         }
238
239         /**
240          * A payment key to channel initiator for transactions broadcast by counterparty
241          */
242         public byte[] get_payment_basepoint() {
243                 byte[] ret = bindings.CommonOpenChannelFields_get_payment_basepoint(this.ptr);
244                 Reference.reachabilityFence(this);
245                 return ret;
246         }
247
248         /**
249          * A payment key to channel initiator for transactions broadcast by counterparty
250          */
251         public void set_payment_basepoint(byte[] val) {
252                 bindings.CommonOpenChannelFields_set_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
253                 Reference.reachabilityFence(this);
254                 Reference.reachabilityFence(val);
255         }
256
257         /**
258          * Used to derive a payment key to channel initiator for transactions broadcast by channel
259          * initiator
260          */
261         public byte[] get_delayed_payment_basepoint() {
262                 byte[] ret = bindings.CommonOpenChannelFields_get_delayed_payment_basepoint(this.ptr);
263                 Reference.reachabilityFence(this);
264                 return ret;
265         }
266
267         /**
268          * Used to derive a payment key to channel initiator for transactions broadcast by channel
269          * initiator
270          */
271         public void set_delayed_payment_basepoint(byte[] val) {
272                 bindings.CommonOpenChannelFields_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
273                 Reference.reachabilityFence(this);
274                 Reference.reachabilityFence(val);
275         }
276
277         /**
278          * Used to derive an HTLC payment key to channel initiator
279          */
280         public byte[] get_htlc_basepoint() {
281                 byte[] ret = bindings.CommonOpenChannelFields_get_htlc_basepoint(this.ptr);
282                 Reference.reachabilityFence(this);
283                 return ret;
284         }
285
286         /**
287          * Used to derive an HTLC payment key to channel initiator
288          */
289         public void set_htlc_basepoint(byte[] val) {
290                 bindings.CommonOpenChannelFields_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
291                 Reference.reachabilityFence(this);
292                 Reference.reachabilityFence(val);
293         }
294
295         /**
296          * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
297          */
298         public byte[] get_first_per_commitment_point() {
299                 byte[] ret = bindings.CommonOpenChannelFields_get_first_per_commitment_point(this.ptr);
300                 Reference.reachabilityFence(this);
301                 return ret;
302         }
303
304         /**
305          * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
306          */
307         public void set_first_per_commitment_point(byte[] val) {
308                 bindings.CommonOpenChannelFields_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
309                 Reference.reachabilityFence(this);
310                 Reference.reachabilityFence(val);
311         }
312
313         /**
314          * The channel flags to be used
315          */
316         public byte get_channel_flags() {
317                 byte ret = bindings.CommonOpenChannelFields_get_channel_flags(this.ptr);
318                 Reference.reachabilityFence(this);
319                 return ret;
320         }
321
322         /**
323          * The channel flags to be used
324          */
325         public void set_channel_flags(byte val) {
326                 bindings.CommonOpenChannelFields_set_channel_flags(this.ptr, val);
327                 Reference.reachabilityFence(this);
328                 Reference.reachabilityFence(val);
329         }
330
331         /**
332          * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
333          * collaboratively close
334          */
335         public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
336                 long ret = bindings.CommonOpenChannelFields_get_shutdown_scriptpubkey(this.ptr);
337                 Reference.reachabilityFence(this);
338                 if (ret >= 0 && ret <= 4096) { return null; }
339                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
340                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
341                 return ret_hu_conv;
342         }
343
344         /**
345          * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
346          * collaboratively close
347          */
348         public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
349                 bindings.CommonOpenChannelFields_set_shutdown_scriptpubkey(this.ptr, val.ptr);
350                 Reference.reachabilityFence(this);
351                 Reference.reachabilityFence(val);
352                 if (this != null) { this.ptrs_to.add(val); };
353         }
354
355         /**
356          * The channel type that this channel will represent
357          * 
358          * If this is `None`, we derive the channel type from the intersection of our
359          * feature bits with our counterparty's feature bits from the [`Init`] message.
360          * 
361          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
362          */
363         @Nullable
364         public ChannelTypeFeatures get_channel_type() {
365                 long ret = bindings.CommonOpenChannelFields_get_channel_type(this.ptr);
366                 Reference.reachabilityFence(this);
367                 if (ret >= 0 && ret <= 4096) { return null; }
368                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
369                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
370                 return ret_hu_conv;
371         }
372
373         /**
374          * The channel type that this channel will represent
375          * 
376          * If this is `None`, we derive the channel type from the intersection of our
377          * feature bits with our counterparty's feature bits from the [`Init`] message.
378          * 
379          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
380          */
381         public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
382                 bindings.CommonOpenChannelFields_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
383                 Reference.reachabilityFence(this);
384                 Reference.reachabilityFence(val);
385                 if (this != null) { this.ptrs_to.add(val); };
386         }
387
388         /**
389          * Constructs a new CommonOpenChannelFields given each field
390          * 
391          * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
392          */
393         public static CommonOpenChannelFields of(byte[] chain_hash_arg, org.ldk.structs.ChannelId temporary_channel_id_arg, long funding_satoshis_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_arg, long htlc_minimum_msat_arg, int commitment_feerate_sat_per_1000_weight_arg, short to_self_delay_arg, short max_accepted_htlcs_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 channel_flags_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
394                 long ret = bindings.CommonOpenChannelFields_new(InternalUtils.check_arr_len(chain_hash_arg, 32), temporary_channel_id_arg.ptr, funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, commitment_feerate_sat_per_1000_weight_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_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), channel_flags_arg, shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
395                 Reference.reachabilityFence(chain_hash_arg);
396                 Reference.reachabilityFence(temporary_channel_id_arg);
397                 Reference.reachabilityFence(funding_satoshis_arg);
398                 Reference.reachabilityFence(dust_limit_satoshis_arg);
399                 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
400                 Reference.reachabilityFence(htlc_minimum_msat_arg);
401                 Reference.reachabilityFence(commitment_feerate_sat_per_1000_weight_arg);
402                 Reference.reachabilityFence(to_self_delay_arg);
403                 Reference.reachabilityFence(max_accepted_htlcs_arg);
404                 Reference.reachabilityFence(funding_pubkey_arg);
405                 Reference.reachabilityFence(revocation_basepoint_arg);
406                 Reference.reachabilityFence(payment_basepoint_arg);
407                 Reference.reachabilityFence(delayed_payment_basepoint_arg);
408                 Reference.reachabilityFence(htlc_basepoint_arg);
409                 Reference.reachabilityFence(first_per_commitment_point_arg);
410                 Reference.reachabilityFence(channel_flags_arg);
411                 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
412                 Reference.reachabilityFence(channel_type_arg);
413                 if (ret >= 0 && ret <= 4096) { return null; }
414                 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
415                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
416                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(temporary_channel_id_arg); };
417                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
418                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
419                 return ret_hu_conv;
420         }
421
422         long clone_ptr() {
423                 long ret = bindings.CommonOpenChannelFields_clone_ptr(this.ptr);
424                 Reference.reachabilityFence(this);
425                 return ret;
426         }
427
428         /**
429          * Creates a copy of the CommonOpenChannelFields
430          */
431         public CommonOpenChannelFields clone() {
432                 long ret = bindings.CommonOpenChannelFields_clone(this.ptr);
433                 Reference.reachabilityFence(this);
434                 if (ret >= 0 && ret <= 4096) { return null; }
435                 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
436                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
437                 return ret_hu_conv;
438         }
439
440         /**
441          * Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields.
442          */
443         public long hash() {
444                 long ret = bindings.CommonOpenChannelFields_hash(this.ptr);
445                 Reference.reachabilityFence(this);
446                 return ret;
447         }
448
449         @Override public int hashCode() {
450                 return (int)this.hash();
451         }
452         /**
453          * Checks if two CommonOpenChannelFieldss contain equal inner contents.
454          * This ignores pointers and is_owned flags and looks at the values in fields.
455          * Two objects with NULL inner values will be considered "equal" here.
456          */
457         public boolean eq(org.ldk.structs.CommonOpenChannelFields b) {
458                 boolean ret = bindings.CommonOpenChannelFields_eq(this.ptr, b.ptr);
459                 Reference.reachabilityFence(this);
460                 Reference.reachabilityFence(b);
461                 if (this != null) { this.ptrs_to.add(b); };
462                 return ret;
463         }
464
465         @Override public boolean equals(Object o) {
466                 if (!(o instanceof CommonOpenChannelFields)) return false;
467                 return this.eq((CommonOpenChannelFields)o);
468         }
469 }