[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / Destination.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 destination of an onion message.
10  */
11 public class Destination : CommonBase {
12         protected Destination(object _dummy, long ptr) : base(ptr) { }
13         ~Destination() {
14                 if (ptr != 0) { bindings.Destination_free(ptr); }
15         }
16
17         internal static Destination constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKDestination_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new Destination_Node(ptr);
21                         case 1: return new Destination_BlindedPath(ptr);
22                         default:
23                                 throw new ArgumentException("Impossible enum variant");
24                 }
25         }
26
27         /** A Destination of type Node */
28         public class Destination_Node : Destination {
29                 public byte[] node;
30                 internal Destination_Node(long ptr) : base(null, ptr) {
31                         long node = bindings.LDKDestination_Node_get_node(ptr);
32                         byte[] node_conv = InternalUtils.decodeUint8Array(node);
33                         this.node = node_conv;
34                 }
35         }
36         /** A Destination of type BlindedPath */
37         public class Destination_BlindedPath : Destination {
38                 public BlindedPath blinded_path;
39                 internal Destination_BlindedPath(long ptr) : base(null, ptr) {
40                         long blinded_path = bindings.LDKDestination_BlindedPath_get_blinded_path(ptr);
41                         org.ldk.structs.BlindedPath blinded_path_hu_conv = null; if (blinded_path < 0 || blinded_path > 4096) { blinded_path_hu_conv = new org.ldk.structs.BlindedPath(null, blinded_path); }
42                         if (blinded_path_hu_conv != null) { blinded_path_hu_conv.ptrs_to.AddLast(this); };
43                         this.blinded_path = blinded_path_hu_conv;
44                 }
45         }
46         internal long clone_ptr() {
47                 long ret = bindings.Destination_clone_ptr(this.ptr);
48                 GC.KeepAlive(this);
49                 return ret;
50         }
51
52         /**
53          * Creates a copy of the Destination
54          */
55         public Destination clone() {
56                 long ret = bindings.Destination_clone(this.ptr);
57                 GC.KeepAlive(this);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
60                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
61                 return ret_hu_conv;
62         }
63
64         /**
65          * Utility method to constructs a new Node-variant Destination
66          */
67         public static Destination node(byte[] a) {
68                 long ret = bindings.Destination_node(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)));
69                 GC.KeepAlive(a);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Utility method to constructs a new BlindedPath-variant Destination
78          */
79         public static Destination blinded_path(org.ldk.structs.BlindedPath a) {
80                 long ret = bindings.Destination_blinded_path(a.ptr);
81                 GC.KeepAlive(a);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret);
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Generates a non-cryptographic 64-bit hash of the Destination.
91          */
92         public long hash() {
93                 long ret = bindings.Destination_hash(this.ptr);
94                 GC.KeepAlive(this);
95                 return ret;
96         }
97
98         public override int GetHashCode() {
99                 return (int)this.hash();
100         }
101         /**
102          * Checks if two Destinations contain equal inner contents.
103          * This ignores pointers and is_owned flags and looks at the values in fields.
104          */
105         public bool eq(org.ldk.structs.Destination b) {
106                 bool ret = bindings.Destination_eq(this.ptr, b.ptr);
107                 GC.KeepAlive(this);
108                 GC.KeepAlive(b);
109                 return ret;
110         }
111
112         public override bool Equals(object o) {
113                 if (!(o is Destination)) return false;
114                 return this.eq((Destination)o);
115         }
116         /**
117          * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a
118          * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the
119          * provided [`ReadOnlyNetworkGraph`].
120          */
121         public void resolve(org.ldk.structs.ReadOnlyNetworkGraph network_graph) {
122                 bindings.Destination_resolve(this.ptr, network_graph.ptr);
123                 GC.KeepAlive(this);
124                 GC.KeepAlive(network_graph);
125                 if (this != null) { this.ptrs_to.AddLast(network_graph); };
126         }
127
128 }
129 } } }