X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FNodeId.cs;h=c994ad56c6623d3808ee7fa500b1faa24f753901;hb=HEAD;hp=b4924b5d0157cc5a2f1d76b5bf3a0f94c4d925cf;hpb=7811d2191440c55034e1abfbf3be442d4b25481b;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/NodeId.cs b/c_sharp/src/org/ldk/structs/NodeId.cs index b4924b5d..a7a211ad 100644 --- a/c_sharp/src/org/ldk/structs/NodeId.cs +++ b/c_sharp/src/org/ldk/structs/NodeId.cs @@ -37,7 +37,7 @@ public class NodeId : CommonBase { * Create a new NodeId from a public key */ public static NodeId from_pubkey(byte[] pubkey) { - long ret = bindings.NodeId_from_pubkey(InternalUtils.check_arr_len(pubkey, 33)); + long ret = bindings.NodeId_from_pubkey(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pubkey, 33))); GC.KeepAlive(pubkey); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); } @@ -45,26 +45,61 @@ public class NodeId : CommonBase { return ret_hu_conv; } + /** + * Create a new NodeId from a slice of bytes + */ + public static Result_NodeIdDecodeErrorZ from_slice(byte[] bytes) { + long ret = bindings.NodeId_from_slice(InternalUtils.encodeUint8Array(bytes)); + GC.KeepAlive(bytes); + if (ret >= 0 && ret <= 4096) { return null; } + Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Get the public key slice from this NodeId */ public byte[] as_slice() { - byte[] ret = bindings.NodeId_as_slice(this.ptr); + long ret = bindings.NodeId_as_slice(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; + } + + /** + * Get the public key as an array from this NodeId + */ + public byte[] as_array() { + long ret = bindings.NodeId_as_array(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** * Get the public key from this NodeId */ - public Result_PublicKeyErrorZ as_pubkey() { + public Result_PublicKeySecp256k1ErrorZ as_pubkey() { long ret = bindings.NodeId_as_pubkey(this.ptr); GC.KeepAlive(this); if (ret >= 0 && ret <= 4096) { return null; } - Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret); + Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret); return ret_hu_conv; } + /** + * Get the string representation of a NodeId object + */ + public string to_str() { + long ret = bindings.NodeId_to_str(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + string ret_conv = InternalUtils.decodeString(ret); + return ret_conv; + } + /** * Generates a non-cryptographic 64-bit hash of the NodeId. */ @@ -81,16 +116,18 @@ public class NodeId : CommonBase { * Serialize the NodeId object into a byte array which can be read by NodeId_read */ public byte[] write() { - byte[] ret = bindings.NodeId_write(this.ptr); + long ret = bindings.NodeId_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 NodeId from a byte array, created by NodeId_write */ public static Result_NodeIdDecodeErrorZ read(byte[] ser) { - long ret = bindings.NodeId_read(ser); + long ret = bindings.NodeId_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);