1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network,
13 * but without the signature information.
14 * Decoding and encoding should not lead to information loss but may lead to different hashes.
16 * For methods without docs see the corresponding methods in [`Bolt11Invoice`].
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class RawBolt11Invoice extends CommonBase {
20 RawBolt11Invoice(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.RawBolt11Invoice_free(ptr); }
30 public RawDataPart get_data() {
31 long ret = bindings.RawBolt11Invoice_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); };
42 public void set_data(org.ldk.structs.RawDataPart val) {
43 bindings.RawBolt11Invoice_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); };
50 * Checks if two RawBolt11Invoices 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.
54 public boolean eq(org.ldk.structs.RawBolt11Invoice b) {
55 boolean ret = bindings.RawBolt11Invoice_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); };
62 @Override public boolean equals(Object o) {
63 if (!(o instanceof RawBolt11Invoice)) return false;
64 return this.eq((RawBolt11Invoice)o);
67 long ret = bindings.RawBolt11Invoice_clone_ptr(this.ptr);
68 Reference.reachabilityFence(this);
73 * Creates a copy of the RawBolt11Invoice
75 public RawBolt11Invoice clone() {
76 long ret = bindings.RawBolt11Invoice_clone(this.ptr);
77 Reference.reachabilityFence(this);
78 if (ret >= 0 && ret <= 4096) { return null; }
79 org.ldk.structs.RawBolt11Invoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawBolt11Invoice(null, ret); }
80 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
85 * Generates a non-cryptographic 64-bit hash of the RawBolt11Invoice.
88 long ret = bindings.RawBolt11Invoice_hash(this.ptr);
89 Reference.reachabilityFence(this);
93 @Override public int hashCode() {
94 return (int)this.hash();
97 * Calculate the hash of the encoded `RawBolt11Invoice` which should be signed.
99 public byte[] signable_hash() {
100 byte[] ret = bindings.RawBolt11Invoice_signable_hash(this.ptr);
101 Reference.reachabilityFence(this);
106 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
109 public Sha256 payment_hash() {
110 long ret = bindings.RawBolt11Invoice_payment_hash(this.ptr);
111 Reference.reachabilityFence(this);
112 if (ret >= 0 && ret <= 4096) { return null; }
113 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(null, ret); }
114 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
119 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
122 public Description description() {
123 long ret = bindings.RawBolt11Invoice_description(this.ptr);
124 Reference.reachabilityFence(this);
125 if (ret >= 0 && ret <= 4096) { return null; }
126 org.ldk.structs.Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Description(null, ret); }
127 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
132 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
135 public PayeePubKey payee_pub_key() {
136 long ret = bindings.RawBolt11Invoice_payee_pub_key(this.ptr);
137 Reference.reachabilityFence(this);
138 if (ret >= 0 && ret <= 4096) { return null; }
139 org.ldk.structs.PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PayeePubKey(null, ret); }
140 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
145 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
148 public Sha256 description_hash() {
149 long ret = bindings.RawBolt11Invoice_description_hash(this.ptr);
150 Reference.reachabilityFence(this);
151 if (ret >= 0 && ret <= 4096) { return null; }
152 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(null, ret); }
153 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
158 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
161 public ExpiryTime expiry_time() {
162 long ret = bindings.RawBolt11Invoice_expiry_time(this.ptr);
163 Reference.reachabilityFence(this);
164 if (ret >= 0 && ret <= 4096) { return null; }
165 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
166 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
171 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
174 public MinFinalCltvExpiryDelta min_final_cltv_expiry_delta() {
175 long ret = bindings.RawBolt11Invoice_min_final_cltv_expiry_delta(this.ptr);
176 Reference.reachabilityFence(this);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 org.ldk.structs.MinFinalCltvExpiryDelta ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.MinFinalCltvExpiryDelta(null, ret); }
179 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
183 public Option_ThirtyTwoBytesZ payment_secret() {
184 long ret = bindings.RawBolt11Invoice_payment_secret(this.ptr);
185 Reference.reachabilityFence(this);
186 if (ret >= 0 && ret <= 4096) { return null; }
187 org.ldk.structs.Option_ThirtyTwoBytesZ ret_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(ret);
188 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
192 public Option_CVec_u8ZZ payment_metadata() {
193 long ret = bindings.RawBolt11Invoice_payment_metadata(this.ptr);
194 Reference.reachabilityFence(this);
195 if (ret >= 0 && ret <= 4096) { return null; }
196 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
197 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
202 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
205 public Bolt11InvoiceFeatures features() {
206 long ret = bindings.RawBolt11Invoice_features(this.ptr);
207 Reference.reachabilityFence(this);
208 if (ret >= 0 && ret <= 4096) { return null; }
209 org.ldk.structs.Bolt11InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, ret); }
210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
214 public PrivateRoute[] private_routes() {
215 long[] ret = bindings.RawBolt11Invoice_private_routes(this.ptr);
216 Reference.reachabilityFence(this);
217 int ret_conv_14_len = ret.length;
218 PrivateRoute[] ret_conv_14_arr = new PrivateRoute[ret_conv_14_len];
219 for (int o = 0; o < ret_conv_14_len; o++) {
220 long ret_conv_14 = ret[o];
221 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); }
222 if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.add(this); };
223 ret_conv_14_arr[o] = ret_conv_14_hu_conv;
225 return ret_conv_14_arr;
228 public Option_u64Z amount_pico_btc() {
229 long ret = bindings.RawBolt11Invoice_amount_pico_btc(this.ptr);
230 Reference.reachabilityFence(this);
231 if (ret >= 0 && ret <= 4096) { return null; }
232 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
233 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
237 public Currency currency() {
238 Currency ret = bindings.RawBolt11Invoice_currency(this.ptr);
239 Reference.reachabilityFence(this);