[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / PaymentPurpose.java
index 276e889565684bd4545e01421f89cbd8c58cc570..c149fa3b8429303caf39d4dde87d7f09e8ccbd58 100644 (file)
@@ -42,10 +42,8 @@ public class PaymentPurpose extends CommonBase {
                 * 
                 * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
                 * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
-                * 
-                * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
                */
-               @Nullable public final byte[] payment_preimage;
+               public final org.ldk.structs.Option_PaymentPreimageZ payment_preimage;
                /**
                 * The \"payment secret\". This authenticates the sender to the recipient, preventing a
                 * number of deanonymization attacks during the routing process.
@@ -61,7 +59,10 @@ public class PaymentPurpose extends CommonBase {
                public final byte[] payment_secret;
                private InvoicePayment(long ptr, bindings.LDKPaymentPurpose.InvoicePayment obj) {
                        super(null, ptr);
-                       this.payment_preimage = obj.payment_preimage;
+                       long payment_preimage = obj.payment_preimage;
+                       org.ldk.structs.Option_PaymentPreimageZ payment_preimage_hu_conv = org.ldk.structs.Option_PaymentPreimageZ.constr_from_ptr(payment_preimage);
+                       if (payment_preimage_hu_conv != null) { payment_preimage_hu_conv.ptrs_to.add(this); };
+                       this.payment_preimage = payment_preimage_hu_conv;
                        this.payment_secret = obj.payment_secret;
                }
        }
@@ -90,20 +91,21 @@ public class PaymentPurpose extends CommonBase {
                Reference.reachabilityFence(this);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.PaymentPurpose ret_hu_conv = org.ldk.structs.PaymentPurpose.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;
        }
 
        /**
         * Utility method to constructs a new InvoicePayment-variant PaymentPurpose
         */
-       public static PaymentPurpose invoice_payment(byte[] payment_preimage, byte[] payment_secret) {
-               long ret = bindings.PaymentPurpose_invoice_payment(InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_secret, 32));
+       public static PaymentPurpose invoice_payment(org.ldk.structs.Option_PaymentPreimageZ payment_preimage, byte[] payment_secret) {
+               long ret = bindings.PaymentPurpose_invoice_payment(payment_preimage.ptr, InternalUtils.check_arr_len(payment_secret, 32));
                Reference.reachabilityFence(payment_preimage);
                Reference.reachabilityFence(payment_secret);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.PaymentPurpose ret_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_preimage); };
                return ret_hu_conv;
        }
 
@@ -115,10 +117,25 @@ public class PaymentPurpose extends CommonBase {
                Reference.reachabilityFence(a);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.PaymentPurpose ret_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(ret);
-               ret_hu_conv.ptrs_to.add(ret_hu_conv);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
                return ret_hu_conv;
        }
 
+       /**
+        * Checks if two PaymentPurposes contain equal inner contents.
+        * This ignores pointers and is_owned flags and looks at the values in fields.
+        */
+       public boolean eq(org.ldk.structs.PaymentPurpose b) {
+               boolean ret = bindings.PaymentPurpose_eq(this.ptr, b == null ? 0 : b.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(b);
+               return ret;
+       }
+
+       @Override public boolean equals(Object o) {
+               if (!(o instanceof PaymentPurpose)) return false;
+               return this.eq((PaymentPurpose)o);
+       }
        /**
         * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read
         */