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