X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FInvoiceError.cs;h=d797add872105ccea32d87b19bf8499070dcd607;hb=8de7213fbf663ff60322896282dad51e8ab2f001;hp=36e7b87d97aa70ddb4df599d4f6b2d787f57e232;hpb=afc50e5d491a11364849383b75a8f939df703bac;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/InvoiceError.cs b/c_sharp/src/org/ldk/structs/InvoiceError.cs index 36e7b87d..d797add8 100644 --- a/c_sharp/src/org/ldk/structs/InvoiceError.cs +++ b/c_sharp/src/org/ldk/structs/InvoiceError.cs @@ -74,6 +74,8 @@ public class InvoiceError : CommonBase { /** * Constructs a new InvoiceError given each field + * + * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ public static InvoiceError of(org.ldk.structs.ErroneousField erroneous_field_arg, org.ldk.structs.UntrustedString message_arg) { long ret = bindings.InvoiceError_new(erroneous_field_arg == null ? 0 : erroneous_field_arg.ptr, message_arg == null ? 0 : message_arg.ptr); @@ -105,20 +107,34 @@ public class InvoiceError : CommonBase { return ret_hu_conv; } + /** + * Creates an [`InvoiceError`] with the given message. + */ + public static InvoiceError from_string(string s) { + long ret = bindings.InvoiceError_from_string(InternalUtils.encodeString(s)); + GC.KeepAlive(s); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.InvoiceError ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceError(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; + return ret_hu_conv; + } + /** * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read */ public byte[] write() { - byte[] ret = bindings.InvoiceError_write(this.ptr); + long ret = bindings.InvoiceError_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 InvoiceError from a byte array, created by InvoiceError_write */ public static Result_InvoiceErrorDecodeErrorZ read(byte[] ser) { - long ret = bindings.InvoiceError_read(ser); + long ret = bindings.InvoiceError_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_InvoiceErrorDecodeErrorZ ret_hu_conv = Result_InvoiceErrorDecodeErrorZ.constr_from_ptr(ret);