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 * Returns the [`TaggedHash`] of the invoice to sign.
31 public TaggedHash tagged_hash() {
32 long ret = bindings.UnsignedBolt12Invoice_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.
43 * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
45 * [`Offer::chains`]: crate::offers::offer::Offer::chains
47 public Option_CVec_ThirtyTwoBytesZZ offer_chains() {
48 long ret = bindings.UnsignedBolt12Invoice_offer_chains(this.ptr);
49 Reference.reachabilityFence(this);
50 if (ret >= 0 && ret <= 4096) { return null; }
51 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
52 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
57 * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
58 * invoice originated from an offer.
60 * From [`InvoiceRequest::chain`] or [`Refund::chain`].
62 * [`offer_chains`]: Self::offer_chains
63 * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
65 public byte[] chain() {
66 byte[] ret = bindings.UnsignedBolt12Invoice_chain(this.ptr);
67 Reference.reachabilityFence(this);
72 * Opaque bytes set by the originating [`Offer`].
74 * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
75 * if the [`Offer`] did not set it.
77 * [`Offer`]: crate::offers::offer::Offer
78 * [`Offer::metadata`]: crate::offers::offer::Offer::metadata
80 public Option_CVec_u8ZZ metadata() {
81 long ret = bindings.UnsignedBolt12Invoice_metadata(this.ptr);
82 Reference.reachabilityFence(this);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
90 * The minimum amount required for a successful payment of a single item.
92 * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
93 * the [`Offer`] did not set it.
95 * [`Offer`]: crate::offers::offer::Offer
96 * [`Offer::amount`]: crate::offers::offer::Offer::amount
98 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
101 public Amount amount() {
102 long ret = bindings.UnsignedBolt12Invoice_amount(this.ptr);
103 Reference.reachabilityFence(this);
104 if (ret >= 0 && ret <= 4096) { return null; }
105 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
111 * Features pertaining to the originating [`Offer`].
113 * From [`Offer::offer_features`]; `None` if the invoice was created in response to a
116 * [`Offer`]: crate::offers::offer::Offer
117 * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
119 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
122 public OfferFeatures offer_features() {
123 long ret = bindings.UnsignedBolt12Invoice_offer_features(this.ptr);
124 Reference.reachabilityFence(this);
125 if (ret >= 0 && ret <= 4096) { return null; }
126 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
127 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
132 * A complete description of the purpose of the originating offer or refund.
134 * From [`Offer::description`] or [`Refund::description`].
136 * [`Offer::description`]: crate::offers::offer::Offer::description
138 public PrintableString description() {
139 long ret = bindings.UnsignedBolt12Invoice_description(this.ptr);
140 Reference.reachabilityFence(this);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
143 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
148 * Duration since the Unix epoch when an invoice should no longer be requested.
150 * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
152 * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
154 public Option_u64Z absolute_expiry() {
155 long ret = bindings.UnsignedBolt12Invoice_absolute_expiry(this.ptr);
156 Reference.reachabilityFence(this);
157 if (ret >= 0 && ret <= 4096) { return null; }
158 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
159 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
164 * The issuer of the offer or refund.
166 * From [`Offer::issuer`] or [`Refund::issuer`].
168 * [`Offer::issuer`]: crate::offers::offer::Offer::issuer
170 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
173 public PrintableString issuer() {
174 long ret = bindings.UnsignedBolt12Invoice_issuer(this.ptr);
175 Reference.reachabilityFence(this);
176 if (ret >= 0 && ret <= 4096) { return null; }
177 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
178 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
183 * Paths to the recipient originating from publicly reachable nodes.
185 * From [`Offer::paths`] or [`Refund::paths`].
187 * [`Offer::paths`]: crate::offers::offer::Offer::paths
189 public BlindedPath[] message_paths() {
190 long[] ret = bindings.UnsignedBolt12Invoice_message_paths(this.ptr);
191 Reference.reachabilityFence(this);
192 int ret_conv_13_len = ret.length;
193 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
194 for (int n = 0; n < ret_conv_13_len; n++) {
195 long ret_conv_13 = ret[n];
196 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); }
197 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
198 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
200 return ret_conv_13_arr;
204 * The quantity of items supported.
206 * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
209 * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
211 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
214 public Quantity supported_quantity() {
215 long ret = bindings.UnsignedBolt12Invoice_supported_quantity(this.ptr);
216 Reference.reachabilityFence(this);
217 if (ret >= 0 && ret <= 4096) { return null; }
218 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
219 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
224 * An unpredictable series of bytes from the payer.
226 * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
228 public byte[] payer_metadata() {
229 byte[] ret = bindings.UnsignedBolt12Invoice_payer_metadata(this.ptr);
230 Reference.reachabilityFence(this);
235 * Features pertaining to requesting an invoice.
237 * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
239 public InvoiceRequestFeatures invoice_request_features() {
240 long ret = bindings.UnsignedBolt12Invoice_invoice_request_features(this.ptr);
241 Reference.reachabilityFence(this);
242 if (ret >= 0 && ret <= 4096) { return null; }
243 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
244 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
249 * The quantity of items requested or refunded for.
251 * From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
253 public Option_u64Z quantity() {
254 long ret = bindings.UnsignedBolt12Invoice_quantity(this.ptr);
255 Reference.reachabilityFence(this);
256 if (ret >= 0 && ret <= 4096) { return null; }
257 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
258 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
263 * A possibly transient pubkey used to sign the invoice request or to send an invoice for a
264 * refund in case there are no [`message_paths`].
266 * [`message_paths`]: Self::message_paths
268 public byte[] payer_id() {
269 byte[] ret = bindings.UnsignedBolt12Invoice_payer_id(this.ptr);
270 Reference.reachabilityFence(this);
275 * A payer-provided note reflected back in the invoice.
277 * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
279 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
282 public PrintableString payer_note() {
283 long ret = bindings.UnsignedBolt12Invoice_payer_note(this.ptr);
284 Reference.reachabilityFence(this);
285 if (ret >= 0 && ret <= 4096) { return null; }
286 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
287 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
292 * Duration since the Unix epoch when the invoice was created.
294 public long created_at() {
295 long ret = bindings.UnsignedBolt12Invoice_created_at(this.ptr);
296 Reference.reachabilityFence(this);
301 * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
302 * should no longer be paid.
304 public long relative_expiry() {
305 long ret = bindings.UnsignedBolt12Invoice_relative_expiry(this.ptr);
306 Reference.reachabilityFence(this);
311 * Whether the invoice has expired.
313 public boolean is_expired() {
314 boolean ret = bindings.UnsignedBolt12Invoice_is_expired(this.ptr);
315 Reference.reachabilityFence(this);
320 * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
322 public byte[] payment_hash() {
323 byte[] ret = bindings.UnsignedBolt12Invoice_payment_hash(this.ptr);
324 Reference.reachabilityFence(this);
329 * The minimum amount required for a successful payment of the invoice.
331 public long amount_msats() {
332 long ret = bindings.UnsignedBolt12Invoice_amount_msats(this.ptr);
333 Reference.reachabilityFence(this);
338 * Features pertaining to paying an invoice.
340 public Bolt12InvoiceFeatures invoice_features() {
341 long ret = bindings.UnsignedBolt12Invoice_invoice_features(this.ptr);
342 Reference.reachabilityFence(this);
343 if (ret >= 0 && ret <= 4096) { return null; }
344 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
345 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
350 * The public key corresponding to the key used to sign the invoice.
352 public byte[] signing_pubkey() {
353 byte[] ret = bindings.UnsignedBolt12Invoice_signing_pubkey(this.ptr);
354 Reference.reachabilityFence(this);
359 * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read
361 public byte[] write() {
362 byte[] ret = bindings.UnsignedBolt12Invoice_write(this.ptr);
363 Reference.reachabilityFence(this);