Merge pull request #139 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / VerifiedInvoiceRequest.java
diff --git a/src/main/java/org/ldk/structs/VerifiedInvoiceRequest.java b/src/main/java/org/ldk/structs/VerifiedInvoiceRequest.java
new file mode 100644 (file)
index 0000000..38b0d8f
--- /dev/null
@@ -0,0 +1,296 @@
+package org.ldk.structs;
+
+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;
+
+
+/**
+ * An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different
+ * ways to respond depending on whether the signing keys were derived.
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class VerifiedInvoiceRequest extends CommonBase {
+       VerifiedInvoiceRequest(Object _dummy, long ptr) { super(ptr); }
+       @Override @SuppressWarnings("deprecation")
+       protected void finalize() throws Throwable {
+               super.finalize();
+               if (ptr != 0) { bindings.VerifiedInvoiceRequest_free(ptr); }
+       }
+
+       /**
+        * Keys used for signing a [`Bolt12Invoice`] if they can be derived.
+        * 
+        * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
+        * [`respond_with`].
+        * 
+        * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+        * [`respond_using_derived_keys`]: Self::respond_using_derived_keys
+        * [`respond_with`]: Self::respond_with
+        */
+       public Option_SecretKeyZ get_keys() {
+               long ret = bindings.VerifiedInvoiceRequest_get_keys(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Option_SecretKeyZ ret_hu_conv = org.ldk.structs.Option_SecretKeyZ.constr_from_ptr(ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Keys used for signing a [`Bolt12Invoice`] if they can be derived.
+        * 
+        * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
+        * [`respond_with`].
+        * 
+        * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+        * [`respond_using_derived_keys`]: Self::respond_using_derived_keys
+        * [`respond_with`]: Self::respond_with
+        */
+       public void set_keys(org.ldk.structs.Option_SecretKeyZ val) {
+               bindings.VerifiedInvoiceRequest_set_keys(this.ptr, val.ptr);
+               Reference.reachabilityFence(this);
+               Reference.reachabilityFence(val);
+               if (this != null) { this.ptrs_to.add(val); };
+       }
+
+       long clone_ptr() {
+               long ret = bindings.VerifiedInvoiceRequest_clone_ptr(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * Creates a copy of the VerifiedInvoiceRequest
+        */
+       public VerifiedInvoiceRequest clone() {
+               long ret = bindings.VerifiedInvoiceRequest_clone(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.VerifiedInvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.VerifiedInvoiceRequest(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
+        * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
+        * for the selected chain.
+        */
+       public byte[][] chains() {
+               byte[][] ret = bindings.VerifiedInvoiceRequest_chains(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * Opaque bytes set by the originator. Useful for authentication and validating fields since it
+        * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
+        */
+       public Option_CVec_u8ZZ metadata() {
+               long ret = bindings.VerifiedInvoiceRequest_metadata(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * The minimum amount required for a successful payment of a single item.
+        * 
+        * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       @Nullable
+       public Amount amount() {
+               long ret = bindings.VerifiedInvoiceRequest_amount(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * A complete description of the purpose of the payment. Intended to be displayed to the user
+        * but with the caveat that it has not been verified in any way.
+        */
+       public PrintableString description() {
+               long ret = bindings.VerifiedInvoiceRequest_description(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Features pertaining to the offer.
+        */
+       public OfferFeatures offer_features() {
+               long ret = bindings.VerifiedInvoiceRequest_offer_features(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Duration since the Unix epoch when an invoice should no longer be requested.
+        * 
+        * If `None`, the offer does not expire.
+        */
+       public Option_u64Z absolute_expiry() {
+               long ret = bindings.VerifiedInvoiceRequest_absolute_expiry(this.ptr);
+               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);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
+        * displayed to the user but with the caveat that it has not been verified in any way.
+        * 
+        * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       @Nullable
+       public PrintableString issuer() {
+               long ret = bindings.VerifiedInvoiceRequest_issuer(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
+        * recipient privacy by obfuscating its node id.
+        */
+       public BlindedPath[] paths() {
+               long[] ret = bindings.VerifiedInvoiceRequest_paths(this.ptr);
+               Reference.reachabilityFence(this);
+               int ret_conv_13_len = ret.length;
+               BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
+               for (int n = 0; n < ret_conv_13_len; n++) {
+                       long ret_conv_13 = ret[n];
+                       org.ldk.structs.BlindedPath ret_conv_13_hu_conv = null; if (ret_conv_13 < 0 || ret_conv_13 > 4096) { ret_conv_13_hu_conv = new org.ldk.structs.BlindedPath(null, ret_conv_13); }
+                       if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
+                       ret_conv_13_arr[n] = ret_conv_13_hu_conv;
+               }
+               return ret_conv_13_arr;
+       }
+
+       /**
+        * The quantity of items supported.
+        */
+       public Quantity supported_quantity() {
+               long ret = bindings.VerifiedInvoiceRequest_supported_quantity(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * The public key used by the recipient to sign invoices.
+        */
+       public byte[] signing_pubkey() {
+               byte[] ret = bindings.VerifiedInvoiceRequest_signing_pubkey(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * An unpredictable series of bytes, typically containing information about the derivation of
+        * [`payer_id`].
+        * 
+        * [`payer_id`]: Self::payer_id
+        */
+       public byte[] payer_metadata() {
+               byte[] ret = bindings.VerifiedInvoiceRequest_payer_metadata(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * A chain from [`Offer::chains`] that the offer is valid for.
+        */
+       public byte[] chain() {
+               byte[] ret = bindings.VerifiedInvoiceRequest_chain(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
+        * must be greater than or equal to [`Offer::amount`], converted if necessary.
+        * 
+        * [`chain`]: Self::chain
+        */
+       public Option_u64Z amount_msats() {
+               long ret = bindings.VerifiedInvoiceRequest_amount_msats(this.ptr);
+               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);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Features pertaining to requesting an invoice.
+        */
+       public InvoiceRequestFeatures invoice_request_features() {
+               long ret = bindings.VerifiedInvoiceRequest_invoice_request_features(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
+        */
+       public Option_u64Z quantity() {
+               long ret = bindings.VerifiedInvoiceRequest_quantity(this.ptr);
+               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);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * A possibly transient pubkey used to sign the invoice request.
+        */
+       public byte[] payer_id() {
+               byte[] ret = bindings.VerifiedInvoiceRequest_payer_id(this.ptr);
+               Reference.reachabilityFence(this);
+               return ret;
+       }
+
+       /**
+        * A payer-provided note which will be seen by the recipient and reflected back in the invoice
+        * response.
+        * 
+        * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+        */
+       @Nullable
+       public PrintableString payer_note() {
+               long ret = bindings.VerifiedInvoiceRequest_payer_note(this.ptr);
+               Reference.reachabilityFence(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+               return ret_hu_conv;
+       }
+
+}