[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / CommitmentUpdate.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  * Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
11  * transaction updates if they were pending.
12  */
13 public class CommitmentUpdate : CommonBase {
14         internal CommitmentUpdate(object _dummy, long ptr) : base(ptr) { }
15         ~CommitmentUpdate() {
16                 if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); }
17         }
18
19         /**
20          * `update_add_htlc` messages which should be sent
21          */
22         public UpdateAddHTLC[] get_update_add_htlcs() {
23                 long ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 int ret_conv_15_len = InternalUtils.getArrayLength(ret);
27                 UpdateAddHTLC[] ret_conv_15_arr = new UpdateAddHTLC[ret_conv_15_len];
28                 for (int p = 0; p < ret_conv_15_len; p++) {
29                         long ret_conv_15 = InternalUtils.getU64ArrayElem(ret, p);
30                         org.ldk.structs.UpdateAddHTLC ret_conv_15_hu_conv = null; if (ret_conv_15 < 0 || ret_conv_15 > 4096) { ret_conv_15_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret_conv_15); }
31                         if (ret_conv_15_hu_conv != null) { ret_conv_15_hu_conv.ptrs_to.AddLast(this); };
32                         ret_conv_15_arr[p] = ret_conv_15_hu_conv;
33                 }
34                 bindings.free_buffer(ret);
35                 return ret_conv_15_arr;
36         }
37
38         /**
39          * `update_add_htlc` messages which should be sent
40          */
41         public void set_update_add_htlcs(UpdateAddHTLC[] val) {
42                 bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_15 => val_conv_15 == null ? 0 : val_conv_15.ptr)));
43                 GC.KeepAlive(this);
44                 GC.KeepAlive(val);
45                 foreach (UpdateAddHTLC val_conv_15 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_15); }; };
46         }
47
48         /**
49          * `update_fulfill_htlc` messages which should be sent
50          */
51         public UpdateFulfillHTLC[] get_update_fulfill_htlcs() {
52                 long ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr);
53                 GC.KeepAlive(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 int ret_conv_19_len = InternalUtils.getArrayLength(ret);
56                 UpdateFulfillHTLC[] ret_conv_19_arr = new UpdateFulfillHTLC[ret_conv_19_len];
57                 for (int t = 0; t < ret_conv_19_len; t++) {
58                         long ret_conv_19 = InternalUtils.getU64ArrayElem(ret, t);
59                         org.ldk.structs.UpdateFulfillHTLC ret_conv_19_hu_conv = null; if (ret_conv_19 < 0 || ret_conv_19 > 4096) { ret_conv_19_hu_conv = new org.ldk.structs.UpdateFulfillHTLC(null, ret_conv_19); }
60                         if (ret_conv_19_hu_conv != null) { ret_conv_19_hu_conv.ptrs_to.AddLast(this); };
61                         ret_conv_19_arr[t] = ret_conv_19_hu_conv;
62                 }
63                 bindings.free_buffer(ret);
64                 return ret_conv_19_arr;
65         }
66
67         /**
68          * `update_fulfill_htlc` messages which should be sent
69          */
70         public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) {
71                 bindings.CommitmentUpdate_set_update_fulfill_htlcs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_19 => val_conv_19 == null ? 0 : val_conv_19.ptr)));
72                 GC.KeepAlive(this);
73                 GC.KeepAlive(val);
74                 foreach (UpdateFulfillHTLC val_conv_19 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_19); }; };
75         }
76
77         /**
78          * `update_fail_htlc` messages which should be sent
79          */
80         public UpdateFailHTLC[] get_update_fail_htlcs() {
81                 long ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr);
82                 GC.KeepAlive(this);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 int ret_conv_16_len = InternalUtils.getArrayLength(ret);
85                 UpdateFailHTLC[] ret_conv_16_arr = new UpdateFailHTLC[ret_conv_16_len];
86                 for (int q = 0; q < ret_conv_16_len; q++) {
87                         long ret_conv_16 = InternalUtils.getU64ArrayElem(ret, q);
88                         org.ldk.structs.UpdateFailHTLC ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new org.ldk.structs.UpdateFailHTLC(null, ret_conv_16); }
89                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
90                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
91                 }
92                 bindings.free_buffer(ret);
93                 return ret_conv_16_arr;
94         }
95
96         /**
97          * `update_fail_htlc` messages which should be sent
98          */
99         public void set_update_fail_htlcs(UpdateFailHTLC[] val) {
100                 bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_16 => val_conv_16 == null ? 0 : val_conv_16.ptr)));
101                 GC.KeepAlive(this);
102                 GC.KeepAlive(val);
103                 foreach (UpdateFailHTLC val_conv_16 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_16); }; };
104         }
105
106         /**
107          * `update_fail_malformed_htlc` messages which should be sent
108          */
109         public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() {
110                 long ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr);
111                 GC.KeepAlive(this);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 int ret_conv_25_len = InternalUtils.getArrayLength(ret);
114                 UpdateFailMalformedHTLC[] ret_conv_25_arr = new UpdateFailMalformedHTLC[ret_conv_25_len];
115                 for (int z = 0; z < ret_conv_25_len; z++) {
116                         long ret_conv_25 = InternalUtils.getU64ArrayElem(ret, z);
117                         org.ldk.structs.UpdateFailMalformedHTLC ret_conv_25_hu_conv = null; if (ret_conv_25 < 0 || ret_conv_25 > 4096) { ret_conv_25_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, ret_conv_25); }
118                         if (ret_conv_25_hu_conv != null) { ret_conv_25_hu_conv.ptrs_to.AddLast(this); };
119                         ret_conv_25_arr[z] = ret_conv_25_hu_conv;
120                 }
121                 bindings.free_buffer(ret);
122                 return ret_conv_25_arr;
123         }
124
125         /**
126          * `update_fail_malformed_htlc` messages which should be sent
127          */
128         public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) {
129                 bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_25 => val_conv_25 == null ? 0 : val_conv_25.ptr)));
130                 GC.KeepAlive(this);
131                 GC.KeepAlive(val);
132                 foreach (UpdateFailMalformedHTLC val_conv_25 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_25); }; };
133         }
134
135         /**
136          * An `update_fee` message which should be sent
137          * 
138          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
139          */
140         public UpdateFee get_update_fee() {
141                 long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
142                 GC.KeepAlive(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
145                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
146                 return ret_hu_conv;
147         }
148
149         /**
150          * An `update_fee` message which should be sent
151          * 
152          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
153          */
154         public void set_update_fee(org.ldk.structs.UpdateFee val) {
155                 bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr);
156                 GC.KeepAlive(this);
157                 GC.KeepAlive(val);
158                 if (this != null) { this.ptrs_to.AddLast(val); };
159         }
160
161         /**
162          * A `commitment_signed` message which should be sent
163          */
164         public CommitmentSigned get_commitment_signed() {
165                 long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
166                 GC.KeepAlive(this);
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
169                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
170                 return ret_hu_conv;
171         }
172
173         /**
174          * A `commitment_signed` message which should be sent
175          */
176         public void set_commitment_signed(org.ldk.structs.CommitmentSigned val) {
177                 bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr);
178                 GC.KeepAlive(this);
179                 GC.KeepAlive(val);
180                 if (this != null) { this.ptrs_to.AddLast(val); };
181         }
182
183         /**
184          * Constructs a new CommitmentUpdate given each field
185          * 
186          * Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
187          */
188         public static CommitmentUpdate of(UpdateAddHTLC[] update_add_htlcs_arg, UpdateFulfillHTLC[] update_fulfill_htlcs_arg, UpdateFailHTLC[] update_fail_htlcs_arg, UpdateFailMalformedHTLC[] update_fail_malformed_htlcs_arg, org.ldk.structs.UpdateFee update_fee_arg, org.ldk.structs.CommitmentSigned commitment_signed_arg) {
189                 long ret = bindings.CommitmentUpdate_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(update_add_htlcs_arg, update_add_htlcs_arg_conv_15 => update_add_htlcs_arg_conv_15 == null ? 0 : update_add_htlcs_arg_conv_15.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_conv_19 => update_fulfill_htlcs_arg_conv_19 == null ? 0 : update_fulfill_htlcs_arg_conv_19.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(update_fail_htlcs_arg, update_fail_htlcs_arg_conv_16 => update_fail_htlcs_arg_conv_16 == null ? 0 : update_fail_htlcs_arg_conv_16.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_conv_25 => update_fail_malformed_htlcs_arg_conv_25 == null ? 0 : update_fail_malformed_htlcs_arg_conv_25.ptr)), update_fee_arg == null ? 0 : update_fee_arg.ptr, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr);
190                 GC.KeepAlive(update_add_htlcs_arg);
191                 GC.KeepAlive(update_fulfill_htlcs_arg);
192                 GC.KeepAlive(update_fail_htlcs_arg);
193                 GC.KeepAlive(update_fail_malformed_htlcs_arg);
194                 GC.KeepAlive(update_fee_arg);
195                 GC.KeepAlive(commitment_signed_arg);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 org.ldk.structs.CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentUpdate(null, ret); }
198                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
199                 foreach (UpdateAddHTLC update_add_htlcs_arg_conv_15 in update_add_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(update_add_htlcs_arg_conv_15); }; };
200                 foreach (UpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19 in update_fulfill_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(update_fulfill_htlcs_arg_conv_19); }; };
201                 foreach (UpdateFailHTLC update_fail_htlcs_arg_conv_16 in update_fail_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(update_fail_htlcs_arg_conv_16); }; };
202                 foreach (UpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25 in update_fail_malformed_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(update_fail_malformed_htlcs_arg_conv_25); }; };
203                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(update_fee_arg); };
204                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(commitment_signed_arg); };
205                 return ret_hu_conv;
206         }
207
208         internal long clone_ptr() {
209                 long ret = bindings.CommitmentUpdate_clone_ptr(this.ptr);
210                 GC.KeepAlive(this);
211                 return ret;
212         }
213
214         /**
215          * Creates a copy of the CommitmentUpdate
216          */
217         public CommitmentUpdate clone() {
218                 long ret = bindings.CommitmentUpdate_clone(this.ptr);
219                 GC.KeepAlive(this);
220                 if (ret >= 0 && ret <= 4096) { return null; }
221                 org.ldk.structs.CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentUpdate(null, ret); }
222                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
223                 return ret_hu_conv;
224         }
225
226         /**
227          * Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
228          */
229         public long hash() {
230                 long ret = bindings.CommitmentUpdate_hash(this.ptr);
231                 GC.KeepAlive(this);
232                 return ret;
233         }
234
235         public override int GetHashCode() {
236                 return (int)this.hash();
237         }
238         /**
239          * Checks if two CommitmentUpdates contain equal inner contents.
240          * This ignores pointers and is_owned flags and looks at the values in fields.
241          * Two objects with NULL inner values will be considered "equal" here.
242          */
243         public bool eq(org.ldk.structs.CommitmentUpdate b) {
244                 bool ret = bindings.CommitmentUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
245                 GC.KeepAlive(this);
246                 GC.KeepAlive(b);
247                 if (this != null) { this.ptrs_to.AddLast(b); };
248                 return ret;
249         }
250
251         public override bool Equals(object o) {
252                 if (!(o is CommitmentUpdate)) return false;
253                 return this.eq((CommitmentUpdate)o);
254         }
255 }
256 } } }