[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / PaymentPurpose.java
index 4b969dd16412f336ee5dac217755dcc6c399ed34..5b915e2f8e1954a0670a9e5a26a961e37934c934 100644 (file)
@@ -22,8 +22,14 @@ public class PaymentPurpose extends CommonBase {
        }
        static PaymentPurpose constr_from_ptr(long ptr) {
                bindings.LDKPaymentPurpose raw_val = bindings.LDKPaymentPurpose_ref_from_ptr(ptr);
-               if (raw_val.getClass() == bindings.LDKPaymentPurpose.InvoicePayment.class) {
-                       return new InvoicePayment(ptr, (bindings.LDKPaymentPurpose.InvoicePayment)raw_val);
+               if (raw_val.getClass() == bindings.LDKPaymentPurpose.Bolt11InvoicePayment.class) {
+                       return new Bolt11InvoicePayment(ptr, (bindings.LDKPaymentPurpose.Bolt11InvoicePayment)raw_val);
+               }
+               if (raw_val.getClass() == bindings.LDKPaymentPurpose.Bolt12OfferPayment.class) {
+                       return new Bolt12OfferPayment(ptr, (bindings.LDKPaymentPurpose.Bolt12OfferPayment)raw_val);
+               }
+               if (raw_val.getClass() == bindings.LDKPaymentPurpose.Bolt12RefundPayment.class) {
+                       return new Bolt12RefundPayment(ptr, (bindings.LDKPaymentPurpose.Bolt12RefundPayment)raw_val);
                }
                if (raw_val.getClass() == bindings.LDKPaymentPurpose.SpontaneousPayment.class) {
                        return new SpontaneousPayment(ptr, (bindings.LDKPaymentPurpose.SpontaneousPayment)raw_val);
@@ -32,13 +38,14 @@ public class PaymentPurpose extends CommonBase {
        }
 
        /**
-        * Information for receiving a payment that we generated an invoice for.
+        * A payment for a BOLT 11 invoice.
         */
-       public final static class InvoicePayment extends PaymentPurpose {
+       public final static class Bolt11InvoicePayment extends PaymentPurpose {
                /**
                 * The preimage to the payment_hash, if the payment hash (and secret) were fetched via
-                * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to
-                * [`ChannelManager::claim_funds`].
+                * [`ChannelManager::create_inbound_payment`]. When handling [`Event::PaymentClaimable`],
+                * this can be passed directly to [`ChannelManager::claim_funds`] to claim the payment. No
+                * action is needed when seen in [`Event::PaymentClaimed`].
                 * 
                 * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
                 * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
@@ -57,13 +64,95 @@ public class PaymentPurpose extends CommonBase {
                 * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
                */
                public final byte[] payment_secret;
-               private InvoicePayment(long ptr, bindings.LDKPaymentPurpose.InvoicePayment obj) {
+               private Bolt11InvoicePayment(long ptr, bindings.LDKPaymentPurpose.Bolt11InvoicePayment obj) {
+                       super(null, ptr);
+                       long payment_preimage = obj.payment_preimage;
+                       org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.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;
+               }
+       }
+       /**
+        * A payment for a BOLT 12 [`Offer`].
+        * 
+        * [`Offer`]: crate::offers::offer::Offer
+        */
+       public final static class Bolt12OfferPayment extends PaymentPurpose {
+               /**
+                * The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be
+                * passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed
+                * when seen in [`Event::PaymentClaimed`].
+                * 
+                * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
+               */
+               public final org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage;
+               /**
+                * The secret used to authenticate the sender to the recipient, preventing a number of
+                * de-anonymization attacks while routing a payment.
+                * 
+                * See [`PaymentPurpose::Bolt11InvoicePayment::payment_secret`] for further details.
+               */
+               public final byte[] payment_secret;
+               /**
+                * The context of the payment such as information about the corresponding [`Offer`] and
+                * [`InvoiceRequest`].
+                * 
+                * [`Offer`]: crate::offers::offer::Offer
+                * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+               */
+               public final org.ldk.structs.Bolt12OfferContext payment_context;
+               private Bolt12OfferPayment(long ptr, bindings.LDKPaymentPurpose.Bolt12OfferPayment obj) {
+                       super(null, ptr);
+                       long payment_preimage = obj.payment_preimage;
+                       org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.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;
+                       long payment_context = obj.payment_context;
+                       org.ldk.structs.Bolt12OfferContext payment_context_hu_conv = null; if (payment_context < 0 || payment_context > 4096) { payment_context_hu_conv = new org.ldk.structs.Bolt12OfferContext(null, payment_context); }
+                       if (payment_context_hu_conv != null) { payment_context_hu_conv.ptrs_to.add(this); };
+                       this.payment_context = payment_context_hu_conv;
+               }
+       }
+       /**
+        * A payment for a BOLT 12 [`Refund`].
+        * 
+        * [`Refund`]: crate::offers::refund::Refund
+        */
+       public final static class Bolt12RefundPayment extends PaymentPurpose {
+               /**
+                * The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be
+                * passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed
+                * when seen in [`Event::PaymentClaimed`].
+                * 
+                * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
+               */
+               public final org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage;
+               /**
+                * The secret used to authenticate the sender to the recipient, preventing a number of
+                * de-anonymization attacks while routing a payment.
+                * 
+                * See [`PaymentPurpose::Bolt11InvoicePayment::payment_secret`] for further details.
+               */
+               public final byte[] payment_secret;
+               /**
+                * The context of the payment such as information about the corresponding [`Refund`].
+                * 
+                * [`Refund`]: crate::offers::refund::Refund
+               */
+               public final org.ldk.structs.Bolt12RefundContext payment_context;
+               private Bolt12RefundPayment(long ptr, bindings.LDKPaymentPurpose.Bolt12RefundPayment obj) {
                        super(null, ptr);
                        long payment_preimage = obj.payment_preimage;
                        org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.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;
+                       long payment_context = obj.payment_context;
+                       org.ldk.structs.Bolt12RefundContext payment_context_hu_conv = null; if (payment_context < 0 || payment_context > 4096) { payment_context_hu_conv = new org.ldk.structs.Bolt12RefundContext(null, payment_context); }
+                       if (payment_context_hu_conv != null) { payment_context_hu_conv.ptrs_to.add(this); };
+                       this.payment_context = payment_context_hu_conv;
                }
        }
        /**
@@ -96,16 +185,48 @@ public class PaymentPurpose extends CommonBase {
        }
 
        /**
-        * Utility method to constructs a new InvoicePayment-variant PaymentPurpose
+        * Utility method to constructs a new Bolt11InvoicePayment-variant PaymentPurpose
+        */
+       public static PaymentPurpose bolt11_invoice_payment(org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage, byte[] payment_secret) {
+               long ret = bindings.PaymentPurpose_bolt11_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);
+               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;
+       }
+
+       /**
+        * Utility method to constructs a new Bolt12OfferPayment-variant PaymentPurpose
+        */
+       public static PaymentPurpose bolt12_offer_payment(org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage, byte[] payment_secret, org.ldk.structs.Bolt12OfferContext payment_context) {
+               long ret = bindings.PaymentPurpose_bolt12_offer_payment(payment_preimage.ptr, InternalUtils.check_arr_len(payment_secret, 32), payment_context.ptr);
+               Reference.reachabilityFence(payment_preimage);
+               Reference.reachabilityFence(payment_secret);
+               Reference.reachabilityFence(payment_context);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.PaymentPurpose ret_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(ret);
+               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); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_context); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Utility method to constructs a new Bolt12RefundPayment-variant PaymentPurpose
         */
-       public static PaymentPurpose invoice_payment(org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage, byte[] payment_secret) {
-               long ret = bindings.PaymentPurpose_invoice_payment(payment_preimage.ptr, InternalUtils.check_arr_len(payment_secret, 32));
+       public static PaymentPurpose bolt12_refund_payment(org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage, byte[] payment_secret, org.ldk.structs.Bolt12RefundContext payment_context) {
+               long ret = bindings.PaymentPurpose_bolt12_refund_payment(payment_preimage.ptr, InternalUtils.check_arr_len(payment_secret, 32), payment_context.ptr);
                Reference.reachabilityFence(payment_preimage);
                Reference.reachabilityFence(payment_secret);
+               Reference.reachabilityFence(payment_context);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.PaymentPurpose ret_hu_conv = org.ldk.structs.PaymentPurpose.constr_from_ptr(ret);
                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); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_context); };
                return ret_hu_conv;
        }
 
@@ -126,7 +247,7 @@ public class PaymentPurpose extends CommonBase {
         * 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);
+               boolean ret = bindings.PaymentPurpose_eq(this.ptr, b.ptr);
                Reference.reachabilityFence(this);
                Reference.reachabilityFence(b);
                return ret;