X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FCommitmentUpdate.java;h=7ee8b0b207c763a758f964eb4aafc39b906aa6e3;hb=ffdd56c967087cba7548599934585b8a9a3102e2;hp=a2b8ff0cfb5a15307b268bb9704f33aa1473c8cb;hpb=330ca992be304d0eac79bd59b411980dff294b03;p=ldk-java diff --git a/src/main/java/org/ldk/structs/CommitmentUpdate.java b/src/main/java/org/ldk/structs/CommitmentUpdate.java index a2b8ff0c..7ee8b0b2 100644 --- a/src/main/java/org/ldk/structs/CommitmentUpdate.java +++ b/src/main/java/org/ldk/structs/CommitmentUpdate.java @@ -9,7 +9,7 @@ import javax.annotation.Nullable; /** - * Struct used to return values from revoke_and_ack messages, containing a bunch of commitment + * Struct used to return values from [`RevokeAndACK`] messages, containing a bunch of commitment * transaction updates if they were pending. */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays @@ -22,7 +22,7 @@ public class CommitmentUpdate extends CommonBase { } /** - * update_add_htlc messages which should be sent + * `update_add_htlc` messages which should be sent */ public UpdateAddHTLC[] get_update_add_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_add_htlcs(this.ptr); @@ -39,17 +39,17 @@ public class CommitmentUpdate extends CommonBase { } /** - * update_add_htlc messages which should be sent + * `update_add_htlc` messages which should be sent */ 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).toArray() : null); + bindings.CommitmentUpdate_set_update_add_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_15 -> val_conv_15.ptr).toArray() : null); Reference.reachabilityFence(this); Reference.reachabilityFence(val); for (UpdateAddHTLC val_conv_15: val) { if (this != null) { this.ptrs_to.add(val_conv_15); }; }; } /** - * update_fulfill_htlc messages which should be sent + * `update_fulfill_htlc` messages which should be sent */ public UpdateFulfillHTLC[] get_update_fulfill_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_fulfill_htlcs(this.ptr); @@ -66,17 +66,17 @@ public class CommitmentUpdate extends CommonBase { } /** - * update_fulfill_htlc messages which should be sent + * `update_fulfill_htlc` messages which should be sent */ 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).toArray() : null); + bindings.CommitmentUpdate_set_update_fulfill_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_19 -> val_conv_19.ptr).toArray() : null); Reference.reachabilityFence(this); Reference.reachabilityFence(val); for (UpdateFulfillHTLC val_conv_19: val) { if (this != null) { this.ptrs_to.add(val_conv_19); }; }; } /** - * update_fail_htlc messages which should be sent + * `update_fail_htlc` messages which should be sent */ public UpdateFailHTLC[] get_update_fail_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_fail_htlcs(this.ptr); @@ -93,17 +93,17 @@ public class CommitmentUpdate extends CommonBase { } /** - * update_fail_htlc messages which should be sent + * `update_fail_htlc` messages which should be sent */ 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).toArray() : null); + bindings.CommitmentUpdate_set_update_fail_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_16 -> val_conv_16.ptr).toArray() : null); Reference.reachabilityFence(this); Reference.reachabilityFence(val); for (UpdateFailHTLC val_conv_16: val) { if (this != null) { this.ptrs_to.add(val_conv_16); }; }; } /** - * update_fail_malformed_htlc messages which should be sent + * `update_fail_malformed_htlc` messages which should be sent */ public UpdateFailMalformedHTLC[] get_update_fail_malformed_htlcs() { long[] ret = bindings.CommitmentUpdate_get_update_fail_malformed_htlcs(this.ptr); @@ -120,17 +120,17 @@ public class CommitmentUpdate extends CommonBase { } /** - * update_fail_malformed_htlc messages which should be sent + * `update_fail_malformed_htlc` messages which should be sent */ 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).toArray() : null); + bindings.CommitmentUpdate_set_update_fail_malformed_htlcs(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_25 -> val_conv_25.ptr).toArray() : null); Reference.reachabilityFence(this); Reference.reachabilityFence(val); for (UpdateFailMalformedHTLC val_conv_25: val) { if (this != null) { this.ptrs_to.add(val_conv_25); }; }; } /** - * An update_fee message which should be sent + * An `update_fee` message which should be sent * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ @@ -145,7 +145,7 @@ public class CommitmentUpdate extends CommonBase { } /** - * An update_fee message which should be sent + * An `update_fee` message which should be sent * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ @@ -157,7 +157,7 @@ public class CommitmentUpdate extends CommonBase { } /** - * Finally, the commitment_signed message which should be sent + * A `commitment_signed` message which should be sent */ public CommitmentSigned get_commitment_signed() { long ret = bindings.CommitmentUpdate_get_commitment_signed(this.ptr); @@ -169,10 +169,10 @@ public class CommitmentUpdate extends CommonBase { } /** - * Finally, the commitment_signed message which should be sent + * A `commitment_signed` message which should be sent */ public void set_commitment_signed(org.ldk.structs.CommitmentSigned val) { - bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val == null ? 0 : val.ptr); + bindings.CommitmentUpdate_set_commitment_signed(this.ptr, val.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(val); if (this != null) { this.ptrs_to.add(val); }; @@ -180,9 +180,11 @@ public class CommitmentUpdate extends CommonBase { /** * Constructs a new CommitmentUpdate given each field + * + * Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ - 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) { - 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); + 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, @Nullable org.ldk.structs.UpdateFee update_fee_arg, org.ldk.structs.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.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.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.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.ptr).toArray() : null, update_fee_arg == null ? 0 : update_fee_arg.ptr, commitment_signed_arg.ptr); Reference.reachabilityFence(update_add_htlcs_arg); Reference.reachabilityFence(update_fulfill_htlcs_arg); Reference.reachabilityFence(update_fail_htlcs_arg); @@ -219,13 +221,25 @@ public class CommitmentUpdate extends CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the CommitmentUpdate. + */ + public long hash() { + long ret = bindings.CommitmentUpdate_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + @Override public int hashCode() { + return (int)this.hash(); + } /** * Checks if two CommitmentUpdates contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ public boolean eq(org.ldk.structs.CommitmentUpdate b) { - boolean ret = bindings.CommitmentUpdate_eq(this.ptr, b == null ? 0 : b.ptr); + boolean ret = bindings.CommitmentUpdate_eq(this.ptr, b.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(b); if (this != null) { this.ptrs_to.add(b); };