[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / OpenChannelV2.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_channel2 message to be sent by or received from the channel initiator.
11  * 
12  * Used in V2 channel establishment
13  */
14 public class OpenChannelV2 : CommonBase {
15         internal OpenChannelV2(object _dummy, long ptr) : base(ptr) { }
16         ~OpenChannelV2() {
17                 if (ptr != 0) { bindings.OpenChannelV2_free(ptr); }
18         }
19
20         /**
21          * Common fields of `open_channel(2)`-like messages
22          */
23         public CommonOpenChannelFields get_common_fields() {
24                 long ret = bindings.OpenChannelV2_get_common_fields(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * Common fields of `open_channel(2)`-like messages
34          */
35         public void set_common_fields(org.ldk.structs.CommonOpenChannelFields val) {
36                 bindings.OpenChannelV2_set_common_fields(this.ptr, val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * The feerate for the funding transaction set by the channel initiator
44          */
45         public int get_funding_feerate_sat_per_1000_weight() {
46                 int ret = bindings.OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * The feerate for the funding transaction set by the channel initiator
53          */
54         public void set_funding_feerate_sat_per_1000_weight(int val) {
55                 bindings.OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * The locktime for the funding transaction
62          */
63         public int get_locktime() {
64                 int ret = bindings.OpenChannelV2_get_locktime(this.ptr);
65                 GC.KeepAlive(this);
66                 return ret;
67         }
68
69         /**
70          * The locktime for the funding transaction
71          */
72         public void set_locktime(int val) {
73                 bindings.OpenChannelV2_set_locktime(this.ptr, val);
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
80          */
81         public byte[] get_second_per_commitment_point() {
82                 long ret = bindings.OpenChannelV2_get_second_per_commitment_point(this.ptr);
83                 GC.KeepAlive(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
86                 return ret_conv;
87         }
88
89         /**
90          * The second to-be-broadcast-by-channel-initiator transaction's per commitment point
91          */
92         public void set_second_per_commitment_point(byte[] val) {
93                 bindings.OpenChannelV2_set_second_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
94                 GC.KeepAlive(this);
95                 GC.KeepAlive(val);
96         }
97
98         /**
99          * Optionally, a requirement that only confirmed inputs can be added
100          */
101         public COption_NoneZ get_require_confirmed_inputs() {
102                 COption_NoneZ ret = bindings.OpenChannelV2_get_require_confirmed_inputs(this.ptr);
103                 GC.KeepAlive(this);
104                 return ret;
105         }
106
107         /**
108          * Optionally, a requirement that only confirmed inputs can be added
109          */
110         public void set_require_confirmed_inputs(COption_NoneZ val) {
111                 bindings.OpenChannelV2_set_require_confirmed_inputs(this.ptr, val);
112                 GC.KeepAlive(this);
113                 GC.KeepAlive(val);
114         }
115
116         /**
117          * Constructs a new OpenChannelV2 given each field
118          */
119         public static OpenChannelV2 of(org.ldk.structs.CommonOpenChannelFields common_fields_arg, int funding_feerate_sat_per_1000_weight_arg, int locktime_arg, byte[] second_per_commitment_point_arg, COption_NoneZ require_confirmed_inputs_arg) {
120                 long ret = bindings.OpenChannelV2_new(common_fields_arg.ptr, funding_feerate_sat_per_1000_weight_arg, locktime_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(second_per_commitment_point_arg, 33)), require_confirmed_inputs_arg);
121                 GC.KeepAlive(common_fields_arg);
122                 GC.KeepAlive(funding_feerate_sat_per_1000_weight_arg);
123                 GC.KeepAlive(locktime_arg);
124                 GC.KeepAlive(second_per_commitment_point_arg);
125                 GC.KeepAlive(require_confirmed_inputs_arg);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(common_fields_arg); };
130                 return ret_hu_conv;
131         }
132
133         internal long clone_ptr() {
134                 long ret = bindings.OpenChannelV2_clone_ptr(this.ptr);
135                 GC.KeepAlive(this);
136                 return ret;
137         }
138
139         /**
140          * Creates a copy of the OpenChannelV2
141          */
142         public OpenChannelV2 clone() {
143                 long ret = bindings.OpenChannelV2_clone(this.ptr);
144                 GC.KeepAlive(this);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 org.ldk.structs.OpenChannelV2 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannelV2(null, ret); }
147                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Generates a non-cryptographic 64-bit hash of the OpenChannelV2.
153          */
154         public long hash() {
155                 long ret = bindings.OpenChannelV2_hash(this.ptr);
156                 GC.KeepAlive(this);
157                 return ret;
158         }
159
160         public override int GetHashCode() {
161                 return (int)this.hash();
162         }
163         /**
164          * Checks if two OpenChannelV2s contain equal inner contents.
165          * This ignores pointers and is_owned flags and looks at the values in fields.
166          * Two objects with NULL inner values will be considered "equal" here.
167          */
168         public bool eq(org.ldk.structs.OpenChannelV2 b) {
169                 bool ret = bindings.OpenChannelV2_eq(this.ptr, b.ptr);
170                 GC.KeepAlive(this);
171                 GC.KeepAlive(b);
172                 if (this != null) { this.ptrs_to.AddLast(b); };
173                 return ret;
174         }
175
176         public override bool Equals(object o) {
177                 if (!(o is OpenChannelV2)) return false;
178                 return this.eq((OpenChannelV2)o);
179         }
180         /**
181          * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read
182          */
183         public byte[] write() {
184                 long ret = bindings.OpenChannelV2_write(this.ptr);
185                 GC.KeepAlive(this);
186                 if (ret >= 0 && ret <= 4096) { return null; }
187                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
188                 return ret_conv;
189         }
190
191         /**
192          * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write
193          */
194         public static Result_OpenChannelV2DecodeErrorZ read(byte[] ser) {
195                 long ret = bindings.OpenChannelV2_read(InternalUtils.encodeUint8Array(ser));
196                 GC.KeepAlive(ser);
197                 if (ret >= 0 && ret <= 4096) { return null; }
198                 Result_OpenChannelV2DecodeErrorZ ret_hu_conv = Result_OpenChannelV2DecodeErrorZ.constr_from_ptr(ret);
199                 return ret_hu_conv;
200         }
201
202 }
203 } } }