6 namespace org { namespace ldk { namespace structs {
9 * A wrapper around the various hop representations.
11 * Can be used to examine the properties of a hop,
12 * potentially to decide whether to include it in a route.
14 public class CandidateRouteHop : CommonBase {
15 protected CandidateRouteHop(object _dummy, long ptr) : base(ptr) { }
16 ~CandidateRouteHop() {
17 if (ptr != 0) { bindings.CandidateRouteHop_free(ptr); }
20 internal static CandidateRouteHop constr_from_ptr(long ptr) {
21 long raw_ty = bindings.LDKCandidateRouteHop_ty_from_ptr(ptr);
23 case 0: return new CandidateRouteHop_FirstHop(ptr);
24 case 1: return new CandidateRouteHop_PublicHop(ptr);
25 case 2: return new CandidateRouteHop_PrivateHop(ptr);
26 case 3: return new CandidateRouteHop_Blinded(ptr);
27 case 4: return new CandidateRouteHop_OneHopBlinded(ptr);
29 throw new ArgumentException("Impossible enum variant");
33 /** A CandidateRouteHop of type FirstHop */
34 public class CandidateRouteHop_FirstHop : CandidateRouteHop {
35 public FirstHopCandidate first_hop;
36 internal CandidateRouteHop_FirstHop(long ptr) : base(null, ptr) {
37 long first_hop = bindings.LDKCandidateRouteHop_FirstHop_get_first_hop(ptr);
38 org.ldk.structs.FirstHopCandidate first_hop_hu_conv = null; if (first_hop < 0 || first_hop > 4096) { first_hop_hu_conv = new org.ldk.structs.FirstHopCandidate(null, first_hop); }
39 if (first_hop_hu_conv != null) { first_hop_hu_conv.ptrs_to.AddLast(this); };
40 this.first_hop = first_hop_hu_conv;
43 /** A CandidateRouteHop of type PublicHop */
44 public class CandidateRouteHop_PublicHop : CandidateRouteHop {
45 public PublicHopCandidate public_hop;
46 internal CandidateRouteHop_PublicHop(long ptr) : base(null, ptr) {
47 long public_hop = bindings.LDKCandidateRouteHop_PublicHop_get_public_hop(ptr);
48 org.ldk.structs.PublicHopCandidate public_hop_hu_conv = null; if (public_hop < 0 || public_hop > 4096) { public_hop_hu_conv = new org.ldk.structs.PublicHopCandidate(null, public_hop); }
49 if (public_hop_hu_conv != null) { public_hop_hu_conv.ptrs_to.AddLast(this); };
50 this.public_hop = public_hop_hu_conv;
53 /** A CandidateRouteHop of type PrivateHop */
54 public class CandidateRouteHop_PrivateHop : CandidateRouteHop {
55 public PrivateHopCandidate private_hop;
56 internal CandidateRouteHop_PrivateHop(long ptr) : base(null, ptr) {
57 long private_hop = bindings.LDKCandidateRouteHop_PrivateHop_get_private_hop(ptr);
58 org.ldk.structs.PrivateHopCandidate private_hop_hu_conv = null; if (private_hop < 0 || private_hop > 4096) { private_hop_hu_conv = new org.ldk.structs.PrivateHopCandidate(null, private_hop); }
59 if (private_hop_hu_conv != null) { private_hop_hu_conv.ptrs_to.AddLast(this); };
60 this.private_hop = private_hop_hu_conv;
63 /** A CandidateRouteHop of type Blinded */
64 public class CandidateRouteHop_Blinded : CandidateRouteHop {
65 public BlindedPathCandidate blinded;
66 internal CandidateRouteHop_Blinded(long ptr) : base(null, ptr) {
67 long blinded = bindings.LDKCandidateRouteHop_Blinded_get_blinded(ptr);
68 org.ldk.structs.BlindedPathCandidate blinded_hu_conv = null; if (blinded < 0 || blinded > 4096) { blinded_hu_conv = new org.ldk.structs.BlindedPathCandidate(null, blinded); }
69 if (blinded_hu_conv != null) { blinded_hu_conv.ptrs_to.AddLast(this); };
70 this.blinded = blinded_hu_conv;
73 /** A CandidateRouteHop of type OneHopBlinded */
74 public class CandidateRouteHop_OneHopBlinded : CandidateRouteHop {
75 public OneHopBlindedPathCandidate one_hop_blinded;
76 internal CandidateRouteHop_OneHopBlinded(long ptr) : base(null, ptr) {
77 long one_hop_blinded = bindings.LDKCandidateRouteHop_OneHopBlinded_get_one_hop_blinded(ptr);
78 org.ldk.structs.OneHopBlindedPathCandidate one_hop_blinded_hu_conv = null; if (one_hop_blinded < 0 || one_hop_blinded > 4096) { one_hop_blinded_hu_conv = new org.ldk.structs.OneHopBlindedPathCandidate(null, one_hop_blinded); }
79 if (one_hop_blinded_hu_conv != null) { one_hop_blinded_hu_conv.ptrs_to.AddLast(this); };
80 this.one_hop_blinded = one_hop_blinded_hu_conv;
83 internal long clone_ptr() {
84 long ret = bindings.CandidateRouteHop_clone_ptr(this.ptr);
90 * Creates a copy of the CandidateRouteHop
92 public CandidateRouteHop clone() {
93 long ret = bindings.CandidateRouteHop_clone(this.ptr);
95 if (ret >= 0 && ret <= 4096) { return null; }
96 org.ldk.structs.CandidateRouteHop ret_hu_conv = org.ldk.structs.CandidateRouteHop.constr_from_ptr(ret);
97 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
102 * Utility method to constructs a new FirstHop-variant CandidateRouteHop
104 public static CandidateRouteHop first_hop(org.ldk.structs.FirstHopCandidate a) {
105 long ret = bindings.CandidateRouteHop_first_hop(a.ptr);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.CandidateRouteHop ret_hu_conv = org.ldk.structs.CandidateRouteHop.constr_from_ptr(ret);
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
115 * Utility method to constructs a new PublicHop-variant CandidateRouteHop
117 public static CandidateRouteHop public_hop(org.ldk.structs.PublicHopCandidate a) {
118 long ret = bindings.CandidateRouteHop_public_hop(a.ptr);
120 if (ret >= 0 && ret <= 4096) { return null; }
121 org.ldk.structs.CandidateRouteHop ret_hu_conv = org.ldk.structs.CandidateRouteHop.constr_from_ptr(ret);
122 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
123 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
128 * Utility method to constructs a new PrivateHop-variant CandidateRouteHop
130 public static CandidateRouteHop private_hop(org.ldk.structs.PrivateHopCandidate a) {
131 long ret = bindings.CandidateRouteHop_private_hop(a.ptr);
133 if (ret >= 0 && ret <= 4096) { return null; }
134 org.ldk.structs.CandidateRouteHop ret_hu_conv = org.ldk.structs.CandidateRouteHop.constr_from_ptr(ret);
135 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
136 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
141 * Utility method to constructs a new Blinded-variant CandidateRouteHop
143 public static CandidateRouteHop blinded(org.ldk.structs.BlindedPathCandidate a) {
144 long ret = bindings.CandidateRouteHop_blinded(a.ptr);
146 if (ret >= 0 && ret <= 4096) { return null; }
147 org.ldk.structs.CandidateRouteHop ret_hu_conv = org.ldk.structs.CandidateRouteHop.constr_from_ptr(ret);
148 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
149 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
154 * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop
156 public static CandidateRouteHop one_hop_blinded(org.ldk.structs.OneHopBlindedPathCandidate a) {
157 long ret = bindings.CandidateRouteHop_one_hop_blinded(a.ptr);
159 if (ret >= 0 && ret <= 4096) { return null; }
160 org.ldk.structs.CandidateRouteHop ret_hu_conv = org.ldk.structs.CandidateRouteHop.constr_from_ptr(ret);
161 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
162 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
167 * Returns the globally unique short channel ID for this hop, if one is known.
169 * This only returns `Some` if the channel is public (either our own, or one we've learned
170 * from the public network graph), and thus the short channel ID we have for this channel is
171 * globally unique and identifies this channel in a global namespace.
173 public Option_u64Z globally_unique_short_channel_id() {
174 long ret = bindings.CandidateRouteHop_globally_unique_short_channel_id(this.ptr);
176 if (ret >= 0 && ret <= 4096) { return null; }
177 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
178 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
183 * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the
184 * next-hop for an HTLC taking this hop.
186 * This is the time that the node(s) in this hop have to claim the HTLC on-chain if the
187 * next-hop goes on chain with a payment preimage.
189 public int cltv_expiry_delta() {
190 int ret = bindings.CandidateRouteHop_cltv_expiry_delta(this.ptr);
196 * Returns the minimum amount that can be sent over this hop, in millisatoshis.
198 public long htlc_minimum_msat() {
199 long ret = bindings.CandidateRouteHop_htlc_minimum_msat(this.ptr);
205 * Returns the fees that must be paid to route an HTLC over this channel.
207 public RoutingFees fees() {
208 long ret = bindings.CandidateRouteHop_fees(this.ptr);
210 if (ret >= 0 && ret <= 4096) { return null; }
211 org.ldk.structs.RoutingFees ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RoutingFees(null, ret); }
212 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
217 * Returns the source node id of current hop.
219 * Source node id refers to the node forwarding the HTLC through this hop.
221 * For [`Self::FirstHop`] we return payer's node id.
223 public NodeId source() {
224 long ret = bindings.CandidateRouteHop_source(this.ptr);
226 if (ret >= 0 && ret <= 4096) { return null; }
227 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
228 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
233 * Returns the target node id of this hop, if known.
235 * Target node id refers to the node receiving the HTLC after this hop.
237 * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded
240 * For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source,
241 * and such a return value would be somewhat nonsensical.
243 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
245 public NodeId target() {
246 long ret = bindings.CandidateRouteHop_target(this.ptr);
248 if (ret >= 0 && ret <= 4096) { return null; }
249 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
250 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };