X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FSignedRawInvoice.java;h=b8e833004de65dce5f5afaf4de114b871b5050dc;hb=5e9de82b3a7712a41189756d9d16d946142b2ac5;hp=f9fd6c3d99994142e38876e689a79ac891d8c3ed;hpb=f3e670e9341decac613d33fc52febf19cea32f20;p=ldk-java diff --git a/src/main/java/org/ldk/structs/SignedRawInvoice.java b/src/main/java/org/ldk/structs/SignedRawInvoice.java index f9fd6c3d..b8e83300 100644 --- a/src/main/java/org/ldk/structs/SignedRawInvoice.java +++ b/src/main/java/org/ldk/structs/SignedRawInvoice.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; @@ -29,13 +30,20 @@ public class SignedRawInvoice extends CommonBase { * 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); + 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; } @@ -44,12 +52,25 @@ public class SignedRawInvoice extends CommonBase { */ public SignedRawInvoice clone() { long ret = bindings.SignedRawInvoice_clone(this.ptr); + Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - SignedRawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new SignedRawInvoice(null, ret); } - ret_hu_conv.ptrs_to.add(this); + 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; } + /** + * Checks if two SignedRawInvoices contain equal inner contents. + */ + 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 @@ -58,10 +79,11 @@ public class SignedRawInvoice extends CommonBase { */ public ThreeTuple_RawInvoice_u832InvoiceSignatureZ into_parts() { long ret = bindings.SignedRawInvoice_into_parts(this.ptr); + Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } ThreeTuple_RawInvoice_u832InvoiceSignatureZ ret_hu_conv = new ThreeTuple_RawInvoice_u832InvoiceSignatureZ(null, ret); - ret_hu_conv.ptrs_to.add(this); - ; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + if (this != null) { this.ptrs_to.add(this); }; return ret_hu_conv; } @@ -70,17 +92,19 @@ public class SignedRawInvoice extends CommonBase { */ public RawInvoice raw_invoice() { long ret = bindings.SignedRawInvoice_raw_invoice(this.ptr); + Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawInvoice(null, ret); } - ret_hu_conv.ptrs_to.add(this); + 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. */ - 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; } @@ -89,9 +113,10 @@ public class SignedRawInvoice extends CommonBase { */ public InvoiceSignature signature() { long ret = bindings.SignedRawInvoice_signature(this.ptr); + Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - InvoiceSignature ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceSignature(null, ret); } - ret_hu_conv.ptrs_to.add(this); + 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; } @@ -100,6 +125,7 @@ public class SignedRawInvoice extends CommonBase { */ public Result_PayeePubKeyErrorZ recover_payee_pub_key() { long ret = bindings.SignedRawInvoice_recover_payee_pub_key(this.ptr); + 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; @@ -111,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); + Reference.reachabilityFence(s); if (ret >= 0 && ret <= 4096) { return null; } - Result_SignedRawInvoiceNoneZ ret_hu_conv = Result_SignedRawInvoiceNoneZ.constr_from_ptr(ret); + Result_SignedRawInvoiceParseErrorZ ret_hu_conv = Result_SignedRawInvoiceParseErrorZ.constr_from_ptr(ret); return ret_hu_conv; } @@ -129,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; }