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.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 byte[] ret = bindings.NodeId_as_slice(this.ptr);
58 * Get the public key from this NodeId
60 public Result_PublicKeyErrorZ as_pubkey() {
61 long ret = bindings.NodeId_as_pubkey(this.ptr);
63 if (ret >= 0 && ret <= 4096) { return null; }
64 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
69 * Generates a non-cryptographic 64-bit hash of the NodeId.
72 long ret = bindings.NodeId_hash(this.ptr);
77 public override int GetHashCode() {
78 return (int)this.hash();
81 * Serialize the NodeId object into a byte array which can be read by NodeId_read
83 public byte[] write() {
84 byte[] ret = bindings.NodeId_write(this.ptr);
90 * Read a NodeId from a byte array, created by NodeId_write
92 public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
93 long ret = bindings.NodeId_read(ser);
95 if (ret >= 0 && ret <= 4096) { return null; }
96 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);