6 namespace org { namespace ldk { namespace structs {
10 * An `Offer` is a potentially long-lived proposal for payment of a good or service.
12 * An offer is a precursor to an [`InvoiceRequest`]. A merchant publishes an offer from which a
13 * customer may request an [`Bolt12Invoice`] for a specific quantity and using an amount sufficient
14 * to cover that quantity (i.e., at least `quantity * amount`). See [`Offer::amount`].
16 * Offers may be denominated in currency other than bitcoin but are ultimately paid using the
19 * Through the use of [`BlindedPath`]s, offers provide recipient privacy.
21 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
22 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
24 public class Offer : CommonBase {
25 internal Offer(object _dummy, long ptr) : base(ptr) { }
27 if (ptr != 0) { bindings.Offer_free(ptr); }
30 internal long clone_ptr() {
31 long ret = bindings.Offer_clone_ptr(this.ptr);
37 * Creates a copy of the Offer
39 public Offer clone() {
40 long ret = bindings.Offer_clone(this.ptr);
42 if (ret >= 0 && ret <= 4096) { return null; }
43 org.ldk.structs.Offer ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Offer(null, ret); }
44 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
49 * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
50 * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
51 * for the selected chain.
53 public byte[][] chains() {
54 long ret = bindings.Offer_chains(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
58 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
59 for (int i = 0; i < ret_conv_8_len; i++) {
60 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
61 byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
62 ret_conv_8_arr[i] = ret_conv_8_conv;
64 bindings.free_buffer(ret);
65 return ret_conv_8_arr;
69 * Opaque bytes set by the originator. Useful for authentication and validating fields since it
70 * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
72 public Option_CVec_u8ZZ metadata() {
73 long ret = bindings.Offer_metadata(this.ptr);
75 if (ret >= 0 && ret <= 4096) { return null; }
76 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
77 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
82 * The minimum amount required for a successful payment of a single item.
84 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
86 public Amount amount() {
87 long ret = bindings.Offer_amount(this.ptr);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
96 * A complete description of the purpose of the payment. Intended to be displayed to the user
97 * but with the caveat that it has not been verified in any way.
99 public PrintableString description() {
100 long ret = bindings.Offer_description(this.ptr);
102 if (ret >= 0 && ret <= 4096) { return null; }
103 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109 * Features pertaining to the offer.
111 public OfferFeatures offer_features() {
112 long ret = bindings.Offer_offer_features(this.ptr);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
121 * Duration since the Unix epoch when an invoice should no longer be requested.
123 * If `None`, the offer does not expire.
125 public Option_u64Z absolute_expiry() {
126 long ret = bindings.Offer_absolute_expiry(this.ptr);
128 if (ret >= 0 && ret <= 4096) { return null; }
129 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
130 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
135 * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
136 * displayed to the user but with the caveat that it has not been verified in any way.
138 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
140 public PrintableString issuer() {
141 long ret = bindings.Offer_issuer(this.ptr);
143 if (ret >= 0 && ret <= 4096) { return null; }
144 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
145 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
150 * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
151 * recipient privacy by obfuscating its node id.
153 public BlindedPath[] paths() {
154 long ret = bindings.Offer_paths(this.ptr);
156 if (ret >= 0 && ret <= 4096) { return null; }
157 int ret_conv_13_len = InternalUtils.getArrayLength(ret);
158 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
159 for (int n = 0; n < ret_conv_13_len; n++) {
160 long ret_conv_13 = InternalUtils.getU64ArrayElem(ret, n);
161 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); }
162 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
163 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
165 bindings.free_buffer(ret);
166 return ret_conv_13_arr;
170 * The quantity of items supported.
172 public Quantity supported_quantity() {
173 long ret = bindings.Offer_supported_quantity(this.ptr);
175 if (ret >= 0 && ret <= 4096) { return null; }
176 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
177 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
182 * The public key used by the recipient to sign invoices.
184 public byte[] signing_pubkey() {
185 long ret = bindings.Offer_signing_pubkey(this.ptr);
187 if (ret >= 0 && ret <= 4096) { return null; }
188 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
193 * Returns whether the given chain is supported by the offer.
195 public bool supports_chain(byte[] chain) {
196 bool ret = bindings.Offer_supports_chain(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(chain, 32)));
203 * Whether the offer has expired.
205 public bool is_expired() {
206 bool ret = bindings.Offer_is_expired(this.ptr);
212 * Returns whether the given quantity is valid for the offer.
214 public bool is_valid_quantity(long quantity) {
215 bool ret = bindings.Offer_is_valid_quantity(this.ptr, quantity);
217 GC.KeepAlive(quantity);
222 * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer.
224 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
226 public bool expects_quantity() {
227 bool ret = bindings.Offer_expects_quantity(this.ptr);
233 * Serialize the Offer object into a byte array which can be read by Offer_read
235 public byte[] write() {
236 long ret = bindings.Offer_write(this.ptr);
238 if (ret >= 0 && ret <= 4096) { return null; }
239 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
244 * Read a Offer object from a string
246 public static Result_OfferBolt12ParseErrorZ from_str(string s) {
247 long ret = bindings.Offer_from_str(InternalUtils.encodeString(s));
249 if (ret >= 0 && ret <= 4096) { return null; }
250 Result_OfferBolt12ParseErrorZ ret_hu_conv = Result_OfferBolt12ParseErrorZ.constr_from_ptr(ret);