X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FCommitmentUpdate.java;h=6a32283415af188a720835deaca0b6a1a2a9d8c1;hb=1854b5cebef22ace9e9e4dd191f609818df9ce08;hp=049a26c7407530de457a0493ab96860a3ae5a272;hpb=7d6be8a5ef72a4ebfe07660cce55f43f6cc30b80;p=ldk-java diff --git a/src/main/java/org/ldk/structs/CommitmentUpdate.java b/src/main/java/org/ldk/structs/CommitmentUpdate.java index 049a26c7..6a322834 100644 --- a/src/main/java/org/ldk/structs/CommitmentUpdate.java +++ b/src/main/java/org/ldk/structs/CommitmentUpdate.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import java.lang.ref.Reference; import javax.annotation.Nullable; @@ -25,10 +26,11 @@ public class CommitmentUpdate extends CommonBase { */ public UpdateAddHTLC[] get_update_add_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr); + Reference.reachabilityFence(this); UpdateAddHTLC[] ret_conv_15_arr = new UpdateAddHTLC[ret.length]; for (int p = 0; p < ret.length; p++) { long ret_conv_15 = ret[p]; - UpdateAddHTLC ret_conv_15_hu_conv = new UpdateAddHTLC(null, ret_conv_15); + 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); } ret_conv_15_hu_conv.ptrs_to.add(this); ret_conv_15_arr[p] = ret_conv_15_hu_conv; } @@ -40,7 +42,8 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_add_htlcs(UpdateAddHTLC[] val) { 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); - for (UpdateAddHTLC val_conv_15: val) { this.ptrs_to.add(val_conv_15); }; + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -48,10 +51,11 @@ public class CommitmentUpdate extends CommonBase { */ public UpdateFulfillHTLC[] get_update_fulfill_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr); + Reference.reachabilityFence(this); UpdateFulfillHTLC[] ret_conv_19_arr = new UpdateFulfillHTLC[ret.length]; for (int t = 0; t < ret.length; t++) { long ret_conv_19 = ret[t]; - UpdateFulfillHTLC ret_conv_19_hu_conv = new UpdateFulfillHTLC(null, ret_conv_19); + 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); } ret_conv_19_hu_conv.ptrs_to.add(this); ret_conv_19_arr[t] = ret_conv_19_hu_conv; } @@ -63,7 +67,8 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_fulfill_htlcs(UpdateFulfillHTLC[] val) { 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); - for (UpdateFulfillHTLC val_conv_19: val) { this.ptrs_to.add(val_conv_19); }; + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -71,10 +76,11 @@ public class CommitmentUpdate extends CommonBase { */ public UpdateFailHTLC[] get_update_fail_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr); + Reference.reachabilityFence(this); UpdateFailHTLC[] ret_conv_16_arr = new UpdateFailHTLC[ret.length]; for (int q = 0; q < ret.length; q++) { long ret_conv_16 = ret[q]; - UpdateFailHTLC ret_conv_16_hu_conv = new UpdateFailHTLC(null, ret_conv_16); + 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); } ret_conv_16_hu_conv.ptrs_to.add(this); ret_conv_16_arr[q] = ret_conv_16_hu_conv; } @@ -86,7 +92,8 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_fail_htlcs(UpdateFailHTLC[] val) { 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); - for (UpdateFailHTLC val_conv_16: val) { this.ptrs_to.add(val_conv_16); }; + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -94,10 +101,11 @@ public class CommitmentUpdate extends CommonBase { */ public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr); + Reference.reachabilityFence(this); UpdateFailMalformedHTLC[] ret_conv_25_arr = new UpdateFailMalformedHTLC[ret.length]; for (int z = 0; z < ret.length; z++) { long ret_conv_25 = ret[z]; - UpdateFailMalformedHTLC ret_conv_25_hu_conv = new UpdateFailMalformedHTLC(null, ret_conv_25); + 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); } ret_conv_25_hu_conv.ptrs_to.add(this); ret_conv_25_arr[z] = ret_conv_25_hu_conv; } @@ -109,7 +117,8 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_fail_malformed_htlcs(UpdateFailMalformedHTLC[] val) { 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); - for (UpdateFailMalformedHTLC val_conv_25: val) { this.ptrs_to.add(val_conv_25); }; + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -120,8 +129,9 @@ public class CommitmentUpdate extends CommonBase { @Nullable public UpdateFee get_update_fee() { long ret = bindings.CommitmentUpdate_get_update_fee(this.ptr); - if (ret < 1024) { return null; } - UpdateFee ret_hu_conv = new UpdateFee(null, ret); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + UpdateFee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UpdateFee(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -133,7 +143,8 @@ public class CommitmentUpdate extends CommonBase { */ public void set_update_fee(@Nullable UpdateFee val) { bindings.CommitmentUpdate_set_update_fee(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -141,8 +152,9 @@ public class CommitmentUpdate extends CommonBase { */ public CommitmentSigned get_commitment_signed() { long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr); - if (ret < 1024) { return null; } - CommitmentSigned ret_hu_conv = new CommitmentSigned(null, ret); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + CommitmentSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentSigned(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -152,7 +164,8 @@ public class CommitmentUpdate extends CommonBase { */ public void set_commitment_signed(CommitmentSigned val) { bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -160,25 +173,32 @@ public class CommitmentUpdate extends CommonBase { */ 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) { 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); - if (ret < 1024) { return null; } - CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret); + Reference.reachabilityFence(update_add_htlcs_arg); + Reference.reachabilityFence(update_fulfill_htlcs_arg); + Reference.reachabilityFence(update_fail_htlcs_arg); + Reference.reachabilityFence(update_fail_malformed_htlcs_arg); + Reference.reachabilityFence(update_fee_arg); + Reference.reachabilityFence(commitment_signed_arg); + if (ret >= 0 && ret <= 4096) { return null; } + CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); - for (UpdateAddHTLC update_add_htlcs_arg_conv_15: update_add_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_add_htlcs_arg_conv_15); }; - for (UpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19: update_fulfill_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fulfill_htlcs_arg_conv_19); }; - for (UpdateFailHTLC update_fail_htlcs_arg_conv_16: update_fail_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fail_htlcs_arg_conv_16); }; - for (UpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25: update_fail_malformed_htlcs_arg) { ret_hu_conv.ptrs_to.add(update_fail_malformed_htlcs_arg_conv_25); }; - ret_hu_conv.ptrs_to.add(update_fee_arg); - ret_hu_conv.ptrs_to.add(commitment_signed_arg); return ret_hu_conv; } + long clone_ptr() { + long ret = bindings.CommitmentUpdate_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + /** * Creates a copy of the CommitmentUpdate */ public CommitmentUpdate clone() { long ret = bindings.CommitmentUpdate_clone(this.ptr); - if (ret < 1024) { return null; } - CommitmentUpdate ret_hu_conv = new CommitmentUpdate(null, ret); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + CommitmentUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CommitmentUpdate(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; }