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 byte[][] ret = bindings.Offer_chains(this.ptr);
60 * Returns whether the given chain is supported by the offer.
62 public bool supports_chain(byte[] chain) {
63 bool ret = bindings.Offer_supports_chain(this.ptr, InternalUtils.check_arr_len(chain, 32));
70 * Opaque bytes set by the originator. Useful for authentication and validating fields since it
71 * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
73 public Option_CVec_u8ZZ metadata() {
74 long ret = bindings.Offer_metadata(this.ptr);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
78 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
83 * The minimum amount required for a successful payment of a single item.
85 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
87 public Amount amount() {
88 long ret = bindings.Offer_amount(this.ptr);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
92 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
97 * A complete description of the purpose of the payment. Intended to be displayed to the user
98 * but with the caveat that it has not been verified in any way.
100 public PrintableString description() {
101 long ret = bindings.Offer_description(this.ptr);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
110 * Features pertaining to the offer.
112 public OfferFeatures features() {
113 long ret = bindings.Offer_features(this.ptr);
115 if (ret >= 0 && ret <= 4096) { return null; }
116 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
117 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
122 * Duration since the Unix epoch when an invoice should no longer be requested.
124 * If `None`, the offer does not expire.
126 public Option_DurationZ absolute_expiry() {
127 long ret = bindings.Offer_absolute_expiry(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.Option_DurationZ ret_hu_conv = org.ldk.structs.Option_DurationZ.constr_from_ptr(ret);
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
136 * Whether the offer has expired.
138 public bool is_expired() {
139 bool ret = bindings.Offer_is_expired(this.ptr);
145 * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
146 * displayed to the user but with the caveat that it has not been verified in any way.
148 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
150 public PrintableString issuer() {
151 long ret = bindings.Offer_issuer(this.ptr);
153 if (ret >= 0 && ret <= 4096) { return null; }
154 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
155 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
160 * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
161 * recipient privacy by obfuscating its node id.
163 public BlindedPath[] paths() {
164 long[] ret = bindings.Offer_paths(this.ptr);
166 int ret_conv_13_len = ret.Length;
167 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
168 for (int n = 0; n < ret_conv_13_len; n++) {
169 long ret_conv_13 = ret[n];
170 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); }
171 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
172 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
174 return ret_conv_13_arr;
178 * The quantity of items supported.
180 public Quantity supported_quantity() {
181 long ret = bindings.Offer_supported_quantity(this.ptr);
183 if (ret >= 0 && ret <= 4096) { return null; }
184 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
185 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
190 * Returns whether the given quantity is valid for the offer.
192 public bool is_valid_quantity(long quantity) {
193 bool ret = bindings.Offer_is_valid_quantity(this.ptr, quantity);
195 GC.KeepAlive(quantity);
200 * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer.
202 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
204 public bool expects_quantity() {
205 bool ret = bindings.Offer_expects_quantity(this.ptr);
211 * The public key used by the recipient to sign invoices.
213 public byte[] signing_pubkey() {
214 byte[] ret = bindings.Offer_signing_pubkey(this.ptr);
220 * Serialize the Offer object into a byte array which can be read by Offer_read
222 public byte[] write() {
223 byte[] ret = bindings.Offer_write(this.ptr);
229 * Read a Offer object from a string
231 public static Result_OfferBolt12ParseErrorZ from_str(string s) {
232 long ret = bindings.Offer_from_str(s);
234 if (ret >= 0 && ret <= 4096) { return null; }
235 Result_OfferBolt12ParseErrorZ ret_hu_conv = Result_OfferBolt12ParseErrorZ.constr_from_ptr(ret);