Update auto-generated bindings to 0.0.103
[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 javax.annotation.Nullable;
8
9
10 /**
11  * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
12  * transaction updates if they were pending.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class CommitmentUpdate extends CommonBase {
16         CommitmentUpdate(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); }
21         }
22
23         /**
24          * update_add_htlc messages which should be sent
25          */
26         public UpdateAddHTLC[] get_update_add_htlcs() {
27                 long[] ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr);
28                 UpdateAddHTLC[] ret_conv_15_arr = new UpdateAddHTLC[ret.length];
29                 for (int p = 0; p < ret.length; p++) {
30                         long ret_conv_15 = ret[p];
31                         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); }
32                         ret_conv_15_hu_conv.ptrs_to.add(this);
33                         ret_conv_15_arr[p] = ret_conv_15_hu_conv;
34                 }
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, val != null ? Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15 == null ? 0 : val_conv_15.ptr & ~1).toArray() : null);
43         }
44
45         /**
46          * update_fulfill_htlc messages which should be sent
47          */
48         public UpdateFulfillHTLC[] get_update_fulfill_htlcs() {
49                 long[] ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr);
50                 UpdateFulfillHTLC[] ret_conv_19_arr = new UpdateFulfillHTLC[ret.length];
51                 for (int t = 0; t < ret.length; t++) {
52                         long ret_conv_19 = ret[t];
53                         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); }
54                         ret_conv_19_hu_conv.ptrs_to.add(this);
55                         ret_conv_19_arr[t] = ret_conv_19_hu_conv;
56                 }
57                 return ret_conv_19_arr;
58         }
59
60         /**
61          * update_fulfill_htlc messages which should be sent
62          */
63         public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) {
64                 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);
65         }
66
67         /**
68          * update_fail_htlc messages which should be sent
69          */
70         public UpdateFailHTLC[] get_update_fail_htlcs() {
71                 long[] ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr);
72                 UpdateFailHTLC[] ret_conv_16_arr = new UpdateFailHTLC[ret.length];
73                 for (int q = 0; q < ret.length; q++) {
74                         long ret_conv_16 = ret[q];
75                         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); }
76                         ret_conv_16_hu_conv.ptrs_to.add(this);
77                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
78                 }
79                 return ret_conv_16_arr;
80         }
81
82         /**
83          * update_fail_htlc messages which should be sent
84          */
85         public void set_update_fail_htlcs(UpdateFailHTLC[] val) {
86                 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);
87         }
88
89         /**
90          * update_fail_malformed_htlc messages which should be sent
91          */
92         public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() {
93                 long[] ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr);
94                 UpdateFailMalformedHTLC[] ret_conv_25_arr = new UpdateFailMalformedHTLC[ret.length];
95                 for (int z = 0; z < ret.length; z++) {
96                         long ret_conv_25 = ret[z];
97                         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); }
98                         ret_conv_25_hu_conv.ptrs_to.add(this);
99                         ret_conv_25_arr[z] = ret_conv_25_hu_conv;
100                 }
101                 return ret_conv_25_arr;
102         }
103
104         /**
105          * update_fail_malformed_htlc messages which should be sent
106          */
107         public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) {
108                 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);
109         }
110
111         /**
112          * An update_fee message which should be sent
113          * 
114          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
115          */
116         @Nullable
117         public UpdateFee get_update_fee() {
118                 long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFee(null, ret); }
121                 ret_hu_conv.ptrs_to.add(this);
122                 return ret_hu_conv;
123         }
124
125         /**
126          * An update_fee message which should be sent
127          * 
128          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
129          */
130         public void set_update_fee(@Nullable UpdateFee val) {
131                 bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr & ~1);
132         }
133
134         /**
135          * Finally, the commitment_signed message which should be sent
136          */
137         public CommitmentSigned get_commitment_signed() {
138                 long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); }
141                 ret_hu_conv.ptrs_to.add(this);
142                 return ret_hu_conv;
143         }
144
145         /**
146          * Finally, the commitment_signed message which should be sent
147          */
148         public void set_commitment_signed(CommitmentSigned val) {
149                 bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr & ~1);
150         }
151
152         /**
153          * Constructs a new CommitmentUpdate given each field
154          */
155         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) {
156                 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);
157                 if (ret >= 0 && ret <= 4096) { return null; }
158                 CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); }
159                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
160                 return ret_hu_conv;
161         }
162
163         /**
164          * Creates a copy of the CommitmentUpdate
165          */
166         public CommitmentUpdate clone() {
167                 long ret = bindings.CommitmentUpdate_clone(this.ptr);
168                 if (ret >= 0 && ret <= 4096) { return null; }
169                 CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); }
170                 ret_hu_conv.ptrs_to.add(this);
171                 return ret_hu_conv;
172         }
173
174 }