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 [`Bolt12Invoice`] 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 UnsignedBolt12Invoice extends CommonBase {
21 UnsignedBolt12Invoice(Object _dummy, long ptr) { super(ptr); }
22 @Override @SuppressWarnings("deprecation")
23 protected void finalize() throws Throwable {
25 if (ptr != 0) { bindings.UnsignedBolt12Invoice_free(ptr); }
29 long ret = bindings.UnsignedBolt12Invoice_clone_ptr(this.ptr);
30 Reference.reachabilityFence(this);
35 * Creates a copy of the UnsignedBolt12Invoice
37 public UnsignedBolt12Invoice clone() {
38 long ret = bindings.UnsignedBolt12Invoice_clone(this.ptr);
39 Reference.reachabilityFence(this);
40 if (ret >= 0 && ret <= 4096) { return null; }
41 org.ldk.structs.UnsignedBolt12Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedBolt12Invoice(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.UnsignedBolt12Invoice_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.
61 * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
63 * [`Offer::chains`]: crate::offers::offer::Offer::chains
65 public Option_CVec_ThirtyTwoBytesZZ offer_chains() {
66 long ret = bindings.UnsignedBolt12Invoice_offer_chains(this.ptr);
67 Reference.reachabilityFence(this);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
75 * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
76 * invoice originated from an offer.
78 * From [`InvoiceRequest::chain`] or [`Refund::chain`].
80 * [`offer_chains`]: Self::offer_chains
81 * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
83 public byte[] chain() {
84 byte[] ret = bindings.UnsignedBolt12Invoice_chain(this.ptr);
85 Reference.reachabilityFence(this);
90 * Opaque bytes set by the originating [`Offer`].
92 * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
93 * if the [`Offer`] did not set it.
95 * [`Offer`]: crate::offers::offer::Offer
96 * [`Offer::metadata`]: crate::offers::offer::Offer::metadata
98 public Option_CVec_u8ZZ metadata() {
99 long ret = bindings.UnsignedBolt12Invoice_metadata(this.ptr);
100 Reference.reachabilityFence(this);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108 * The minimum amount required for a successful payment of a single item.
110 * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
111 * the [`Offer`] did not set it.
113 * [`Offer`]: crate::offers::offer::Offer
114 * [`Offer::amount`]: crate::offers::offer::Offer::amount
116 public Option_AmountZ amount() {
117 long ret = bindings.UnsignedBolt12Invoice_amount(this.ptr);
118 Reference.reachabilityFence(this);
119 if (ret >= 0 && ret <= 4096) { return null; }
120 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
121 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
126 * Features pertaining to the originating [`Offer`].
128 * From [`Offer::offer_features`]; `None` if the invoice was created in response to a
131 * [`Offer`]: crate::offers::offer::Offer
132 * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
134 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
137 public OfferFeatures offer_features() {
138 long ret = bindings.UnsignedBolt12Invoice_offer_features(this.ptr);
139 Reference.reachabilityFence(this);
140 if (ret >= 0 && ret <= 4096) { return null; }
141 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
142 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
147 * A complete description of the purpose of the originating offer or refund.
149 * From [`Offer::description`] or [`Refund::description`].
151 * [`Offer::description`]: crate::offers::offer::Offer::description
153 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
156 public PrintableString description() {
157 long ret = bindings.UnsignedBolt12Invoice_description(this.ptr);
158 Reference.reachabilityFence(this);
159 if (ret >= 0 && ret <= 4096) { return null; }
160 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
161 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
166 * Duration since the Unix epoch when an invoice should no longer be requested.
168 * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
170 * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
172 public Option_u64Z absolute_expiry() {
173 long ret = bindings.UnsignedBolt12Invoice_absolute_expiry(this.ptr);
174 Reference.reachabilityFence(this);
175 if (ret >= 0 && ret <= 4096) { return null; }
176 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
177 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
182 * The issuer of the offer or refund.
184 * From [`Offer::issuer`] or [`Refund::issuer`].
186 * [`Offer::issuer`]: crate::offers::offer::Offer::issuer
188 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
191 public PrintableString issuer() {
192 long ret = bindings.UnsignedBolt12Invoice_issuer(this.ptr);
193 Reference.reachabilityFence(this);
194 if (ret >= 0 && ret <= 4096) { return null; }
195 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
196 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
201 * Paths to the recipient originating from publicly reachable nodes.
203 * From [`Offer::paths`] or [`Refund::paths`].
205 * [`Offer::paths`]: crate::offers::offer::Offer::paths
207 public BlindedPath[] message_paths() {
208 long[] ret = bindings.UnsignedBolt12Invoice_message_paths(this.ptr);
209 Reference.reachabilityFence(this);
210 int ret_conv_13_len = ret.length;
211 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
212 for (int n = 0; n < ret_conv_13_len; n++) {
213 long ret_conv_13 = ret[n];
214 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); }
215 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
216 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
218 return ret_conv_13_arr;
222 * The quantity of items supported.
224 * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
227 * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
229 public Option_QuantityZ supported_quantity() {
230 long ret = bindings.UnsignedBolt12Invoice_supported_quantity(this.ptr);
231 Reference.reachabilityFence(this);
232 if (ret >= 0 && ret <= 4096) { return null; }
233 org.ldk.structs.Option_QuantityZ ret_hu_conv = org.ldk.structs.Option_QuantityZ.constr_from_ptr(ret);
234 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
239 * An unpredictable series of bytes from the payer.
241 * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
243 public byte[] payer_metadata() {
244 byte[] ret = bindings.UnsignedBolt12Invoice_payer_metadata(this.ptr);
245 Reference.reachabilityFence(this);
250 * Features pertaining to requesting an invoice.
252 * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
254 public InvoiceRequestFeatures invoice_request_features() {
255 long ret = bindings.UnsignedBolt12Invoice_invoice_request_features(this.ptr);
256 Reference.reachabilityFence(this);
257 if (ret >= 0 && ret <= 4096) { return null; }
258 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
259 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
264 * The quantity of items requested or refunded for.
266 * From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
268 public Option_u64Z quantity() {
269 long ret = bindings.UnsignedBolt12Invoice_quantity(this.ptr);
270 Reference.reachabilityFence(this);
271 if (ret >= 0 && ret <= 4096) { return null; }
272 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
273 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
278 * A possibly transient pubkey used to sign the invoice request or to send an invoice for a
279 * refund in case there are no [`message_paths`].
281 * [`message_paths`]: Self::message_paths
283 public byte[] payer_id() {
284 byte[] ret = bindings.UnsignedBolt12Invoice_payer_id(this.ptr);
285 Reference.reachabilityFence(this);
290 * A payer-provided note reflected back in the invoice.
292 * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
294 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
297 public PrintableString payer_note() {
298 long ret = bindings.UnsignedBolt12Invoice_payer_note(this.ptr);
299 Reference.reachabilityFence(this);
300 if (ret >= 0 && ret <= 4096) { return null; }
301 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
302 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
307 * Duration since the Unix epoch when the invoice was created.
309 public long created_at() {
310 long ret = bindings.UnsignedBolt12Invoice_created_at(this.ptr);
311 Reference.reachabilityFence(this);
316 * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
317 * should no longer be paid.
319 public long relative_expiry() {
320 long ret = bindings.UnsignedBolt12Invoice_relative_expiry(this.ptr);
321 Reference.reachabilityFence(this);
326 * Whether the invoice has expired.
328 public boolean is_expired() {
329 boolean ret = bindings.UnsignedBolt12Invoice_is_expired(this.ptr);
330 Reference.reachabilityFence(this);
335 * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
337 public byte[] payment_hash() {
338 byte[] ret = bindings.UnsignedBolt12Invoice_payment_hash(this.ptr);
339 Reference.reachabilityFence(this);
344 * The minimum amount required for a successful payment of the invoice.
346 public long amount_msats() {
347 long ret = bindings.UnsignedBolt12Invoice_amount_msats(this.ptr);
348 Reference.reachabilityFence(this);
353 * Features pertaining to paying an invoice.
355 public Bolt12InvoiceFeatures invoice_features() {
356 long ret = bindings.UnsignedBolt12Invoice_invoice_features(this.ptr);
357 Reference.reachabilityFence(this);
358 if (ret >= 0 && ret <= 4096) { return null; }
359 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
360 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
365 * The public key corresponding to the key used to sign the invoice.
367 public byte[] signing_pubkey() {
368 byte[] ret = bindings.UnsignedBolt12Invoice_signing_pubkey(this.ptr);
369 Reference.reachabilityFence(this);
374 * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read
376 public byte[] write() {
377 byte[] ret = bindings.UnsignedBolt12Invoice_write(this.ptr);
378 Reference.reachabilityFence(this);