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 message to be sent or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ErrorMessage extends CommonBase {
16 ErrorMessage(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ErrorMessage_free(ptr); }
24 * The channel ID involved in the error
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.ErrorMessage_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
33 * The channel ID involved in the error
35 public void set_channel_id(byte[] val) {
36 bindings.ErrorMessage_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * A possibly human-readable error description.
43 * The string should be sanitized before it is used (e.g. emitted to logs
44 * or printed to stdout). Otherwise, a well crafted error message may trigger a security
45 * vulnerability in the terminal emulator or the logging subsystem.
47 public String get_data() {
48 String ret = bindings.ErrorMessage_get_data(this.ptr);
49 Reference.reachabilityFence(this);
54 * A possibly human-readable error description.
55 * The string should be sanitized before it is used (e.g. emitted to logs
56 * or printed to stdout). Otherwise, a well crafted error message may trigger a security
57 * vulnerability in the terminal emulator or the logging subsystem.
59 public void set_data(java.lang.String val) {
60 bindings.ErrorMessage_set_data(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * Constructs a new ErrorMessage given each field
68 public static ErrorMessage of(byte[] channel_id_arg, java.lang.String data_arg) {
69 long ret = bindings.ErrorMessage_new(InternalUtils.check_arr_len(channel_id_arg, 32), data_arg);
70 Reference.reachabilityFence(channel_id_arg);
71 Reference.reachabilityFence(data_arg);
72 if (ret >= 0 && ret <= 4096) { return null; }
73 ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ErrorMessage(null, ret); }
74 ret_hu_conv.ptrs_to.add(ret_hu_conv);
79 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
80 Reference.reachabilityFence(this);
85 * Creates a copy of the ErrorMessage
87 public ErrorMessage clone() {
88 long ret = bindings.ErrorMessage_clone(this.ptr);
89 Reference.reachabilityFence(this);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ErrorMessage(null, ret); }
92 ret_hu_conv.ptrs_to.add(this);
97 * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
99 public byte[] write() {
100 byte[] ret = bindings.ErrorMessage_write(this.ptr);
101 Reference.reachabilityFence(this);
106 * Read a ErrorMessage from a byte array, created by ErrorMessage_write
108 public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
109 long ret = bindings.ErrorMessage_read(ser);
110 Reference.reachabilityFence(ser);
111 if (ret >= 0 && ret <= 4096) { return null; }
112 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);