6 namespace org { namespace ldk { namespace structs {
10 * An [`error`] message to be sent to or received from a peer.
12 * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
14 public class ErrorMessage : CommonBase {
15 internal ErrorMessage(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.ErrorMessage_free(ptr); }
21 * The channel ID involved in the error.
23 * All-0s indicates a general error unrelated to a specific channel, after which all channels
24 * with the sending peer should be closed.
26 public ChannelId get_channel_id() {
27 long ret = bindings.ErrorMessage_get_channel_id(this.ptr);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
31 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
36 * The channel ID involved in the error.
38 * All-0s indicates a general error unrelated to a specific channel, after which all channels
39 * with the sending peer should be closed.
41 public void set_channel_id(org.ldk.structs.ChannelId val) {
42 bindings.ErrorMessage_set_channel_id(this.ptr, val.ptr);
45 if (this != null) { this.ptrs_to.AddLast(val); };
49 * A possibly human-readable error description.
51 * The string should be sanitized before it is used (e.g., emitted to logs or printed to
52 * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
53 * the terminal emulator or the logging subsystem.
55 public string get_data() {
56 long ret = bindings.ErrorMessage_get_data(this.ptr);
58 if (ret >= 0 && ret <= 4096) { return null; }
59 string ret_conv = InternalUtils.decodeString(ret);
64 * A possibly human-readable error description.
66 * The string should be sanitized before it is used (e.g., emitted to logs or printed to
67 * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
68 * the terminal emulator or the logging subsystem.
70 public void set_data(string val) {
71 bindings.ErrorMessage_set_data(this.ptr, InternalUtils.encodeString(val));
77 * Constructs a new ErrorMessage given each field
79 public static ErrorMessage of(org.ldk.structs.ChannelId channel_id_arg, string data_arg) {
80 long ret = bindings.ErrorMessage_new(channel_id_arg.ptr, InternalUtils.encodeString(data_arg));
81 GC.KeepAlive(channel_id_arg);
82 GC.KeepAlive(data_arg);
83 if (ret >= 0 && ret <= 4096) { return null; }
84 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
85 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
86 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
90 internal long clone_ptr() {
91 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
97 * Creates a copy of the ErrorMessage
99 public ErrorMessage clone() {
100 long ret = bindings.ErrorMessage_clone(this.ptr);
102 if (ret >= 0 && ret <= 4096) { return null; }
103 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109 * Generates a non-cryptographic 64-bit hash of the ErrorMessage.
112 long ret = bindings.ErrorMessage_hash(this.ptr);
117 public override int GetHashCode() {
118 return (int)this.hash();
121 * Checks if two ErrorMessages contain equal inner contents.
122 * This ignores pointers and is_owned flags and looks at the values in fields.
123 * Two objects with NULL inner values will be considered "equal" here.
125 public bool eq(org.ldk.structs.ErrorMessage b) {
126 bool ret = bindings.ErrorMessage_eq(this.ptr, b.ptr);
129 if (this != null) { this.ptrs_to.AddLast(b); };
133 public override bool Equals(object o) {
134 if (!(o is ErrorMessage)) return false;
135 return this.eq((ErrorMessage)o);
138 * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
140 public byte[] write() {
141 long ret = bindings.ErrorMessage_write(this.ptr);
143 if (ret >= 0 && ret <= 4096) { return null; }
144 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
149 * Read a ErrorMessage from a byte array, created by ErrorMessage_write
151 public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
152 long ret = bindings.ErrorMessage_read(InternalUtils.encodeUint8Array(ser));
154 if (ret >= 0 && ret <= 4096) { return null; }
155 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);