6 namespace org { namespace ldk { namespace structs {
9 * The next hop to forward an onion message along its path.
11 * Note that payment blinded paths always specify their next hop using an explicit node id.
13 public class NextMessageHop : CommonBase {
14 protected NextMessageHop(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.NextMessageHop_free(ptr); }
19 internal static NextMessageHop constr_from_ptr(long ptr) {
20 long raw_ty = bindings.LDKNextMessageHop_ty_from_ptr(ptr);
22 case 0: return new NextMessageHop_NodeId(ptr);
23 case 1: return new NextMessageHop_ShortChannelId(ptr);
25 throw new ArgumentException("Impossible enum variant");
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;
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);
45 internal long clone_ptr() {
46 long ret = bindings.NextMessageHop_clone_ptr(this.ptr);
52 * Creates a copy of the NextMessageHop
54 public NextMessageHop clone() {
55 long ret = bindings.NextMessageHop_clone(this.ptr);
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); };
64 * Utility method to constructs a new NodeId-variant NextMessageHop
66 public static NextMessageHop node_id(byte[] a) {
67 long ret = bindings.NextMessageHop_node_id(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)));
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); };
76 * Utility method to constructs a new ShortChannelId-variant NextMessageHop
78 public static NextMessageHop short_channel_id(long a) {
79 long ret = bindings.NextMessageHop_short_channel_id(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); };
88 * Generates a non-cryptographic 64-bit hash of the NextMessageHop.
91 long ret = bindings.NextMessageHop_hash(this.ptr);
96 public override int GetHashCode() {
97 return (int)this.hash();
100 * Checks if two NextMessageHops contain equal inner contents.
101 * This ignores pointers and is_owned flags and looks at the values in fields.
103 public bool eq(org.ldk.structs.NextMessageHop b) {
104 bool ret = bindings.NextMessageHop_eq(this.ptr, b.ptr);
110 public override bool Equals(object o) {
111 if (!(o is NextMessageHop)) return false;
112 return this.eq((NextMessageHop)o);