Update auto-generated bindings to 0.0.103
[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         /**
23          * Creates a copy of the NodeId
24          */
25         public NodeId clone() {
26                 long ret = bindings.NodeId_clone(this.ptr);
27                 if (ret >= 0 && ret <= 4096) { return null; }
28                 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
29                 ret_hu_conv.ptrs_to.add(this);
30                 return ret_hu_conv;
31         }
32
33         /**
34          * Create a new NodeId from a public key
35          */
36         public static NodeId from_pubkey(byte[] pubkey) {
37                 long ret = bindings.NodeId_from_pubkey(pubkey);
38                 if (ret >= 0 && ret <= 4096) { return null; }
39                 NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new NodeId(null, ret); }
40                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
41                 return ret_hu_conv;
42         }
43
44         /**
45          * Get the public key slice from this NodeId
46          */
47         public byte[] as_slice() {
48                 byte[] ret = bindings.NodeId_as_slice(this.ptr);
49                 return ret;
50         }
51
52         /**
53          * Checks if two NodeIds contain equal inner contents.
54          */
55         public long hash() {
56                 long ret = bindings.NodeId_hash(this.ptr);
57                 return ret;
58         }
59
60         /**
61          * Serialize the NodeId object into a byte array which can be read by NodeId_read
62          */
63         public byte[] write() {
64                 byte[] ret = bindings.NodeId_write(this.ptr);
65                 return ret;
66         }
67
68         /**
69          * Read a NodeId from a byte array, created by NodeId_write
70          */
71         public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
72                 long ret = bindings.NodeId_read(ser);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
75                 return ret_hu_conv;
76         }
77
78 }