[Java] Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / RawInvoice.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  * Represents an syntactically correct Invoice for a payment on the lightning network,
13  * but without the signature information.
14  * De- and encoding should not lead to information loss but may lead to different hashes.
15  * 
16  * For methods without docs see the corresponding methods in `Invoice`.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class RawInvoice extends CommonBase {
20         RawInvoice(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.RawInvoice_free(ptr); }
25         }
26
27         /**
28          * data part
29          */
30         public RawDataPart get_data() {
31                 long ret = bindings.RawInvoice_get_data(this.ptr);
32                 Reference.reachabilityFence(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 RawDataPart ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawDataPart(null, ret); }
35                 ret_hu_conv.ptrs_to.add(this);
36                 return ret_hu_conv;
37         }
38
39         /**
40          * data part
41          */
42         public void set_data(RawDataPart val) {
43                 bindings.RawInvoice_set_data(this.ptr, val == null ? 0 : val.ptr & ~1);
44                 Reference.reachabilityFence(this);
45                 Reference.reachabilityFence(val);
46         }
47
48         /**
49          * Checks if two RawInvoices contain equal inner contents.
50          * This ignores pointers and is_owned flags and looks at the values in fields.
51          * Two objects with NULL inner values will be considered "equal" here.
52          */
53         public boolean eq(RawInvoice b) {
54                 boolean ret = bindings.RawInvoice_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(b);
57                 this.ptrs_to.add(b);
58                 return ret;
59         }
60
61         @Override public boolean equals(Object o) {
62                 if (!(o instanceof RawInvoice)) return false;
63                 return this.eq((RawInvoice)o);
64         }
65         long clone_ptr() {
66                 long ret = bindings.RawInvoice_clone_ptr(this.ptr);
67                 Reference.reachabilityFence(this);
68                 return ret;
69         }
70
71         /**
72          * Creates a copy of the RawInvoice
73          */
74         public RawInvoice clone() {
75                 long ret = bindings.RawInvoice_clone(this.ptr);
76                 Reference.reachabilityFence(this);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawInvoice(null, ret); }
79                 ret_hu_conv.ptrs_to.add(this);
80                 return ret_hu_conv;
81         }
82
83         /**
84          * Calculate the hash of the encoded `RawInvoice`
85          */
86         public byte[] hash() {
87                 byte[] ret = bindings.RawInvoice_hash(this.ptr);
88                 Reference.reachabilityFence(this);
89                 return ret;
90         }
91
92         /**
93          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
94          */
95         @Nullable
96         public Sha256 payment_hash() {
97                 long ret = bindings.RawInvoice_payment_hash(this.ptr);
98                 Reference.reachabilityFence(this);
99                 if (ret >= 0 && ret <= 4096) { return null; }
100                 Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
101                 ret_hu_conv.ptrs_to.add(this);
102                 return ret_hu_conv;
103         }
104
105         /**
106          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
107          */
108         @Nullable
109         public Description description() {
110                 long ret = bindings.RawInvoice_description(this.ptr);
111                 Reference.reachabilityFence(this);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Description(null, ret); }
114                 ret_hu_conv.ptrs_to.add(this);
115                 return ret_hu_conv;
116         }
117
118         /**
119          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
120          */
121         @Nullable
122         public PayeePubKey payee_pub_key() {
123                 long ret = bindings.RawInvoice_payee_pub_key(this.ptr);
124                 Reference.reachabilityFence(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PayeePubKey(null, ret); }
127                 ret_hu_conv.ptrs_to.add(this);
128                 return ret_hu_conv;
129         }
130
131         /**
132          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
133          */
134         @Nullable
135         public Sha256 description_hash() {
136                 long ret = bindings.RawInvoice_description_hash(this.ptr);
137                 Reference.reachabilityFence(this);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
140                 ret_hu_conv.ptrs_to.add(this);
141                 return ret_hu_conv;
142         }
143
144         /**
145          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
146          */
147         @Nullable
148         public ExpiryTime expiry_time() {
149                 long ret = bindings.RawInvoice_expiry_time(this.ptr);
150                 Reference.reachabilityFence(this);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ExpiryTime(null, ret); }
153                 ret_hu_conv.ptrs_to.add(this);
154                 return ret_hu_conv;
155         }
156
157         /**
158          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
159          */
160         @Nullable
161         public MinFinalCltvExpiry min_final_cltv_expiry() {
162                 long ret = bindings.RawInvoice_min_final_cltv_expiry(this.ptr);
163                 Reference.reachabilityFence(this);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 MinFinalCltvExpiry ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MinFinalCltvExpiry(null, ret); }
166                 ret_hu_conv.ptrs_to.add(this);
167                 return ret_hu_conv;
168         }
169
170         /**
171          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
172          */
173         @Nullable
174         public byte[] payment_secret() {
175                 byte[] ret = bindings.RawInvoice_payment_secret(this.ptr);
176                 Reference.reachabilityFence(this);
177                 return ret;
178         }
179
180         /**
181          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
182          */
183         @Nullable
184         public InvoiceFeatures features() {
185                 long ret = bindings.RawInvoice_features(this.ptr);
186                 Reference.reachabilityFence(this);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
189                 ret_hu_conv.ptrs_to.add(this);
190                 return ret_hu_conv;
191         }
192
193         public PrivateRoute[] private_routes() {
194                 long[] ret = bindings.RawInvoice_private_routes(this.ptr);
195                 Reference.reachabilityFence(this);
196                 int ret_conv_14_len = ret.length;
197                 PrivateRoute[] ret_conv_14_arr = new PrivateRoute[ret_conv_14_len];
198                 for (int o = 0; o < ret_conv_14_len; o++) {
199                         long ret_conv_14 = ret[o];
200                         PrivateRoute ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new PrivateRoute(null, ret_conv_14); }
201                         ret_conv_14_hu_conv.ptrs_to.add(this);
202                         ret_conv_14_arr[o] = ret_conv_14_hu_conv;
203                 }
204                 return ret_conv_14_arr;
205         }
206
207         public Option_u64Z amount_pico_btc() {
208                 long ret = bindings.RawInvoice_amount_pico_btc(this.ptr);
209                 Reference.reachabilityFence(this);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
212                 ret_hu_conv.ptrs_to.add(this);
213                 return ret_hu_conv;
214         }
215
216         public Currency currency() {
217                 Currency ret = bindings.RawInvoice_currency(this.ptr);
218                 Reference.reachabilityFence(this);
219                 return ret;
220         }
221
222 }