6 namespace org { namespace ldk { namespace structs {
10 * A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`].
12 * An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent
13 * directly after scanning a refund. It includes all the information needed to pay a recipient.
15 * [`Offer`]: crate::offers::offer::Offer
16 * [`Refund`]: crate::offers::refund::Refund
17 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
19 public class Bolt12Invoice : CommonBase {
20 internal Bolt12Invoice(object _dummy, long ptr) : base(ptr) { }
22 if (ptr != 0) { bindings.Bolt12Invoice_free(ptr); }
25 internal long clone_ptr() {
26 long ret = bindings.Bolt12Invoice_clone_ptr(this.ptr);
32 * Creates a copy of the Bolt12Invoice
34 public Bolt12Invoice clone() {
35 long ret = bindings.Bolt12Invoice_clone(this.ptr);
37 if (ret >= 0 && ret <= 4096) { return null; }
38 org.ldk.structs.Bolt12Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12Invoice(null, ret); }
39 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
44 * The chains that may be used when paying a requested invoice.
46 * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`].
48 * [`Offer::chains`]: crate::offers::offer::Offer::chains
50 public Option_CVec_ThirtyTwoBytesZZ offer_chains() {
51 long ret = bindings.Bolt12Invoice_offer_chains(this.ptr);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ ret_hu_conv = org.ldk.structs.Option_CVec_ThirtyTwoBytesZZ.constr_from_ptr(ret);
55 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
60 * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the
61 * invoice originated from an offer.
63 * From [`InvoiceRequest::chain`] or [`Refund::chain`].
65 * [`offer_chains`]: Self::offer_chains
66 * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain
68 public byte[] chain() {
69 long ret = bindings.Bolt12Invoice_chain(this.ptr);
71 if (ret >= 0 && ret <= 4096) { return null; }
72 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
77 * Opaque bytes set by the originating [`Offer`].
79 * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or
80 * if the [`Offer`] did not set it.
82 * [`Offer`]: crate::offers::offer::Offer
83 * [`Offer::metadata`]: crate::offers::offer::Offer::metadata
85 public Option_CVec_u8ZZ metadata() {
86 long ret = bindings.Bolt12Invoice_metadata(this.ptr);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
95 * The minimum amount required for a successful payment of a single item.
97 * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if
98 * the [`Offer`] did not set it.
100 * [`Offer`]: crate::offers::offer::Offer
101 * [`Offer::amount`]: crate::offers::offer::Offer::amount
103 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
105 public Amount amount() {
106 long ret = bindings.Bolt12Invoice_amount(this.ptr);
108 if (ret >= 0 && ret <= 4096) { return null; }
109 org.ldk.structs.Amount ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Amount(null, ret); }
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
115 * Features pertaining to the originating [`Offer`].
117 * From [`Offer::offer_features`]; `None` if the invoice was created in response to a
120 * [`Offer`]: crate::offers::offer::Offer
121 * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
123 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
125 public OfferFeatures offer_features() {
126 long ret = bindings.Bolt12Invoice_offer_features(this.ptr);
128 if (ret >= 0 && ret <= 4096) { return null; }
129 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
130 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
135 * A complete description of the purpose of the originating offer or refund.
137 * From [`Offer::description`] or [`Refund::description`].
139 * [`Offer::description`]: crate::offers::offer::Offer::description
141 public PrintableString description() {
142 long ret = bindings.Bolt12Invoice_description(this.ptr);
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
151 * Duration since the Unix epoch when an invoice should no longer be requested.
153 * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`].
155 * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry
157 public Option_u64Z absolute_expiry() {
158 long ret = bindings.Bolt12Invoice_absolute_expiry(this.ptr);
160 if (ret >= 0 && ret <= 4096) { return null; }
161 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
162 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
167 * The issuer of the offer or refund.
169 * From [`Offer::issuer`] or [`Refund::issuer`].
171 * [`Offer::issuer`]: crate::offers::offer::Offer::issuer
173 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
175 public PrintableString issuer() {
176 long ret = bindings.Bolt12Invoice_issuer(this.ptr);
178 if (ret >= 0 && ret <= 4096) { return null; }
179 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
185 * Paths to the recipient originating from publicly reachable nodes.
187 * From [`Offer::paths`] or [`Refund::paths`].
189 * [`Offer::paths`]: crate::offers::offer::Offer::paths
191 public BlindedPath[] message_paths() {
192 long ret = bindings.Bolt12Invoice_message_paths(this.ptr);
194 if (ret >= 0 && ret <= 4096) { return null; }
195 int ret_conv_13_len = InternalUtils.getArrayLength(ret);
196 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
197 for (int n = 0; n < ret_conv_13_len; n++) {
198 long ret_conv_13 = InternalUtils.getU64ArrayElem(ret, n);
199 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); }
200 if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
201 ret_conv_13_arr[n] = ret_conv_13_hu_conv;
203 bindings.free_buffer(ret);
204 return ret_conv_13_arr;
208 * The quantity of items supported.
210 * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a
213 * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity
215 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
217 public Quantity supported_quantity() {
218 long ret = bindings.Bolt12Invoice_supported_quantity(this.ptr);
220 if (ret >= 0 && ret <= 4096) { return null; }
221 org.ldk.structs.Quantity ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Quantity(null, ret); }
222 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
227 * An unpredictable series of bytes from the payer.
229 * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
231 public byte[] payer_metadata() {
232 long ret = bindings.Bolt12Invoice_payer_metadata(this.ptr);
234 if (ret >= 0 && ret <= 4096) { return null; }
235 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
240 * Features pertaining to requesting an invoice.
242 * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
244 public InvoiceRequestFeatures invoice_request_features() {
245 long ret = bindings.Bolt12Invoice_invoice_request_features(this.ptr);
247 if (ret >= 0 && ret <= 4096) { return null; }
248 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
249 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
254 * The quantity of items requested or refunded for.
256 * From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
258 public Option_u64Z quantity() {
259 long ret = bindings.Bolt12Invoice_quantity(this.ptr);
261 if (ret >= 0 && ret <= 4096) { return null; }
262 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
263 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
268 * A possibly transient pubkey used to sign the invoice request or to send an invoice for a
269 * refund in case there are no [`message_paths`].
271 * [`message_paths`]: Self::message_paths
273 public byte[] payer_id() {
274 long ret = bindings.Bolt12Invoice_payer_id(this.ptr);
276 if (ret >= 0 && ret <= 4096) { return null; }
277 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
282 * A payer-provided note reflected back in the invoice.
284 * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
286 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
288 public PrintableString payer_note() {
289 long ret = bindings.Bolt12Invoice_payer_note(this.ptr);
291 if (ret >= 0 && ret <= 4096) { return null; }
292 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
293 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
298 * Duration since the Unix epoch when the invoice was created.
300 public long created_at() {
301 long ret = bindings.Bolt12Invoice_created_at(this.ptr);
307 * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
308 * should no longer be paid.
310 public long relative_expiry() {
311 long ret = bindings.Bolt12Invoice_relative_expiry(this.ptr);
317 * Whether the invoice has expired.
319 public bool is_expired() {
320 bool ret = bindings.Bolt12Invoice_is_expired(this.ptr);
326 * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
328 public byte[] payment_hash() {
329 long ret = bindings.Bolt12Invoice_payment_hash(this.ptr);
331 if (ret >= 0 && ret <= 4096) { return null; }
332 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
337 * The minimum amount required for a successful payment of the invoice.
339 public long amount_msats() {
340 long ret = bindings.Bolt12Invoice_amount_msats(this.ptr);
346 * Features pertaining to paying an invoice.
348 public Bolt12InvoiceFeatures invoice_features() {
349 long ret = bindings.Bolt12Invoice_invoice_features(this.ptr);
351 if (ret >= 0 && ret <= 4096) { return null; }
352 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
353 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
358 * The public key corresponding to the key used to sign the invoice.
360 public byte[] signing_pubkey() {
361 long ret = bindings.Bolt12Invoice_signing_pubkey(this.ptr);
363 if (ret >= 0 && ret <= 4096) { return null; }
364 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
369 * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
371 public byte[] signature() {
372 long ret = bindings.Bolt12Invoice_signature(this.ptr);
374 if (ret >= 0 && ret <= 4096) { return null; }
375 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
380 * Hash that was used for signing the invoice.
382 public byte[] signable_hash() {
383 long ret = bindings.Bolt12Invoice_signable_hash(this.ptr);
385 if (ret >= 0 && ret <= 4096) { return null; }
386 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
391 * Verifies that the invoice was for a request or refund created using the given key. Returns
392 * the associated [`PaymentId`] to use when sending the payment.
394 public Result_ThirtyTwoBytesNoneZ verify(org.ldk.structs.ExpandedKey key) {
395 long ret = bindings.Bolt12Invoice_verify(this.ptr, key == null ? 0 : key.ptr);
398 if (ret >= 0 && ret <= 4096) { return null; }
399 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
400 if (this != null) { this.ptrs_to.AddLast(key); };
405 * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
407 public byte[] write() {
408 long ret = bindings.Bolt12Invoice_write(this.ptr);
410 if (ret >= 0 && ret <= 4096) { return null; }
411 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);