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