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 * An error in response to an [`InvoiceRequest`] or an [`Bolt12Invoice`].
14 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
15 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class InvoiceError extends CommonBase {
19 InvoiceError(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.InvoiceError_free(ptr); }
27 * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error.
29 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
30 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
32 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
35 public ErroneousField get_erroneous_field() {
36 long ret = bindings.InvoiceError_get_erroneous_field(this.ptr);
37 Reference.reachabilityFence(this);
38 if (ret >= 0 && ret <= 4096) { return null; }
39 org.ldk.structs.ErroneousField ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErroneousField(null, ret); }
40 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
45 * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error.
47 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
48 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
50 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
52 public void set_erroneous_field(@Nullable org.ldk.structs.ErroneousField val) {
53 bindings.InvoiceError_set_erroneous_field(this.ptr, val == null ? 0 : val.ptr);
54 Reference.reachabilityFence(this);
55 Reference.reachabilityFence(val);
56 if (this != null) { this.ptrs_to.add(val); };
60 * An explanation of the error.
62 public UntrustedString get_message() {
63 long ret = bindings.InvoiceError_get_message(this.ptr);
64 Reference.reachabilityFence(this);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
67 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
72 * An explanation of the error.
74 public void set_message(org.ldk.structs.UntrustedString val) {
75 bindings.InvoiceError_set_message(this.ptr, val == null ? 0 : val.ptr);
76 Reference.reachabilityFence(this);
77 Reference.reachabilityFence(val);
78 if (this != null) { this.ptrs_to.add(val); };
82 * Constructs a new InvoiceError given each field
84 * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
86 public static InvoiceError of(@Nullable org.ldk.structs.ErroneousField erroneous_field_arg, org.ldk.structs.UntrustedString message_arg) {
87 long ret = bindings.InvoiceError_new(erroneous_field_arg == null ? 0 : erroneous_field_arg.ptr, message_arg == null ? 0 : message_arg.ptr);
88 Reference.reachabilityFence(erroneous_field_arg);
89 Reference.reachabilityFence(message_arg);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.InvoiceError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceError(null, ret); }
92 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(erroneous_field_arg); };
94 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(message_arg); };
99 long ret = bindings.InvoiceError_clone_ptr(this.ptr);
100 Reference.reachabilityFence(this);
105 * Creates a copy of the InvoiceError
107 public InvoiceError clone() {
108 long ret = bindings.InvoiceError_clone(this.ptr);
109 Reference.reachabilityFence(this);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 org.ldk.structs.InvoiceError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceError(null, ret); }
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
117 * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read
119 public byte[] write() {
120 byte[] ret = bindings.InvoiceError_write(this.ptr);
121 Reference.reachabilityFence(this);
126 * Read a InvoiceError from a byte array, created by InvoiceError_write
128 public static Result_InvoiceErrorDecodeErrorZ read(byte[] ser) {
129 long ret = bindings.InvoiceError_read(ser);
130 Reference.reachabilityFence(ser);
131 if (ret >= 0 && ret <= 4096) { return null; }
132 Result_InvoiceErrorDecodeErrorZ ret_hu_conv = Result_InvoiceErrorDecodeErrorZ.constr_from_ptr(ret);