6 namespace org { namespace ldk { namespace structs {
10 * Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment
11 * transaction updates if they were pending.
13 public class CommitmentUpdate : CommonBase {
14 internal CommitmentUpdate(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); }
20 * `update_add_htlc` messages which should be sent
22 public UpdateAddHTLC[] get_update_add_htlcs() {
23 long ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr);
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;
34 bindings.free_buffer(ret);
35 return ret_conv_15_arr;
39 * `update_add_htlc` messages which should be sent
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.ptr)));
45 foreach (UpdateAddHTLC val_conv_15 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_15); }; };
49 * `update_fulfill_htlc` messages which should be sent
51 public UpdateFulfillHTLC[] get_update_fulfill_htlcs() {
52 long ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr);
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;
63 bindings.free_buffer(ret);
64 return ret_conv_19_arr;
68 * `update_fulfill_htlc` messages which should be sent
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.ptr)));
74 foreach (UpdateFulfillHTLC val_conv_19 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_19); }; };
78 * `update_fail_htlc` messages which should be sent
80 public UpdateFailHTLC[] get_update_fail_htlcs() {
81 long ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr);
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;
92 bindings.free_buffer(ret);
93 return ret_conv_16_arr;
97 * `update_fail_htlc` messages which should be sent
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.ptr)));
103 foreach (UpdateFailHTLC val_conv_16 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_16); }; };
107 * `update_fail_malformed_htlc` messages which should be sent
109 public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() {
110 long ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr);
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;
121 bindings.free_buffer(ret);
122 return ret_conv_25_arr;
126 * `update_fail_malformed_htlc` messages which should be sent
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.ptr)));
132 foreach (UpdateFailMalformedHTLC val_conv_25 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_25); }; };
136 * An `update_fee` message which should be sent
138 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
140 public UpdateFee get_update_fee() {
141 long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
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); };
150 * An `update_fee` message which should be sent
152 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
154 public void set_update_fee(org.ldk.structs.UpdateFee val) {
155 bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr);
158 if (this != null) { this.ptrs_to.AddLast(val); };
162 * A `commitment_signed` message which should be sent
164 public CommitmentSigned get_commitment_signed() {
165 long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
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); };
174 * A `commitment_signed` message which should be sent
176 public void set_commitment_signed(org.ldk.structs.CommitmentSigned val) {
177 bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val.ptr);
180 if (this != null) { this.ptrs_to.AddLast(val); };
184 * Constructs a new CommitmentUpdate given each field
186 * Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
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.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_conv_19 => 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.ptr)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_conv_25 => update_fail_malformed_htlcs_arg_conv_25.ptr)), update_fee_arg == null ? 0 : update_fee_arg.ptr, 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); };
208 internal long clone_ptr() {
209 long ret = bindings.CommitmentUpdate_clone_ptr(this.ptr);
215 * Creates a copy of the CommitmentUpdate
217 public CommitmentUpdate clone() {
218 long ret = bindings.CommitmentUpdate_clone(this.ptr);
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); };
227 * Generates a non-cryptographic 64-bit hash of the CommitmentUpdate.
230 long ret = bindings.CommitmentUpdate_hash(this.ptr);
235 public override int GetHashCode() {
236 return (int)this.hash();
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.
243 public bool eq(org.ldk.structs.CommitmentUpdate b) {
244 bool ret = bindings.CommitmentUpdate_eq(this.ptr, b.ptr);
247 if (this != null) { this.ptrs_to.AddLast(b); };
251 public override bool Equals(object o) {
252 if (!(o is CommitmentUpdate)) return false;
253 return this.eq((CommitmentUpdate)o);