]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/ErrorMessage.cs
Update CI references to LDK 0.0.124 drop stale memchr pins
[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 ChannelId 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                 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); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The channel ID involved in the error.
37          * 
38          * All-0s indicates a general error unrelated to a specific channel, after which all channels
39          * with the sending peer should be closed.
40          */
41         public void set_channel_id(org.ldk.structs.ChannelId val) {
42                 bindings.ErrorMessage_set_channel_id(this.ptr, val.ptr);
43                 GC.KeepAlive(this);
44                 GC.KeepAlive(val);
45         }
46
47         /**
48          * A possibly human-readable error description.
49          * 
50          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
51          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
52          * the terminal emulator or the logging subsystem.
53          */
54         public string get_data() {
55                 long ret = bindings.ErrorMessage_get_data(this.ptr);
56                 GC.KeepAlive(this);
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 string ret_conv = InternalUtils.decodeString(ret);
59                 return ret_conv;
60         }
61
62         /**
63          * A possibly human-readable error description.
64          * 
65          * The string should be sanitized before it is used (e.g., emitted to logs or printed to
66          * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in
67          * the terminal emulator or the logging subsystem.
68          */
69         public void set_data(string val) {
70                 bindings.ErrorMessage_set_data(this.ptr, InternalUtils.encodeString(val));
71                 GC.KeepAlive(this);
72                 GC.KeepAlive(val);
73         }
74
75         /**
76          * Constructs a new ErrorMessage given each field
77          */
78         public static ErrorMessage of(org.ldk.structs.ChannelId channel_id_arg, string data_arg) {
79                 long ret = bindings.ErrorMessage_new(channel_id_arg.ptr, InternalUtils.encodeString(data_arg));
80                 GC.KeepAlive(channel_id_arg);
81                 GC.KeepAlive(data_arg);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
85                 return ret_hu_conv;
86         }
87
88         internal long clone_ptr() {
89                 long ret = bindings.ErrorMessage_clone_ptr(this.ptr);
90                 GC.KeepAlive(this);
91                 return ret;
92         }
93
94         /**
95          * Creates a copy of the ErrorMessage
96          */
97         public ErrorMessage clone() {
98                 long ret = bindings.ErrorMessage_clone(this.ptr);
99                 GC.KeepAlive(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.ErrorMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ErrorMessage(null, ret); }
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
103                 return ret_hu_conv;
104         }
105
106         /**
107          * Generates a non-cryptographic 64-bit hash of the ErrorMessage.
108          */
109         public long hash() {
110                 long ret = bindings.ErrorMessage_hash(this.ptr);
111                 GC.KeepAlive(this);
112                 return ret;
113         }
114
115         public override int GetHashCode() {
116                 return (int)this.hash();
117         }
118         /**
119          * Checks if two ErrorMessages contain equal inner contents.
120          * This ignores pointers and is_owned flags and looks at the values in fields.
121          * Two objects with NULL inner values will be considered "equal" here.
122          */
123         public bool eq(org.ldk.structs.ErrorMessage b) {
124                 bool ret = bindings.ErrorMessage_eq(this.ptr, b.ptr);
125                 GC.KeepAlive(this);
126                 GC.KeepAlive(b);
127                 if (this != null) { this.ptrs_to.AddLast(b); };
128                 return ret;
129         }
130
131         public override bool Equals(object o) {
132                 if (!(o is ErrorMessage)) return false;
133                 return this.eq((ErrorMessage)o);
134         }
135         /**
136          * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read
137          */
138         public byte[] write() {
139                 long ret = bindings.ErrorMessage_write(this.ptr);
140                 GC.KeepAlive(this);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
143                 return ret_conv;
144         }
145
146         /**
147          * Read a ErrorMessage from a byte array, created by ErrorMessage_write
148          */
149         public static Result_ErrorMessageDecodeErrorZ read(byte[] ser) {
150                 long ret = bindings.ErrorMessage_read(InternalUtils.encodeUint8Array(ser));
151                 GC.KeepAlive(ser);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 Result_ErrorMessageDecodeErrorZ ret_hu_conv = Result_ErrorMessageDecodeErrorZ.constr_from_ptr(ret);
154                 return ret_hu_conv;
155         }
156
157 }
158 } } }