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 * A semantically valid [`InvoiceRequest`] that hasn't been signed.
16 * This is serialized as a TLV stream, which includes TLV records from the originating message. As
17 * such, it may include unknown, odd TLV records.
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class UnsignedInvoiceRequest extends CommonBase {
21 UnsignedInvoiceRequest(Object _dummy, long ptr) { super(ptr); }
22 @Override @SuppressWarnings("deprecation")
23 protected void finalize() throws Throwable {
25 if (ptr != 0) { bindings.UnsignedInvoiceRequest_free(ptr); }
29 long ret = bindings.UnsignedInvoiceRequest_clone_ptr(this.ptr);
30 Reference.reachabilityFence(this);
35 * Creates a copy of the UnsignedInvoiceRequest
37 public UnsignedInvoiceRequest clone() {
38 long ret = bindings.UnsignedInvoiceRequest_clone(this.ptr);
39 Reference.reachabilityFence(this);
40 if (ret >= 0 && ret <= 4096) { return null; }
41 org.ldk.structs.UnsignedInvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedInvoiceRequest(null, ret); }
42 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
47 * Returns the [`TaggedHash`] of the invoice to sign.
49 public TaggedHash tagged_hash() {
50 long ret = bindings.UnsignedInvoiceRequest_tagged_hash(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.TaggedHash ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TaggedHash(null, ret); }
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
59 * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
60 * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
61 * for the selected chain.
63 public byte[][] chains() {
64 byte[][] ret = bindings.UnsignedInvoiceRequest_chains(this.ptr);
65 Reference.reachabilityFence(this);
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.UnsignedInvoiceRequest_metadata(this.ptr);
75 Reference.reachabilityFence(this);
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.add(this); };
83 * The minimum amount required for a successful payment of a single item.
85 public Option_AmountZ amount() {
86 long ret = bindings.UnsignedInvoiceRequest_amount(this.ptr);
87 Reference.reachabilityFence(this);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
95 * A complete description of the purpose of the payment. Intended to be displayed to the user
96 * but with the caveat that it has not been verified in any way.
98 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
101 public PrintableString description() {
102 long ret = bindings.UnsignedInvoiceRequest_description(this.ptr);
103 Reference.reachabilityFence(this);
104 if (ret >= 0 && ret <= 4096) { return null; }
105 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
111 * Features pertaining to the offer.
113 public OfferFeatures offer_features() {
114 long ret = bindings.UnsignedInvoiceRequest_offer_features(this.ptr);
115 Reference.reachabilityFence(this);
116 if (ret >= 0 && ret <= 4096) { return null; }
117 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
118 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
123 * Duration since the Unix epoch when an invoice should no longer be requested.
125 * If `None`, the offer does not expire.
127 public Option_u64Z absolute_expiry() {
128 long ret = bindings.UnsignedInvoiceRequest_absolute_expiry(this.ptr);
129 Reference.reachabilityFence(this);
130 if (ret >= 0 && ret <= 4096) { return null; }
131 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
132 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
137 * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
138 * displayed to the user but with the caveat that it has not been verified in any way.
140 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
143 public PrintableString issuer() {
144 long ret = bindings.UnsignedInvoiceRequest_issuer(this.ptr);
145 Reference.reachabilityFence(this);
146 if (ret >= 0 && ret <= 4096) { return null; }
147 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
148 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
153 * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
154 * recipient privacy by obfuscating its node id.
156 public BlindedPath[] paths() {
157 long[] ret = bindings.UnsignedInvoiceRequest_paths(this.ptr);
158 Reference.reachabilityFence(this);
159 int ret_conv_13_len = ret.length;
160 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
161 for (int n = 0; n < ret_conv_13_len; n++) {
162 long ret_conv_13 = ret[n];
163 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); }
164 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
165 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
167 return ret_conv_13_arr;
171 * The quantity of items supported.
173 public Quantity supported_quantity() {
174 long ret = bindings.UnsignedInvoiceRequest_supported_quantity(this.ptr);
175 Reference.reachabilityFence(this);
176 if (ret >= 0 && ret <= 4096) { return null; }
177 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
178 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
183 * The public key used by the recipient to sign invoices.
185 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
188 public byte[] signing_pubkey() {
189 byte[] ret = bindings.UnsignedInvoiceRequest_signing_pubkey(this.ptr);
190 Reference.reachabilityFence(this);
195 * An unpredictable series of bytes, typically containing information about the derivation of
198 * [`payer_id`]: Self::payer_id
200 public byte[] payer_metadata() {
201 byte[] ret = bindings.UnsignedInvoiceRequest_payer_metadata(this.ptr);
202 Reference.reachabilityFence(this);
207 * A chain from [`Offer::chains`] that the offer is valid for.
209 public byte[] chain() {
210 byte[] ret = bindings.UnsignedInvoiceRequest_chain(this.ptr);
211 Reference.reachabilityFence(this);
216 * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
217 * must be greater than or equal to [`Offer::amount`], converted if necessary.
219 * [`chain`]: Self::chain
221 public Option_u64Z amount_msats() {
222 long ret = bindings.UnsignedInvoiceRequest_amount_msats(this.ptr);
223 Reference.reachabilityFence(this);
224 if (ret >= 0 && ret <= 4096) { return null; }
225 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
226 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
231 * Features pertaining to requesting an invoice.
233 public InvoiceRequestFeatures invoice_request_features() {
234 long ret = bindings.UnsignedInvoiceRequest_invoice_request_features(this.ptr);
235 Reference.reachabilityFence(this);
236 if (ret >= 0 && ret <= 4096) { return null; }
237 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
238 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
243 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
245 public Option_u64Z quantity() {
246 long ret = bindings.UnsignedInvoiceRequest_quantity(this.ptr);
247 Reference.reachabilityFence(this);
248 if (ret >= 0 && ret <= 4096) { return null; }
249 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
250 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
255 * A possibly transient pubkey used to sign the invoice request.
257 public byte[] payer_id() {
258 byte[] ret = bindings.UnsignedInvoiceRequest_payer_id(this.ptr);
259 Reference.reachabilityFence(this);
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
270 public PrintableString payer_note() {
271 long ret = bindings.UnsignedInvoiceRequest_payer_note(this.ptr);
272 Reference.reachabilityFence(this);
273 if (ret >= 0 && ret <= 4096) { return null; }
274 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
275 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
280 * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
282 public byte[] write() {
283 byte[] ret = bindings.UnsignedInvoiceRequest_write(this.ptr);
284 Reference.reachabilityFence(this);