78b053475a6a91a049ca238a05ad3a26c4ee1ce9
[ldk-java] / c_sharp / src / org / ldk / structs / AcceptChannel.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * An [`accept_channel`] message to be sent to or received from a peer.
11  * 
12  * Used in V1 channel establishment
13  * 
14  * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message
15  */
16 public class AcceptChannel : CommonBase {
17         internal AcceptChannel(object _dummy, long ptr) : base(ptr) { }
18         ~AcceptChannel() {
19                 if (ptr != 0) { bindings.AcceptChannel_free(ptr); }
20         }
21
22         /**
23          * A temporary channel ID, until the funding outpoint is announced
24          */
25         public byte[] get_temporary_channel_id() {
26                 long ret = bindings.AcceptChannel_get_temporary_channel_id(this.ptr);
27                 GC.KeepAlive(this);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
30                 return ret_conv;
31         }
32
33         /**
34          * A temporary channel ID, until the funding outpoint is announced
35          */
36         public void set_temporary_channel_id(byte[] val) {
37                 bindings.AcceptChannel_set_temporary_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
38                 GC.KeepAlive(this);
39                 GC.KeepAlive(val);
40         }
41
42         /**
43          * The threshold below which outputs on transactions broadcast by sender will be omitted
44          */
45         public long get_dust_limit_satoshis() {
46                 long ret = bindings.AcceptChannel_get_dust_limit_satoshis(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * The threshold below which outputs on transactions broadcast by sender will be omitted
53          */
54         public void set_dust_limit_satoshis(long val) {
55                 bindings.AcceptChannel_set_dust_limit_satoshis(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
62          */
63         public long get_max_htlc_value_in_flight_msat() {
64                 long ret = bindings.AcceptChannel_get_max_htlc_value_in_flight_msat(this.ptr);
65                 GC.KeepAlive(this);
66                 return ret;
67         }
68
69         /**
70          * The maximum inbound HTLC value in flight towards sender, in milli-satoshi
71          */
72         public void set_max_htlc_value_in_flight_msat(long val) {
73                 bindings.AcceptChannel_set_max_htlc_value_in_flight_msat(this.ptr, val);
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
80          */
81         public long get_channel_reserve_satoshis() {
82                 long ret = bindings.AcceptChannel_get_channel_reserve_satoshis(this.ptr);
83                 GC.KeepAlive(this);
84                 return ret;
85         }
86
87         /**
88          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
89          */
90         public void set_channel_reserve_satoshis(long val) {
91                 bindings.AcceptChannel_set_channel_reserve_satoshis(this.ptr, val);
92                 GC.KeepAlive(this);
93                 GC.KeepAlive(val);
94         }
95
96         /**
97          * The minimum HTLC size incoming to sender, in milli-satoshi
98          */
99         public long get_htlc_minimum_msat() {
100                 long ret = bindings.AcceptChannel_get_htlc_minimum_msat(this.ptr);
101                 GC.KeepAlive(this);
102                 return ret;
103         }
104
105         /**
106          * The minimum HTLC size incoming to sender, in milli-satoshi
107          */
108         public void set_htlc_minimum_msat(long val) {
109                 bindings.AcceptChannel_set_htlc_minimum_msat(this.ptr, val);
110                 GC.KeepAlive(this);
111                 GC.KeepAlive(val);
112         }
113
114         /**
115          * Minimum depth of the funding transaction before the channel is considered open
116          */
117         public int get_minimum_depth() {
118                 int ret = bindings.AcceptChannel_get_minimum_depth(this.ptr);
119                 GC.KeepAlive(this);
120                 return ret;
121         }
122
123         /**
124          * Minimum depth of the funding transaction before the channel is considered open
125          */
126         public void set_minimum_depth(int val) {
127                 bindings.AcceptChannel_set_minimum_depth(this.ptr, val);
128                 GC.KeepAlive(this);
129                 GC.KeepAlive(val);
130         }
131
132         /**
133          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
134          */
135         public short get_to_self_delay() {
136                 short ret = bindings.AcceptChannel_get_to_self_delay(this.ptr);
137                 GC.KeepAlive(this);
138                 return ret;
139         }
140
141         /**
142          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction
143          */
144         public void set_to_self_delay(short val) {
145                 bindings.AcceptChannel_set_to_self_delay(this.ptr, val);
146                 GC.KeepAlive(this);
147                 GC.KeepAlive(val);
148         }
149
150         /**
151          * The maximum number of inbound HTLCs towards sender
152          */
153         public short get_max_accepted_htlcs() {
154                 short ret = bindings.AcceptChannel_get_max_accepted_htlcs(this.ptr);
155                 GC.KeepAlive(this);
156                 return ret;
157         }
158
159         /**
160          * The maximum number of inbound HTLCs towards sender
161          */
162         public void set_max_accepted_htlcs(short val) {
163                 bindings.AcceptChannel_set_max_accepted_htlcs(this.ptr, val);
164                 GC.KeepAlive(this);
165                 GC.KeepAlive(val);
166         }
167
168         /**
169          * The sender's key controlling the funding transaction
170          */
171         public byte[] get_funding_pubkey() {
172                 long ret = bindings.AcceptChannel_get_funding_pubkey(this.ptr);
173                 GC.KeepAlive(this);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
176                 return ret_conv;
177         }
178
179         /**
180          * The sender's key controlling the funding transaction
181          */
182         public void set_funding_pubkey(byte[] val) {
183                 bindings.AcceptChannel_set_funding_pubkey(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
184                 GC.KeepAlive(this);
185                 GC.KeepAlive(val);
186         }
187
188         /**
189          * Used to derive a revocation key for transactions broadcast by counterparty
190          */
191         public byte[] get_revocation_basepoint() {
192                 long ret = bindings.AcceptChannel_get_revocation_basepoint(this.ptr);
193                 GC.KeepAlive(this);
194                 if (ret >= 0 && ret <= 4096) { return null; }
195                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
196                 return ret_conv;
197         }
198
199         /**
200          * Used to derive a revocation key for transactions broadcast by counterparty
201          */
202         public void set_revocation_basepoint(byte[] val) {
203                 bindings.AcceptChannel_set_revocation_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
204                 GC.KeepAlive(this);
205                 GC.KeepAlive(val);
206         }
207
208         /**
209          * A payment key to sender for transactions broadcast by counterparty
210          */
211         public byte[] get_payment_point() {
212                 long ret = bindings.AcceptChannel_get_payment_point(this.ptr);
213                 GC.KeepAlive(this);
214                 if (ret >= 0 && ret <= 4096) { return null; }
215                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
216                 return ret_conv;
217         }
218
219         /**
220          * A payment key to sender for transactions broadcast by counterparty
221          */
222         public void set_payment_point(byte[] val) {
223                 bindings.AcceptChannel_set_payment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
224                 GC.KeepAlive(this);
225                 GC.KeepAlive(val);
226         }
227
228         /**
229          * Used to derive a payment key to sender for transactions broadcast by sender
230          */
231         public byte[] get_delayed_payment_basepoint() {
232                 long ret = bindings.AcceptChannel_get_delayed_payment_basepoint(this.ptr);
233                 GC.KeepAlive(this);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
236                 return ret_conv;
237         }
238
239         /**
240          * Used to derive a payment key to sender for transactions broadcast by sender
241          */
242         public void set_delayed_payment_basepoint(byte[] val) {
243                 bindings.AcceptChannel_set_delayed_payment_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
244                 GC.KeepAlive(this);
245                 GC.KeepAlive(val);
246         }
247
248         /**
249          * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
250          */
251         public byte[] get_htlc_basepoint() {
252                 long ret = bindings.AcceptChannel_get_htlc_basepoint(this.ptr);
253                 GC.KeepAlive(this);
254                 if (ret >= 0 && ret <= 4096) { return null; }
255                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
256                 return ret_conv;
257         }
258
259         /**
260          * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty
261          */
262         public void set_htlc_basepoint(byte[] val) {
263                 bindings.AcceptChannel_set_htlc_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
264                 GC.KeepAlive(this);
265                 GC.KeepAlive(val);
266         }
267
268         /**
269          * The first to-be-broadcast-by-sender transaction's per commitment point
270          */
271         public byte[] get_first_per_commitment_point() {
272                 long ret = bindings.AcceptChannel_get_first_per_commitment_point(this.ptr);
273                 GC.KeepAlive(this);
274                 if (ret >= 0 && ret <= 4096) { return null; }
275                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
276                 return ret_conv;
277         }
278
279         /**
280          * The first to-be-broadcast-by-sender transaction's per commitment point
281          */
282         public void set_first_per_commitment_point(byte[] val) {
283                 bindings.AcceptChannel_set_first_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
284                 GC.KeepAlive(this);
285                 GC.KeepAlive(val);
286         }
287
288         /**
289          * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
290          */
291         public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
292                 long ret = bindings.AcceptChannel_get_shutdown_scriptpubkey(this.ptr);
293                 GC.KeepAlive(this);
294                 if (ret >= 0 && ret <= 4096) { return null; }
295                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
296                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
297                 return ret_hu_conv;
298         }
299
300         /**
301          * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close
302          */
303         public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
304                 bindings.AcceptChannel_set_shutdown_scriptpubkey(this.ptr, val.ptr);
305                 GC.KeepAlive(this);
306                 GC.KeepAlive(val);
307                 if (this != null) { this.ptrs_to.AddLast(val); };
308         }
309
310         /**
311          * The channel type that this channel will represent.
312          * 
313          * If this is `None`, we derive the channel type from the intersection of
314          * our feature bits with our counterparty's feature bits from the [`Init`] message.
315          * This is required to match the equivalent field in [`OpenChannel::channel_type`].
316          * 
317          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
318          */
319         public ChannelTypeFeatures get_channel_type() {
320                 long ret = bindings.AcceptChannel_get_channel_type(this.ptr);
321                 GC.KeepAlive(this);
322                 if (ret >= 0 && ret <= 4096) { return null; }
323                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
324                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
325                 return ret_hu_conv;
326         }
327
328         /**
329          * The channel type that this channel will represent.
330          * 
331          * If this is `None`, we derive the channel type from the intersection of
332          * our feature bits with our counterparty's feature bits from the [`Init`] message.
333          * This is required to match the equivalent field in [`OpenChannel::channel_type`].
334          * 
335          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
336          */
337         public void set_channel_type(org.ldk.structs.ChannelTypeFeatures val) {
338                 bindings.AcceptChannel_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
339                 GC.KeepAlive(this);
340                 GC.KeepAlive(val);
341                 if (this != null) { this.ptrs_to.AddLast(val); };
342         }
343
344         /**
345          * Constructs a new AcceptChannel given each field
346          * 
347          * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
348          */
349         public static AcceptChannel of(byte[] temporary_channel_id_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 minimum_depth_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, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
350                 long ret = bindings.AcceptChannel_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(temporary_channel_id_arg, 32)), dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_pubkey_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(revocation_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_point_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(first_per_commitment_point_arg, 33)), shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr);
351                 GC.KeepAlive(temporary_channel_id_arg);
352                 GC.KeepAlive(dust_limit_satoshis_arg);
353                 GC.KeepAlive(max_htlc_value_in_flight_msat_arg);
354                 GC.KeepAlive(channel_reserve_satoshis_arg);
355                 GC.KeepAlive(htlc_minimum_msat_arg);
356                 GC.KeepAlive(minimum_depth_arg);
357                 GC.KeepAlive(to_self_delay_arg);
358                 GC.KeepAlive(max_accepted_htlcs_arg);
359                 GC.KeepAlive(funding_pubkey_arg);
360                 GC.KeepAlive(revocation_basepoint_arg);
361                 GC.KeepAlive(payment_point_arg);
362                 GC.KeepAlive(delayed_payment_basepoint_arg);
363                 GC.KeepAlive(htlc_basepoint_arg);
364                 GC.KeepAlive(first_per_commitment_point_arg);
365                 GC.KeepAlive(shutdown_scriptpubkey_arg);
366                 GC.KeepAlive(channel_type_arg);
367                 if (ret >= 0 && ret <= 4096) { return null; }
368                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
369                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
370                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(shutdown_scriptpubkey_arg); };
371                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_type_arg); };
372                 return ret_hu_conv;
373         }
374
375         internal long clone_ptr() {
376                 long ret = bindings.AcceptChannel_clone_ptr(this.ptr);
377                 GC.KeepAlive(this);
378                 return ret;
379         }
380
381         /**
382          * Creates a copy of the AcceptChannel
383          */
384         public AcceptChannel clone() {
385                 long ret = bindings.AcceptChannel_clone(this.ptr);
386                 GC.KeepAlive(this);
387                 if (ret >= 0 && ret <= 4096) { return null; }
388                 org.ldk.structs.AcceptChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannel(null, ret); }
389                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
390                 return ret_hu_conv;
391         }
392
393         /**
394          * Checks if two AcceptChannels contain equal inner contents.
395          * This ignores pointers and is_owned flags and looks at the values in fields.
396          * Two objects with NULL inner values will be considered "equal" here.
397          */
398         public bool eq(org.ldk.structs.AcceptChannel b) {
399                 bool ret = bindings.AcceptChannel_eq(this.ptr, b == null ? 0 : b.ptr);
400                 GC.KeepAlive(this);
401                 GC.KeepAlive(b);
402                 if (this != null) { this.ptrs_to.AddLast(b); };
403                 return ret;
404         }
405
406         public override bool Equals(object o) {
407                 if (!(o is AcceptChannel)) return false;
408                 return this.eq((AcceptChannel)o);
409         }
410         /**
411          * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read
412          */
413         public byte[] write() {
414                 long ret = bindings.AcceptChannel_write(this.ptr);
415                 GC.KeepAlive(this);
416                 if (ret >= 0 && ret <= 4096) { return null; }
417                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
418                 return ret_conv;
419         }
420
421         /**
422          * Read a AcceptChannel from a byte array, created by AcceptChannel_write
423          */
424         public static Result_AcceptChannelDecodeErrorZ read(byte[] ser) {
425                 long ret = bindings.AcceptChannel_read(InternalUtils.encodeUint8Array(ser));
426                 GC.KeepAlive(ser);
427                 if (ret >= 0 && ret <= 4096) { return null; }
428                 Result_AcceptChannelDecodeErrorZ ret_hu_conv = Result_AcceptChannelDecodeErrorZ.constr_from_ptr(ret);
429                 return ret_hu_conv;
430         }
431
432 }
433 } } }