c63f192719fc4d3d7fde118a948e9d8b55afdc5d
[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  * [`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 OpenChannel extends CommonBase {
18         OpenChannel(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.OpenChannel_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.OpenChannel_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.OpenChannel_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, until the funding outpoint is announced
45          */
46         public byte[] get_temporary_channel_id() {
47                 byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * A temporary channel ID, until the funding outpoint is announced
54          */
55         public void set_temporary_channel_id(byte[] val) {
56                 bindings.OpenChannel_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 channel value
63          */
64         public long get_funding_satoshis() {
65                 long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The channel value
72          */
73         public void set_funding_satoshis(long val) {
74                 bindings.OpenChannel_set_funding_satoshis(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * The amount to push to the counterparty as part of the open, in milli-satoshi
81          */
82         public long get_push_msat() {
83                 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * The amount to push to the counterparty as part of the open, in milli-satoshi
90          */
91         public void set_push_msat(long val) {
92                 bindings.OpenChannel_set_push_msat(this.ptr, val);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * The threshold below which outputs on transactions broadcast by sender will be omitted
99          */
100         public long get_dust_limit_satoshis() {
101                 long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * The threshold below which outputs on transactions broadcast by sender will be omitted
108          */
109         public void set_dust_limit_satoshis(long val) {
110                 bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val);
111                 Reference.reachabilityFence(this);
112                 Reference.reachabilityFence(val);
113         }
114
115         /**
116          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
117          */
118         public long get_max_htlc_value_in_flight_msat() {
119                 long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr);
120                 Reference.reachabilityFence(this);
121                 return ret;
122         }
123
124         /**
125          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
126          */
127         public void set_max_htlc_value_in_flight_msat(long val) {
128                 bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
129                 Reference.reachabilityFence(this);
130                 Reference.reachabilityFence(val);
131         }
132
133         /**
134          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
135          */
136         public long get_channel_reserve_satoshis() {
137                 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
138                 Reference.reachabilityFence(this);
139                 return ret;
140         }
141
142         /**
143          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
144          */
145         public void set_channel_reserve_satoshis(long val) {
146                 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
147                 Reference.reachabilityFence(this);
148                 Reference.reachabilityFence(val);
149         }
150
151         /**
152          * The minimum HTLC size incoming to sender, in milli-satoshi
153          */
154         public long get_htlc_minimum_msat() {
155                 long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr);
156                 Reference.reachabilityFence(this);
157                 return ret;
158         }
159
160         /**
161          * The minimum HTLC size incoming to sender, in milli-satoshi
162          */
163         public void set_htlc_minimum_msat(long val) {
164                 bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val);
165                 Reference.reachabilityFence(this);
166                 Reference.reachabilityFence(val);
167         }
168
169         /**
170          * The feerate per 1000-weight of sender generated transactions, until updated by
171          * [`UpdateFee`]
172          */
173         public int get_feerate_per_kw() {
174                 int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr);
175                 Reference.reachabilityFence(this);
176                 return ret;
177         }
178
179         /**
180          * The feerate per 1000-weight of sender generated transactions, until updated by
181          * [`UpdateFee`]
182          */
183         public void set_feerate_per_kw(int val) {
184                 bindings.OpenChannel_set_feerate_per_kw(this.ptr, val);
185                 Reference.reachabilityFence(this);
186                 Reference.reachabilityFence(val);
187         }
188
189         /**
190          * The number of blocks which the counterparty will have to wait to claim on-chain funds if
191          * they broadcast a commitment transaction
192          */
193         public short get_to_self_delay() {
194                 short ret = bindings.OpenChannel_get_to_self_delay(this.ptr);
195                 Reference.reachabilityFence(this);
196                 return ret;
197         }
198
199         /**
200          * The number of blocks which the counterparty will have to wait to claim on-chain funds if
201          * they broadcast a commitment transaction
202          */
203         public void set_to_self_delay(short val) {
204                 bindings.OpenChannel_set_to_self_delay(this.ptr, val);
205                 Reference.reachabilityFence(this);
206                 Reference.reachabilityFence(val);
207         }
208
209         /**
210          * The maximum number of inbound HTLCs towards sender
211          */
212         public short get_max_accepted_htlcs() {
213                 short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr);
214                 Reference.reachabilityFence(this);
215                 return ret;
216         }
217
218         /**
219          * The maximum number of inbound HTLCs towards sender
220          */
221         public void set_max_accepted_htlcs(short val) {
222                 bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val);
223                 Reference.reachabilityFence(this);
224                 Reference.reachabilityFence(val);
225         }
226
227         /**
228          * The sender's key controlling the funding transaction
229          */
230         public byte[] get_funding_pubkey() {
231                 byte[] ret = bindings.OpenChannel_get_funding_pubkey(this.ptr);
232                 Reference.reachabilityFence(this);
233                 return ret;
234         }
235
236         /**
237          * The sender's key controlling the funding transaction
238          */
239         public void set_funding_pubkey(byte[] val) {
240                 bindings.OpenChannel_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.OpenChannel_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.OpenChannel_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 sender for transactions broadcast by counterparty
265          */
266         public byte[] get_payment_point() {
267                 byte[] ret = bindings.OpenChannel_get_payment_point(this.ptr);
268                 Reference.reachabilityFence(this);
269                 return ret;
270         }
271
272         /**
273          * A payment key to sender for transactions broadcast by counterparty
274          */
275         public void set_payment_point(byte[] val) {
276                 bindings.OpenChannel_set_payment_point(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 sender for transactions broadcast by sender
283          */
284         public byte[] get_delayed_payment_basepoint() {
285                 byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr);
286                 Reference.reachabilityFence(this);
287                 return ret;
288         }
289
290         /**
291          * Used to derive a payment key to sender for transactions broadcast by sender
292          */
293         public void set_delayed_payment_basepoint(byte[] val) {
294                 bindings.OpenChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
295                 Reference.reachabilityFence(this);
296                 Reference.reachabilityFence(val);
297         }
298
299         /**
300          * Used to derive an HTLC payment key to sender
301          */
302         public byte[] get_htlc_basepoint() {
303                 byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr);
304                 Reference.reachabilityFence(this);
305                 return ret;
306         }
307
308         /**
309          * Used to derive an HTLC payment key to sender
310          */
311         public void set_htlc_basepoint(byte[] val) {
312                 bindings.OpenChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
313                 Reference.reachabilityFence(this);
314                 Reference.reachabilityFence(val);
315         }
316
317         /**
318          * The first to-be-broadcast-by-sender transaction's per commitment point
319          */
320         public byte[] get_first_per_commitment_point() {
321                 byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr);
322                 Reference.reachabilityFence(this);
323                 return ret;
324         }
325
326         /**
327          * The first to-be-broadcast-by-sender transaction's per commitment point
328          */
329         public void set_first_per_commitment_point(byte[] val) {
330                 bindings.OpenChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
331                 Reference.reachabilityFence(this);
332                 Reference.reachabilityFence(val);
333         }
334
335         /**
336          * The channel flags to be used
337          */
338         public byte get_channel_flags() {
339                 byte ret = bindings.OpenChannel_get_channel_flags(this.ptr);
340                 Reference.reachabilityFence(this);
341                 return ret;
342         }
343
344         /**
345          * The channel flags to be used
346          */
347         public void set_channel_flags(byte val) {
348                 bindings.OpenChannel_set_channel_flags(this.ptr, val);
349                 Reference.reachabilityFence(this);
350                 Reference.reachabilityFence(val);
351         }
352
353         /**
354          * The channel type that this channel will represent
355          * 
356          * If this is `None`, we derive the channel type from the intersection of our
357          * feature bits with our counterparty's feature bits from the [`Init`] message.
358          * 
359          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
360          */
361         @Nullable
362         public ChannelTypeFeatures get_channel_type() {
363                 long ret = bindings.OpenChannel_get_channel_type(this.ptr);
364                 Reference.reachabilityFence(this);
365                 if (ret >= 0 && ret <= 4096) { return null; }
366                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
367                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
368                 return ret_hu_conv;
369         }
370
371         /**
372          * The channel type that this channel will represent
373          * 
374          * If this is `None`, we derive the channel type from the intersection of our
375          * feature bits with our counterparty's feature bits from the [`Init`] message.
376          * 
377          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
378          */
379         public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
380                 bindings.OpenChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
381                 Reference.reachabilityFence(this);
382                 Reference.reachabilityFence(val);
383                 if (this != null) { this.ptrs_to.add(val); };
384         }
385
386         long clone_ptr() {
387                 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
388                 Reference.reachabilityFence(this);
389                 return ret;
390         }
391
392         /**
393          * Creates a copy of the OpenChannel
394          */
395         public OpenChannel clone() {
396                 long ret = bindings.OpenChannel_clone(this.ptr);
397                 Reference.reachabilityFence(this);
398                 if (ret >= 0 && ret <= 4096) { return null; }
399                 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
400                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
401                 return ret_hu_conv;
402         }
403
404         /**
405          * Checks if two OpenChannels contain equal inner contents.
406          * This ignores pointers and is_owned flags and looks at the values in fields.
407          * Two objects with NULL inner values will be considered "equal" here.
408          */
409         public boolean eq(org.ldk.structs.OpenChannel b) {
410                 boolean ret = bindings.OpenChannel_eq(this.ptr, b == null ? 0 : b.ptr);
411                 Reference.reachabilityFence(this);
412                 Reference.reachabilityFence(b);
413                 if (this != null) { this.ptrs_to.add(b); };
414                 return ret;
415         }
416
417         @Override public boolean equals(Object o) {
418                 if (!(o instanceof OpenChannel)) return false;
419                 return this.eq((OpenChannel)o);
420         }
421         /**
422          * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
423          */
424         public byte[] write() {
425                 byte[] ret = bindings.OpenChannel_write(this.ptr);
426                 Reference.reachabilityFence(this);
427                 return ret;
428         }
429
430         /**
431          * Read a OpenChannel from a byte array, created by OpenChannel_write
432          */
433         public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
434                 long ret = bindings.OpenChannel_read(ser);
435                 Reference.reachabilityFence(ser);
436                 if (ret >= 0 && ret <= 4096) { return null; }
437                 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
438                 return ret_hu_conv;
439         }
440
441 }