[C#] Update auto-generated C# bindings
[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.encodeUint8Array(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                 long ret = bindings.NodeId_as_slice(this.ptr);
53                 GC.KeepAlive(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
56                 return ret_conv;
57         }
58
59         /**
60          * Get the public key from this NodeId
61          */
62         public Result_PublicKeySecp256k1ErrorZ as_pubkey() {
63                 long ret = bindings.NodeId_as_pubkey(this.ptr);
64                 GC.KeepAlive(this);
65                 if (ret >= 0 && ret <= 4096) { return null; }
66                 Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret);
67                 return ret_hu_conv;
68         }
69
70         /**
71          * Generates a non-cryptographic 64-bit hash of the NodeId.
72          */
73         public long hash() {
74                 long ret = bindings.NodeId_hash(this.ptr);
75                 GC.KeepAlive(this);
76                 return ret;
77         }
78
79         public override int GetHashCode() {
80                 return (int)this.hash();
81         }
82         /**
83          * Serialize the NodeId object into a byte array which can be read by NodeId_read
84          */
85         public byte[] write() {
86                 long ret = bindings.NodeId_write(this.ptr);
87                 GC.KeepAlive(this);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
90                 return ret_conv;
91         }
92
93         /**
94          * Read a NodeId from a byte array, created by NodeId_write
95          */
96         public static Result_NodeIdDecodeErrorZ read(byte[] ser) {
97                 long ret = bindings.NodeId_read(InternalUtils.encodeUint8Array(ser));
98                 GC.KeepAlive(ser);
99                 if (ret >= 0 && ret <= 4096) { return null; }
100                 Result_NodeIdDecodeErrorZ ret_hu_conv = Result_NodeIdDecodeErrorZ.constr_from_ptr(ret);
101                 return ret_hu_conv;
102         }
103
104 }
105 } } }