[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ErrorMessage.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * An [`error`] message to be sent to or received from a peer.
11  * 
12  * [`error`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
13  */
14 public class ErrorMessage : CommonBase {
15         internal ErrorMessage(object _dummy, long ptr) : base(ptr) { }
16         ~ErrorMessage() {
17                 if (ptr != 0) { bindings.ErrorMessage_free(ptr); }
18         }
19
20         /**
21          * The channel ID involved in the error.
22          * 
23          * All-0s indicates a general error unrelated to a specific channel, after which all channels
24          * with the sending peer should be closed.
25          */
26         public byte[] get_channel_id() {
27                 long ret = bindings.ErrorMessage_get_channel_id(this.ptr);
28                 GC.KeepAlive(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
31                 return ret_conv;
32         }
33
34         /**
35          * The channel ID involved in the error.
36          * 
37          * All-0s indicates a general error unrelated to a specific channel, after which all channels
38          * with the sending peer should be closed.
39          */
40         public void set_channel_id(byte[] val) {
41                 bindings.ErrorMessage_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
42                 GC.KeepAlive(this);
43                 GC.KeepAlive(val);
44         }
45
46         /**
47          * A possibly human-readable error description.
48          * 
49          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
50          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
51          * the terminal emulator or the logging subsystem.
52          */
53         public string get_data() {
54                 long ret = bindings.ErrorMessage_get_data(this.ptr);
55                 GC.KeepAlive(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 string ret_conv = InternalUtils.decodeString(ret);
58                 return ret_conv;
59         }
60
61         /**
62          * A possibly human-readable error description.
63          * 
64          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
65          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
66          * the terminal emulator or the logging subsystem.
67          */
68         public void set_data(string val) {
69                 bindings.ErrorMessage_set_data(this.ptr, InternalUtils.encodeString(val));
70                 GC.KeepAlive(this);
71                 GC.KeepAlive(val);
72         }
73
74         /**
75          * Constructs a new ErrorMessage given each field
76          */
77         public static ErrorMessage of(byte[] channel_id_arg, string data_arg) {
78                 long ret = bindings.ErrorMessage_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeString(data_arg));
79                 GC.KeepAlive(channel_id_arg);
80                 GC.KeepAlive(data_arg);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
84                 return ret_hu_conv;
85         }
86
87         internal long clone_ptr() {
88                 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
89                 GC.KeepAlive(this);
90                 return ret;
91         }
92
93         /**
94          * Creates a copy of the ErrorMessage
95          */
96         public ErrorMessage clone() {
97                 long ret = bindings.ErrorMessage_clone(this.ptr);
98                 GC.KeepAlive(this);
99                 if (ret >= 0 && ret <= 4096) { return null; }
100                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
101                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
102                 return ret_hu_conv;
103         }
104
105         /**
106          * Generates a non-cryptographic 64-bit hash of the ErrorMessage.
107          */
108         public long hash() {
109                 long ret = bindings.ErrorMessage_hash(this.ptr);
110                 GC.KeepAlive(this);
111                 return ret;
112         }
113
114         public override int GetHashCode() {
115                 return (int)this.hash();
116         }
117         /**
118          * Checks if two ErrorMessages contain equal inner contents.
119          * This ignores pointers and is_owned flags and looks at the values in fields.
120          * Two objects with NULL inner values will be considered "equal" here.
121          */
122         public bool eq(org.ldk.structs.ErrorMessage b) {
123                 bool ret = bindings.ErrorMessage_eq(this.ptr, b == null ? 0 : b.ptr);
124                 GC.KeepAlive(this);
125                 GC.KeepAlive(b);
126                 if (this != null) { this.ptrs_to.AddLast(b); };
127                 return ret;
128         }
129
130         public override bool Equals(object o) {
131                 if (!(o is ErrorMessage)) return false;
132                 return this.eq((ErrorMessage)o);
133         }
134         /**
135          * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
136          */
137         public byte[] write() {
138                 long ret = bindings.ErrorMessage_write(this.ptr);
139                 GC.KeepAlive(this);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
142                 return ret_conv;
143         }
144
145         /**
146          * Read a ErrorMessage from a byte array, created by ErrorMessage_write
147          */
148         public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
149                 long ret = bindings.ErrorMessage_read(InternalUtils.encodeUint8Array(ser));
150                 GC.KeepAlive(ser);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
153                 return ret_hu_conv;
154         }
155
156 }
157 } } }