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 * Create a new NodeId from a slice of bytes
51 public static Result_NodeIdDecodeErrorZ from_slice(byte[] bytes) {
52 long ret = bindings.NodeId_from_slice(InternalUtils.encodeUint8Array(bytes));
54 if (ret >= 0 && ret <= 4096) { return null; }
55 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
60 * Get the public key slice from this NodeId
62 public byte[] as_slice() {
63 long ret = bindings.NodeId_as_slice(this.ptr);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
71 * Get the public key as an array from this NodeId
73 public byte[] as_array() {
74 long ret = bindings.NodeId_as_array(this.ptr);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
82 * Get the public key from this NodeId
84 public Result_PublicKeySecp256k1ErrorZ as_pubkey() {
85 long ret = bindings.NodeId_as_pubkey(this.ptr);
87 if (ret >= 0 && ret <= 4096) { return null; }
88 Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret);
93 * Generates a non-cryptographic 64-bit hash of the NodeId.
96 long ret = bindings.NodeId_hash(this.ptr);
101 public override int GetHashCode() {
102 return (int)this.hash();
105 * Serialize the NodeId object into a byte array which can be read by NodeId_read
107 public byte[] write() {
108 long ret = bindings.NodeId_write(this.ptr);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
116 * Read a NodeId from a byte array, created by NodeId_write
118 public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
119 long ret = bindings.NodeId_read(InternalUtils.encodeUint8Array(ser));
121 if (ret >= 0 && ret <= 4096) { return null; }
122 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);