1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Represents the compressed public key of a node
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class NodeId extends CommonBase {
15 NodeId(Object _dummy, long ptr) { super(ptr); }
16 @Override @SuppressWarnings("deprecation")
17 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.NodeId_free(ptr); }
23 * Creates a copy of the NodeId
25 public NodeId clone() {
26 long ret = bindings.NodeId_clone(this.ptr);
27 if (ret >= 0 && ret < 1024) { return null; }
28 NodeId ret_hu_conv = new NodeId(null, ret);
29 ret_hu_conv.ptrs_to.add(this);
34 * Create a new NodeId from a public key
36 public static NodeId from_pubkey(byte[] pubkey) {
37 long ret = bindings.NodeId_from_pubkey(pubkey);
38 if (ret >= 0 && ret < 1024) { return null; }
39 NodeId ret_hu_conv = new NodeId(null, ret);
40 ret_hu_conv.ptrs_to.add(ret_hu_conv);
45 * Get the public key slice from this NodeId
47 public byte[] as_slice() {
48 byte[] ret = bindings.NodeId_as_slice(this.ptr);
53 * Checks if two NodeIds contain equal inner contents.
56 long ret = bindings.NodeId_hash(this.ptr);
61 * Serialize the NodeId object into a byte array which can be read by NodeId_read
63 public byte[] write() {
64 byte[] ret = bindings.NodeId_write(this.ptr);
69 * Read a NodeId from a byte array, created by NodeId_write
71 public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
72 long ret = bindings.NodeId_read(ser);
73 if (ret >= 0 && ret < 1024) { return null; }
74 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);