]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/CommonOpenChannelFields.cs
Update CI references to LDK 0.0.124 drop stale memchr pins
[ldk-java] / c_sharp / src / org / ldk / structs / CommonOpenChannelFields.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  * Contains fields that are both common to [`open_channel`] and `open_channel2` messages.
11  * 
12  * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
13  */
14 public class CommonOpenChannelFields : CommonBase {
15         internal CommonOpenChannelFields(object _dummy, long ptr) : base(ptr) { }
16         ~CommonOpenChannelFields() {
17                 if (ptr != 0) { bindings.CommonOpenChannelFields_free(ptr); }
18         }
19
20         /**
21          * The genesis hash of the blockchain where the channel is to be opened
22          */
23         public byte[] get_chain_hash() {
24                 long ret = bindings.CommonOpenChannelFields_get_chain_hash(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
28                 return ret_conv;
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.CommonOpenChannelFields_set_chain_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * A temporary channel ID
42          * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
43          * For V1 channels: a temporary channel ID, until the funding outpoint is announced
44          */
45         public ChannelId get_temporary_channel_id() {
46                 long ret = bindings.CommonOpenChannelFields_get_temporary_channel_id(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
50                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
51                 return ret_hu_conv;
52         }
53
54         /**
55          * A temporary channel ID
56          * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint
57          * For V1 channels: a temporary channel ID, until the funding outpoint is announced
58          */
59         public void set_temporary_channel_id(org.ldk.structs.ChannelId val) {
60                 bindings.CommonOpenChannelFields_set_temporary_channel_id(this.ptr, val.ptr);
61                 GC.KeepAlive(this);
62                 GC.KeepAlive(val);
63         }
64
65         /**
66          * For V1 channels: The channel value
67          * For V2 channels: Part of the channel value contributed by the channel initiator
68          */
69         public long get_funding_satoshis() {
70                 long ret = bindings.CommonOpenChannelFields_get_funding_satoshis(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75         /**
76          * For V1 channels: The channel value
77          * For V2 channels: Part of the channel value contributed by the channel initiator
78          */
79         public void set_funding_satoshis(long val) {
80                 bindings.CommonOpenChannelFields_set_funding_satoshis(this.ptr, val);
81                 GC.KeepAlive(this);
82                 GC.KeepAlive(val);
83         }
84
85         /**
86          * The threshold below which outputs on transactions broadcast by the channel initiator will be
87          * omitted
88          */
89         public long get_dust_limit_satoshis() {
90                 long ret = bindings.CommonOpenChannelFields_get_dust_limit_satoshis(this.ptr);
91                 GC.KeepAlive(this);
92                 return ret;
93         }
94
95         /**
96          * The threshold below which outputs on transactions broadcast by the channel initiator will be
97          * omitted
98          */
99         public void set_dust_limit_satoshis(long val) {
100                 bindings.CommonOpenChannelFields_set_dust_limit_satoshis(this.ptr, val);
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(val);
103         }
104
105         /**
106          * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
107          */
108         public long get_max_htlc_value_in_flight_msat() {
109                 long ret = bindings.CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(this.ptr);
110                 GC.KeepAlive(this);
111                 return ret;
112         }
113
114         /**
115          * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi
116          */
117         public void set_max_htlc_value_in_flight_msat(long val) {
118                 bindings.CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(this.ptr, val);
119                 GC.KeepAlive(this);
120                 GC.KeepAlive(val);
121         }
122
123         /**
124          * The minimum HTLC size incoming to channel initiator, in milli-satoshi
125          */
126         public long get_htlc_minimum_msat() {
127                 long ret = bindings.CommonOpenChannelFields_get_htlc_minimum_msat(this.ptr);
128                 GC.KeepAlive(this);
129                 return ret;
130         }
131
132         /**
133          * The minimum HTLC size incoming to channel initiator, in milli-satoshi
134          */
135         public void set_htlc_minimum_msat(long val) {
136                 bindings.CommonOpenChannelFields_set_htlc_minimum_msat(this.ptr, val);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(val);
139         }
140
141         /**
142          * The feerate for the commitment transaction set by the channel initiator until updated by
143          * [`UpdateFee`]
144          */
145         public int get_commitment_feerate_sat_per_1000_weight() {
146                 int ret = bindings.CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(this.ptr);
147                 GC.KeepAlive(this);
148                 return ret;
149         }
150
151         /**
152          * The feerate for the commitment transaction set by the channel initiator until updated by
153          * [`UpdateFee`]
154          */
155         public void set_commitment_feerate_sat_per_1000_weight(int val) {
156                 bindings.CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(this.ptr, val);
157                 GC.KeepAlive(this);
158                 GC.KeepAlive(val);
159         }
160
161         /**
162          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
163          * broadcast a commitment transaction
164          */
165         public short get_to_self_delay() {
166                 short ret = bindings.CommonOpenChannelFields_get_to_self_delay(this.ptr);
167                 GC.KeepAlive(this);
168                 return ret;
169         }
170
171         /**
172          * The number of blocks which the counterparty will have to wait to claim on-chain funds if they
173          * broadcast a commitment transaction
174          */
175         public void set_to_self_delay(short val) {
176                 bindings.CommonOpenChannelFields_set_to_self_delay(this.ptr, val);
177                 GC.KeepAlive(this);
178                 GC.KeepAlive(val);
179         }
180
181         /**
182          * The maximum number of inbound HTLCs towards channel initiator
183          */
184         public short get_max_accepted_htlcs() {
185                 short ret = bindings.CommonOpenChannelFields_get_max_accepted_htlcs(this.ptr);
186                 GC.KeepAlive(this);
187                 return ret;
188         }
189
190         /**
191          * The maximum number of inbound HTLCs towards channel initiator
192          */
193         public void set_max_accepted_htlcs(short val) {
194                 bindings.CommonOpenChannelFields_set_max_accepted_htlcs(this.ptr, val);
195                 GC.KeepAlive(this);
196                 GC.KeepAlive(val);
197         }
198
199         /**
200          * The channel initiator's key controlling the funding transaction
201          */
202         public byte[] get_funding_pubkey() {
203                 long ret = bindings.CommonOpenChannelFields_get_funding_pubkey(this.ptr);
204                 GC.KeepAlive(this);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
207                 return ret_conv;
208         }
209
210         /**
211          * The channel initiator's key controlling the funding transaction
212          */
213         public void set_funding_pubkey(byte[] val) {
214                 bindings.CommonOpenChannelFields_set_funding_pubkey(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
215                 GC.KeepAlive(this);
216                 GC.KeepAlive(val);
217         }
218
219         /**
220          * Used to derive a revocation key for transactions broadcast by counterparty
221          */
222         public byte[] get_revocation_basepoint() {
223                 long ret = bindings.CommonOpenChannelFields_get_revocation_basepoint(this.ptr);
224                 GC.KeepAlive(this);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
227                 return ret_conv;
228         }
229
230         /**
231          * Used to derive a revocation key for transactions broadcast by counterparty
232          */
233         public void set_revocation_basepoint(byte[] val) {
234                 bindings.CommonOpenChannelFields_set_revocation_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
235                 GC.KeepAlive(this);
236                 GC.KeepAlive(val);
237         }
238
239         /**
240          * A payment key to channel initiator for transactions broadcast by counterparty
241          */
242         public byte[] get_payment_basepoint() {
243                 long ret = bindings.CommonOpenChannelFields_get_payment_basepoint(this.ptr);
244                 GC.KeepAlive(this);
245                 if (ret >= 0 && ret <= 4096) { return null; }
246                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
247                 return ret_conv;
248         }
249
250         /**
251          * A payment key to channel initiator for transactions broadcast by counterparty
252          */
253         public void set_payment_basepoint(byte[] val) {
254                 bindings.CommonOpenChannelFields_set_payment_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
255                 GC.KeepAlive(this);
256                 GC.KeepAlive(val);
257         }
258
259         /**
260          * Used to derive a payment key to channel initiator for transactions broadcast by channel
261          * initiator
262          */
263         public byte[] get_delayed_payment_basepoint() {
264                 long ret = bindings.CommonOpenChannelFields_get_delayed_payment_basepoint(this.ptr);
265                 GC.KeepAlive(this);
266                 if (ret >= 0 && ret <= 4096) { return null; }
267                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
268                 return ret_conv;
269         }
270
271         /**
272          * Used to derive a payment key to channel initiator for transactions broadcast by channel
273          * initiator
274          */
275         public void set_delayed_payment_basepoint(byte[] val) {
276                 bindings.CommonOpenChannelFields_set_delayed_payment_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
277                 GC.KeepAlive(this);
278                 GC.KeepAlive(val);
279         }
280
281         /**
282          * Used to derive an HTLC payment key to channel initiator
283          */
284         public byte[] get_htlc_basepoint() {
285                 long ret = bindings.CommonOpenChannelFields_get_htlc_basepoint(this.ptr);
286                 GC.KeepAlive(this);
287                 if (ret >= 0 && ret <= 4096) { return null; }
288                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
289                 return ret_conv;
290         }
291
292         /**
293          * Used to derive an HTLC payment key to channel initiator
294          */
295         public void set_htlc_basepoint(byte[] val) {
296                 bindings.CommonOpenChannelFields_set_htlc_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
297                 GC.KeepAlive(this);
298                 GC.KeepAlive(val);
299         }
300
301         /**
302          * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
303          */
304         public byte[] get_first_per_commitment_point() {
305                 long ret = bindings.CommonOpenChannelFields_get_first_per_commitment_point(this.ptr);
306                 GC.KeepAlive(this);
307                 if (ret >= 0 && ret <= 4096) { return null; }
308                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
309                 return ret_conv;
310         }
311
312         /**
313          * The first to-be-broadcast-by-channel-initiator transaction's per commitment point
314          */
315         public void set_first_per_commitment_point(byte[] val) {
316                 bindings.CommonOpenChannelFields_set_first_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
317                 GC.KeepAlive(this);
318                 GC.KeepAlive(val);
319         }
320
321         /**
322          * The channel flags to be used
323          */
324         public byte get_channel_flags() {
325                 byte ret = bindings.CommonOpenChannelFields_get_channel_flags(this.ptr);
326                 GC.KeepAlive(this);
327                 return ret;
328         }
329
330         /**
331          * The channel flags to be used
332          */
333         public void set_channel_flags(byte val) {
334                 bindings.CommonOpenChannelFields_set_channel_flags(this.ptr, val);
335                 GC.KeepAlive(this);
336                 GC.KeepAlive(val);
337         }
338
339         /**
340          * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
341          * collaboratively close
342          */
343         public Option_CVec_u8ZZ get_shutdown_scriptpubkey() {
344                 long ret = bindings.CommonOpenChannelFields_get_shutdown_scriptpubkey(this.ptr);
345                 GC.KeepAlive(this);
346                 if (ret >= 0 && ret <= 4096) { return null; }
347                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
348                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
349                 return ret_hu_conv;
350         }
351
352         /**
353          * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we
354          * collaboratively close
355          */
356         public void set_shutdown_scriptpubkey(org.ldk.structs.Option_CVec_u8ZZ val) {
357                 bindings.CommonOpenChannelFields_set_shutdown_scriptpubkey(this.ptr, val.ptr);
358                 GC.KeepAlive(this);
359                 GC.KeepAlive(val);
360         }
361
362         /**
363          * The channel type that this channel will represent
364          * 
365          * If this is `None`, we derive the channel type from the intersection of our
366          * feature bits with our counterparty's feature bits from the [`Init`] message.
367          * 
368          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
369          */
370         public ChannelTypeFeatures get_channel_type() {
371                 long ret = bindings.CommonOpenChannelFields_get_channel_type(this.ptr);
372                 GC.KeepAlive(this);
373                 if (ret >= 0 && ret <= 4096) { return null; }
374                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
375                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
376                 return ret_hu_conv;
377         }
378
379         /**
380          * The channel type that this channel will represent
381          * 
382          * If this is `None`, we derive the channel type from the intersection of our
383          * feature bits with our counterparty's feature bits from the [`Init`] message.
384          * 
385          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
386          */
387         public void set_channel_type(org.ldk.structs.ChannelTypeFeatures val) {
388                 bindings.CommonOpenChannelFields_set_channel_type(this.ptr, val == null ? 0 : val.ptr);
389                 GC.KeepAlive(this);
390                 GC.KeepAlive(val);
391         }
392
393         /**
394          * Constructs a new CommonOpenChannelFields given each field
395          * 
396          * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
397          */
398         public static CommonOpenChannelFields of(byte[] chain_hash_arg, org.ldk.structs.ChannelId 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 commitment_feerate_sat_per_1000_weight_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 channel_flags_arg, org.ldk.structs.Option_CVec_u8ZZ shutdown_scriptpubkey_arg, org.ldk.structs.ChannelTypeFeatures channel_type_arg) {
399                 long ret = bindings.CommonOpenChannelFields_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain_hash_arg, 32)), temporary_channel_id_arg.ptr, funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, commitment_feerate_sat_per_1000_weight_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_basepoint_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);
400                 GC.KeepAlive(chain_hash_arg);
401                 GC.KeepAlive(temporary_channel_id_arg);
402                 GC.KeepAlive(funding_satoshis_arg);
403                 GC.KeepAlive(dust_limit_satoshis_arg);
404                 GC.KeepAlive(max_htlc_value_in_flight_msat_arg);
405                 GC.KeepAlive(htlc_minimum_msat_arg);
406                 GC.KeepAlive(commitment_feerate_sat_per_1000_weight_arg);
407                 GC.KeepAlive(to_self_delay_arg);
408                 GC.KeepAlive(max_accepted_htlcs_arg);
409                 GC.KeepAlive(funding_pubkey_arg);
410                 GC.KeepAlive(revocation_basepoint_arg);
411                 GC.KeepAlive(payment_basepoint_arg);
412                 GC.KeepAlive(delayed_payment_basepoint_arg);
413                 GC.KeepAlive(htlc_basepoint_arg);
414                 GC.KeepAlive(first_per_commitment_point_arg);
415                 GC.KeepAlive(channel_flags_arg);
416                 GC.KeepAlive(shutdown_scriptpubkey_arg);
417                 GC.KeepAlive(channel_type_arg);
418                 if (ret >= 0 && ret <= 4096) { return null; }
419                 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
420                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
421                 return ret_hu_conv;
422         }
423
424         internal long clone_ptr() {
425                 long ret = bindings.CommonOpenChannelFields_clone_ptr(this.ptr);
426                 GC.KeepAlive(this);
427                 return ret;
428         }
429
430         /**
431          * Creates a copy of the CommonOpenChannelFields
432          */
433         public CommonOpenChannelFields clone() {
434                 long ret = bindings.CommonOpenChannelFields_clone(this.ptr);
435                 GC.KeepAlive(this);
436                 if (ret >= 0 && ret <= 4096) { return null; }
437                 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
438                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
439                 return ret_hu_conv;
440         }
441
442         /**
443          * Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields.
444          */
445         public long hash() {
446                 long ret = bindings.CommonOpenChannelFields_hash(this.ptr);
447                 GC.KeepAlive(this);
448                 return ret;
449         }
450
451         public override int GetHashCode() {
452                 return (int)this.hash();
453         }
454         /**
455          * Checks if two CommonOpenChannelFieldss contain equal inner contents.
456          * This ignores pointers and is_owned flags and looks at the values in fields.
457          * Two objects with NULL inner values will be considered "equal" here.
458          */
459         public bool eq(org.ldk.structs.CommonOpenChannelFields b) {
460                 bool ret = bindings.CommonOpenChannelFields_eq(this.ptr, b.ptr);
461                 GC.KeepAlive(this);
462                 GC.KeepAlive(b);
463                 if (this != null) { this.ptrs_to.AddLast(b); };
464                 return ret;
465         }
466
467         public override bool Equals(object o) {
468                 if (!(o is CommonOpenChannelFields)) return false;
469                 return this.eq((CommonOpenChannelFields)o);
470         }
471         /**
472          * The [`ChannelParameters`] for this channel.
473          */
474         public ChannelParameters channel_parameters() {
475                 long ret = bindings.CommonOpenChannelFields_channel_parameters(this.ptr);
476                 GC.KeepAlive(this);
477                 if (ret >= 0 && ret <= 4096) { return null; }
478                 org.ldk.structs.ChannelParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelParameters(null, ret); }
479                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
480                 return ret_hu_conv;
481         }
482
483 }
484 } } }