[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / NextMessageHop.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  * The next hop to forward an onion message along its path.
10  * 
11  * Note that payment blinded paths always specify their next hop using an explicit node id.
12  */
13 public class NextMessageHop : CommonBase {
14         protected NextMessageHop(object _dummy, long ptr) : base(ptr) { }
15         ~NextMessageHop() {
16                 if (ptr != 0) { bindings.NextMessageHop_free(ptr); }
17         }
18
19         internal static NextMessageHop constr_from_ptr(long ptr) {
20                 long raw_ty = bindings.LDKNextMessageHop_ty_from_ptr(ptr);
21                 switch (raw_ty) {
22                         case 0: return new NextMessageHop_NodeId(ptr);
23                         case 1: return new NextMessageHop_ShortChannelId(ptr);
24                         default:
25                                 throw new ArgumentException("Impossible enum variant");
26                 }
27         }
28
29         /** A NextMessageHop of type NodeId */
30         public class NextMessageHop_NodeId : NextMessageHop {
31                 public byte[] node_id;
32                 internal NextMessageHop_NodeId(long ptr) : base(null, ptr) {
33                         long node_id = bindings.LDKNextMessageHop_NodeId_get_node_id(ptr);
34                         byte[] node_id_conv = InternalUtils.decodeUint8Array(node_id);
35                         this.node_id = node_id_conv;
36                 }
37         }
38         /** A NextMessageHop of type ShortChannelId */
39         public class NextMessageHop_ShortChannelId : NextMessageHop {
40                 public long short_channel_id;
41                 internal NextMessageHop_ShortChannelId(long ptr) : base(null, ptr) {
42                         this.short_channel_id = bindings.LDKNextMessageHop_ShortChannelId_get_short_channel_id(ptr);
43                 }
44         }
45         internal long clone_ptr() {
46                 long ret = bindings.NextMessageHop_clone_ptr(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * Creates a copy of the NextMessageHop
53          */
54         public NextMessageHop clone() {
55                 long ret = bindings.NextMessageHop_clone(this.ptr);
56                 GC.KeepAlive(this);
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 org.ldk.structs.NextMessageHop ret_hu_conv = org.ldk.structs.NextMessageHop.constr_from_ptr(ret);
59                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
60                 return ret_hu_conv;
61         }
62
63         /**
64          * Utility method to constructs a new NodeId-variant NextMessageHop
65          */
66         public static NextMessageHop node_id(byte[] a) {
67                 long ret = bindings.NextMessageHop_node_id(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)));
68                 GC.KeepAlive(a);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.NextMessageHop ret_hu_conv = org.ldk.structs.NextMessageHop.constr_from_ptr(ret);
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
72                 return ret_hu_conv;
73         }
74
75         /**
76          * Utility method to constructs a new ShortChannelId-variant NextMessageHop
77          */
78         public static NextMessageHop short_channel_id(long a) {
79                 long ret = bindings.NextMessageHop_short_channel_id(a);
80                 GC.KeepAlive(a);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 org.ldk.structs.NextMessageHop ret_hu_conv = org.ldk.structs.NextMessageHop.constr_from_ptr(ret);
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
84                 return ret_hu_conv;
85         }
86
87         /**
88          * Generates a non-cryptographic 64-bit hash of the NextMessageHop.
89          */
90         public long hash() {
91                 long ret = bindings.NextMessageHop_hash(this.ptr);
92                 GC.KeepAlive(this);
93                 return ret;
94         }
95
96         public override int GetHashCode() {
97                 return (int)this.hash();
98         }
99         /**
100          * Checks if two NextMessageHops contain equal inner contents.
101          * This ignores pointers and is_owned flags and looks at the values in fields.
102          */
103         public bool eq(org.ldk.structs.NextMessageHop b) {
104                 bool ret = bindings.NextMessageHop_eq(this.ptr, b.ptr);
105                 GC.KeepAlive(this);
106                 GC.KeepAlive(b);
107                 return ret;
108         }
109
110         public override bool Equals(object o) {
111                 if (!(o is NextMessageHop)) return false;
112                 return this.eq((NextMessageHop)o);
113         }
114 }
115 } } }