6 namespace org { namespace ldk { namespace structs {
10 * An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
12 * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
13 * specifies these such that its recipient can send an invoice for payment.
15 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
16 * [`Offer`]: crate::offers::offer::Offer
18 public class InvoiceRequest : CommonBase {
19 internal InvoiceRequest(object _dummy, long ptr) : base(ptr) { }
21 if (ptr != 0) { bindings.InvoiceRequest_free(ptr); }
24 internal long clone_ptr() {
25 long ret = bindings.InvoiceRequest_clone_ptr(this.ptr);
31 * Creates a copy of the InvoiceRequest
33 public InvoiceRequest clone() {
34 long ret = bindings.InvoiceRequest_clone(this.ptr);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 org.ldk.structs.InvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequest(null, ret); }
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
43 * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
44 * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
45 * for the selected chain.
47 public byte[][] chains() {
48 long ret = bindings.InvoiceRequest_chains(this.ptr);
50 if (ret >= 0 && ret <= 4096) { return null; }
51 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
52 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
53 for (int i = 0; i < ret_conv_8_len; i++) {
54 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
55 byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
56 ret_conv_8_arr[i] = ret_conv_8_conv;
58 bindings.free_buffer(ret);
59 return ret_conv_8_arr;
63 * Opaque bytes set by the originator. Useful for authentication and validating fields since it
64 * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
66 public Option_CVec_u8ZZ metadata() {
67 long ret = bindings.InvoiceRequest_metadata(this.ptr);
69 if (ret >= 0 && ret <= 4096) { return null; }
70 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
71 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
76 * The minimum amount required for a successful payment of a single item.
78 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
80 public Amount amount() {
81 long ret = bindings.InvoiceRequest_amount(this.ptr);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
90 * A complete description of the purpose of the payment. Intended to be displayed to the user
91 * but with the caveat that it has not been verified in any way.
93 public PrintableString description() {
94 long ret = bindings.InvoiceRequest_description(this.ptr);
96 if (ret >= 0 && ret <= 4096) { return null; }
97 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
98 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
103 * Features pertaining to the offer.
105 public OfferFeatures offer_features() {
106 long ret = bindings.InvoiceRequest_offer_features(this.ptr);
108 if (ret >= 0 && ret <= 4096) { return null; }
109 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
115 * Duration since the Unix epoch when an invoice should no longer be requested.
117 * If `None`, the offer does not expire.
119 public Option_u64Z absolute_expiry() {
120 long ret = bindings.InvoiceRequest_absolute_expiry(this.ptr);
122 if (ret >= 0 && ret <= 4096) { return null; }
123 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
124 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
129 * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
130 * displayed to the user but with the caveat that it has not been verified in any way.
132 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
134 public PrintableString issuer() {
135 long ret = bindings.InvoiceRequest_issuer(this.ptr);
137 if (ret >= 0 && ret <= 4096) { return null; }
138 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
139 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
144 * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
145 * recipient privacy by obfuscating its node id.
147 public BlindedPath[] paths() {
148 long ret = bindings.InvoiceRequest_paths(this.ptr);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 int ret_conv_13_len = InternalUtils.getArrayLength(ret);
152 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
153 for (int n = 0; n < ret_conv_13_len; n++) {
154 long ret_conv_13 = InternalUtils.getU64ArrayElem(ret, n);
155 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); }
156 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
157 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
159 bindings.free_buffer(ret);
160 return ret_conv_13_arr;
164 * The quantity of items supported.
166 public Quantity supported_quantity() {
167 long ret = bindings.InvoiceRequest_supported_quantity(this.ptr);
169 if (ret >= 0 && ret <= 4096) { return null; }
170 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
171 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
176 * The public key used by the recipient to sign invoices.
178 public byte[] signing_pubkey() {
179 long ret = bindings.InvoiceRequest_signing_pubkey(this.ptr);
181 if (ret >= 0 && ret <= 4096) { return null; }
182 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
187 * An unpredictable series of bytes, typically containing information about the derivation of
190 * [`payer_id`]: Self::payer_id
192 public byte[] payer_metadata() {
193 long ret = bindings.InvoiceRequest_payer_metadata(this.ptr);
195 if (ret >= 0 && ret <= 4096) { return null; }
196 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
201 * A chain from [`Offer::chains`] that the offer is valid for.
203 public byte[] chain() {
204 long ret = bindings.InvoiceRequest_chain(this.ptr);
206 if (ret >= 0 && ret <= 4096) { return null; }
207 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
212 * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
213 * must be greater than or equal to [`Offer::amount`], converted if necessary.
215 * [`chain`]: Self::chain
217 public Option_u64Z amount_msats() {
218 long ret = bindings.InvoiceRequest_amount_msats(this.ptr);
220 if (ret >= 0 && ret <= 4096) { return null; }
221 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
222 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
227 * Features pertaining to requesting an invoice.
229 public InvoiceRequestFeatures invoice_request_features() {
230 long ret = bindings.InvoiceRequest_invoice_request_features(this.ptr);
232 if (ret >= 0 && ret <= 4096) { return null; }
233 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
234 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
239 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
241 public Option_u64Z quantity() {
242 long ret = bindings.InvoiceRequest_quantity(this.ptr);
244 if (ret >= 0 && ret <= 4096) { return null; }
245 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
246 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
251 * A possibly transient pubkey used to sign the invoice request.
253 public byte[] payer_id() {
254 long ret = bindings.InvoiceRequest_payer_id(this.ptr);
256 if (ret >= 0 && ret <= 4096) { return null; }
257 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
262 * A payer-provided note which will be seen by the recipient and reflected back in the invoice
265 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
267 public PrintableString payer_note() {
268 long ret = bindings.InvoiceRequest_payer_note(this.ptr);
270 if (ret >= 0 && ret <= 4096) { return null; }
271 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
272 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
277 * Signature of the invoice request using [`payer_id`].
279 * [`payer_id`]: Self::payer_id
281 public byte[] signature() {
282 long ret = bindings.InvoiceRequest_signature(this.ptr);
284 if (ret >= 0 && ret <= 4096) { return null; }
285 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
290 * Verifies that the request was for an offer created using the given key. Returns the verified
291 * request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
292 * if they could be extracted from the metadata.
294 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
296 public Result_VerifiedInvoiceRequestNoneZ verify(org.ldk.structs.ExpandedKey key) {
297 long ret = bindings.InvoiceRequest_verify(this.ptr, key == null ? 0 : key.ptr);
300 if (ret >= 0 && ret <= 4096) { return null; }
301 Result_VerifiedInvoiceRequestNoneZ ret_hu_conv = Result_VerifiedInvoiceRequestNoneZ.constr_from_ptr(ret);
302 if (this != null) { this.ptrs_to.AddLast(key); };
303 if (this != null) { this.ptrs_to.AddLast(this); };
308 * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
310 public byte[] write() {
311 long ret = bindings.InvoiceRequest_write(this.ptr);
313 if (ret >= 0 && ret <= 4096) { return null; }
314 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);