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 * An unpredictable series of bytes, typically containing information about the derivation of
51 * [`payer_id`]: Self::payer_id
53 public byte[] metadata() {
54 byte[] ret = bindings.InvoiceRequest_metadata(this.ptr);
55 Reference.reachabilityFence(this);
60 * A chain from [`Offer::chains`] that the offer is valid for.
62 public byte[] chain() {
63 byte[] ret = bindings.InvoiceRequest_chain(this.ptr);
64 Reference.reachabilityFence(this);
69 * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
70 * must be greater than or equal to [`Offer::amount`], converted if necessary.
72 * [`chain`]: Self::chain
74 public Option_u64Z amount_msats() {
75 long ret = bindings.InvoiceRequest_amount_msats(this.ptr);
76 Reference.reachabilityFence(this);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
84 * Features pertaining to requesting an invoice.
86 public InvoiceRequestFeatures features() {
87 long ret = bindings.InvoiceRequest_features(this.ptr);
88 Reference.reachabilityFence(this);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
98 public Option_u64Z quantity() {
99 long ret = bindings.InvoiceRequest_quantity(this.ptr);
100 Reference.reachabilityFence(this);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108 * A possibly transient pubkey used to sign the invoice request.
110 public byte[] payer_id() {
111 byte[] ret = bindings.InvoiceRequest_payer_id(this.ptr);
112 Reference.reachabilityFence(this);
117 * A payer-provided note which will be seen by the recipient and reflected back in the invoice
120 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
123 public PrintableString payer_note() {
124 long ret = bindings.InvoiceRequest_payer_note(this.ptr);
125 Reference.reachabilityFence(this);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
133 * Verifies that the request was for an offer created using the given key. Returns the derived
134 * keys need to sign an [`Bolt12Invoice`] for the request if they could be extracted from the
137 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
139 public Result_COption_KeyPairZNoneZ verify(org.ldk.structs.ExpandedKey key) {
140 long ret = bindings.InvoiceRequest_verify(this.ptr, key == null ? 0 : key.ptr);
141 Reference.reachabilityFence(this);
142 Reference.reachabilityFence(key);
143 if (ret >= 0 && ret <= 4096) { return null; }
144 Result_COption_KeyPairZNoneZ ret_hu_conv = Result_COption_KeyPairZNoneZ.constr_from_ptr(ret);
145 if (this != null) { this.ptrs_to.add(key); };
150 * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
152 public byte[] write() {
153 byte[] ret = bindings.InvoiceRequest_write(this.ptr);
154 Reference.reachabilityFence(this);