X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FInvoice.java;h=596982ab493c4dcabd6097eb951f1b301b87fec7;hb=330ca992be304d0eac79bd59b411980dff294b03;hp=2299daabb209684beebe284e53f96bb6c016f4ec;hpb=9760d533f7ecac9bb7a8249f9b557e3f995c276d;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Invoice.java b/src/main/java/org/ldk/structs/Invoice.java index 2299daab..596982ab 100644 --- a/src/main/java/org/ldk/structs/Invoice.java +++ b/src/main/java/org/ldk/structs/Invoice.java @@ -30,11 +30,11 @@ public class Invoice 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(Invoice b) { + public boolean eq(org.ldk.structs.Invoice b) { boolean ret = bindings.Invoice_eq(this.ptr, b == null ? 0 : b.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(b); - this.ptrs_to.add(b); + if (this != null) { this.ptrs_to.add(b); }; return ret; } @@ -56,10 +56,22 @@ public class Invoice extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Invoice(null, ret); } - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } + /** + * Checks if two Invoices contain equal inner contents. + */ + public long hash() { + long ret = bindings.Invoice_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + @Override public int hashCode() { + return (int)this.hash(); + } /** * Transform the `Invoice` into it's unchecked version */ @@ -68,8 +80,8 @@ public class Invoice extends CommonBase { 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); } - ret_hu_conv.ptrs_to.add(this); - this.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; } @@ -106,12 +118,12 @@ public class Invoice extends CommonBase { * assert!(Invoice::from_signed(signed).is_ok()); * ``` */ - public static Result_InvoiceSemanticErrorZ from_signed(SignedRawInvoice signed_invoice) { + public static Result_InvoiceSemanticErrorZ from_signed(org.ldk.structs.SignedRawInvoice signed_invoice) { long ret = bindings.Invoice_from_signed(signed_invoice == null ? 0 : signed_invoice.ptr); Reference.reachabilityFence(signed_invoice); if (ret >= 0 && ret <= 4096) { return null; } Result_InvoiceSemanticErrorZ ret_hu_conv = Result_InvoiceSemanticErrorZ.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(signed_invoice); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(signed_invoice); }; return ret_hu_conv; } @@ -174,7 +186,7 @@ public class Invoice extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); } - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -237,7 +249,7 @@ public class Invoice extends CommonBase { for (int o = 0; o < ret_conv_14_len; o++) { long ret_conv_14 = ret[o]; org.ldk.structs.PrivateRoute ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new org.ldk.structs.PrivateRoute(null, ret_conv_14); } - ret_conv_14_hu_conv.ptrs_to.add(this); + if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.add(this); }; ret_conv_14_arr[o] = ret_conv_14_hu_conv; } return ret_conv_14_arr; @@ -254,7 +266,7 @@ public class Invoice extends CommonBase { for (int l = 0; l < ret_conv_11_len; l++) { long ret_conv_11 = ret[l]; org.ldk.structs.RouteHint ret_conv_11_hu_conv = null; if (ret_conv_11 < 0 || ret_conv_11 > 4096) { ret_conv_11_hu_conv = new org.ldk.structs.RouteHint(null, ret_conv_11); } - ret_conv_11_hu_conv.ptrs_to.add(this); + if (ret_conv_11_hu_conv != null) { ret_conv_11_hu_conv.ptrs_to.add(this); }; ret_conv_11_arr[l] = ret_conv_11_hu_conv; } return ret_conv_11_arr; @@ -277,7 +289,7 @@ public class Invoice extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; }