--- /dev/null
+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 `Offer` is a potentially long-lived proposal for payment of a good or service.
+ *
+ * An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a
+ * customer may request an [`Invoice`] for a specific quantity and using an amount sufficient to
+ * cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`].
+ *
+ * Offers may be denominated in currency other than bitcoin but are ultimately paid using the
+ * latter.
+ *
+ * Through the use of [`BlindedPath`]s, offers provide recipient privacy.
+ *
+ * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+ * [`Invoice`]: crate::offers::invoice::Invoice
+ */
+@SuppressWarnings("unchecked") // We correctly assign various generic arrays
+public class Offer extends CommonBase {
+ Offer(Object _dummy, long ptr) { super(ptr); }
+ @Override @SuppressWarnings("deprecation")
+ protected void finalize() throws Throwable {
+ super.finalize();
+ if (ptr != 0) { bindings.Offer_free(ptr); }
+ }
+
+ long clone_ptr() {
+ long ret = bindings.Offer_clone_ptr(this.ptr);
+ Reference.reachabilityFence(this);
+ return ret;
+ }
+
+ /**
+ * Creates a copy of the Offer
+ */
+ public Offer clone() {
+ long ret = bindings.Offer_clone(this.ptr);
+ Reference.reachabilityFence(this);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.Offer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Offer(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.Offer_chains(this.ptr);
+ Reference.reachabilityFence(this);
+ return ret;
+ }
+
+ /**
+ * Returns whether the given chain is supported by the offer.
+ */
+ public boolean supports_chain(byte[] chain) {
+ boolean ret = bindings.Offer_supports_chain(this.ptr, InternalUtils.check_arr_len(chain, 32));
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(chain);
+ 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.Offer_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.Offer_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.Offer_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 features() {
+ long ret = bindings.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_DurationZ absolute_expiry() {
+ long ret = bindings.Offer_absolute_expiry(this.ptr);
+ Reference.reachabilityFence(this);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.Option_DurationZ ret_hu_conv = org.ldk.structs.Option_DurationZ.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Whether the offer has expired.
+ */
+ public boolean is_expired() {
+ boolean ret = bindings.Offer_is_expired(this.ptr);
+ Reference.reachabilityFence(this);
+ return ret;
+ }
+
+ /**
+ * 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.Offer_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.Offer_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.Offer_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;
+ }
+
+ /**
+ * Returns whether the given quantity is valid for the offer.
+ */
+ public boolean is_valid_quantity(long quantity) {
+ boolean ret = bindings.Offer_is_valid_quantity(this.ptr, quantity);
+ Reference.reachabilityFence(this);
+ Reference.reachabilityFence(quantity);
+ return ret;
+ }
+
+ /**
+ * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer.
+ *
+ * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+ */
+ public boolean expects_quantity() {
+ boolean ret = bindings.Offer_expects_quantity(this.ptr);
+ Reference.reachabilityFence(this);
+ return ret;
+ }
+
+ /**
+ * The public key used by the recipient to sign invoices.
+ */
+ public byte[] signing_pubkey() {
+ byte[] ret = bindings.Offer_signing_pubkey(this.ptr);
+ Reference.reachabilityFence(this);
+ return ret;
+ }
+
+ /**
+ * Serialize the Offer object into a byte array which can be read by Offer_read
+ */
+ public byte[] write() {
+ byte[] ret = bindings.Offer_write(this.ptr);
+ Reference.reachabilityFence(this);
+ return ret;
+ }
+
+}