[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / OpenChannel.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_channel`] message to be sent to or received from a peer.
13  * 
14  * Used in V1 channel establishment
15  * 
16  * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class OpenChannel extends CommonBase {
20         OpenChannel(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.OpenChannel_free(ptr); }
25         }
26
27         /**
28          * The genesis hash of the blockchain where the channel is to be opened
29          */
30         public byte[] get_chain_hash() {
31                 byte[] ret = bindings.OpenChannel_get_chain_hash(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * The genesis hash of the blockchain where the channel is to be opened
38          */
39         public void set_chain_hash(byte[] val) {
40                 bindings.OpenChannel_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * A temporary channel ID, until the funding outpoint is announced
47          */
48         public byte[] get_temporary_channel_id() {
49                 byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * A temporary channel ID, until the funding outpoint is announced
56          */
57         public void set_temporary_channel_id(byte[] val) {
58                 bindings.OpenChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61         }
62
63         /**
64          * The channel value
65          */
66         public long get_funding_satoshis() {
67                 long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         /**
73          * The channel value
74          */
75         public void set_funding_satoshis(long val) {
76                 bindings.OpenChannel_set_funding_satoshis(this.ptr, val);
77                 Reference.reachabilityFence(this);
78                 Reference.reachabilityFence(val);
79         }
80
81         /**
82          * The amount to push to the counterparty as part of the open, in milli-satoshi
83          */
84         public long get_push_msat() {
85                 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
86                 Reference.reachabilityFence(this);
87                 return ret;
88         }
89
90         /**
91          * The amount to push to the counterparty as part of the open, in milli-satoshi
92          */
93         public void set_push_msat(long val) {
94                 bindings.OpenChannel_set_push_msat(this.ptr, val);
95                 Reference.reachabilityFence(this);
96                 Reference.reachabilityFence(val);
97         }
98
99         /**
100          * The threshold below which outputs on transactions broadcast by sender will be omitted
101          */
102         public long get_dust_limit_satoshis() {
103                 long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr);
104                 Reference.reachabilityFence(this);
105                 return ret;
106         }
107
108         /**
109          * The threshold below which outputs on transactions broadcast by sender will be omitted
110          */
111         public void set_dust_limit_satoshis(long val) {
112                 bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val);
113                 Reference.reachabilityFence(this);
114                 Reference.reachabilityFence(val);
115         }
116
117         /**
118          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
119          */
120         public long get_max_htlc_value_in_flight_msat() {
121                 long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr);
122                 Reference.reachabilityFence(this);
123                 return ret;
124         }
125
126         /**
127          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
128          */
129         public void set_max_htlc_value_in_flight_msat(long val) {
130                 bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
131                 Reference.reachabilityFence(this);
132                 Reference.reachabilityFence(val);
133         }
134
135         /**
136          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
137          */
138         public long get_channel_reserve_satoshis() {
139                 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
146          */
147         public void set_channel_reserve_satoshis(long val) {
148                 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(val);
151         }
152
153         /**
154          * The minimum HTLC size incoming to sender, in milli-satoshi
155          */
156         public long get_htlc_minimum_msat() {
157                 long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr);
158                 Reference.reachabilityFence(this);
159                 return ret;
160         }
161
162         /**
163          * The minimum HTLC size incoming to sender, in milli-satoshi
164          */
165         public void set_htlc_minimum_msat(long val) {
166                 bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val);
167                 Reference.reachabilityFence(this);
168                 Reference.reachabilityFence(val);
169         }
170
171         /**
172          * The feerate per 1000-weight of sender generated transactions, until updated by
173          * [`UpdateFee`]
174          */
175         public int get_feerate_per_kw() {
176                 int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr);
177                 Reference.reachabilityFence(this);
178                 return ret;
179         }
180
181         /**
182          * The feerate per 1000-weight of sender generated transactions, until updated by
183          * [`UpdateFee`]
184          */
185         public void set_feerate_per_kw(int val) {
186                 bindings.OpenChannel_set_feerate_per_kw(this.ptr, val);
187                 Reference.reachabilityFence(this);
188                 Reference.reachabilityFence(val);
189         }
190
191         /**
192          * The number of blocks which the counterparty will have to wait to claim on-chain funds if
193          * they broadcast a commitment transaction
194          */
195         public short get_to_self_delay() {
196                 short ret = bindings.OpenChannel_get_to_self_delay(this.ptr);
197                 Reference.reachabilityFence(this);
198                 return ret;
199         }
200
201         /**
202          * The number of blocks which the counterparty will have to wait to claim on-chain funds if
203          * they broadcast a commitment transaction
204          */
205         public void set_to_self_delay(short val) {
206                 bindings.OpenChannel_set_to_self_delay(this.ptr, val);
207                 Reference.reachabilityFence(this);
208                 Reference.reachabilityFence(val);
209         }
210
211         /**
212          * The maximum number of inbound HTLCs towards sender
213          */
214         public short get_max_accepted_htlcs() {
215                 short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr);
216                 Reference.reachabilityFence(this);
217                 return ret;
218         }
219
220         /**
221          * The maximum number of inbound HTLCs towards sender
222          */
223         public void set_max_accepted_htlcs(short val) {
224                 bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val);
225                 Reference.reachabilityFence(this);
226                 Reference.reachabilityFence(val);
227         }
228
229         /**
230          * The sender's key controlling the funding transaction
231          */
232         public byte[] get_funding_pubkey() {
233                 byte[] ret = bindings.OpenChannel_get_funding_pubkey(this.ptr);
234                 Reference.reachabilityFence(this);
235                 return ret;
236         }
237
238         /**
239          * The sender's key controlling the funding transaction
240          */
241         public void set_funding_pubkey(byte[] val) {
242                 bindings.OpenChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
243                 Reference.reachabilityFence(this);
244                 Reference.reachabilityFence(val);
245         }
246
247         /**
248          * Used to derive a revocation key for transactions broadcast by counterparty
249          */
250         public byte[] get_revocation_basepoint() {
251                 byte[] ret = bindings.OpenChannel_get_revocation_basepoint(this.ptr);
252                 Reference.reachabilityFence(this);
253                 return ret;
254         }
255
256         /**
257          * Used to derive a revocation key for transactions broadcast by counterparty
258          */
259         public void set_revocation_basepoint(byte[] val) {
260                 bindings.OpenChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
261                 Reference.reachabilityFence(this);
262                 Reference.reachabilityFence(val);
263         }
264
265         /**
266          * A payment key to sender for transactions broadcast by counterparty
267          */
268         public byte[] get_payment_point() {
269                 byte[] ret = bindings.OpenChannel_get_payment_point(this.ptr);
270                 Reference.reachabilityFence(this);
271                 return ret;
272         }
273
274         /**
275          * A payment key to sender for transactions broadcast by counterparty
276          */
277         public void set_payment_point(byte[] val) {
278                 bindings.OpenChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
279                 Reference.reachabilityFence(this);
280                 Reference.reachabilityFence(val);
281         }
282
283         /**
284          * Used to derive a payment key to sender for transactions broadcast by sender
285          */
286         public byte[] get_delayed_payment_basepoint() {
287                 byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr);
288                 Reference.reachabilityFence(this);
289                 return ret;
290         }
291
292         /**
293          * Used to derive a payment key to sender for transactions broadcast by sender
294          */
295         public void set_delayed_payment_basepoint(byte[] val) {
296                 bindings.OpenChannel_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 sender
303          */
304         public byte[] get_htlc_basepoint() {
305                 byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr);
306                 Reference.reachabilityFence(this);
307                 return ret;
308         }
309
310         /**
311          * Used to derive an HTLC payment key to sender
312          */
313         public void set_htlc_basepoint(byte[] val) {
314                 bindings.OpenChannel_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-sender transaction's per commitment point
321          */
322         public byte[] get_first_per_commitment_point() {
323                 byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr);
324                 Reference.reachabilityFence(this);
325                 return ret;
326         }
327
328         /**
329          * The first to-be-broadcast-by-sender transaction's per commitment point
330          */
331         public void set_first_per_commitment_point(byte[] val) {
332                 bindings.OpenChannel_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 channel flags to be used
339          */
340         public byte get_channel_flags() {
341                 byte ret = bindings.OpenChannel_get_channel_flags(this.ptr);
342                 Reference.reachabilityFence(this);
343                 return ret;
344         }
345
346         /**
347          * The channel flags to be used
348          */
349         public void set_channel_flags(byte val) {
350                 bindings.OpenChannel_set_channel_flags(this.ptr, val);
351                 Reference.reachabilityFence(this);
352                 Reference.reachabilityFence(val);
353         }
354
355         /**
356          * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
357          */
358         public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
359                 long ret = bindings.OpenChannel_get_shutdown_scriptpubkey(this.ptr);
360                 Reference.reachabilityFence(this);
361                 if (ret >= 0 && ret <= 4096) { return null; }
362                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
363                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
364                 return ret_hu_conv;
365         }
366
367         /**
368          * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close
369          */
370         public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
371                 bindings.OpenChannel_set_shutdown_scriptpubkey(this.ptr, val.ptr);
372                 Reference.reachabilityFence(this);
373                 Reference.reachabilityFence(val);
374                 if (this != null) { this.ptrs_to.add(val); };
375         }
376
377         /**
378          * The channel type that this channel will represent
379          * 
380          * If this is `None`, we derive the channel type from the intersection of our
381          * feature bits with our counterparty's feature bits from the [`Init`] message.
382          * 
383          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
384          */
385         @Nullable
386         public ChannelTypeFeatures get_channel_type() {
387                 long ret = bindings.OpenChannel_get_channel_type(this.ptr);
388                 Reference.reachabilityFence(this);
389                 if (ret >= 0 && ret <= 4096) { return null; }
390                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
391                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
392                 return ret_hu_conv;
393         }
394
395         /**
396          * The channel type that this channel will represent
397          * 
398          * If this is `None`, we derive the channel type from the intersection of our
399          * feature bits with our counterparty's feature bits from the [`Init`] message.
400          * 
401          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
402          */
403         public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
404                 bindings.OpenChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
405                 Reference.reachabilityFence(this);
406                 Reference.reachabilityFence(val);
407                 if (this != null) { this.ptrs_to.add(val); };
408         }
409
410         /**
411          * Constructs a new OpenChannel given each field
412          * 
413          * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
414          */
415         public static OpenChannel of(byte[] chain_hash_arg, byte[] temporary_channel_id_arg, long funding_satoshis_arg, long push_msat_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 feerate_per_kw_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, byte channel_flags_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, @Nullable org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
416                 long ret = bindings.OpenChannel_new(InternalUtils.check_arr_len(chain_hash_arg, 32), InternalUtils.check_arr_len(temporary_channel_id_arg, 32), funding_satoshis_arg, push_msat_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_arg, htlc_minimum_msat_arg, feerate_per_kw_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), channel_flags_arg, shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
417                 Reference.reachabilityFence(chain_hash_arg);
418                 Reference.reachabilityFence(temporary_channel_id_arg);
419                 Reference.reachabilityFence(funding_satoshis_arg);
420                 Reference.reachabilityFence(push_msat_arg);
421                 Reference.reachabilityFence(dust_limit_satoshis_arg);
422                 Reference.reachabilityFence(max_htlc_value_in_flight_msat_arg);
423                 Reference.reachabilityFence(channel_reserve_satoshis_arg);
424                 Reference.reachabilityFence(htlc_minimum_msat_arg);
425                 Reference.reachabilityFence(feerate_per_kw_arg);
426                 Reference.reachabilityFence(to_self_delay_arg);
427                 Reference.reachabilityFence(max_accepted_htlcs_arg);
428                 Reference.reachabilityFence(funding_pubkey_arg);
429                 Reference.reachabilityFence(revocation_basepoint_arg);
430                 Reference.reachabilityFence(payment_point_arg);
431                 Reference.reachabilityFence(delayed_payment_basepoint_arg);
432                 Reference.reachabilityFence(htlc_basepoint_arg);
433                 Reference.reachabilityFence(first_per_commitment_point_arg);
434                 Reference.reachabilityFence(channel_flags_arg);
435                 Reference.reachabilityFence(shutdown_scriptpubkey_arg);
436                 Reference.reachabilityFence(channel_type_arg);
437                 if (ret >= 0 && ret <= 4096) { return null; }
438                 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
439                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
440                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(shutdown_scriptpubkey_arg); };
441                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_type_arg); };
442                 return ret_hu_conv;
443         }
444
445         long clone_ptr() {
446                 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
447                 Reference.reachabilityFence(this);
448                 return ret;
449         }
450
451         /**
452          * Creates a copy of the OpenChannel
453          */
454         public OpenChannel clone() {
455                 long ret = bindings.OpenChannel_clone(this.ptr);
456                 Reference.reachabilityFence(this);
457                 if (ret >= 0 && ret <= 4096) { return null; }
458                 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
459                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
460                 return ret_hu_conv;
461         }
462
463         /**
464          * Checks if two OpenChannels contain equal inner contents.
465          * This ignores pointers and is_owned flags and looks at the values in fields.
466          * Two objects with NULL inner values will be considered "equal" here.
467          */
468         public boolean eq(org.ldk.structs.OpenChannel b) {
469                 boolean ret = bindings.OpenChannel_eq(this.ptr, b == null ? 0 : b.ptr);
470                 Reference.reachabilityFence(this);
471                 Reference.reachabilityFence(b);
472                 if (this != null) { this.ptrs_to.add(b); };
473                 return ret;
474         }
475
476         @Override public boolean equals(Object o) {
477                 if (!(o instanceof OpenChannel)) return false;
478                 return this.eq((OpenChannel)o);
479         }
480         /**
481          * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
482          */
483         public byte[] write() {
484                 byte[] ret = bindings.OpenChannel_write(this.ptr);
485                 Reference.reachabilityFence(this);
486                 return ret;
487         }
488
489         /**
490          * Read a OpenChannel from a byte array, created by OpenChannel_write
491          */
492         public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
493                 long ret = bindings.OpenChannel_read(ser);
494                 Reference.reachabilityFence(ser);
495                 if (ret >= 0 && ret <= 4096) { return null; }
496                 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
497                 return ret_hu_conv;
498         }
499
500 }