6 namespace org { namespace ldk { namespace structs {
10 * A [`warning`] message to be sent to or received from a peer.
12 * [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages
14 public class WarningMessage : CommonBase {
15 internal WarningMessage(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.WarningMessage_free(ptr); }
21 * The channel ID involved in the warning.
23 * All-0s indicates a warning unrelated to a specific channel.
25 public ChannelId get_channel_id() {
26 long ret = bindings.WarningMessage_get_channel_id(this.ptr);
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); };
35 * The channel ID involved in the warning.
37 * All-0s indicates a warning unrelated to a specific channel.
39 public void set_channel_id(org.ldk.structs.ChannelId val) {
40 bindings.WarningMessage_set_channel_id(this.ptr, val.ptr);
43 if (this != null) { this.ptrs_to.AddLast(val); };
47 * A possibly human-readable warning description.
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.
53 public string get_data() {
54 long ret = bindings.WarningMessage_get_data(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 string ret_conv = InternalUtils.decodeString(ret);
62 * A possibly human-readable warning description.
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.
68 public void set_data(string val) {
69 bindings.WarningMessage_set_data(this.ptr, InternalUtils.encodeString(val));
75 * Constructs a new WarningMessage given each field
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); };
88 internal long clone_ptr() {
89 long ret = bindings.WarningMessage_clone_ptr(this.ptr);
95 * Creates a copy of the WarningMessage
97 public WarningMessage clone() {
98 long ret = bindings.WarningMessage_clone(this.ptr);
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); };
107 * Generates a non-cryptographic 64-bit hash of the WarningMessage.
110 long ret = bindings.WarningMessage_hash(this.ptr);
115 public override int GetHashCode() {
116 return (int)this.hash();
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.
123 public bool eq(org.ldk.structs.WarningMessage b) {
124 bool ret = bindings.WarningMessage_eq(this.ptr, b.ptr);
127 if (this != null) { this.ptrs_to.AddLast(b); };
131 public override bool Equals(object o) {
132 if (!(o is WarningMessage)) return false;
133 return this.eq((WarningMessage)o);
136 * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
138 public byte[] write() {
139 long ret = bindings.WarningMessage_write(this.ptr);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
147 * Read a WarningMessage from a byte array, created by WarningMessage_write
149 public static Result_WarningMessageDecodeErrorZ read(byte[] ser) {
150 long ret = bindings.WarningMessage_read(InternalUtils.encodeUint8Array(ser));
152 if (ret >= 0 && ret <= 4096) { return null; }
153 Result_WarningMessageDecodeErrorZ ret_hu_conv = Result_WarningMessageDecodeErrorZ.constr_from_ptr(ret);