X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FDestination.cs;h=74cf38c85afd63228a88e1cb5212f0fe3995165f;hb=152d721883552dd92925833d15687d7d64d01c35;hp=1fd19a55f81ad9654931fbbe2cc299f56ab09e84;hpb=810f7404202e04f70db946ced7363b64ddaf4ce4;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/Destination.cs b/c_sharp/src/org/ldk/structs/Destination.cs index 1fd19a55..74cf38c8 100644 --- a/c_sharp/src/org/ldk/structs/Destination.cs +++ b/c_sharp/src/org/ldk/structs/Destination.cs @@ -28,7 +28,9 @@ public class Destination : CommonBase { public class Destination_Node : Destination { public byte[] node; internal Destination_Node(long ptr) : base(null, ptr) { - this.node = bindings.LDKDestination_Node_get_node(ptr); + long node = bindings.LDKDestination_Node_get_node(ptr); + byte[] node_conv = InternalUtils.decodeUint8Array(node); + this.node = node_conv; } } /** A Destination of type BlindedPath */ @@ -63,7 +65,7 @@ public class Destination : CommonBase { * Utility method to constructs a new Node-variant Destination */ public static Destination node(byte[] a) { - long ret = bindings.Destination_node(InternalUtils.check_arr_len(a, 33)); + long ret = bindings.Destination_node(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33))); GC.KeepAlive(a); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret); @@ -75,7 +77,7 @@ public class Destination : CommonBase { * Utility method to constructs a new BlindedPath-variant Destination */ public static Destination blinded_path(org.ldk.structs.BlindedPath a) { - long ret = bindings.Destination_blinded_path(a == null ? 0 : a.ptr); + long ret = bindings.Destination_blinded_path(a.ptr); GC.KeepAlive(a); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Destination ret_hu_conv = org.ldk.structs.Destination.constr_from_ptr(ret); @@ -84,5 +86,44 @@ public class Destination : CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the Destination. + */ + public long hash() { + long ret = bindings.Destination_hash(this.ptr); + GC.KeepAlive(this); + return ret; + } + + public override int GetHashCode() { + return (int)this.hash(); + } + /** + * Checks if two Destinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ + public bool eq(org.ldk.structs.Destination b) { + bool ret = bindings.Destination_eq(this.ptr, b.ptr); + GC.KeepAlive(this); + GC.KeepAlive(b); + return ret; + } + + public override bool Equals(object o) { + if (!(o is Destination)) return false; + return this.eq((Destination)o); + } + /** + * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a + * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the + * provided [`ReadOnlyNetworkGraph`]. + */ + public void resolve(org.ldk.structs.ReadOnlyNetworkGraph network_graph) { + bindings.Destination_resolve(this.ptr, network_graph.ptr); + GC.KeepAlive(this); + GC.KeepAlive(network_graph); + if (this != null) { this.ptrs_to.AddLast(network_graph); }; + } + } } } }