Update auto-updated Java files
[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 or received from a peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class OpenChannel extends CommonBase {
16         OpenChannel(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.OpenChannel_free(ptr); }
21         }
22
23         /**
24          * The genesis hash of the blockchain where the channel is to be opened
25          */
26         public byte[] get_chain_hash() {
27                 byte[] ret = bindings.OpenChannel_get_chain_hash(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The genesis hash of the blockchain where the channel is to be opened
34          */
35         public void set_chain_hash(byte[] val) {
36                 bindings.OpenChannel_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * A temporary channel ID, until the funding outpoint is announced
43          */
44         public byte[] get_temporary_channel_id() {
45                 byte[] ret = bindings.OpenChannel_get_temporary_channel_id(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * A temporary channel ID, until the funding outpoint is announced
52          */
53         public void set_temporary_channel_id(byte[] val) {
54                 bindings.OpenChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(val);
57         }
58
59         /**
60          * The channel value
61          */
62         public long get_funding_satoshis() {
63                 long ret = bindings.OpenChannel_get_funding_satoshis(this.ptr);
64                 Reference.reachabilityFence(this);
65                 return ret;
66         }
67
68         /**
69          * The channel value
70          */
71         public void set_funding_satoshis(long val) {
72                 bindings.OpenChannel_set_funding_satoshis(this.ptr, val);
73                 Reference.reachabilityFence(this);
74                 Reference.reachabilityFence(val);
75         }
76
77         /**
78          * The amount to push to the counterparty as part of the open, in milli-satoshi
79          */
80         public long get_push_msat() {
81                 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
82                 Reference.reachabilityFence(this);
83                 return ret;
84         }
85
86         /**
87          * The amount to push to the counterparty as part of the open, in milli-satoshi
88          */
89         public void set_push_msat(long val) {
90                 bindings.OpenChannel_set_push_msat(this.ptr, val);
91                 Reference.reachabilityFence(this);
92                 Reference.reachabilityFence(val);
93         }
94
95         /**
96          * The threshold below which outputs on transactions broadcast by sender will be omitted
97          */
98         public long get_dust_limit_satoshis() {
99                 long ret = bindings.OpenChannel_get_dust_limit_satoshis(this.ptr);
100                 Reference.reachabilityFence(this);
101                 return ret;
102         }
103
104         /**
105          * The threshold below which outputs on transactions broadcast by sender will be omitted
106          */
107         public void set_dust_limit_satoshis(long val) {
108                 bindings.OpenChannel_set_dust_limit_satoshis(this.ptr, val);
109                 Reference.reachabilityFence(this);
110                 Reference.reachabilityFence(val);
111         }
112
113         /**
114          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
115          */
116         public long get_max_htlc_value_in_flight_msat() {
117                 long ret = bindings.OpenChannel_get_max_htlc_value_in_flight_msat(this.ptr);
118                 Reference.reachabilityFence(this);
119                 return ret;
120         }
121
122         /**
123          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
124          */
125         public void set_max_htlc_value_in_flight_msat(long val) {
126                 bindings.OpenChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
127                 Reference.reachabilityFence(this);
128                 Reference.reachabilityFence(val);
129         }
130
131         /**
132          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
133          */
134         public long get_channel_reserve_satoshis() {
135                 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
136                 Reference.reachabilityFence(this);
137                 return ret;
138         }
139
140         /**
141          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
142          */
143         public void set_channel_reserve_satoshis(long val) {
144                 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
145                 Reference.reachabilityFence(this);
146                 Reference.reachabilityFence(val);
147         }
148
149         /**
150          * The minimum HTLC size incoming to sender, in milli-satoshi
151          */
152         public long get_htlc_minimum_msat() {
153                 long ret = bindings.OpenChannel_get_htlc_minimum_msat(this.ptr);
154                 Reference.reachabilityFence(this);
155                 return ret;
156         }
157
158         /**
159          * The minimum HTLC size incoming to sender, in milli-satoshi
160          */
161         public void set_htlc_minimum_msat(long val) {
162                 bindings.OpenChannel_set_htlc_minimum_msat(this.ptr, val);
163                 Reference.reachabilityFence(this);
164                 Reference.reachabilityFence(val);
165         }
166
167         /**
168          * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
169          */
170         public int get_feerate_per_kw() {
171                 int ret = bindings.OpenChannel_get_feerate_per_kw(this.ptr);
172                 Reference.reachabilityFence(this);
173                 return ret;
174         }
175
176         /**
177          * The feerate per 1000-weight of sender generated transactions, until updated by update_fee
178          */
179         public void set_feerate_per_kw(int val) {
180                 bindings.OpenChannel_set_feerate_per_kw(this.ptr, val);
181                 Reference.reachabilityFence(this);
182                 Reference.reachabilityFence(val);
183         }
184
185         /**
186          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
187          */
188         public short get_to_self_delay() {
189                 short ret = bindings.OpenChannel_get_to_self_delay(this.ptr);
190                 Reference.reachabilityFence(this);
191                 return ret;
192         }
193
194         /**
195          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
196          */
197         public void set_to_self_delay(short val) {
198                 bindings.OpenChannel_set_to_self_delay(this.ptr, val);
199                 Reference.reachabilityFence(this);
200                 Reference.reachabilityFence(val);
201         }
202
203         /**
204          * The maximum number of inbound HTLCs towards sender
205          */
206         public short get_max_accepted_htlcs() {
207                 short ret = bindings.OpenChannel_get_max_accepted_htlcs(this.ptr);
208                 Reference.reachabilityFence(this);
209                 return ret;
210         }
211
212         /**
213          * The maximum number of inbound HTLCs towards sender
214          */
215         public void set_max_accepted_htlcs(short val) {
216                 bindings.OpenChannel_set_max_accepted_htlcs(this.ptr, val);
217                 Reference.reachabilityFence(this);
218                 Reference.reachabilityFence(val);
219         }
220
221         /**
222          * The sender's key controlling the funding transaction
223          */
224         public byte[] get_funding_pubkey() {
225                 byte[] ret = bindings.OpenChannel_get_funding_pubkey(this.ptr);
226                 Reference.reachabilityFence(this);
227                 return ret;
228         }
229
230         /**
231          * The sender's key controlling the funding transaction
232          */
233         public void set_funding_pubkey(byte[] val) {
234                 bindings.OpenChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
235                 Reference.reachabilityFence(this);
236                 Reference.reachabilityFence(val);
237         }
238
239         /**
240          * Used to derive a revocation key for transactions broadcast by counterparty
241          */
242         public byte[] get_revocation_basepoint() {
243                 byte[] ret = bindings.OpenChannel_get_revocation_basepoint(this.ptr);
244                 Reference.reachabilityFence(this);
245                 return ret;
246         }
247
248         /**
249          * Used to derive a revocation key for transactions broadcast by counterparty
250          */
251         public void set_revocation_basepoint(byte[] val) {
252                 bindings.OpenChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
253                 Reference.reachabilityFence(this);
254                 Reference.reachabilityFence(val);
255         }
256
257         /**
258          * A payment key to sender for transactions broadcast by counterparty
259          */
260         public byte[] get_payment_point() {
261                 byte[] ret = bindings.OpenChannel_get_payment_point(this.ptr);
262                 Reference.reachabilityFence(this);
263                 return ret;
264         }
265
266         /**
267          * A payment key to sender for transactions broadcast by counterparty
268          */
269         public void set_payment_point(byte[] val) {
270                 bindings.OpenChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
271                 Reference.reachabilityFence(this);
272                 Reference.reachabilityFence(val);
273         }
274
275         /**
276          * Used to derive a payment key to sender for transactions broadcast by sender
277          */
278         public byte[] get_delayed_payment_basepoint() {
279                 byte[] ret = bindings.OpenChannel_get_delayed_payment_basepoint(this.ptr);
280                 Reference.reachabilityFence(this);
281                 return ret;
282         }
283
284         /**
285          * Used to derive a payment key to sender for transactions broadcast by sender
286          */
287         public void set_delayed_payment_basepoint(byte[] val) {
288                 bindings.OpenChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
289                 Reference.reachabilityFence(this);
290                 Reference.reachabilityFence(val);
291         }
292
293         /**
294          * Used to derive an HTLC payment key to sender
295          */
296         public byte[] get_htlc_basepoint() {
297                 byte[] ret = bindings.OpenChannel_get_htlc_basepoint(this.ptr);
298                 Reference.reachabilityFence(this);
299                 return ret;
300         }
301
302         /**
303          * Used to derive an HTLC payment key to sender
304          */
305         public void set_htlc_basepoint(byte[] val) {
306                 bindings.OpenChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
307                 Reference.reachabilityFence(this);
308                 Reference.reachabilityFence(val);
309         }
310
311         /**
312          * The first to-be-broadcast-by-sender transaction's per commitment point
313          */
314         public byte[] get_first_per_commitment_point() {
315                 byte[] ret = bindings.OpenChannel_get_first_per_commitment_point(this.ptr);
316                 Reference.reachabilityFence(this);
317                 return ret;
318         }
319
320         /**
321          * The first to-be-broadcast-by-sender transaction's per commitment point
322          */
323         public void set_first_per_commitment_point(byte[] val) {
324                 bindings.OpenChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
325                 Reference.reachabilityFence(this);
326                 Reference.reachabilityFence(val);
327         }
328
329         /**
330          * Channel flags
331          */
332         public byte get_channel_flags() {
333                 byte ret = bindings.OpenChannel_get_channel_flags(this.ptr);
334                 Reference.reachabilityFence(this);
335                 return ret;
336         }
337
338         /**
339          * Channel flags
340          */
341         public void set_channel_flags(byte val) {
342                 bindings.OpenChannel_set_channel_flags(this.ptr, val);
343                 Reference.reachabilityFence(this);
344                 Reference.reachabilityFence(val);
345         }
346
347         /**
348          * The channel type that this channel will represent. If none is set, we derive the channel
349          * type from the intersection of our feature bits with our counterparty's feature bits from
350          * the Init message.
351          * 
352          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
353          */
354         @Nullable
355         public ChannelTypeFeatures get_channel_type() {
356                 long ret = bindings.OpenChannel_get_channel_type(this.ptr);
357                 Reference.reachabilityFence(this);
358                 if (ret >= 0 && ret <= 4096) { return null; }
359                 ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelTypeFeatures(null, ret); }
360                 ret_hu_conv.ptrs_to.add(this);
361                 return ret_hu_conv;
362         }
363
364         /**
365          * The channel type that this channel will represent. If none is set, we derive the channel
366          * type from the intersection of our feature bits with our counterparty's feature bits from
367          * the Init message.
368          * 
369          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
370          */
371         public void set_channel_type(@Nullable ChannelTypeFeatures val) {
372                 bindings.OpenChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr & ~1);
373                 Reference.reachabilityFence(this);
374                 Reference.reachabilityFence(val);
375         }
376
377         long clone_ptr() {
378                 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
379                 Reference.reachabilityFence(this);
380                 return ret;
381         }
382
383         /**
384          * Creates a copy of the OpenChannel
385          */
386         public OpenChannel clone() {
387                 long ret = bindings.OpenChannel_clone(this.ptr);
388                 Reference.reachabilityFence(this);
389                 if (ret >= 0 && ret <= 4096) { return null; }
390                 OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OpenChannel(null, ret); }
391                 ret_hu_conv.ptrs_to.add(this);
392                 return ret_hu_conv;
393         }
394
395         /**
396          * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
397          */
398         public byte[] write() {
399                 byte[] ret = bindings.OpenChannel_write(this.ptr);
400                 Reference.reachabilityFence(this);
401                 return ret;
402         }
403
404         /**
405          * Read a OpenChannel from a byte array, created by OpenChannel_write
406          */
407         public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
408                 long ret = bindings.OpenChannel_read(ser);
409                 Reference.reachabilityFence(ser);
410                 if (ret >= 0 && ret <= 4096) { return null; }
411                 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
412                 return ret_hu_conv;
413         }
414
415 }