6 namespace org { namespace ldk { namespace structs {
10 * An error message to be sent or received from a peer
12 public class ErrorMessage : CommonBase {
13 internal ErrorMessage(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.ErrorMessage_free(ptr); }
19 * The channel ID involved in the error.
21 * All-0s indicates a general error unrelated to a specific channel, after which all channels
22 * with the sending peer should be closed.
24 public byte[] get_channel_id() {
25 byte[] ret = bindings.ErrorMessage_get_channel_id(this.ptr);
31 * The channel ID involved in the error.
33 * All-0s indicates a general error unrelated to a specific channel, after which all channels
34 * with the sending peer should be closed.
36 public void set_channel_id(byte[] val) {
37 bindings.ErrorMessage_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
43 * A possibly human-readable error description.
44 * The string should be sanitized before it is used (e.g. emitted to logs or printed to
45 * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
46 * the terminal emulator or the logging subsystem.
48 public string get_data() {
49 string ret = bindings.ErrorMessage_get_data(this.ptr);
55 * A possibly human-readable error description.
56 * The string should be sanitized before it is used (e.g. emitted to logs or printed to
57 * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
58 * the terminal emulator or the logging subsystem.
60 public void set_data(string val) {
61 bindings.ErrorMessage_set_data(this.ptr, val);
67 * Constructs a new ErrorMessage given each field
69 public static ErrorMessage of(byte[] channel_id_arg, string data_arg) {
70 long ret = bindings.ErrorMessage_new(InternalUtils.check_arr_len(channel_id_arg, 32), data_arg);
71 GC.KeepAlive(channel_id_arg);
72 GC.KeepAlive(data_arg);
73 if (ret >= 0 && ret <= 4096) { return null; }
74 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
75 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
79 internal long clone_ptr() {
80 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
86 * Creates a copy of the ErrorMessage
88 public ErrorMessage clone() {
89 long ret = bindings.ErrorMessage_clone(this.ptr);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
98 * Checks if two ErrorMessages contain equal inner contents.
99 * This ignores pointers and is_owned flags and looks at the values in fields.
100 * Two objects with NULL inner values will be considered "equal" here.
102 public bool eq(org.ldk.structs.ErrorMessage b) {
103 bool ret = bindings.ErrorMessage_eq(this.ptr, b == null ? 0 : b.ptr);
106 if (this != null) { this.ptrs_to.AddLast(b); };
110 public override bool Equals(object o) {
111 if (!(o is ErrorMessage)) return false;
112 return this.eq((ErrorMessage)o);
115 * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
117 public byte[] write() {
118 byte[] ret = bindings.ErrorMessage_write(this.ptr);
124 * Read a ErrorMessage from a byte array, created by ErrorMessage_write
126 public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
127 long ret = bindings.ErrorMessage_read(ser);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);