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