[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / Bolt12Invoice.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`].
13  * 
14  * An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent
15  * directly after scanning a refund. It includes all the information needed to pay a recipient.
16  * 
17  * [`Offer`]: crate::offers::offer::Offer
18  * [`Refund`]: crate::offers::refund::Refund
19  * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
20  */
21 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
22 public class Bolt12Invoice extends CommonBase {
23         Bolt12Invoice(Object _dummy, long ptr) { super(ptr); }
24         @Override @SuppressWarnings("deprecation")
25         protected void finalize() throws Throwable {
26                 super.finalize();
27                 if (ptr != 0) { bindings.Bolt12Invoice_free(ptr); }
28         }
29
30         long clone_ptr() {
31                 long ret = bindings.Bolt12Invoice_clone_ptr(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * Creates a copy of the Bolt12Invoice
38          */
39         public Bolt12Invoice clone() {
40                 long ret = bindings.Bolt12Invoice_clone(this.ptr);
41                 Reference.reachabilityFence(this);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 org.ldk.structs.Bolt12Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12Invoice(null, ret); }
44                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
45                 return ret_hu_conv;
46         }
47
48         /**
49          * A complete description of the purpose of the originating offer or refund. Intended to be
50          * displayed to the user but with the caveat that it has not been verified in any way.
51          */
52         public PrintableString description() {
53                 long ret = bindings.Bolt12Invoice_description(this.ptr);
54                 Reference.reachabilityFence(this);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
57                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Duration since the Unix epoch when the invoice was created.
63          */
64         public long created_at() {
65                 long ret = bindings.Bolt12Invoice_created_at(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore
72          * should no longer be paid.
73          */
74         public long relative_expiry() {
75                 long ret = bindings.Bolt12Invoice_relative_expiry(this.ptr);
76                 Reference.reachabilityFence(this);
77                 return ret;
78         }
79
80         /**
81          * Whether the invoice has expired.
82          */
83         public boolean is_expired() {
84                 boolean ret = bindings.Bolt12Invoice_is_expired(this.ptr);
85                 Reference.reachabilityFence(this);
86                 return ret;
87         }
88
89         /**
90          * SHA256 hash of the payment preimage that will be given in return for paying the invoice.
91          */
92         public byte[] payment_hash() {
93                 byte[] ret = bindings.Bolt12Invoice_payment_hash(this.ptr);
94                 Reference.reachabilityFence(this);
95                 return ret;
96         }
97
98         /**
99          * The minimum amount required for a successful payment of the invoice.
100          */
101         public long amount_msats() {
102                 long ret = bindings.Bolt12Invoice_amount_msats(this.ptr);
103                 Reference.reachabilityFence(this);
104                 return ret;
105         }
106
107         /**
108          * Features pertaining to paying an invoice.
109          */
110         public Bolt12InvoiceFeatures features() {
111                 long ret = bindings.Bolt12Invoice_features(this.ptr);
112                 Reference.reachabilityFence(this);
113                 if (ret >= 0 && ret <= 4096) { return null; }
114                 org.ldk.structs.Bolt12InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, ret); }
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
116                 return ret_hu_conv;
117         }
118
119         /**
120          * The public key corresponding to the key used to sign the invoice.
121          */
122         public byte[] signing_pubkey() {
123                 byte[] ret = bindings.Bolt12Invoice_signing_pubkey(this.ptr);
124                 Reference.reachabilityFence(this);
125                 return ret;
126         }
127
128         /**
129          * Hash that was used for signing the invoice.
130          */
131         public byte[] signable_hash() {
132                 byte[] ret = bindings.Bolt12Invoice_signable_hash(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * Verifies that the invoice was for a request or refund created using the given key.
139          */
140         public boolean verify(org.ldk.structs.ExpandedKey key) {
141                 boolean ret = bindings.Bolt12Invoice_verify(this.ptr, key == null ? 0 : key.ptr);
142                 Reference.reachabilityFence(this);
143                 Reference.reachabilityFence(key);
144                 if (this != null) { this.ptrs_to.add(key); };
145                 return ret;
146         }
147
148         /**
149          * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read
150          */
151         public byte[] write() {
152                 byte[] ret = bindings.Bolt12Invoice_write(this.ptr);
153                 Reference.reachabilityFence(this);
154                 return ret;
155         }
156
157 }