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 public Option_AmountZ amount() {
104 long ret = bindings.Bolt12Invoice_amount(this.ptr);
106 if (ret >= 0 && ret <= 4096) { return null; }
107 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
108 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
113 * Features pertaining to the originating [`Offer`].
115 * From [`Offer::offer_features`]; `None` if the invoice was created in response to a
118 * [`Offer`]: crate::offers::offer::Offer
119 * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features
121 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
123 public OfferFeatures offer_features() {
124 long ret = bindings.Bolt12Invoice_offer_features(this.ptr);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
133 * A complete description of the purpose of the originating offer or refund.
135 * From [`Offer::description`] or [`Refund::description`].
137 * [`Offer::description`]: crate::offers::offer::Offer::description
139 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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 public Option_QuantityZ supported_quantity() {
216 long ret = bindings.Bolt12Invoice_supported_quantity(this.ptr);
218 if (ret >= 0 && ret <= 4096) { return null; }
219 org.ldk.structs.Option_QuantityZ ret_hu_conv = org.ldk.structs.Option_QuantityZ.constr_from_ptr(ret);
220 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
225 * An unpredictable series of bytes from the payer.
227 * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`].
229 public byte[] payer_metadata() {
230 long ret = bindings.Bolt12Invoice_payer_metadata(this.ptr);
232 if (ret >= 0 && ret <= 4096) { return null; }
233 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
238 * Features pertaining to requesting an invoice.
240 * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`].
242 public InvoiceRequestFeatures invoice_request_features() {
243 long ret = bindings.Bolt12Invoice_invoice_request_features(this.ptr);
245 if (ret >= 0 && ret <= 4096) { return null; }
246 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
247 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
252 * The quantity of items requested or refunded for.
254 * From [`InvoiceRequest::quantity`] or [`Refund::quantity`].
256 public Option_u64Z quantity() {
257 long ret = bindings.Bolt12Invoice_quantity(this.ptr);
259 if (ret >= 0 && ret <= 4096) { return null; }
260 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
261 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
266 * A possibly transient pubkey used to sign the invoice request or to send an invoice for a
267 * refund in case there are no [`message_paths`].
269 * [`message_paths`]: Self::message_paths
271 public byte[] payer_id() {
272 long ret = bindings.Bolt12Invoice_payer_id(this.ptr);
274 if (ret >= 0 && ret <= 4096) { return null; }
275 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
280 * A payer-provided note reflected back in the invoice.
282 * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`].
284 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
286 public PrintableString payer_note() {
287 long ret = bindings.Bolt12Invoice_payer_note(this.ptr);
289 if (ret >= 0 && ret <= 4096) { return null; }
290 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
291 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
296 * Duration since the Unix epoch when the invoice was created.
298 public long created_at() {
299 long ret = bindings.Bolt12Invoice_created_at(this.ptr);
305 * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
306 * should no longer be paid.
308 public long relative_expiry() {
309 long ret = bindings.Bolt12Invoice_relative_expiry(this.ptr);
315 * Whether the invoice has expired.
317 public bool is_expired() {
318 bool ret = bindings.Bolt12Invoice_is_expired(this.ptr);
324 * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
326 public byte[] payment_hash() {
327 long ret = bindings.Bolt12Invoice_payment_hash(this.ptr);
329 if (ret >= 0 && ret <= 4096) { return null; }
330 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
335 * The minimum amount required for a successful payment of the invoice.
337 public long amount_msats() {
338 long ret = bindings.Bolt12Invoice_amount_msats(this.ptr);
344 * Features pertaining to paying an invoice.
346 public Bolt12InvoiceFeatures invoice_features() {
347 long ret = bindings.Bolt12Invoice_invoice_features(this.ptr);
349 if (ret >= 0 && ret <= 4096) { return null; }
350 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
351 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
356 * The public key corresponding to the key used to sign the invoice.
358 public byte[] signing_pubkey() {
359 long ret = bindings.Bolt12Invoice_signing_pubkey(this.ptr);
361 if (ret >= 0 && ret <= 4096) { return null; }
362 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
367 * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`].
369 public byte[] signature() {
370 long ret = bindings.Bolt12Invoice_signature(this.ptr);
372 if (ret >= 0 && ret <= 4096) { return null; }
373 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
378 * Hash that was used for signing the invoice.
380 public byte[] signable_hash() {
381 long ret = bindings.Bolt12Invoice_signable_hash(this.ptr);
383 if (ret >= 0 && ret <= 4096) { return null; }
384 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
389 * Verifies that the invoice was for a request or refund created using the given key. Returns
390 * the associated [`PaymentId`] to use when sending the payment.
392 public Result_ThirtyTwoBytesNoneZ verify(org.ldk.structs.ExpandedKey key) {
393 long ret = bindings.Bolt12Invoice_verify(this.ptr, key.ptr);
396 if (ret >= 0 && ret <= 4096) { return null; }
397 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
398 if (this != null) { this.ptrs_to.AddLast(key); };
403 * Generates a non-cryptographic 64-bit hash of the Bolt12Invoice.
406 long ret = bindings.Bolt12Invoice_hash(this.ptr);
411 public override int GetHashCode() {
412 return (int)this.hash();
415 * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
417 public byte[] write() {
418 long ret = bindings.Bolt12Invoice_write(this.ptr);
420 if (ret >= 0 && ret <= 4096) { return null; }
421 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);