[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / UpdateFailMalformedHTLC.java
index 66e394dd494186a999bef0708757139894ab0007..7bfc2ffc8364a45a5d804ecfe71f1266df7527ea 100644 (file)
@@ -2,56 +2,145 @@ package org.ldk.structs;
 
 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;
 
+
+/**
+ * An [`update_fail_malformed_htlc`] message to be sent to or received from a peer.
+ * 
+ * [`update_fail_malformed_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class UpdateFailMalformedHTLC extends CommonBase {
        UpdateFailMalformedHTLC(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
                super.finalize();
-               bindings.UpdateFailMalformedHTLC_free(ptr);
+               if (ptr != 0) { bindings.UpdateFailMalformedHTLC_free(ptr); }
+       }
+
+       /**
+        * The channel ID
+        */
+       public byte[] get_channel_id() {
+               byte[] ret = bindings.UpdateFailMalformedHTLC_get_channel_id(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
        }
 
-       public UpdateFailMalformedHTLC(UpdateFailMalformedHTLC orig) {
-               super(bindings.UpdateFailMalformedHTLC_clone(orig == null ? 0 : orig.ptr & ~1));
-               this.ptrs_to.add(orig);
+       /**
+        * The channel ID
+        */
+       public void set_channel_id(byte[] val) {
+               bindings.UpdateFailMalformedHTLC_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
        }
 
-       public byte[] get_channel_id(UpdateFailMalformedHTLC this_ptr) {
-               byte[] ret = bindings.UpdateFailMalformedHTLC_get_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The HTLC ID
+        */
+       public long get_htlc_id() {
+               long ret = bindings.UpdateFailMalformedHTLC_get_htlc_id(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
-       public void set_channel_id(UpdateFailMalformedHTLC this_ptr, byte[] val) {
-               bindings.UpdateFailMalformedHTLC_set_channel_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The HTLC ID
+        */
+       public void set_htlc_id(long val) {
+               bindings.UpdateFailMalformedHTLC_set_htlc_id(this.ptr, val);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
        }
 
-       public long get_htlc_id(UpdateFailMalformedHTLC this_ptr) {
-               long ret = bindings.UpdateFailMalformedHTLC_get_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The failure code
+        */
+       public short get_failure_code() {
+               short ret = bindings.UpdateFailMalformedHTLC_get_failure_code(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
-       public void set_htlc_id(UpdateFailMalformedHTLC this_ptr, long val) {
-               bindings.UpdateFailMalformedHTLC_set_htlc_id(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The failure code
+        */
+       public void set_failure_code(short val) {
+               bindings.UpdateFailMalformedHTLC_set_failure_code(this.ptr, val);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
        }
 
-       public short get_failure_code(UpdateFailMalformedHTLC this_ptr) {
-               short ret = bindings.UpdateFailMalformedHTLC_get_failure_code(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       long clone_ptr() {
+               long ret = bindings.UpdateFailMalformedHTLC_clone_ptr(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
-       public void set_failure_code(UpdateFailMalformedHTLC this_ptr, short val) {
-               bindings.UpdateFailMalformedHTLC_set_failure_code(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * Creates a copy of the UpdateFailMalformedHTLC
+        */
+       public UpdateFailMalformedHTLC clone() {
+               long ret = bindings.UpdateFailMalformedHTLC_clone(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.UpdateFailMalformedHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateFailMalformedHTLC(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC.
+        */
+       public long hash() {
+               long ret = bindings.UpdateFailMalformedHTLC_hash(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       @Override public int hashCode() {
+               return (int)this.hash();
+       }
+       /**
+        * Checks if two UpdateFailMalformedHTLCs 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.UpdateFailMalformedHTLC b) {
+               boolean ret = bindings.UpdateFailMalformedHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(b);
+               if (this != null) { this.ptrs_to.add(b); };
+               return ret;
+       }
+
+       @Override public boolean equals(Object o) {
+               if (!(o instanceof UpdateFailMalformedHTLC)) return false;
+               return this.eq((UpdateFailMalformedHTLC)o);
+       }
+       /**
+        * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.UpdateFailMalformedHTLC_write(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
        }
 
-       // Skipped UpdateFailMalformedHTLC_write
-       public UpdateFailMalformedHTLC(byte[] ser) {
-               super(bindings.UpdateFailMalformedHTLC_read(ser));
+       /**
+        * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write
+        */
+       public static Result_UpdateFailMalformedHTLCDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.UpdateFailMalformedHTLC_read(ser);
+               Reference.reachabilityFence(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_UpdateFailMalformedHTLCDecodeErrorZ ret_hu_conv = Result_UpdateFailMalformedHTLCDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
        }
 
 }