[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / NodeId.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Represents the compressed public key of a node
11  */
12 public class NodeId : CommonBase {
13         internal NodeId(object _dummy, long ptr) : base(ptr) { }
14         ~NodeId() {
15                 if (ptr != 0) { bindings.NodeId_free(ptr); }
16         }
17
18         internal long clone_ptr() {
19                 long ret = bindings.NodeId_clone_ptr(this.ptr);
20                 GC.KeepAlive(this);
21                 return ret;
22         }
23
24         /**
25          * Creates a copy of the NodeId
26          */
27         public NodeId clone() {
28                 long ret = bindings.NodeId_clone(this.ptr);
29                 GC.KeepAlive(this);
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); };
33                 return ret_hu_conv;
34         }
35
36         /**
37          * Create a new NodeId from a public key
38          */
39         public static NodeId from_pubkey(byte[] pubkey) {
40                 long ret = bindings.NodeId_from_pubkey(InternalUtils.check_arr_len(pubkey, 33));
41                 GC.KeepAlive(pubkey);
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); };
45                 return ret_hu_conv;
46         }
47
48         /**
49          * Get the public key slice from this NodeId
50          */
51         public byte[] as_slice() {
52                 byte[] ret = bindings.NodeId_as_slice(this.ptr);
53                 GC.KeepAlive(this);
54                 return ret;
55         }
56
57         /**
58          * Get the public key from this NodeId
59          */
60         public Result_PublicKeyErrorZ as_pubkey() {
61                 long ret = bindings.NodeId_as_pubkey(this.ptr);
62                 GC.KeepAlive(this);
63                 if (ret >= 0 && ret <= 4096) { return null; }
64                 Result_PublicKeyErrorZ ret_hu_conv = Result_PublicKeyErrorZ.constr_from_ptr(ret);
65                 return ret_hu_conv;
66         }
67
68         /**
69          * Generates a non-cryptographic 64-bit hash of the NodeId.
70          */
71         public long hash() {
72                 long ret = bindings.NodeId_hash(this.ptr);
73                 GC.KeepAlive(this);
74                 return ret;
75         }
76
77         public override int GetHashCode() {
78                 return (int)this.hash();
79         }
80         /**
81          * Serialize the NodeId object into a byte array which can be read by NodeId_read
82          */
83         public byte[] write() {
84                 byte[] ret = bindings.NodeId_write(this.ptr);
85                 GC.KeepAlive(this);
86                 return ret;
87         }
88
89         /**
90          * Read a NodeId from a byte array, created by NodeId_write
91          */
92         public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
93                 long ret = bindings.NodeId_read(ser);
94                 GC.KeepAlive(ser);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
97                 return ret_hu_conv;
98         }
99
100 }
101 } } }