1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
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.
15 * For methods without docs see the corresponding methods in `Invoice`.
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 {
23 if (ptr != 0) { bindings.RawInvoice_free(ptr); }
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);
40 public void set_data(RawDataPart val) {
41 bindings.RawInvoice_set_data(this.ptr, val == null ? 0 : val.ptr & ~1);
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.
49 public boolean eq(RawInvoice b) {
50 boolean ret = bindings.RawInvoice_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
56 long ret = bindings.RawInvoice_clone_ptr(this.ptr);
61 * Creates a copy of the RawInvoice
63 public RawInvoice clone() {
64 long ret = bindings.RawInvoice_clone(this.ptr);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new RawInvoice(null, ret); }
67 ret_hu_conv.ptrs_to.add(this);
72 * Calculate the hash of the encoded `RawInvoice`
74 public byte[] hash() {
75 byte[] ret = bindings.RawInvoice_hash(this.ptr);
80 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
83 public Sha256 payment_hash() {
84 long ret = bindings.RawInvoice_payment_hash(this.ptr);
85 if (ret >= 0 && ret <= 4096) { return null; }
86 Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
87 ret_hu_conv.ptrs_to.add(this);
92 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
95 public Description description() {
96 long ret = bindings.RawInvoice_description(this.ptr);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Description(null, ret); }
99 ret_hu_conv.ptrs_to.add(this);
104 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
107 public PayeePubKey payee_pub_key() {
108 long ret = bindings.RawInvoice_payee_pub_key(this.ptr);
109 if (ret >= 0 && ret <= 4096) { return null; }
110 PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PayeePubKey(null, ret); }
111 ret_hu_conv.ptrs_to.add(this);
116 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
119 public Sha256 description_hash() {
120 long ret = bindings.RawInvoice_description_hash(this.ptr);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Sha256(null, ret); }
123 ret_hu_conv.ptrs_to.add(this);
128 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
131 public ExpiryTime expiry_time() {
132 long ret = bindings.RawInvoice_expiry_time(this.ptr);
133 if (ret >= 0 && ret <= 4096) { return null; }
134 ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ExpiryTime(null, ret); }
135 ret_hu_conv.ptrs_to.add(this);
140 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
143 public MinFinalCltvExpiry min_final_cltv_expiry() {
144 long ret = bindings.RawInvoice_min_final_cltv_expiry(this.ptr);
145 if (ret >= 0 && ret <= 4096) { return null; }
146 MinFinalCltvExpiry ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new MinFinalCltvExpiry(null, ret); }
147 ret_hu_conv.ptrs_to.add(this);
152 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
155 public byte[] payment_secret() {
156 byte[] ret = bindings.RawInvoice_payment_secret(this.ptr);
161 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
164 public InvoiceFeatures features() {
165 long ret = bindings.RawInvoice_features(this.ptr);
166 if (ret >= 0 && ret <= 4096) { return null; }
167 InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
168 ret_hu_conv.ptrs_to.add(this);
172 public PrivateRoute[] private_routes() {
173 long[] ret = bindings.RawInvoice_private_routes(this.ptr);
174 PrivateRoute[] ret_conv_14_arr = new PrivateRoute[ret.length];
175 for (int o = 0; o < ret.length; o++) {
176 long ret_conv_14 = ret[o];
177 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); }
178 ret_conv_14_hu_conv.ptrs_to.add(this);
179 ret_conv_14_arr[o] = ret_conv_14_hu_conv;
181 return ret_conv_14_arr;
184 public Option_u64Z amount_pico_btc() {
185 long ret = bindings.RawInvoice_amount_pico_btc(this.ptr);
186 if (ret >= 0 && ret <= 4096) { return null; }
187 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
188 ret_hu_conv.ptrs_to.add(this);
192 public Currency currency() {
193 Currency ret = bindings.RawInvoice_currency(this.ptr);