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);
46 * A possibly human-readable warning description.
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.
52 public string get_data() {
53 long ret = bindings.WarningMessage_get_data(this.ptr);
55 if (ret >= 0 && ret <= 4096) { return null; }
56 string ret_conv = InternalUtils.decodeString(ret);
61 * A possibly human-readable warning description.
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.
67 public void set_data(string val) {
68 bindings.WarningMessage_set_data(this.ptr, InternalUtils.encodeString(val));
74 * Constructs a new WarningMessage given each field
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); };
86 internal long clone_ptr() {
87 long ret = bindings.WarningMessage_clone_ptr(this.ptr);
93 * Creates a copy of the WarningMessage
95 public WarningMessage clone() {
96 long ret = bindings.WarningMessage_clone(this.ptr);
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); };
105 * Generates a non-cryptographic 64-bit hash of the WarningMessage.
108 long ret = bindings.WarningMessage_hash(this.ptr);
113 public override int GetHashCode() {
114 return (int)this.hash();
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.
121 public bool eq(org.ldk.structs.WarningMessage b) {
122 bool ret = bindings.WarningMessage_eq(this.ptr, b.ptr);
125 if (this != null) { this.ptrs_to.AddLast(b); };
129 public override bool Equals(object o) {
130 if (!(o is WarningMessage)) return false;
131 return this.eq((WarningMessage)o);
134 * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
136 public byte[] write() {
137 long ret = bindings.WarningMessage_write(this.ptr);
139 if (ret >= 0 && ret <= 4096) { return null; }
140 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
145 * Read a WarningMessage from a byte array, created by WarningMessage_write
147 public static Result_WarningMessageDecodeErrorZ read(byte[] ser) {
148 long ret = bindings.WarningMessage_read(InternalUtils.encodeUint8Array(ser));
150 if (ret >= 0 && ret <= 4096) { return null; }
151 Result_WarningMessageDecodeErrorZ ret_hu_conv = Result_WarningMessageDecodeErrorZ.constr_from_ptr(ret);