b0cb8e6b8eec0c59646dc7b56799745f3c1e3910
[ldk-java] / c_sharp / src / org / ldk / structs / NodeAlias.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  * A user-defined name for a node, which may be used when displaying the node in a graph.
11  * 
12  * Since node aliases are provided by third parties, they are a potential avenue for injection
13  * attacks. Care must be taken when processing.
14  */
15 public class NodeAlias : CommonBase {
16         internal NodeAlias(object _dummy, long ptr) : base(ptr) { }
17         ~NodeAlias() {
18                 if (ptr != 0) { bindings.NodeAlias_free(ptr); }
19         }
20
21         public byte[] get_a() {
22                 byte[] ret = bindings.NodeAlias_get_a(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         public void set_a(byte[] val) {
28                 bindings.NodeAlias_set_a(this.ptr, InternalUtils.check_arr_len(val, 32));
29                 GC.KeepAlive(this);
30                 GC.KeepAlive(val);
31         }
32
33         /**
34          * Constructs a new NodeAlias given each field
35          */
36         public static NodeAlias of(byte[] a_arg) {
37                 long ret = bindings.NodeAlias_new(InternalUtils.check_arr_len(a_arg, 32));
38                 GC.KeepAlive(a_arg);
39                 if (ret >= 0 && ret <= 4096) { return null; }
40                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
41                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
42                 return ret_hu_conv;
43         }
44
45         internal long clone_ptr() {
46                 long ret = bindings.NodeAlias_clone_ptr(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * Creates a copy of the NodeAlias
53          */
54         public NodeAlias clone() {
55                 long ret = bindings.NodeAlias_clone(this.ptr);
56                 GC.KeepAlive(this);
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 org.ldk.structs.NodeAlias ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeAlias(null, ret); }
59                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
60                 return ret_hu_conv;
61         }
62
63         /**
64          * Checks if two NodeAliass contain equal inner contents.
65          * This ignores pointers and is_owned flags and looks at the values in fields.
66          * Two objects with NULL inner values will be considered "equal" here.
67          */
68         public bool eq(org.ldk.structs.NodeAlias b) {
69                 bool ret = bindings.NodeAlias_eq(this.ptr, b == null ? 0 : b.ptr);
70                 GC.KeepAlive(this);
71                 GC.KeepAlive(b);
72                 if (this != null) { this.ptrs_to.AddLast(b); };
73                 return ret;
74         }
75
76         public override bool Equals(object o) {
77                 if (!(o is NodeAlias)) return false;
78                 return this.eq((NodeAlias)o);
79         }
80         /**
81          * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read
82          */
83         public byte[] write() {
84                 byte[] ret = bindings.NodeAlias_write(this.ptr);
85                 GC.KeepAlive(this);
86                 return ret;
87         }
88
89         /**
90          * Read a NodeAlias from a byte array, created by NodeAlias_write
91          */
92         public static Result_NodeAliasDecodeErrorZ read(byte[] ser) {
93                 long ret = bindings.NodeAlias_read(ser);
94                 GC.KeepAlive(ser);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 Result_NodeAliasDecodeErrorZ ret_hu_conv = Result_NodeAliasDecodeErrorZ.constr_from_ptr(ret);
97                 return ret_hu_conv;
98         }
99
100 }
101 } } }