66bafbaf610dbca41ccbbf08132bfae3a0220f97
[ldk-java] / src / main / java / org / ldk / structs / AcceptChannel.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 [`accept_channel`] message to be sent to or received from a peer.
13  * 
14  * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class AcceptChannel extends CommonBase {
18         AcceptChannel(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
23         }
24
25         /**
26          * A temporary channel ID, until the funding outpoint is announced
27          */
28         public byte[] get_temporary_channel_id() {
29                 byte[] ret = bindings.AcceptChannel_get_temporary_channel_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * A temporary channel ID, until the funding outpoint is announced
36          */
37         public void set_temporary_channel_id(byte[] val) {
38                 bindings.AcceptChannel_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The threshold below which outputs on transactions broadcast by sender will be omitted
45          */
46         public long get_dust_limit_satoshis() {
47                 long ret = bindings.AcceptChannel_get_dust_limit_satoshis(this.ptr);
48                 Reference.reachabilityFence(this);
49                 return ret;
50         }
51
52         /**
53          * The threshold below which outputs on transactions broadcast by sender will be omitted
54          */
55         public void set_dust_limit_satoshis(long val) {
56                 bindings.AcceptChannel_set_dust_limit_satoshis(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
63          */
64         public long get_max_htlc_value_in_flight_msat() {
65                 long ret = bindings.AcceptChannel_get_max_htlc_value_in_flight_msat(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
72          */
73         public void set_max_htlc_value_in_flight_msat(long val) {
74                 bindings.AcceptChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
81          */
82         public long get_channel_reserve_satoshis() {
83                 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
90          */
91         public void set_channel_reserve_satoshis(long val) {
92                 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * The minimum HTLC size incoming to sender, in milli-satoshi
99          */
100         public long get_htlc_minimum_msat() {
101                 long ret = bindings.AcceptChannel_get_htlc_minimum_msat(this.ptr);
102                 Reference.reachabilityFence(this);
103                 return ret;
104         }
105
106         /**
107          * The minimum HTLC size incoming to sender, in milli-satoshi
108          */
109         public void set_htlc_minimum_msat(long val) {
110                 bindings.AcceptChannel_set_htlc_minimum_msat(this.ptr, val);
111                 Reference.reachabilityFence(this);
112                 Reference.reachabilityFence(val);
113         }
114
115         /**
116          * Minimum depth of the funding transaction before the channel is considered open
117          */
118         public int get_minimum_depth() {
119                 int ret = bindings.AcceptChannel_get_minimum_depth(this.ptr);
120                 Reference.reachabilityFence(this);
121                 return ret;
122         }
123
124         /**
125          * Minimum depth of the funding transaction before the channel is considered open
126          */
127         public void set_minimum_depth(int val) {
128                 bindings.AcceptChannel_set_minimum_depth(this.ptr, val);
129                 Reference.reachabilityFence(this);
130                 Reference.reachabilityFence(val);
131         }
132
133         /**
134          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
135          */
136         public short get_to_self_delay() {
137                 short ret = bindings.AcceptChannel_get_to_self_delay(this.ptr);
138                 Reference.reachabilityFence(this);
139                 return ret;
140         }
141
142         /**
143          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
144          */
145         public void set_to_self_delay(short val) {
146                 bindings.AcceptChannel_set_to_self_delay(this.ptr, val);
147                 Reference.reachabilityFence(this);
148                 Reference.reachabilityFence(val);
149         }
150
151         /**
152          * The maximum number of inbound HTLCs towards sender
153          */
154         public short get_max_accepted_htlcs() {
155                 short ret = bindings.AcceptChannel_get_max_accepted_htlcs(this.ptr);
156                 Reference.reachabilityFence(this);
157                 return ret;
158         }
159
160         /**
161          * The maximum number of inbound HTLCs towards sender
162          */
163         public void set_max_accepted_htlcs(short val) {
164                 bindings.AcceptChannel_set_max_accepted_htlcs(this.ptr, val);
165                 Reference.reachabilityFence(this);
166                 Reference.reachabilityFence(val);
167         }
168
169         /**
170          * The sender's key controlling the funding transaction
171          */
172         public byte[] get_funding_pubkey() {
173                 byte[] ret = bindings.AcceptChannel_get_funding_pubkey(this.ptr);
174                 Reference.reachabilityFence(this);
175                 return ret;
176         }
177
178         /**
179          * The sender's key controlling the funding transaction
180          */
181         public void set_funding_pubkey(byte[] val) {
182                 bindings.AcceptChannel_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
183                 Reference.reachabilityFence(this);
184                 Reference.reachabilityFence(val);
185         }
186
187         /**
188          * Used to derive a revocation key for transactions broadcast by counterparty
189          */
190         public byte[] get_revocation_basepoint() {
191                 byte[] ret = bindings.AcceptChannel_get_revocation_basepoint(this.ptr);
192                 Reference.reachabilityFence(this);
193                 return ret;
194         }
195
196         /**
197          * Used to derive a revocation key for transactions broadcast by counterparty
198          */
199         public void set_revocation_basepoint(byte[] val) {
200                 bindings.AcceptChannel_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
201                 Reference.reachabilityFence(this);
202                 Reference.reachabilityFence(val);
203         }
204
205         /**
206          * A payment key to sender for transactions broadcast by counterparty
207          */
208         public byte[] get_payment_point() {
209                 byte[] ret = bindings.AcceptChannel_get_payment_point(this.ptr);
210                 Reference.reachabilityFence(this);
211                 return ret;
212         }
213
214         /**
215          * A payment key to sender for transactions broadcast by counterparty
216          */
217         public void set_payment_point(byte[] val) {
218                 bindings.AcceptChannel_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
219                 Reference.reachabilityFence(this);
220                 Reference.reachabilityFence(val);
221         }
222
223         /**
224          * Used to derive a payment key to sender for transactions broadcast by sender
225          */
226         public byte[] get_delayed_payment_basepoint() {
227                 byte[] ret = bindings.AcceptChannel_get_delayed_payment_basepoint(this.ptr);
228                 Reference.reachabilityFence(this);
229                 return ret;
230         }
231
232         /**
233          * Used to derive a payment key to sender for transactions broadcast by sender
234          */
235         public void set_delayed_payment_basepoint(byte[] val) {
236                 bindings.AcceptChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
237                 Reference.reachabilityFence(this);
238                 Reference.reachabilityFence(val);
239         }
240
241         /**
242          * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
243          */
244         public byte[] get_htlc_basepoint() {
245                 byte[] ret = bindings.AcceptChannel_get_htlc_basepoint(this.ptr);
246                 Reference.reachabilityFence(this);
247                 return ret;
248         }
249
250         /**
251          * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
252          */
253         public void set_htlc_basepoint(byte[] val) {
254                 bindings.AcceptChannel_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
255                 Reference.reachabilityFence(this);
256                 Reference.reachabilityFence(val);
257         }
258
259         /**
260          * The first to-be-broadcast-by-sender transaction's per commitment point
261          */
262         public byte[] get_first_per_commitment_point() {
263                 byte[] ret = bindings.AcceptChannel_get_first_per_commitment_point(this.ptr);
264                 Reference.reachabilityFence(this);
265                 return ret;
266         }
267
268         /**
269          * The first to-be-broadcast-by-sender transaction's per commitment point
270          */
271         public void set_first_per_commitment_point(byte[] val) {
272                 bindings.AcceptChannel_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
273                 Reference.reachabilityFence(this);
274                 Reference.reachabilityFence(val);
275         }
276
277         /**
278          * The channel type that this channel will represent.
279          * 
280          * If this is `None`, we derive the channel type from the intersection of
281          * our feature bits with our counterparty's feature bits from the [`Init`] message.
282          * This is required to match the equivalent field in [`OpenChannel::channel_type`].
283          * 
284          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
285          */
286         @Nullable
287         public ChannelTypeFeatures get_channel_type() {
288                 long ret = bindings.AcceptChannel_get_channel_type(this.ptr);
289                 Reference.reachabilityFence(this);
290                 if (ret >= 0 && ret <= 4096) { return null; }
291                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
292                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
293                 return ret_hu_conv;
294         }
295
296         /**
297          * The channel type that this channel will represent.
298          * 
299          * If this is `None`, we derive the channel type from the intersection of
300          * our feature bits with our counterparty's feature bits from the [`Init`] message.
301          * This is required to match the equivalent field in [`OpenChannel::channel_type`].
302          * 
303          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
304          */
305         public void set_channel_type(@Nullable org.ldk.structs.ChannelTypeFeatures val) {
306                 bindings.AcceptChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
307                 Reference.reachabilityFence(this);
308                 Reference.reachabilityFence(val);
309                 if (this != null) { this.ptrs_to.add(val); };
310         }
311
312         long clone_ptr() {
313                 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
314                 Reference.reachabilityFence(this);
315                 return ret;
316         }
317
318         /**
319          * Creates a copy of the AcceptChannel
320          */
321         public AcceptChannel clone() {
322                 long ret = bindings.AcceptChannel_clone(this.ptr);
323                 Reference.reachabilityFence(this);
324                 if (ret >= 0 && ret <= 4096) { return null; }
325                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
326                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
327                 return ret_hu_conv;
328         }
329
330         /**
331          * Checks if two AcceptChannels contain equal inner contents.
332          * This ignores pointers and is_owned flags and looks at the values in fields.
333          * Two objects with NULL inner values will be considered "equal" here.
334          */
335         public boolean eq(org.ldk.structs.AcceptChannel b) {
336                 boolean ret = bindings.AcceptChannel_eq(this.ptr, b == null ? 0 : b.ptr);
337                 Reference.reachabilityFence(this);
338                 Reference.reachabilityFence(b);
339                 if (this != null) { this.ptrs_to.add(b); };
340                 return ret;
341         }
342
343         @Override public boolean equals(Object o) {
344                 if (!(o instanceof AcceptChannel)) return false;
345                 return this.eq((AcceptChannel)o);
346         }
347         /**
348          * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
349          */
350         public byte[] write() {
351                 byte[] ret = bindings.AcceptChannel_write(this.ptr);
352                 Reference.reachabilityFence(this);
353                 return ret;
354         }
355
356         /**
357          * Read a AcceptChannel from a byte array, created by AcceptChannel_write
358          */
359         public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
360                 long ret = bindings.AcceptChannel_read(ser);
361                 Reference.reachabilityFence(ser);
362                 if (ret >= 0 && ret <= 4096) { return null; }
363                 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
364                 return ret_hu_conv;
365         }
366
367 }