[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / WarningMessage.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  * A [`warning`] message to be sent to or received from a peer.
11  * 
12  * [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
13  */
14 public class WarningMessage : CommonBase {
15         internal WarningMessage(object _dummy, long ptr) : base(ptr) { }
16         ~WarningMessage() {
17                 if (ptr != 0) { bindings.WarningMessage_free(ptr); }
18         }
19
20         /**
21          * The channel ID involved in the warning.
22          * 
23          * All-0s indicates a warning unrelated to a specific channel.
24          */
25         public ChannelId get_channel_id() {
26                 long ret = bindings.WarningMessage_get_channel_id(this.ptr);
27                 GC.KeepAlive(this);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
30                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
31                 return ret_hu_conv;
32         }
33
34         /**
35          * The channel ID involved in the warning.
36          * 
37          * All-0s indicates a warning unrelated to a specific channel.
38          */
39         public void set_channel_id(org.ldk.structs.ChannelId val) {
40                 bindings.WarningMessage_set_channel_id(this.ptr, val.ptr);
41                 GC.KeepAlive(this);
42                 GC.KeepAlive(val);
43                 if (this != null) { this.ptrs_to.AddLast(val); };
44         }
45
46         /**
47          * A possibly human-readable warning 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.WarningMessage_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 warning 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.WarningMessage_set_data(this.ptr, InternalUtils.encodeString(val));
70                 GC.KeepAlive(this);
71                 GC.KeepAlive(val);
72         }
73
74         /**
75          * Constructs a new WarningMessage given each field
76          */
77         public static WarningMessage of(org.ldk.structs.ChannelId channel_id_arg, string data_arg) {
78                 long ret = bindings.WarningMessage_new(channel_id_arg.ptr, 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.WarningMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WarningMessage(null, ret); }
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
85                 return ret_hu_conv;
86         }
87
88         internal long clone_ptr() {
89                 long ret = bindings.WarningMessage_clone_ptr(this.ptr);
90                 GC.KeepAlive(this);
91                 return ret;
92         }
93
94         /**
95          * Creates a copy of the WarningMessage
96          */
97         public WarningMessage clone() {
98                 long ret = bindings.WarningMessage_clone(this.ptr);
99                 GC.KeepAlive(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.WarningMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WarningMessage(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 WarningMessage.
108          */
109         public long hash() {
110                 long ret = bindings.WarningMessage_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 WarningMessages 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.WarningMessage b) {
124                 bool ret = bindings.WarningMessage_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 WarningMessage)) return false;
133                 return this.eq((WarningMessage)o);
134         }
135         /**
136          * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
137          */
138         public byte[] write() {
139                 long ret = bindings.WarningMessage_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 WarningMessage from a byte array, created by WarningMessage_write
148          */
149         public static Result_WarningMessageDecodeErrorZ read(byte[] ser) {
150                 long ret = bindings.WarningMessage_read(InternalUtils.encodeUint8Array(ser));
151                 GC.KeepAlive(ser);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 Result_WarningMessageDecodeErrorZ ret_hu_conv = Result_WarningMessageDecodeErrorZ.constr_from_ptr(ret);
154                 return ret_hu_conv;
155         }
156
157 }
158 } } }