Update auto-generated Java bindings (all functionally equivalent)
[ldk-java] / src / main / java / org / ldk / structs / CommitmentUpdate.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
13  * transaction updates if they were pending.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class CommitmentUpdate extends CommonBase {
17         CommitmentUpdate(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); }
22         }
23
24         /**
25          * update_add_htlc messages which should be sent
26          */
27         public UpdateAddHTLC[] get_update_add_htlcs() {
28                 long[] ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr);
29                 Reference.reachabilityFence(this);
30                 int ret_conv_15_len = ret.length;
31                 UpdateAddHTLC[] ret_conv_15_arr = new UpdateAddHTLC[ret_conv_15_len];
32                 for (int p = 0; p < ret_conv_15_len; p++) {
33                         long ret_conv_15 = ret[p];
34                         UpdateAddHTLC ret_conv_15_hu_conv = null; if (ret_conv_15 < 0 || ret_conv_15 > 4096) { ret_conv_15_hu_conv = new UpdateAddHTLC(null, ret_conv_15); }
35                         ret_conv_15_hu_conv.ptrs_to.add(this);
36                         ret_conv_15_arr[p] = ret_conv_15_hu_conv;
37                 }
38                 return ret_conv_15_arr;
39         }
40
41         /**
42          * update_add_htlc messages which should be sent
43          */
44         public void set_update_add_htlcs(UpdateAddHTLC[] val) {
45                 bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15 == null ? 0 : val_conv_15.ptr & ~1).toArray() : null);
46                 Reference.reachabilityFence(this);
47                 Reference.reachabilityFence(val);
48         }
49
50         /**
51          * update_fulfill_htlc messages which should be sent
52          */
53         public UpdateFulfillHTLC[] get_update_fulfill_htlcs() {
54                 long[] ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr);
55                 Reference.reachabilityFence(this);
56                 int ret_conv_19_len = ret.length;
57                 UpdateFulfillHTLC[] ret_conv_19_arr = new UpdateFulfillHTLC[ret_conv_19_len];
58                 for (int t = 0; t < ret_conv_19_len; t++) {
59                         long ret_conv_19 = ret[t];
60                         UpdateFulfillHTLC ret_conv_19_hu_conv = null; if (ret_conv_19 < 0 || ret_conv_19 > 4096) { ret_conv_19_hu_conv = new UpdateFulfillHTLC(null, ret_conv_19); }
61                         ret_conv_19_hu_conv.ptrs_to.add(this);
62                         ret_conv_19_arr[t] = ret_conv_19_hu_conv;
63                 }
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, val != null ? Arrays.stream(val).mapToLong(val_conv_19 -> val_conv_19 == null ? 0 : val_conv_19.ptr & ~1).toArray() : null);
72                 Reference.reachabilityFence(this);
73                 Reference.reachabilityFence(val);
74         }
75
76         /**
77          * update_fail_htlc messages which should be sent
78          */
79         public UpdateFailHTLC[] get_update_fail_htlcs() {
80                 long[] ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr);
81                 Reference.reachabilityFence(this);
82                 int ret_conv_16_len = ret.length;
83                 UpdateFailHTLC[] ret_conv_16_arr = new UpdateFailHTLC[ret_conv_16_len];
84                 for (int q = 0; q < ret_conv_16_len; q++) {
85                         long ret_conv_16 = ret[q];
86                         UpdateFailHTLC ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new UpdateFailHTLC(null, ret_conv_16); }
87                         ret_conv_16_hu_conv.ptrs_to.add(this);
88                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
89                 }
90                 return ret_conv_16_arr;
91         }
92
93         /**
94          * update_fail_htlc messages which should be sent
95          */
96         public void set_update_fail_htlcs(UpdateFailHTLC[] val) {
97                 bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_16 -> val_conv_16 == null ? 0 : val_conv_16.ptr & ~1).toArray() : null);
98                 Reference.reachabilityFence(this);
99                 Reference.reachabilityFence(val);
100         }
101
102         /**
103          * update_fail_malformed_htlc messages which should be sent
104          */
105         public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() {
106                 long[] ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr);
107                 Reference.reachabilityFence(this);
108                 int ret_conv_25_len = ret.length;
109                 UpdateFailMalformedHTLC[] ret_conv_25_arr = new UpdateFailMalformedHTLC[ret_conv_25_len];
110                 for (int z = 0; z < ret_conv_25_len; z++) {
111                         long ret_conv_25 = ret[z];
112                         UpdateFailMalformedHTLC ret_conv_25_hu_conv = null; if (ret_conv_25 < 0 || ret_conv_25 > 4096) { ret_conv_25_hu_conv = new UpdateFailMalformedHTLC(null, ret_conv_25); }
113                         ret_conv_25_hu_conv.ptrs_to.add(this);
114                         ret_conv_25_arr[z] = ret_conv_25_hu_conv;
115                 }
116                 return ret_conv_25_arr;
117         }
118
119         /**
120          * update_fail_malformed_htlc messages which should be sent
121          */
122         public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) {
123                 bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_25 -> val_conv_25 == null ? 0 : val_conv_25.ptr & ~1).toArray() : null);
124                 Reference.reachabilityFence(this);
125                 Reference.reachabilityFence(val);
126         }
127
128         /**
129          * An update_fee message which should be sent
130          * 
131          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
132          */
133         @Nullable
134         public UpdateFee get_update_fee() {
135                 long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
136                 Reference.reachabilityFence(this);
137                 if (ret >= 0 && ret <= 4096) { return null; }
138                 UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFee(null, ret); }
139                 ret_hu_conv.ptrs_to.add(this);
140                 return ret_hu_conv;
141         }
142
143         /**
144          * An update_fee message which should be sent
145          * 
146          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
147          */
148         public void set_update_fee(@Nullable UpdateFee val) {
149                 bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr & ~1);
150                 Reference.reachabilityFence(this);
151                 Reference.reachabilityFence(val);
152         }
153
154         /**
155          * Finally, the commitment_signed message which should be sent
156          */
157         public CommitmentSigned get_commitment_signed() {
158                 long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
159                 Reference.reachabilityFence(this);
160                 if (ret >= 0 && ret <= 4096) { return null; }
161                 CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); }
162                 ret_hu_conv.ptrs_to.add(this);
163                 return ret_hu_conv;
164         }
165
166         /**
167          * Finally, the commitment_signed message which should be sent
168          */
169         public void set_commitment_signed(CommitmentSigned val) {
170                 bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr & ~1);
171                 Reference.reachabilityFence(this);
172                 Reference.reachabilityFence(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, UpdateFee update_fee_arg, CommitmentSigned commitment_signed_arg) {
179                 long ret = bindings.CommitmentUpdate_new(update_add_htlcs_arg != null ? Arrays.stream(update_add_htlcs_arg).mapToLong(update_add_htlcs_arg_conv_15 -> update_add_htlcs_arg_conv_15 == null ? 0 : update_add_htlcs_arg_conv_15.ptr & ~1).toArray() : null, update_fulfill_htlcs_arg != null ? Arrays.stream(update_fulfill_htlcs_arg).mapToLong(update_fulfill_htlcs_arg_conv_19 -> update_fulfill_htlcs_arg_conv_19 == null ? 0 : update_fulfill_htlcs_arg_conv_19.ptr & ~1).toArray() : null, update_fail_htlcs_arg != null ? Arrays.stream(update_fail_htlcs_arg).mapToLong(update_fail_htlcs_arg_conv_16 -> update_fail_htlcs_arg_conv_16 == null ? 0 : update_fail_htlcs_arg_conv_16.ptr & ~1).toArray() : null, update_fail_malformed_htlcs_arg != null ? Arrays.stream(update_fail_malformed_htlcs_arg).mapToLong(update_fail_malformed_htlcs_arg_conv_25 -> update_fail_malformed_htlcs_arg_conv_25 == null ? 0 : update_fail_malformed_htlcs_arg_conv_25.ptr & ~1).toArray() : null, update_fee_arg == null ? 0 : update_fee_arg.ptr & ~1, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr & ~1);
180                 Reference.reachabilityFence(update_add_htlcs_arg);
181                 Reference.reachabilityFence(update_fulfill_htlcs_arg);
182                 Reference.reachabilityFence(update_fail_htlcs_arg);
183                 Reference.reachabilityFence(update_fail_malformed_htlcs_arg);
184                 Reference.reachabilityFence(update_fee_arg);
185                 Reference.reachabilityFence(commitment_signed_arg);
186                 if (ret >= 0 && ret <= 4096) { return null; }
187                 CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); }
188                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
189                 return ret_hu_conv;
190         }
191
192         long clone_ptr() {
193                 long ret = bindings.CommitmentUpdate_clone_ptr(this.ptr);
194                 Reference.reachabilityFence(this);
195                 return ret;
196         }
197
198         /**
199          * Creates a copy of the CommitmentUpdate
200          */
201         public CommitmentUpdate clone() {
202                 long ret = bindings.CommitmentUpdate_clone(this.ptr);
203                 Reference.reachabilityFence(this);
204                 if (ret >= 0 && ret <= 4096) { return null; }
205                 CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); }
206                 ret_hu_conv.ptrs_to.add(this);
207                 return ret_hu_conv;
208         }
209
210 }