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 * Returns the [`TaggedHash`] of the invoice to sign.
31 public TaggedHash tagged_hash() {
32 long ret = bindings.UnsignedInvoiceRequest_tagged_hash(this.ptr);
33 Reference.reachabilityFence(this);
34 if (ret >= 0 && ret <= 4096) { return null; }
35 org.ldk.structs.TaggedHash ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TaggedHash(null, ret); }
36 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
41 * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
42 * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
43 * for the selected chain.
45 public byte[][] chains() {
46 byte[][] ret = bindings.UnsignedInvoiceRequest_chains(this.ptr);
47 Reference.reachabilityFence(this);
52 * Opaque bytes set by the originator. Useful for authentication and validating fields since it
53 * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
55 public Option_CVec_u8ZZ metadata() {
56 long ret = bindings.UnsignedInvoiceRequest_metadata(this.ptr);
57 Reference.reachabilityFence(this);
58 if (ret >= 0 && ret <= 4096) { return null; }
59 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
60 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
65 * The minimum amount required for a successful payment of a single item.
67 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
70 public Amount amount() {
71 long ret = bindings.UnsignedInvoiceRequest_amount(this.ptr);
72 Reference.reachabilityFence(this);
73 if (ret >= 0 && ret <= 4096) { return null; }
74 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
75 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
80 * A complete description of the purpose of the payment. Intended to be displayed to the user
81 * but with the caveat that it has not been verified in any way.
83 public PrintableString description() {
84 long ret = bindings.UnsignedInvoiceRequest_description(this.ptr);
85 Reference.reachabilityFence(this);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
88 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
93 * Features pertaining to the offer.
95 public OfferFeatures offer_features() {
96 long ret = bindings.UnsignedInvoiceRequest_offer_features(this.ptr);
97 Reference.reachabilityFence(this);
98 if (ret >= 0 && ret <= 4096) { return null; }
99 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
100 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
105 * Duration since the Unix epoch when an invoice should no longer be requested.
107 * If `None`, the offer does not expire.
109 public Option_u64Z absolute_expiry() {
110 long ret = bindings.UnsignedInvoiceRequest_absolute_expiry(this.ptr);
111 Reference.reachabilityFence(this);
112 if (ret >= 0 && ret <= 4096) { return null; }
113 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
114 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
119 * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
120 * displayed to the user but with the caveat that it has not been verified in any way.
122 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
125 public PrintableString issuer() {
126 long ret = bindings.UnsignedInvoiceRequest_issuer(this.ptr);
127 Reference.reachabilityFence(this);
128 if (ret >= 0 && ret <= 4096) { return null; }
129 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
130 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
135 * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
136 * recipient privacy by obfuscating its node id.
138 public BlindedPath[] paths() {
139 long[] ret = bindings.UnsignedInvoiceRequest_paths(this.ptr);
140 Reference.reachabilityFence(this);
141 int ret_conv_13_len = ret.length;
142 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
143 for (int n = 0; n < ret_conv_13_len; n++) {
144 long ret_conv_13 = ret[n];
145 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); }
146 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
147 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
149 return ret_conv_13_arr;
153 * The quantity of items supported.
155 public Quantity supported_quantity() {
156 long ret = bindings.UnsignedInvoiceRequest_supported_quantity(this.ptr);
157 Reference.reachabilityFence(this);
158 if (ret >= 0 && ret <= 4096) { return null; }
159 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
160 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
165 * The public key used by the recipient to sign invoices.
167 public byte[] signing_pubkey() {
168 byte[] ret = bindings.UnsignedInvoiceRequest_signing_pubkey(this.ptr);
169 Reference.reachabilityFence(this);
174 * An unpredictable series of bytes, typically containing information about the derivation of
177 * [`payer_id`]: Self::payer_id
179 public byte[] payer_metadata() {
180 byte[] ret = bindings.UnsignedInvoiceRequest_payer_metadata(this.ptr);
181 Reference.reachabilityFence(this);
186 * A chain from [`Offer::chains`] that the offer is valid for.
188 public byte[] chain() {
189 byte[] ret = bindings.UnsignedInvoiceRequest_chain(this.ptr);
190 Reference.reachabilityFence(this);
195 * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
196 * must be greater than or equal to [`Offer::amount`], converted if necessary.
198 * [`chain`]: Self::chain
200 public Option_u64Z amount_msats() {
201 long ret = bindings.UnsignedInvoiceRequest_amount_msats(this.ptr);
202 Reference.reachabilityFence(this);
203 if (ret >= 0 && ret <= 4096) { return null; }
204 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
205 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
210 * Features pertaining to requesting an invoice.
212 public InvoiceRequestFeatures invoice_request_features() {
213 long ret = bindings.UnsignedInvoiceRequest_invoice_request_features(this.ptr);
214 Reference.reachabilityFence(this);
215 if (ret >= 0 && ret <= 4096) { return null; }
216 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
217 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
222 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
224 public Option_u64Z quantity() {
225 long ret = bindings.UnsignedInvoiceRequest_quantity(this.ptr);
226 Reference.reachabilityFence(this);
227 if (ret >= 0 && ret <= 4096) { return null; }
228 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
229 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
234 * A possibly transient pubkey used to sign the invoice request.
236 public byte[] payer_id() {
237 byte[] ret = bindings.UnsignedInvoiceRequest_payer_id(this.ptr);
238 Reference.reachabilityFence(this);
243 * A payer-provided note which will be seen by the recipient and reflected back in the invoice
246 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
249 public PrintableString payer_note() {
250 long ret = bindings.UnsignedInvoiceRequest_payer_note(this.ptr);
251 Reference.reachabilityFence(this);
252 if (ret >= 0 && ret <= 4096) { return null; }
253 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
254 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
259 * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read
261 public byte[] write() {
262 byte[] ret = bindings.UnsignedInvoiceRequest_write(this.ptr);
263 Reference.reachabilityFence(this);