[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / CandidateRouteHop.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  * A wrapper around the various hop representations.
10  * 
11  * Can be used to examine the properties of a hop,
12  * potentially to decide whether to include it in a route.
13  */
14 public class CandidateRouteHop : CommonBase {
15         protected CandidateRouteHop(object _dummy, long ptr) : base(ptr) { }
16         ~CandidateRouteHop() {
17                 if (ptr != 0) { bindings.CandidateRouteHop_free(ptr); }
18         }
19
20         internal static CandidateRouteHop constr_from_ptr(long ptr) {
21                 long raw_ty = bindings.LDKCandidateRouteHop_ty_from_ptr(ptr);
22                 switch (raw_ty) {
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);
28                         default:
29                                 throw new ArgumentException("Impossible enum variant");
30                 }
31         }
32
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;
41                 }
42         }
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;
51                 }
52         }
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;
61                 }
62         }
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;
71                 }
72         }
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;
81                 }
82         }
83         internal long clone_ptr() {
84                 long ret = bindings.CandidateRouteHop_clone_ptr(this.ptr);
85                 GC.KeepAlive(this);
86                 return ret;
87         }
88
89         /**
90          * Creates a copy of the CandidateRouteHop
91          */
92         public CandidateRouteHop clone() {
93                 long ret = bindings.CandidateRouteHop_clone(this.ptr);
94                 GC.KeepAlive(this);
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); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Utility method to constructs a new FirstHop-variant CandidateRouteHop
103          */
104         public static CandidateRouteHop first_hop(org.ldk.structs.FirstHopCandidate a) {
105                 long ret = bindings.CandidateRouteHop_first_hop(a == null ? 0 : a.ptr);
106                 GC.KeepAlive(a);
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); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Utility method to constructs a new PublicHop-variant CandidateRouteHop
116          */
117         public static CandidateRouteHop public_hop(org.ldk.structs.PublicHopCandidate a) {
118                 long ret = bindings.CandidateRouteHop_public_hop(a == null ? 0 : a.ptr);
119                 GC.KeepAlive(a);
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); };
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Utility method to constructs a new PrivateHop-variant CandidateRouteHop
129          */
130         public static CandidateRouteHop private_hop(org.ldk.structs.PrivateHopCandidate a) {
131                 long ret = bindings.CandidateRouteHop_private_hop(a == null ? 0 : a.ptr);
132                 GC.KeepAlive(a);
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); };
137                 return ret_hu_conv;
138         }
139
140         /**
141          * Utility method to constructs a new Blinded-variant CandidateRouteHop
142          */
143         public static CandidateRouteHop blinded(org.ldk.structs.BlindedPathCandidate a) {
144                 long ret = bindings.CandidateRouteHop_blinded(a == null ? 0 : a.ptr);
145                 GC.KeepAlive(a);
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); };
150                 return ret_hu_conv;
151         }
152
153         /**
154          * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop
155          */
156         public static CandidateRouteHop one_hop_blinded(org.ldk.structs.OneHopBlindedPathCandidate a) {
157                 long ret = bindings.CandidateRouteHop_one_hop_blinded(a == null ? 0 : a.ptr);
158                 GC.KeepAlive(a);
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); };
163                 return ret_hu_conv;
164         }
165
166         /**
167          * Returns the globally unique short channel ID for this hop, if one is known.
168          * 
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.
172          */
173         public Option_u64Z globally_unique_short_channel_id() {
174                 long ret = bindings.CandidateRouteHop_globally_unique_short_channel_id(this.ptr);
175                 GC.KeepAlive(this);
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); };
179                 return ret_hu_conv;
180         }
181
182         /**
183          * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the
184          * next-hop for an HTLC taking this hop.
185          * 
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.
188          */
189         public int cltv_expiry_delta() {
190                 int ret = bindings.CandidateRouteHop_cltv_expiry_delta(this.ptr);
191                 GC.KeepAlive(this);
192                 return ret;
193         }
194
195         /**
196          * Returns the minimum amount that can be sent over this hop, in millisatoshis.
197          */
198         public long htlc_minimum_msat() {
199                 long ret = bindings.CandidateRouteHop_htlc_minimum_msat(this.ptr);
200                 GC.KeepAlive(this);
201                 return ret;
202         }
203
204         /**
205          * Returns the fees that must be paid to route an HTLC over this channel.
206          */
207         public RoutingFees fees() {
208                 long ret = bindings.CandidateRouteHop_fees(this.ptr);
209                 GC.KeepAlive(this);
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); };
213                 return ret_hu_conv;
214         }
215
216         /**
217          * Returns the source node id of current hop.
218          * 
219          * Source node id refers to the node forwarding the HTLC through this hop.
220          * 
221          * For [`Self::FirstHop`] we return payer's node id.
222          */
223         public NodeId source() {
224                 long ret = bindings.CandidateRouteHop_source(this.ptr);
225                 GC.KeepAlive(this);
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); };
229                 return ret_hu_conv;
230         }
231
232         /**
233          * Returns the target node id of this hop, if known.
234          * 
235          * Target node id refers to the node receiving the HTLC after this hop.
236          * 
237          * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded
238          * path is unknown.
239          * 
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.
242          * 
243          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
244          */
245         public NodeId target() {
246                 long ret = bindings.CandidateRouteHop_target(this.ptr);
247                 GC.KeepAlive(this);
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); };
251                 return ret_hu_conv;
252         }
253
254 }
255 } } }