[Java] Update auto-generated Java structs
[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                 org.ldk.structs.RawDataPart ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawDataPart(null, ret); }
35                 if (ret_hu_conv != null) { 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);
44                 Reference.reachabilityFence(this);
45                 Reference.reachabilityFence(val);
46                 if (this != null) { this.ptrs_to.add(val); };
47         }
48
49         /**
50          * Checks if two RawInvoices contain equal inner contents.
51          * This ignores pointers and is_owned flags and looks at the values in fields.
52          * Two objects with NULL inner values will be considered "equal" here.
53          */
54         public boolean eq(RawInvoice b) {
55                 boolean ret = bindings.RawInvoice_eq(this.ptr, b == null ? 0 : b.ptr);
56                 Reference.reachabilityFence(this);
57                 Reference.reachabilityFence(b);
58                 if (this != null) { this.ptrs_to.add(b); };
59                 return ret;
60         }
61
62         @Override public boolean equals(Object o) {
63                 if (!(o instanceof RawInvoice)) return false;
64                 return this.eq((RawInvoice)o);
65         }
66         long clone_ptr() {
67                 long ret = bindings.RawInvoice_clone_ptr(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         /**
73          * Creates a copy of the RawInvoice
74          */
75         public RawInvoice clone() {
76                 long ret = bindings.RawInvoice_clone(this.ptr);
77                 Reference.reachabilityFence(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 org.ldk.structs.RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawInvoice(null, ret); }
80                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Calculate the hash of the encoded `RawInvoice`
86          */
87         public byte[] hash() {
88                 byte[] ret = bindings.RawInvoice_hash(this.ptr);
89                 Reference.reachabilityFence(this);
90                 return ret;
91         }
92
93         /**
94          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
95          */
96         @Nullable
97         public Sha256 payment_hash() {
98                 long ret = bindings.RawInvoice_payment_hash(this.ptr);
99                 Reference.reachabilityFence(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(null, ret); }
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
103                 return ret_hu_conv;
104         }
105
106         /**
107          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
108          */
109         @Nullable
110         public Description description() {
111                 long ret = bindings.RawInvoice_description(this.ptr);
112                 Reference.reachabilityFence(this);
113                 if (ret >= 0 && ret <= 4096) { return null; }
114                 org.ldk.structs.Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Description(null, ret); }
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
116                 return ret_hu_conv;
117         }
118
119         /**
120          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
121          */
122         @Nullable
123         public PayeePubKey payee_pub_key() {
124                 long ret = bindings.RawInvoice_payee_pub_key(this.ptr);
125                 Reference.reachabilityFence(this);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 org.ldk.structs.PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PayeePubKey(null, ret); }
128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
129                 return ret_hu_conv;
130         }
131
132         /**
133          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
134          */
135         @Nullable
136         public Sha256 description_hash() {
137                 long ret = bindings.RawInvoice_description_hash(this.ptr);
138                 Reference.reachabilityFence(this);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(null, ret); }
141                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
142                 return ret_hu_conv;
143         }
144
145         /**
146          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
147          */
148         @Nullable
149         public ExpiryTime expiry_time() {
150                 long ret = bindings.RawInvoice_expiry_time(this.ptr);
151                 Reference.reachabilityFence(this);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
155                 return ret_hu_conv;
156         }
157
158         /**
159          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
160          */
161         @Nullable
162         public MinFinalCltvExpiry min_final_cltv_expiry() {
163                 long ret = bindings.RawInvoice_min_final_cltv_expiry(this.ptr);
164                 Reference.reachabilityFence(this);
165                 if (ret >= 0 && ret <= 4096) { return null; }
166                 org.ldk.structs.MinFinalCltvExpiry ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.MinFinalCltvExpiry(null, ret); }
167                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
168                 return ret_hu_conv;
169         }
170
171         /**
172          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
173          */
174         @Nullable
175         public byte[] payment_secret() {
176                 byte[] ret = bindings.RawInvoice_payment_secret(this.ptr);
177                 Reference.reachabilityFence(this);
178                 return ret;
179         }
180
181         /**
182          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
183          */
184         @Nullable
185         public InvoiceFeatures features() {
186                 long ret = bindings.RawInvoice_features(this.ptr);
187                 Reference.reachabilityFence(this);
188                 if (ret >= 0 && ret <= 4096) { return null; }
189                 org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); }
190                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
191                 return ret_hu_conv;
192         }
193
194         public PrivateRoute[] private_routes() {
195                 long[] ret = bindings.RawInvoice_private_routes(this.ptr);
196                 Reference.reachabilityFence(this);
197                 int ret_conv_14_len = ret.length;
198                 PrivateRoute[] ret_conv_14_arr = new PrivateRoute[ret_conv_14_len];
199                 for (int o = 0; o < ret_conv_14_len; o++) {
200                         long ret_conv_14 = ret[o];
201                         org.ldk.structs.PrivateRoute ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new org.ldk.structs.PrivateRoute(null, ret_conv_14); }
202                         if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.add(this); };
203                         ret_conv_14_arr[o] = ret_conv_14_hu_conv;
204                 }
205                 return ret_conv_14_arr;
206         }
207
208         public Option_u64Z amount_pico_btc() {
209                 long ret = bindings.RawInvoice_amount_pico_btc(this.ptr);
210                 Reference.reachabilityFence(this);
211                 if (ret >= 0 && ret <= 4096) { return null; }
212                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
213                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
214                 return ret_hu_conv;
215         }
216
217         public Currency currency() {
218                 Currency ret = bindings.RawInvoice_currency(this.ptr);
219                 Reference.reachabilityFence(this);
220                 return ret;
221         }
222
223 }