[Java] Update auto-generated bindings to 0.0.115
[ldk-java] / src / main / java / org / ldk / structs / SignedRawInvoice.java
index c097c202990ba3dc555f508ed9c15df641c3edfe..7c3252cbc9de50225ae3eed6f17081923fd48d62 100644 (file)
@@ -4,15 +4,16 @@ 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;
 
 
 /**
- * Represents a signed `RawInvoice` with cached hash. The signature is not checked and may be
+ * Represents a signed [`RawInvoice`] with cached hash. The signature is not checked and may be
  * invalid.
  * 
  * # Invariants
- * The hash has to be either from the deserialized invoice or from the serialized `raw_invoice`.
+ * The hash has to be either from the deserialized invoice or from the serialized [`RawInvoice`].
  */
 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
 public class SignedRawInvoice extends CommonBase {
@@ -28,9 +29,21 @@ public class SignedRawInvoice extends CommonBase {
         * 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(SignedRawInvoice b) {
-               boolean ret = bindings.SignedRawInvoice_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
-               this.ptrs_to.add(b);
+       public boolean eq(org.ldk.structs.SignedRawInvoice b) {
+               boolean ret = bindings.SignedRawInvoice_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 SignedRawInvoice)) return false;
+               return this.eq((SignedRawInvoice)o);
+       }
+       long clone_ptr() {
+               long ret = bindings.SignedRawInvoice_clone_ptr(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
@@ -39,64 +52,71 @@ public class SignedRawInvoice extends CommonBase {
         */
        public SignedRawInvoice clone() {
                long ret = bindings.SignedRawInvoice_clone(this.ptr);
-               if (ret < 1024) { return null; }
-               SignedRawInvoice ret_hu_conv = new SignedRawInvoice(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.SignedRawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.SignedRawInvoice(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 SignedRawInvoice.
+        */
+       public long hash() {
+               long ret = bindings.SignedRawInvoice_hash(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       @Override public int hashCode() {
+               return (int)this.hash();
+       }
        /**
         * Disassembles the `SignedRawInvoice` into its three parts:
         * 1. raw invoice
         * 2. hash of the raw invoice
         * 3. signature
         */
-       public ThreeTuple<RawInvoice, byte[], InvoiceSignature> into_parts() {
+       public ThreeTuple_RawInvoice_u832InvoiceSignatureZ into_parts() {
                long ret = bindings.SignedRawInvoice_into_parts(this.ptr);
-               if (ret < 1024) { return null; }
-               long ret_a = bindings.LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(ret);
-               RawInvoice ret_a_hu_conv = new RawInvoice(null, ret_a);
-               ret_a_hu_conv.ptrs_to.add(this);;
-               byte[] ret_b = bindings.LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(ret);
-               long ret_c = bindings.LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(ret);
-               InvoiceSignature ret_c_hu_conv = new InvoiceSignature(null, ret_c);
-               ret_c_hu_conv.ptrs_to.add(this);;
-               ThreeTuple<RawInvoice, byte[], InvoiceSignature> ret_conv = new ThreeTuple<RawInvoice, byte[], InvoiceSignature>(ret_a_hu_conv, ret_b, ret_c_hu_conv, () -> {
-                       bindings.C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(ret);
-               });
-               ret_a_hu_conv.ptrs_to.add(ret_conv);
-               ret_c_hu_conv.ptrs_to.add(ret_conv);
-               this.ptrs_to.add(this);
-               return ret_conv;
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               ThreeTuple_RawInvoice_u832InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawInvoice_u832InvoiceSignatureZ(null, ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               if (this != null) { this.ptrs_to.add(this); };
+               return ret_hu_conv;
        }
 
        /**
-        * The `RawInvoice` which was signed.
+        * The [`RawInvoice`] which was signed.
         */
        public RawInvoice raw_invoice() {
                long ret = bindings.SignedRawInvoice_raw_invoice(this.ptr);
-               if (ret < 1024) { return null; }
-               RawInvoice ret_hu_conv = new RawInvoice(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawInvoice(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
        /**
-        * The hash of the `RawInvoice` that was signed.
+        * The hash of the [`RawInvoice`] that was signed.
         */
-       public byte[] hash() {
-               byte[] ret = bindings.SignedRawInvoice_hash(this.ptr);
+       public byte[] signable_hash() {
+               byte[] ret = bindings.SignedRawInvoice_signable_hash(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
        /**
-        * InvoiceSignature for the invoice.
+        * Signature for the invoice.
         */
        public InvoiceSignature signature() {
                long ret = bindings.SignedRawInvoice_signature(this.ptr);
-               if (ret < 1024) { return null; }
-               InvoiceSignature ret_hu_conv = new InvoiceSignature(null, ret);
-               ret_hu_conv.ptrs_to.add(this);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceSignature(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
                return ret_hu_conv;
        }
 
@@ -105,7 +125,8 @@ public class SignedRawInvoice extends CommonBase {
         */
        public Result_PayeePubKeyErrorZ recover_payee_pub_key() {
                long ret = bindings.SignedRawInvoice_recover_payee_pub_key(this.ptr);
-               if (ret < 1024) { return null; }
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
                Result_PayeePubKeyErrorZ ret_hu_conv = Result_PayeePubKeyErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
@@ -116,16 +137,18 @@ public class SignedRawInvoice extends CommonBase {
         */
        public boolean check_signature() {
                boolean ret = bindings.SignedRawInvoice_check_signature(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }
 
        /**
         * Read a SignedRawInvoice object from a string
         */
-       public static Result_SignedRawInvoiceNoneZ from_str(java.lang.String s) {
+       public static Result_SignedRawInvoiceParseErrorZ from_str(java.lang.String s) {
                long ret = bindings.SignedRawInvoice_from_str(s);
-               if (ret < 1024) { return null; }
-               Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret);
+               Reference.reachabilityFence(s);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_SignedRawInvoiceParseErrorZ ret_hu_conv = Result_SignedRawInvoiceParseErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
 
@@ -134,6 +157,7 @@ public class SignedRawInvoice extends CommonBase {
         */
        public String to_str() {
                String ret = bindings.SignedRawInvoice_to_str(this.ptr);
+               Reference.reachabilityFence(this);
                return ret;
        }