1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
13 * transaction updates if they were pending.
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 {
21 if (ptr != 0) { bindings.CommitmentUpdate_free(ptr); }
25 * update_add_htlc messages which should be sent
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 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); }
35 if (ret_conv_15_hu_conv != null) { ret_conv_15_hu_conv.ptrs_to.add(this); };
36 ret_conv_15_arr[p] = ret_conv_15_hu_conv;
38 return ret_conv_15_arr;
42 * update_add_htlc messages which should be sent
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).toArray() : null);
46 Reference.reachabilityFence(this);
47 Reference.reachabilityFence(val);
48 for (UpdateAddHTLC val_conv_15: val) { if (this != null) { this.ptrs_to.add(val_conv_15); }; };
52 * update_fulfill_htlc messages which should be sent
54 public UpdateFulfillHTLC[] get_update_fulfill_htlcs() {
55 long[] ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr);
56 Reference.reachabilityFence(this);
57 int ret_conv_19_len = ret.length;
58 UpdateFulfillHTLC[] ret_conv_19_arr = new UpdateFulfillHTLC[ret_conv_19_len];
59 for (int t = 0; t < ret_conv_19_len; t++) {
60 long ret_conv_19 = ret[t];
61 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); }
62 if (ret_conv_19_hu_conv != null) { ret_conv_19_hu_conv.ptrs_to.add(this); };
63 ret_conv_19_arr[t] = ret_conv_19_hu_conv;
65 return ret_conv_19_arr;
69 * update_fulfill_htlc messages which should be sent
71 public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) {
72 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).toArray() : null);
73 Reference.reachabilityFence(this);
74 Reference.reachabilityFence(val);
75 for (UpdateFulfillHTLC val_conv_19: val) { if (this != null) { this.ptrs_to.add(val_conv_19); }; };
79 * update_fail_htlc messages which should be sent
81 public UpdateFailHTLC[] get_update_fail_htlcs() {
82 long[] ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr);
83 Reference.reachabilityFence(this);
84 int ret_conv_16_len = ret.length;
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 = 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.add(this); };
90 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
92 return ret_conv_16_arr;
96 * update_fail_htlc messages which should be sent
98 public void set_update_fail_htlcs(UpdateFailHTLC[] val) {
99 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).toArray() : null);
100 Reference.reachabilityFence(this);
101 Reference.reachabilityFence(val);
102 for (UpdateFailHTLC val_conv_16: val) { if (this != null) { this.ptrs_to.add(val_conv_16); }; };
106 * update_fail_malformed_htlc messages which should be sent
108 public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() {
109 long[] ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr);
110 Reference.reachabilityFence(this);
111 int ret_conv_25_len = ret.length;
112 UpdateFailMalformedHTLC[] ret_conv_25_arr = new UpdateFailMalformedHTLC[ret_conv_25_len];
113 for (int z = 0; z < ret_conv_25_len; z++) {
114 long ret_conv_25 = ret[z];
115 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); }
116 if (ret_conv_25_hu_conv != null) { ret_conv_25_hu_conv.ptrs_to.add(this); };
117 ret_conv_25_arr[z] = ret_conv_25_hu_conv;
119 return ret_conv_25_arr;
123 * update_fail_malformed_htlc messages which should be sent
125 public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) {
126 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).toArray() : null);
127 Reference.reachabilityFence(this);
128 Reference.reachabilityFence(val);
129 for (UpdateFailMalformedHTLC val_conv_25: val) { if (this != null) { this.ptrs_to.add(val_conv_25); }; };
133 * An update_fee message which should be sent
135 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
138 public UpdateFee get_update_fee() {
139 long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr);
140 Reference.reachabilityFence(this);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 org.ldk.structs.UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFee(null, ret); }
143 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
148 * An update_fee message which should be sent
150 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
152 public void set_update_fee(@Nullable UpdateFee val) {
153 bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr);
154 Reference.reachabilityFence(this);
155 Reference.reachabilityFence(val);
156 if (this != null) { this.ptrs_to.add(val); };
160 * Finally, the commitment_signed message which should be sent
162 public CommitmentSigned get_commitment_signed() {
163 long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr);
164 Reference.reachabilityFence(this);
165 if (ret >= 0 && ret <= 4096) { return null; }
166 org.ldk.structs.CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentSigned(null, ret); }
167 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
172 * Finally, the commitment_signed message which should be sent
174 public void set_commitment_signed(CommitmentSigned val) {
175 bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr);
176 Reference.reachabilityFence(this);
177 Reference.reachabilityFence(val);
178 if (this != null) { this.ptrs_to.add(val); };
182 * Constructs a new CommitmentUpdate given each field
184 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) {
185 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).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).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).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).toArray() : null, update_fee_arg == null ? 0 : update_fee_arg.ptr, commitment_signed_arg == null ? 0 : commitment_signed_arg.ptr);
186 Reference.reachabilityFence(update_add_htlcs_arg);
187 Reference.reachabilityFence(update_fulfill_htlcs_arg);
188 Reference.reachabilityFence(update_fail_htlcs_arg);
189 Reference.reachabilityFence(update_fail_malformed_htlcs_arg);
190 Reference.reachabilityFence(update_fee_arg);
191 Reference.reachabilityFence(commitment_signed_arg);
192 if (ret >= 0 && ret <= 4096) { return null; }
193 org.ldk.structs.CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentUpdate(null, ret); }
194 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
195 for (UpdateAddHTLC update_add_htlcs_arg_conv_15: update_add_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(update_add_htlcs_arg_conv_15); }; };
196 for (UpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19: update_fulfill_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(update_fulfill_htlcs_arg_conv_19); }; };
197 for (UpdateFailHTLC update_fail_htlcs_arg_conv_16: update_fail_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(update_fail_htlcs_arg_conv_16); }; };
198 for (UpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25: update_fail_malformed_htlcs_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(update_fail_malformed_htlcs_arg_conv_25); }; };
199 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(update_fee_arg); };
200 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(commitment_signed_arg); };
205 long ret = bindings.CommitmentUpdate_clone_ptr(this.ptr);
206 Reference.reachabilityFence(this);
211 * Creates a copy of the CommitmentUpdate
213 public CommitmentUpdate clone() {
214 long ret = bindings.CommitmentUpdate_clone(this.ptr);
215 Reference.reachabilityFence(this);
216 if (ret >= 0 && ret <= 4096) { return null; }
217 org.ldk.structs.CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentUpdate(null, ret); }
218 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };