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 byte[] get_channel_id() {
26 long ret = bindings.WarningMessage_get_channel_id(this.ptr);
28 if (ret >= 0 && ret <= 4096) { return null; }
29 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
34 * The channel ID involved in the warning.
36 * All-0s indicates a warning unrelated to a specific channel.
38 public void set_channel_id(byte[] val) {
39 bindings.WarningMessage_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
45 * A possibly human-readable warning description.
47 * The string should be sanitized before it is used (e.g. emitted to logs or printed to
48 * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
49 * the terminal emulator or the logging subsystem.
51 public string get_data() {
52 long ret = bindings.WarningMessage_get_data(this.ptr);
54 if (ret >= 0 && ret <= 4096) { return null; }
55 string ret_conv = InternalUtils.decodeString(ret);
60 * A possibly human-readable warning description.
62 * The string should be sanitized before it is used (e.g. emitted to logs or printed to
63 * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
64 * the terminal emulator or the logging subsystem.
66 public void set_data(string val) {
67 bindings.WarningMessage_set_data(this.ptr, InternalUtils.encodeString(val));
73 * Constructs a new WarningMessage given each field
75 public static WarningMessage of(byte[] channel_id_arg, string data_arg) {
76 long ret = bindings.WarningMessage_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeString(data_arg));
77 GC.KeepAlive(channel_id_arg);
78 GC.KeepAlive(data_arg);
79 if (ret >= 0 && ret <= 4096) { return null; }
80 org.ldk.structs.WarningMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WarningMessage(null, ret); }
81 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
85 internal long clone_ptr() {
86 long ret = bindings.WarningMessage_clone_ptr(this.ptr);
92 * Creates a copy of the WarningMessage
94 public WarningMessage clone() {
95 long ret = bindings.WarningMessage_clone(this.ptr);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 org.ldk.structs.WarningMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.WarningMessage(null, ret); }
99 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
104 * Checks if two WarningMessages contain equal inner contents.
105 * This ignores pointers and is_owned flags and looks at the values in fields.
106 * Two objects with NULL inner values will be considered "equal" here.
108 public bool eq(org.ldk.structs.WarningMessage b) {
109 bool ret = bindings.WarningMessage_eq(this.ptr, b == null ? 0 : b.ptr);
112 if (this != null) { this.ptrs_to.AddLast(b); };
116 public override bool Equals(object o) {
117 if (!(o is WarningMessage)) return false;
118 return this.eq((WarningMessage)o);
121 * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
123 public byte[] write() {
124 long ret = bindings.WarningMessage_write(this.ptr);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
132 * Read a WarningMessage from a byte array, created by WarningMessage_write
134 public static Result_WarningMessageDecodeErrorZ read(byte[] ser) {
135 long ret = bindings.WarningMessage_read(InternalUtils.encodeUint8Array(ser));
137 if (ret >= 0 && ret <= 4096) { return null; }
138 Result_WarningMessageDecodeErrorZ ret_hu_conv = Result_WarningMessageDecodeErrorZ.constr_from_ptr(ret);