X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FWarningMessage.cs;h=b9b7b52ffd2dde10deef35460e0302ccfaeb8cf0;hb=8de7213fbf663ff60322896282dad51e8ab2f001;hp=aa7882cd4abd5ec1a9efd80f4caacbc78e4e24b9;hpb=810f7404202e04f70db946ced7363b64ddaf4ce4;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/WarningMessage.cs b/c_sharp/src/org/ldk/structs/WarningMessage.cs index aa7882cd..b9b7b52f 100644 --- a/c_sharp/src/org/ldk/structs/WarningMessage.cs +++ b/c_sharp/src/org/ldk/structs/WarningMessage.cs @@ -7,7 +7,9 @@ namespace org { namespace ldk { namespace structs { /** - * A warning message to be sent or received from a peer + * A [`warning`] message to be sent to or received from a peer. + * + * [`warning`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-error-and-warning-messages */ public class WarningMessage : CommonBase { internal WarningMessage(object _dummy, long ptr) : base(ptr) { } @@ -21,9 +23,11 @@ public class WarningMessage : CommonBase { * All-0s indicates a warning unrelated to a specific channel. */ public byte[] get_channel_id() { - byte[] ret = bindings.WarningMessage_get_channel_id(this.ptr); + long ret = bindings.WarningMessage_get_channel_id(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** @@ -32,31 +36,35 @@ public class WarningMessage : CommonBase { * All-0s indicates a warning unrelated to a specific channel. */ public void set_channel_id(byte[] val) { - bindings.WarningMessage_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32)); + bindings.WarningMessage_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32))); GC.KeepAlive(this); GC.KeepAlive(val); } /** * A possibly human-readable warning description. + * * The string should be sanitized before it is used (e.g. emitted to logs or printed to * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in * the terminal emulator or the logging subsystem. */ public string get_data() { - string ret = bindings.WarningMessage_get_data(this.ptr); + long ret = bindings.WarningMessage_get_data(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + string ret_conv = InternalUtils.decodeString(ret); + return ret_conv; } /** * A possibly human-readable warning description. + * * The string should be sanitized before it is used (e.g. emitted to logs or printed to * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in * the terminal emulator or the logging subsystem. */ public void set_data(string val) { - bindings.WarningMessage_set_data(this.ptr, val); + bindings.WarningMessage_set_data(this.ptr, InternalUtils.encodeString(val)); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -65,7 +73,7 @@ public class WarningMessage : CommonBase { * Constructs a new WarningMessage given each field */ public static WarningMessage of(byte[] channel_id_arg, string data_arg) { - long ret = bindings.WarningMessage_new(InternalUtils.check_arr_len(channel_id_arg, 32), data_arg); + long ret = bindings.WarningMessage_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), InternalUtils.encodeString(data_arg)); GC.KeepAlive(channel_id_arg); GC.KeepAlive(data_arg); if (ret >= 0 && ret <= 4096) { return null; } @@ -113,16 +121,18 @@ public class WarningMessage : CommonBase { * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read */ public byte[] write() { - byte[] ret = bindings.WarningMessage_write(this.ptr); + long ret = bindings.WarningMessage_write(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Read a WarningMessage from a byte array, created by WarningMessage_write */ public static Result_WarningMessageDecodeErrorZ read(byte[] ser) { - long ret = bindings.WarningMessage_read(ser); + long ret = bindings.WarningMessage_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_WarningMessageDecodeErrorZ ret_hu_conv = Result_WarningMessageDecodeErrorZ.constr_from_ptr(ret);