6 namespace org { namespace ldk { namespace structs {
9 * The destination of an onion message.
11 public class Destination : CommonBase {
12 protected Destination(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.Destination_free(ptr); }
17 internal static Destination constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKDestination_ty_from_ptr(ptr);
20 case 0: return new Destination_Node(ptr);
21 case 1: return new Destination_BlindedPath(ptr);
23 throw new ArgumentException("Impossible enum variant");
27 /** A Destination of type Node */
28 public class Destination_Node : Destination {
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;
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;
46 internal long clone_ptr() {
47 long ret = bindings.Destination_clone_ptr(this.ptr);
53 * Creates a copy of the Destination
55 public Destination clone() {
56 long ret = bindings.Destination_clone(this.ptr);
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); };
65 * Utility method to constructs a new Node-variant Destination
67 public static Destination node(byte[] a) {
68 long ret = bindings.Destination_node(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)));
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); };
77 * Utility method to constructs a new BlindedPath-variant Destination
79 public static Destination blinded_path(org.ldk.structs.BlindedPath a) {
80 long ret = bindings.Destination_blinded_path(a.ptr);
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); };
90 * Generates a non-cryptographic 64-bit hash of the Destination.
93 long ret = bindings.Destination_hash(this.ptr);
98 public override int GetHashCode() {
99 return (int)this.hash();
102 * Checks if two Destinations contain equal inner contents.
103 * This ignores pointers and is_owned flags and looks at the values in fields.
105 public bool eq(org.ldk.structs.Destination b) {
106 bool ret = bindings.Destination_eq(this.ptr, b.ptr);
112 public override bool Equals(object o) {
113 if (!(o is Destination)) return false;
114 return this.eq((Destination)o);
117 * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a
118 * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the
119 * provided [`ReadOnlyNetworkGraph`].
121 public void resolve(org.ldk.structs.ReadOnlyNetworkGraph network_graph) {
122 bindings.Destination_resolve(this.ptr, network_graph.ptr);
124 GC.KeepAlive(network_graph);
125 if (this != null) { this.ptrs_to.AddLast(network_graph); };