6 namespace org { namespace ldk { namespace structs {
10 * Represents the compressed public key of a node
12 public class NodeId : CommonBase {
13 internal NodeId(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.NodeId_free(ptr); }
18 internal long clone_ptr() {
19 long ret = bindings.NodeId_clone_ptr(this.ptr);
25 * Creates a copy of the NodeId
27 public NodeId clone() {
28 long ret = bindings.NodeId_clone(this.ptr);
30 if (ret >= 0 && ret <= 4096) { return null; }
31 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
32 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
37 * Create a new NodeId from a public key
39 public static NodeId from_pubkey(byte[] pubkey) {
40 long ret = bindings.NodeId_from_pubkey(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(pubkey, 33)));
42 if (ret >= 0 && ret <= 4096) { return null; }
43 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
44 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
49 * Get the public key slice from this NodeId
51 public byte[] as_slice() {
52 long ret = bindings.NodeId_as_slice(this.ptr);
54 if (ret >= 0 && ret <= 4096) { return null; }
55 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
60 * Get the public key as an array from this NodeId
62 public byte[] as_array() {
63 long ret = bindings.NodeId_as_array(this.ptr);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
71 * Get the public key from this NodeId
73 public Result_PublicKeySecp256k1ErrorZ as_pubkey() {
74 long ret = bindings.NodeId_as_pubkey(this.ptr);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret);
82 * Generates a non-cryptographic 64-bit hash of the NodeId.
85 long ret = bindings.NodeId_hash(this.ptr);
90 public override int GetHashCode() {
91 return (int)this.hash();
94 * Serialize the NodeId object into a byte array which can be read by NodeId_read
96 public byte[] write() {
97 long ret = bindings.NodeId_write(this.ptr);
99 if (ret >= 0 && ret <= 4096) { return null; }
100 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
105 * Read a NodeId from a byte array, created by NodeId_write
107 public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
108 long ret = bindings.NodeId_read(InternalUtils.encodeUint8Array(ser));
110 if (ret >= 0 && ret <= 4096) { return null; }
111 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);