Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / OutPoint.java
index a980f095193119f33d335f239fa0a957e38ead07..edb136126a7d606f93cd3f0b8e3e3e83c589d591 100644 (file)
@@ -2,59 +2,121 @@ package org.ldk.structs;
 
 import org.ldk.impl.bindings;
 import org.ldk.enums.*;
+import org.ldk.util.*;
+import java.util.Arrays;
+import javax.annotation.Nullable;
 
+
+/**
+ * A reference to a transaction output.
+ * 
+ * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
+ * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class OutPoint extends CommonBase {
        OutPoint(Object _dummy, long ptr) { super(ptr); }
        @Override @SuppressWarnings("deprecation")
        protected void finalize() throws Throwable {
                super.finalize();
-               bindings.OutPoint_free(ptr);
+               if (ptr != 0) { bindings.OutPoint_free(ptr); }
        }
 
-       public OutPoint(OutPoint orig) {
-               super(bindings.OutPoint_clone(orig == null ? 0 : orig.ptr & ~1));
-               this.ptrs_to.add(orig);
+       /**
+        * The referenced transaction's txid.
+        */
+       public byte[] get_txid() {
+               byte[] ret = bindings.OutPoint_get_txid(this.ptr);
+               return ret;
        }
 
-       public byte[] get_txid(OutPoint this_ptr) {
-               byte[] ret = bindings.OutPoint_get_txid(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The referenced transaction's txid.
+        */
+       public void set_txid(byte[] val) {
+               bindings.OutPoint_set_txid(this.ptr, val);
+       }
+
+       /**
+        * The index of the referenced output in its transaction's vout.
+        */
+       public short get_index() {
+               short ret = bindings.OutPoint_get_index(this.ptr);
                return ret;
        }
 
-       public void set_txid(OutPoint this_ptr, byte[] val) {
-               bindings.OutPoint_set_txid(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * The index of the referenced output in its transaction's vout.
+        */
+       public void set_index(short val) {
+               bindings.OutPoint_set_index(this.ptr, val);
        }
 
-       public short get_index(OutPoint this_ptr) {
-               short ret = bindings.OutPoint_get_index(this_ptr == null ? 0 : this_ptr.ptr & ~1);
-               this.ptrs_to.add(this_ptr);
-               return ret;
+       /**
+        * Constructs a new OutPoint given each field
+        */
+       public static OutPoint of(byte[] txid_arg, short index_arg) {
+               long ret = bindings.OutPoint_new(txid_arg, index_arg);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
+               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               return ret_hu_conv;
        }
 
-       public void set_index(OutPoint this_ptr, short val) {
-               bindings.OutPoint_set_index(this_ptr == null ? 0 : this_ptr.ptr & ~1, val);
-               this.ptrs_to.add(this_ptr);
+       /**
+        * Creates a copy of the OutPoint
+        */
+       public OutPoint clone() {
+               long ret = bindings.OutPoint_clone(this.ptr);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
        }
 
-       public OutPoint(byte[] txid_arg, short index_arg) {
-               super(bindings.OutPoint_new(txid_arg, index_arg));
+       /**
+        * Checks if two OutPoints 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(OutPoint b) {
+               boolean ret = bindings.OutPoint_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
+               this.ptrs_to.add(b);
+               return ret;
+       }
+
+       /**
+        * Checks if two OutPoints contain equal inner contents.
+        */
+       public long hash() {
+               long ret = bindings.OutPoint_hash(this.ptr);
+               return ret;
        }
 
+       /**
+        * Convert an `OutPoint` to a lightning channel id.
+        */
        public byte[] to_channel_id() {
                byte[] ret = bindings.OutPoint_to_channel_id(this.ptr);
                return ret;
        }
 
-       public byte[] write(OutPoint obj) {
-               byte[] ret = bindings.OutPoint_write(obj == null ? 0 : obj.ptr & ~1);
-               this.ptrs_to.add(obj);
+       /**
+        * Serialize the OutPoint object into a byte array which can be read by OutPoint_read
+        */
+       public byte[] write() {
+               byte[] ret = bindings.OutPoint_write(this.ptr);
                return ret;
        }
 
-       public OutPoint(byte[] ser) {
-               super(bindings.OutPoint_read(ser));
+       /**
+        * Read a OutPoint from a byte array, created by OutPoint_write
+        */
+       public static Result_OutPointDecodeErrorZ read(byte[] ser) {
+               long ret = bindings.OutPoint_read(ser);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
        }
 
 }