[C#] Drop reference to `assert` which makes building on Win hard
[ldk-java] / c_sharp / src / org / ldk / structs / AcceptChannelV2.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_channel2 message to be sent by or received from the channel accepter.
11  * 
12  * Used in V2 channel establishment
13  */
14 public class AcceptChannelV2 : CommonBase {
15         internal AcceptChannelV2(object _dummy, long ptr) : base(ptr) { }
16         ~AcceptChannelV2() {
17                 if (ptr != 0) { bindings.AcceptChannelV2_free(ptr); }
18         }
19
20         /**
21          * The same `temporary_channel_id` received from the initiator's `open_channel2` message.
22          */
23         public byte[] get_temporary_channel_id() {
24                 byte[] ret = bindings.AcceptChannelV2_get_temporary_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 return ret;
27         }
28
29         /**
30          * The same `temporary_channel_id` received from the initiator's `open_channel2` message.
31          */
32         public void set_temporary_channel_id(byte[] val) {
33                 bindings.AcceptChannelV2_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * Part of the channel value contributed by the channel acceptor
40          */
41         public long get_funding_satoshis() {
42                 long ret = bindings.AcceptChannelV2_get_funding_satoshis(this.ptr);
43                 GC.KeepAlive(this);
44                 return ret;
45         }
46
47         /**
48          * Part of the channel value contributed by the channel acceptor
49          */
50         public void set_funding_satoshis(long val) {
51                 bindings.AcceptChannelV2_set_funding_satoshis(this.ptr, val);
52                 GC.KeepAlive(this);
53                 GC.KeepAlive(val);
54         }
55
56         /**
57          * The threshold below which outputs on transactions broadcast by the channel acceptor will be
58          * omitted
59          */
60         public long get_dust_limit_satoshis() {
61                 long ret = bindings.AcceptChannelV2_get_dust_limit_satoshis(this.ptr);
62                 GC.KeepAlive(this);
63                 return ret;
64         }
65
66         /**
67          * The threshold below which outputs on transactions broadcast by the channel acceptor will be
68          * omitted
69          */
70         public void set_dust_limit_satoshis(long val) {
71                 bindings.AcceptChannelV2_set_dust_limit_satoshis(this.ptr, val);
72                 GC.KeepAlive(this);
73                 GC.KeepAlive(val);
74         }
75
76         /**
77          * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
78          */
79         public long get_max_htlc_value_in_flight_msat() {
80                 long ret = bindings.AcceptChannelV2_get_max_htlc_value_in_flight_msat(this.ptr);
81                 GC.KeepAlive(this);
82                 return ret;
83         }
84
85         /**
86          * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi
87          */
88         public void set_max_htlc_value_in_flight_msat(long val) {
89                 bindings.AcceptChannelV2_set_max_htlc_value_in_flight_msat(this.ptr, val);
90                 GC.KeepAlive(this);
91                 GC.KeepAlive(val);
92         }
93
94         /**
95          * The minimum HTLC size incoming to channel acceptor, in milli-satoshi
96          */
97         public long get_htlc_minimum_msat() {
98                 long ret = bindings.AcceptChannelV2_get_htlc_minimum_msat(this.ptr);
99                 GC.KeepAlive(this);
100                 return ret;
101         }
102
103         /**
104          * The minimum HTLC size incoming to channel acceptor, in milli-satoshi
105          */
106         public void set_htlc_minimum_msat(long val) {
107                 bindings.AcceptChannelV2_set_htlc_minimum_msat(this.ptr, val);
108                 GC.KeepAlive(this);
109                 GC.KeepAlive(val);
110         }
111
112         /**
113          * Minimum depth of the funding transaction before the channel is considered open
114          */
115         public int get_minimum_depth() {
116                 int ret = bindings.AcceptChannelV2_get_minimum_depth(this.ptr);
117                 GC.KeepAlive(this);
118                 return ret;
119         }
120
121         /**
122          * Minimum depth of the funding transaction before the channel is considered open
123          */
124         public void set_minimum_depth(int val) {
125                 bindings.AcceptChannelV2_set_minimum_depth(this.ptr, val);
126                 GC.KeepAlive(this);
127                 GC.KeepAlive(val);
128         }
129
130         /**
131          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
132          * broadcast a commitment transaction
133          */
134         public short get_to_self_delay() {
135                 short ret = bindings.AcceptChannelV2_get_to_self_delay(this.ptr);
136                 GC.KeepAlive(this);
137                 return ret;
138         }
139
140         /**
141          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
142          * broadcast a commitment transaction
143          */
144         public void set_to_self_delay(short val) {
145                 bindings.AcceptChannelV2_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 channel acceptor
152          */
153         public short get_max_accepted_htlcs() {
154                 short ret = bindings.AcceptChannelV2_get_max_accepted_htlcs(this.ptr);
155                 GC.KeepAlive(this);
156                 return ret;
157         }
158
159         /**
160          * The maximum number of inbound HTLCs towards channel acceptor
161          */
162         public void set_max_accepted_htlcs(short val) {
163                 bindings.AcceptChannelV2_set_max_accepted_htlcs(this.ptr, val);
164                 GC.KeepAlive(this);
165                 GC.KeepAlive(val);
166         }
167
168         /**
169          * The channel acceptor's key controlling the funding transaction
170          */
171         public byte[] get_funding_pubkey() {
172                 byte[] ret = bindings.AcceptChannelV2_get_funding_pubkey(this.ptr);
173                 GC.KeepAlive(this);
174                 return ret;
175         }
176
177         /**
178          * The channel acceptor's key controlling the funding transaction
179          */
180         public void set_funding_pubkey(byte[] val) {
181                 bindings.AcceptChannelV2_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
182                 GC.KeepAlive(this);
183                 GC.KeepAlive(val);
184         }
185
186         /**
187          * Used to derive a revocation key for transactions broadcast by counterparty
188          */
189         public byte[] get_revocation_basepoint() {
190                 byte[] ret = bindings.AcceptChannelV2_get_revocation_basepoint(this.ptr);
191                 GC.KeepAlive(this);
192                 return ret;
193         }
194
195         /**
196          * Used to derive a revocation key for transactions broadcast by counterparty
197          */
198         public void set_revocation_basepoint(byte[] val) {
199                 bindings.AcceptChannelV2_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
200                 GC.KeepAlive(this);
201                 GC.KeepAlive(val);
202         }
203
204         /**
205          * A payment key to channel acceptor for transactions broadcast by counterparty
206          */
207         public byte[] get_payment_basepoint() {
208                 byte[] ret = bindings.AcceptChannelV2_get_payment_basepoint(this.ptr);
209                 GC.KeepAlive(this);
210                 return ret;
211         }
212
213         /**
214          * A payment key to channel acceptor for transactions broadcast by counterparty
215          */
216         public void set_payment_basepoint(byte[] val) {
217                 bindings.AcceptChannelV2_set_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
218                 GC.KeepAlive(this);
219                 GC.KeepAlive(val);
220         }
221
222         /**
223          * Used to derive a payment key to channel acceptor for transactions broadcast by channel
224          * acceptor
225          */
226         public byte[] get_delayed_payment_basepoint() {
227                 byte[] ret = bindings.AcceptChannelV2_get_delayed_payment_basepoint(this.ptr);
228                 GC.KeepAlive(this);
229                 return ret;
230         }
231
232         /**
233          * Used to derive a payment key to channel acceptor for transactions broadcast by channel
234          * acceptor
235          */
236         public void set_delayed_payment_basepoint(byte[] val) {
237                 bindings.AcceptChannelV2_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
238                 GC.KeepAlive(this);
239                 GC.KeepAlive(val);
240         }
241
242         /**
243          * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
244          */
245         public byte[] get_htlc_basepoint() {
246                 byte[] ret = bindings.AcceptChannelV2_get_htlc_basepoint(this.ptr);
247                 GC.KeepAlive(this);
248                 return ret;
249         }
250
251         /**
252          * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty
253          */
254         public void set_htlc_basepoint(byte[] val) {
255                 bindings.AcceptChannelV2_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
256                 GC.KeepAlive(this);
257                 GC.KeepAlive(val);
258         }
259
260         /**
261          * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
262          */
263         public byte[] get_first_per_commitment_point() {
264                 byte[] ret = bindings.AcceptChannelV2_get_first_per_commitment_point(this.ptr);
265                 GC.KeepAlive(this);
266                 return ret;
267         }
268
269         /**
270          * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point
271          */
272         public void set_first_per_commitment_point(byte[] val) {
273                 bindings.AcceptChannelV2_set_first_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
274                 GC.KeepAlive(this);
275                 GC.KeepAlive(val);
276         }
277
278         /**
279          * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
280          */
281         public byte[] get_second_per_commitment_point() {
282                 byte[] ret = bindings.AcceptChannelV2_get_second_per_commitment_point(this.ptr);
283                 GC.KeepAlive(this);
284                 return ret;
285         }
286
287         /**
288          * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point
289          */
290         public void set_second_per_commitment_point(byte[] val) {
291                 bindings.AcceptChannelV2_set_second_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
292                 GC.KeepAlive(this);
293                 GC.KeepAlive(val);
294         }
295
296         /**
297          * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
298          * collaboratively close
299          */
300         public Option_ScriptZ get_shutdown_scriptpubkey() {
301                 long ret = bindings.AcceptChannelV2_get_shutdown_scriptpubkey(this.ptr);
302                 GC.KeepAlive(this);
303                 if (ret >= 0 && ret <= 4096) { return null; }
304                 org.ldk.structs.Option_ScriptZ ret_hu_conv = org.ldk.structs.Option_ScriptZ.constr_from_ptr(ret);
305                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
306                 return ret_hu_conv;
307         }
308
309         /**
310          * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we
311          * collaboratively close
312          */
313         public void set_shutdown_scriptpubkey(org.ldk.structs.Option_ScriptZ val) {
314                 bindings.AcceptChannelV2_set_shutdown_scriptpubkey(this.ptr, val.ptr);
315                 GC.KeepAlive(this);
316                 GC.KeepAlive(val);
317                 if (this != null) { this.ptrs_to.AddLast(val); };
318         }
319
320         /**
321          * The channel type that this channel will represent. If none is set, we derive the channel
322          * type from the intersection of our feature bits with our counterparty's feature bits from
323          * the Init message.
324          * 
325          * This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
326          * 
327          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
328          */
329         public ChannelTypeFeatures get_channel_type() {
330                 long ret = bindings.AcceptChannelV2_get_channel_type(this.ptr);
331                 GC.KeepAlive(this);
332                 if (ret >= 0 && ret <= 4096) { return null; }
333                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
334                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
335                 return ret_hu_conv;
336         }
337
338         /**
339          * The channel type that this channel will represent. If none is set, we derive the channel
340          * type from the intersection of our feature bits with our counterparty's feature bits from
341          * the Init message.
342          * 
343          * This is required to match the equivalent field in [`OpenChannelV2::channel_type`].
344          * 
345          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
346          */
347         public void set_channel_type(org.ldk.structs.ChannelTypeFeatures val) {
348                 bindings.AcceptChannelV2_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
349                 GC.KeepAlive(this);
350                 GC.KeepAlive(val);
351                 if (this != null) { this.ptrs_to.AddLast(val); };
352         }
353
354         /**
355          * Optionally, a requirement that only confirmed inputs can be added
356          */
357         public COption_NoneZ get_require_confirmed_inputs() {
358                 COption_NoneZ ret = bindings.AcceptChannelV2_get_require_confirmed_inputs(this.ptr);
359                 GC.KeepAlive(this);
360                 return ret;
361         }
362
363         /**
364          * Optionally, a requirement that only confirmed inputs can be added
365          */
366         public void set_require_confirmed_inputs(COption_NoneZ val) {
367                 bindings.AcceptChannelV2_set_require_confirmed_inputs(this.ptr, val);
368                 GC.KeepAlive(this);
369                 GC.KeepAlive(val);
370         }
371
372         /**
373          * Constructs a new AcceptChannelV2 given each field
374          */
375         public static AcceptChannelV2 of(byte[] temporary_channel_id_arg, long funding_satoshis_arg, long dust_limit_satoshis_arg, long max_htlc_value_in_flight_msat_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_basepoint_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg, byte[] first_per_commitment_point_arg, byte[] second_per_commitment_point_arg, org.ldk.structs.Option_ScriptZ shutdown_scriptpubkey_arg, org.ldk.structs.ChannelTypeFeatures channel_type_arg, COption_NoneZ require_confirmed_inputs_arg) {
376                 long ret = bindings.AcceptChannelV2_new(InternalUtils.check_arr_len(temporary_channel_id_arg, 32), funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, minimum_depth_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_basepoint_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), InternalUtils.check_arr_len(second_per_commitment_point_arg, 33), shutdown_scriptpubkey_arg.ptr, channel_type_arg == null ? 0 : channel_type_arg.ptr, require_confirmed_inputs_arg);
377                 GC.KeepAlive(temporary_channel_id_arg);
378                 GC.KeepAlive(funding_satoshis_arg);
379                 GC.KeepAlive(dust_limit_satoshis_arg);
380                 GC.KeepAlive(max_htlc_value_in_flight_msat_arg);
381                 GC.KeepAlive(htlc_minimum_msat_arg);
382                 GC.KeepAlive(minimum_depth_arg);
383                 GC.KeepAlive(to_self_delay_arg);
384                 GC.KeepAlive(max_accepted_htlcs_arg);
385                 GC.KeepAlive(funding_pubkey_arg);
386                 GC.KeepAlive(revocation_basepoint_arg);
387                 GC.KeepAlive(payment_basepoint_arg);
388                 GC.KeepAlive(delayed_payment_basepoint_arg);
389                 GC.KeepAlive(htlc_basepoint_arg);
390                 GC.KeepAlive(first_per_commitment_point_arg);
391                 GC.KeepAlive(second_per_commitment_point_arg);
392                 GC.KeepAlive(shutdown_scriptpubkey_arg);
393                 GC.KeepAlive(channel_type_arg);
394                 GC.KeepAlive(require_confirmed_inputs_arg);
395                 if (ret >= 0 && ret <= 4096) { return null; }
396                 org.ldk.structs.AcceptChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannelV2(null, ret); }
397                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
398                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(shutdown_scriptpubkey_arg); };
399                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_type_arg); };
400                 return ret_hu_conv;
401         }
402
403         internal long clone_ptr() {
404                 long ret = bindings.AcceptChannelV2_clone_ptr(this.ptr);
405                 GC.KeepAlive(this);
406                 return ret;
407         }
408
409         /**
410          * Creates a copy of the AcceptChannelV2
411          */
412         public AcceptChannelV2 clone() {
413                 long ret = bindings.AcceptChannelV2_clone(this.ptr);
414                 GC.KeepAlive(this);
415                 if (ret >= 0 && ret <= 4096) { return null; }
416                 org.ldk.structs.AcceptChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.AcceptChannelV2(null, ret); }
417                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
418                 return ret_hu_conv;
419         }
420
421         /**
422          * Checks if two AcceptChannelV2s contain equal inner contents.
423          * This ignores pointers and is_owned flags and looks at the values in fields.
424          * Two objects with NULL inner values will be considered "equal" here.
425          */
426         public bool eq(org.ldk.structs.AcceptChannelV2 b) {
427                 bool ret = bindings.AcceptChannelV2_eq(this.ptr, b == null ? 0 : b.ptr);
428                 GC.KeepAlive(this);
429                 GC.KeepAlive(b);
430                 if (this != null) { this.ptrs_to.AddLast(b); };
431                 return ret;
432         }
433
434         public override bool Equals(object o) {
435                 if (!(o is AcceptChannelV2)) return false;
436                 return this.eq((AcceptChannelV2)o);
437         }
438         /**
439          * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read
440          */
441         public byte[] write() {
442                 byte[] ret = bindings.AcceptChannelV2_write(this.ptr);
443                 GC.KeepAlive(this);
444                 return ret;
445         }
446
447         /**
448          * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write
449          */
450         public static Result_AcceptChannelV2DecodeErrorZ read(byte[] ser) {
451                 long ret = bindings.AcceptChannelV2_read(ser);
452                 GC.KeepAlive(ser);
453                 if (ret >= 0 && ret <= 4096) { return null; }
454                 Result_AcceptChannelV2DecodeErrorZ ret_hu_conv = Result_AcceptChannelV2DecodeErrorZ.constr_from_ptr(ret);
455                 return ret_hu_conv;
456         }
457
458 }
459 } } }