Update CI references to 0.0.122
[ldk-java] / src / main / java / org / ldk / structs / EffectiveCapacity.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * The effective capacity of a channel for routing purposes.
13  * 
14  * While this may be smaller than the actual channel capacity, amounts greater than
15  * [`Self::as_msat`] should not be routed through the channel.
16  */
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class EffectiveCapacity extends CommonBase {
19         private EffectiveCapacity(Object _dummy, long ptr) { super(ptr); }
20         @Override @SuppressWarnings("deprecation")
21         protected void finalize() throws Throwable {
22                 super.finalize();
23                 if (ptr != 0) { bindings.EffectiveCapacity_free(ptr); }
24         }
25         static EffectiveCapacity constr_from_ptr(long ptr) {
26                 bindings.LDKEffectiveCapacity raw_val = bindings.LDKEffectiveCapacity_ref_from_ptr(ptr);
27                 if (raw_val.getClass() == bindings.LDKEffectiveCapacity.ExactLiquidity.class) {
28                         return new ExactLiquidity(ptr, (bindings.LDKEffectiveCapacity.ExactLiquidity)raw_val);
29                 }
30                 if (raw_val.getClass() == bindings.LDKEffectiveCapacity.AdvertisedMaxHTLC.class) {
31                         return new AdvertisedMaxHTLC(ptr, (bindings.LDKEffectiveCapacity.AdvertisedMaxHTLC)raw_val);
32                 }
33                 if (raw_val.getClass() == bindings.LDKEffectiveCapacity.Total.class) {
34                         return new Total(ptr, (bindings.LDKEffectiveCapacity.Total)raw_val);
35                 }
36                 if (raw_val.getClass() == bindings.LDKEffectiveCapacity.Infinite.class) {
37                         return new Infinite(ptr, (bindings.LDKEffectiveCapacity.Infinite)raw_val);
38                 }
39                 if (raw_val.getClass() == bindings.LDKEffectiveCapacity.HintMaxHTLC.class) {
40                         return new HintMaxHTLC(ptr, (bindings.LDKEffectiveCapacity.HintMaxHTLC)raw_val);
41                 }
42                 if (raw_val.getClass() == bindings.LDKEffectiveCapacity.Unknown.class) {
43                         return new Unknown(ptr, (bindings.LDKEffectiveCapacity.Unknown)raw_val);
44                 }
45                 assert false; return null; // Unreachable without extending the (internal) bindings interface
46         }
47
48         /**
49          * The available liquidity in the channel known from being a channel counterparty, and thus a
50          * direct hop.
51          */
52         public final static class ExactLiquidity extends EffectiveCapacity {
53                 /**
54                  * Either the inbound or outbound liquidity depending on the direction, denominated in
55                  * millisatoshi.
56                 */
57                 public final long liquidity_msat;
58                 private ExactLiquidity(long ptr, bindings.LDKEffectiveCapacity.ExactLiquidity obj) {
59                         super(null, ptr);
60                         this.liquidity_msat = obj.liquidity_msat;
61                 }
62         }
63         /**
64          * The maximum HTLC amount in one direction as advertised on the gossip network.
65          */
66         public final static class AdvertisedMaxHTLC extends EffectiveCapacity {
67                 /**
68                  * The maximum HTLC amount denominated in millisatoshi.
69                 */
70                 public final long amount_msat;
71                 private AdvertisedMaxHTLC(long ptr, bindings.LDKEffectiveCapacity.AdvertisedMaxHTLC obj) {
72                         super(null, ptr);
73                         this.amount_msat = obj.amount_msat;
74                 }
75         }
76         /**
77          * The total capacity of the channel as determined by the funding transaction.
78          */
79         public final static class Total extends EffectiveCapacity {
80                 /**
81                  * The funding amount denominated in millisatoshi.
82                 */
83                 public final long capacity_msat;
84                 /**
85                  * The maximum HTLC amount denominated in millisatoshi.
86                 */
87                 public final long htlc_maximum_msat;
88                 private Total(long ptr, bindings.LDKEffectiveCapacity.Total obj) {
89                         super(null, ptr);
90                         this.capacity_msat = obj.capacity_msat;
91                         this.htlc_maximum_msat = obj.htlc_maximum_msat;
92                 }
93         }
94         /**
95          * A capacity sufficient to route any payment, typically used for private channels provided by
96          * an invoice.
97          */
98         public final static class Infinite extends EffectiveCapacity {
99                 private Infinite(long ptr, bindings.LDKEffectiveCapacity.Infinite obj) {
100                         super(null, ptr);
101                 }
102         }
103         /**
104          * The maximum HTLC amount as provided by an invoice route hint.
105          */
106         public final static class HintMaxHTLC extends EffectiveCapacity {
107                 /**
108                  * The maximum HTLC amount denominated in millisatoshi.
109                 */
110                 public final long amount_msat;
111                 private HintMaxHTLC(long ptr, bindings.LDKEffectiveCapacity.HintMaxHTLC obj) {
112                         super(null, ptr);
113                         this.amount_msat = obj.amount_msat;
114                 }
115         }
116         /**
117          * A capacity that is unknown possibly because either the chain state is unavailable to know
118          * the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network.
119          */
120         public final static class Unknown extends EffectiveCapacity {
121                 private Unknown(long ptr, bindings.LDKEffectiveCapacity.Unknown obj) {
122                         super(null, ptr);
123                 }
124         }
125         long clone_ptr() {
126                 long ret = bindings.EffectiveCapacity_clone_ptr(this.ptr);
127                 Reference.reachabilityFence(this);
128                 return ret;
129         }
130
131         /**
132          * Creates a copy of the EffectiveCapacity
133          */
134         public EffectiveCapacity clone() {
135                 long ret = bindings.EffectiveCapacity_clone(this.ptr);
136                 Reference.reachabilityFence(this);
137                 if (ret >= 0 && ret <= 4096) { return null; }
138                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
139                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
140                 return ret_hu_conv;
141         }
142
143         /**
144          * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity
145          */
146         public static EffectiveCapacity exact_liquidity(long liquidity_msat) {
147                 long ret = bindings.EffectiveCapacity_exact_liquidity(liquidity_msat);
148                 Reference.reachabilityFence(liquidity_msat);
149                 if (ret >= 0 && ret <= 4096) { return null; }
150                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
151                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity
157          */
158         public static EffectiveCapacity advertised_max_htlc(long amount_msat) {
159                 long ret = bindings.EffectiveCapacity_advertised_max_htlc(amount_msat);
160                 Reference.reachabilityFence(amount_msat);
161                 if (ret >= 0 && ret <= 4096) { return null; }
162                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
163                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
164                 return ret_hu_conv;
165         }
166
167         /**
168          * Utility method to constructs a new Total-variant EffectiveCapacity
169          */
170         public static EffectiveCapacity total(long capacity_msat, long htlc_maximum_msat) {
171                 long ret = bindings.EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
172                 Reference.reachabilityFence(capacity_msat);
173                 Reference.reachabilityFence(htlc_maximum_msat);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
176                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Utility method to constructs a new Infinite-variant EffectiveCapacity
182          */
183         public static EffectiveCapacity infinite() {
184                 long ret = bindings.EffectiveCapacity_infinite();
185                 if (ret >= 0 && ret <= 4096) { return null; }
186                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
187                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
188                 return ret_hu_conv;
189         }
190
191         /**
192          * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity
193          */
194         public static EffectiveCapacity hint_max_htlc(long amount_msat) {
195                 long ret = bindings.EffectiveCapacity_hint_max_htlc(amount_msat);
196                 Reference.reachabilityFence(amount_msat);
197                 if (ret >= 0 && ret <= 4096) { return null; }
198                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
199                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
200                 return ret_hu_conv;
201         }
202
203         /**
204          * Utility method to constructs a new Unknown-variant EffectiveCapacity
205          */
206         public static EffectiveCapacity unknown() {
207                 long ret = bindings.EffectiveCapacity_unknown();
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
211                 return ret_hu_conv;
212         }
213
214         /**
215          * Returns the effective capacity denominated in millisatoshi.
216          */
217         public long as_msat() {
218                 long ret = bindings.EffectiveCapacity_as_msat(this.ptr);
219                 Reference.reachabilityFence(this);
220                 return ret;
221         }
222
223 }