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