1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
14 * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
15 * specifies these such that its recipient can send an invoice for payment.
17 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
18 * [`Offer`]: crate::offers::offer::Offer
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class InvoiceRequest extends CommonBase {
22 InvoiceRequest(Object _dummy, long ptr) { super(ptr); }
23 @Override @SuppressWarnings("deprecation")
24 protected void finalize() throws Throwable {
26 if (ptr != 0) { bindings.InvoiceRequest_free(ptr); }
30 long ret = bindings.InvoiceRequest_clone_ptr(this.ptr);
31 Reference.reachabilityFence(this);
36 * Creates a copy of the InvoiceRequest
38 public InvoiceRequest clone() {
39 long ret = bindings.InvoiceRequest_clone(this.ptr);
40 Reference.reachabilityFence(this);
41 if (ret >= 0 && ret <= 4096) { return null; }
42 org.ldk.structs.InvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequest(null, ret); }
43 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
48 * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
49 * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
50 * for the selected chain.
52 public byte[][] chains() {
53 byte[][] ret = bindings.InvoiceRequest_chains(this.ptr);
54 Reference.reachabilityFence(this);
59 * Opaque bytes set by the originator. Useful for authentication and validating fields since it
60 * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
62 public Option_CVec_u8ZZ metadata() {
63 long ret = bindings.InvoiceRequest_metadata(this.ptr);
64 Reference.reachabilityFence(this);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
67 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
72 * The minimum amount required for a successful payment of a single item.
74 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
77 public Amount amount() {
78 long ret = bindings.InvoiceRequest_amount(this.ptr);
79 Reference.reachabilityFence(this);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
82 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
87 * A complete description of the purpose of the payment. Intended to be displayed to the user
88 * but with the caveat that it has not been verified in any way.
90 public PrintableString description() {
91 long ret = bindings.InvoiceRequest_description(this.ptr);
92 Reference.reachabilityFence(this);
93 if (ret >= 0 && ret <= 4096) { return null; }
94 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
95 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
100 * Features pertaining to the offer.
102 public OfferFeatures offer_features() {
103 long ret = bindings.InvoiceRequest_offer_features(this.ptr);
104 Reference.reachabilityFence(this);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
112 * Duration since the Unix epoch when an invoice should no longer be requested.
114 * If `None`, the offer does not expire.
116 public Option_u64Z absolute_expiry() {
117 long ret = bindings.InvoiceRequest_absolute_expiry(this.ptr);
118 Reference.reachabilityFence(this);
119 if (ret >= 0 && ret <= 4096) { return null; }
120 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
121 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
126 * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
127 * displayed to the user but with the caveat that it has not been verified in any way.
129 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
132 public PrintableString issuer() {
133 long ret = bindings.InvoiceRequest_issuer(this.ptr);
134 Reference.reachabilityFence(this);
135 if (ret >= 0 && ret <= 4096) { return null; }
136 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
137 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
142 * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
143 * recipient privacy by obfuscating its node id.
145 public BlindedPath[] paths() {
146 long[] ret = bindings.InvoiceRequest_paths(this.ptr);
147 Reference.reachabilityFence(this);
148 int ret_conv_13_len = ret.length;
149 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
150 for (int n = 0; n < ret_conv_13_len; n++) {
151 long ret_conv_13 = ret[n];
152 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); }
153 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
154 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
156 return ret_conv_13_arr;
160 * The quantity of items supported.
162 public Quantity supported_quantity() {
163 long ret = bindings.InvoiceRequest_supported_quantity(this.ptr);
164 Reference.reachabilityFence(this);
165 if (ret >= 0 && ret <= 4096) { return null; }
166 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
167 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
172 * The public key used by the recipient to sign invoices.
174 public byte[] signing_pubkey() {
175 byte[] ret = bindings.InvoiceRequest_signing_pubkey(this.ptr);
176 Reference.reachabilityFence(this);
181 * An unpredictable series of bytes, typically containing information about the derivation of
184 * [`payer_id`]: Self::payer_id
186 public byte[] payer_metadata() {
187 byte[] ret = bindings.InvoiceRequest_payer_metadata(this.ptr);
188 Reference.reachabilityFence(this);
193 * A chain from [`Offer::chains`] that the offer is valid for.
195 public byte[] chain() {
196 byte[] ret = bindings.InvoiceRequest_chain(this.ptr);
197 Reference.reachabilityFence(this);
202 * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
203 * must be greater than or equal to [`Offer::amount`], converted if necessary.
205 * [`chain`]: Self::chain
207 public Option_u64Z amount_msats() {
208 long ret = bindings.InvoiceRequest_amount_msats(this.ptr);
209 Reference.reachabilityFence(this);
210 if (ret >= 0 && ret <= 4096) { return null; }
211 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
217 * Features pertaining to requesting an invoice.
219 public InvoiceRequestFeatures invoice_request_features() {
220 long ret = bindings.InvoiceRequest_invoice_request_features(this.ptr);
221 Reference.reachabilityFence(this);
222 if (ret >= 0 && ret <= 4096) { return null; }
223 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
224 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
229 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
231 public Option_u64Z quantity() {
232 long ret = bindings.InvoiceRequest_quantity(this.ptr);
233 Reference.reachabilityFence(this);
234 if (ret >= 0 && ret <= 4096) { return null; }
235 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
236 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
241 * A possibly transient pubkey used to sign the invoice request.
243 public byte[] payer_id() {
244 byte[] ret = bindings.InvoiceRequest_payer_id(this.ptr);
245 Reference.reachabilityFence(this);
250 * A payer-provided note which will be seen by the recipient and reflected back in the invoice
253 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
256 public PrintableString payer_note() {
257 long ret = bindings.InvoiceRequest_payer_note(this.ptr);
258 Reference.reachabilityFence(this);
259 if (ret >= 0 && ret <= 4096) { return null; }
260 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
261 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
266 * Signature of the invoice request using [`payer_id`].
268 * [`payer_id`]: Self::payer_id
270 public byte[] signature() {
271 byte[] ret = bindings.InvoiceRequest_signature(this.ptr);
272 Reference.reachabilityFence(this);
277 * Verifies that the request was for an offer created using the given key. Returns the verified
278 * request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
279 * if they could be extracted from the metadata.
281 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
283 public Result_VerifiedInvoiceRequestNoneZ verify(org.ldk.structs.ExpandedKey key) {
284 long ret = bindings.InvoiceRequest_verify(this.ptr, key == null ? 0 : key.ptr);
285 Reference.reachabilityFence(this);
286 Reference.reachabilityFence(key);
287 if (ret >= 0 && ret <= 4096) { return null; }
288 Result_VerifiedInvoiceRequestNoneZ ret_hu_conv = Result_VerifiedInvoiceRequestNoneZ.constr_from_ptr(ret);
289 if (this != null) { this.ptrs_to.add(key); };
290 if (this != null) { this.ptrs_to.add(this); };
295 * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
297 public byte[] write() {
298 byte[] ret = bindings.InvoiceRequest_write(this.ptr);
299 Reference.reachabilityFence(this);