Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / NodeId.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * Represents the compressed public key of a node
12  */
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 {
18                 super.finalize();
19                 if (ptr != 0) { bindings.NodeId_free(ptr); }
20         }
21
22         long clone_ptr() {
23                 long ret = bindings.NodeId_clone_ptr(this.ptr);
24                 return ret;
25         }
26
27         /**
28          * Creates a copy of the NodeId
29          */
30         public NodeId clone() {
31                 long ret = bindings.NodeId_clone(this.ptr);
32                 if (ret >= 0 && ret <= 4096) { return null; }
33                 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
34                 ret_hu_conv.ptrs_to.add(this);
35                 return ret_hu_conv;
36         }
37
38         /**
39          * Create a new NodeId from a public key
40          */
41         public static NodeId from_pubkey(byte[] pubkey) {
42                 long ret = bindings.NodeId_from_pubkey(InternalUtils.check_arr_len(pubkey, 33));
43                 if (ret >= 0 && ret <= 4096) { return null; }
44                 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
45                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
46                 return ret_hu_conv;
47         }
48
49         /**
50          * Get the public key slice from this NodeId
51          */
52         public byte[] as_slice() {
53                 byte[] ret = bindings.NodeId_as_slice(this.ptr);
54                 return ret;
55         }
56
57         /**
58          * Checks if two NodeIds contain equal inner contents.
59          */
60         public long hash() {
61                 long ret = bindings.NodeId_hash(this.ptr);
62                 return ret;
63         }
64
65         /**
66          * Serialize the NodeId object into a byte array which can be read by NodeId_read
67          */
68         public byte[] write() {
69                 byte[] ret = bindings.NodeId_write(this.ptr);
70                 return ret;
71         }
72
73         /**
74          * Read a NodeId from a byte array, created by NodeId_write
75          */
76         public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
77                 long ret = bindings.NodeId_read(ser);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
80                 return ret_hu_conv;
81         }
82
83 }