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