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 public Option_AmountZ amount() {
79 long ret = bindings.InvoiceRequest_amount(this.ptr);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
83 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
88 * A complete description of the purpose of the payment. Intended to be displayed to the user
89 * but with the caveat that it has not been verified in any way.
91 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 = org.ldk.structs.Quantity.constr_from_ptr(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 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
180 public byte[] signing_pubkey() {
181 long ret = bindings.InvoiceRequest_signing_pubkey(this.ptr);
183 if (ret >= 0 && ret <= 4096) { return null; }
184 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
189 * An unpredictable series of bytes, typically containing information about the derivation of
192 * [`payer_id`]: Self::payer_id
194 public byte[] payer_metadata() {
195 long ret = bindings.InvoiceRequest_payer_metadata(this.ptr);
197 if (ret >= 0 && ret <= 4096) { return null; }
198 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
203 * A chain from [`Offer::chains`] that the offer is valid for.
205 public byte[] chain() {
206 long ret = bindings.InvoiceRequest_chain(this.ptr);
208 if (ret >= 0 && ret <= 4096) { return null; }
209 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
214 * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
215 * must be greater than or equal to [`Offer::amount`], converted if necessary.
217 * [`chain`]: Self::chain
219 public Option_u64Z amount_msats() {
220 long ret = bindings.InvoiceRequest_amount_msats(this.ptr);
222 if (ret >= 0 && ret <= 4096) { return null; }
223 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
224 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
229 * Features pertaining to requesting an invoice.
231 public InvoiceRequestFeatures invoice_request_features() {
232 long ret = bindings.InvoiceRequest_invoice_request_features(this.ptr);
234 if (ret >= 0 && ret <= 4096) { return null; }
235 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
236 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
241 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
243 public Option_u64Z quantity() {
244 long ret = bindings.InvoiceRequest_quantity(this.ptr);
246 if (ret >= 0 && ret <= 4096) { return null; }
247 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
248 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
253 * A possibly transient pubkey used to sign the invoice request.
255 public byte[] payer_id() {
256 long ret = bindings.InvoiceRequest_payer_id(this.ptr);
258 if (ret >= 0 && ret <= 4096) { return null; }
259 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
264 * A payer-provided note which will be seen by the recipient and reflected back in the invoice
267 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
269 public PrintableString payer_note() {
270 long ret = bindings.InvoiceRequest_payer_note(this.ptr);
272 if (ret >= 0 && ret <= 4096) { return null; }
273 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
274 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
279 * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
280 * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
282 * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
283 * creation time is used for the `created_at` parameter.
285 * [`Duration`]: core::time::Duration
287 public Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ respond_with(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash) {
288 long ret = bindings.InvoiceRequest_respond_with(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
290 GC.KeepAlive(payment_paths);
291 GC.KeepAlive(payment_hash);
292 if (ret >= 0 && ret <= 4096) { return null; }
293 Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
298 * Creates an [`InvoiceBuilder`] for the request with the given required fields.
300 * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
301 * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
302 * where [`std::time::SystemTime`] is not available.
304 * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
307 * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
308 * must contain one or more elements ordered from most-preferred to least-preferred, if there's
309 * a preference. Note, however, that any privacy is lost if a public node id was used for
310 * [`Offer::signing_pubkey`].
312 * Errors if the request contains unknown required features.
316 * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
317 * then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
319 * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
320 * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
322 public Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ respond_with_no_std(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash, long created_at) {
323 long ret = bindings.InvoiceRequest_respond_with_no_std(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), created_at);
325 GC.KeepAlive(payment_paths);
326 GC.KeepAlive(payment_hash);
327 GC.KeepAlive(created_at);
328 if (ret >= 0 && ret <= 4096) { return null; }
329 Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
334 * Verifies that the request was for an offer created using the given key. Returns the verified
335 * request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request
336 * if they could be extracted from the metadata.
338 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
340 public Result_VerifiedInvoiceRequestNoneZ verify(org.ldk.structs.ExpandedKey key) {
341 long ret = bindings.InvoiceRequest_verify(this.ptr, key.ptr);
344 if (ret >= 0 && ret <= 4096) { return null; }
345 Result_VerifiedInvoiceRequestNoneZ ret_hu_conv = Result_VerifiedInvoiceRequestNoneZ.constr_from_ptr(ret);
346 if (this != null) { this.ptrs_to.AddLast(key); };
347 if (this != null) { this.ptrs_to.AddLast(this); };
352 * Signature of the invoice request using [`payer_id`].
354 * [`payer_id`]: Self::payer_id
356 public byte[] signature() {
357 long ret = bindings.InvoiceRequest_signature(this.ptr);
359 if (ret >= 0 && ret <= 4096) { return null; }
360 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
365 * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
367 public byte[] write() {
368 long ret = bindings.InvoiceRequest_write(this.ptr);
370 if (ret >= 0 && ret <= 4096) { return null; }
371 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);