[Java] Update auto-generated Java bindings
[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.MaximumHTLC.class) {
31                         return new MaximumHTLC(ptr, (bindings.LDKEffectiveCapacity.MaximumHTLC)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.Unknown.class) {
40                         return new Unknown(ptr, (bindings.LDKEffectiveCapacity.Unknown)raw_val);
41                 }
42                 assert false; return null; // Unreachable without extending the (internal) bindings interface
43         }
44
45         /**
46          * The available liquidity in the channel known from being a channel counterparty, and thus a
47          * direct hop.
48          */
49         public final static class ExactLiquidity extends EffectiveCapacity {
50                 /**
51                  * Either the inbound or outbound liquidity depending on the direction, denominated in
52                  * millisatoshi.
53                 */
54                 public final long liquidity_msat;
55                 private ExactLiquidity(long ptr, bindings.LDKEffectiveCapacity.ExactLiquidity obj) {
56                         super(null, ptr);
57                         this.liquidity_msat = obj.liquidity_msat;
58                 }
59         }
60         /**
61          * The maximum HTLC amount in one direction as advertised on the gossip network.
62          */
63         public final static class MaximumHTLC extends EffectiveCapacity {
64                 /**
65                  * The maximum HTLC amount denominated in millisatoshi.
66                 */
67                 public final long amount_msat;
68                 private MaximumHTLC(long ptr, bindings.LDKEffectiveCapacity.MaximumHTLC obj) {
69                         super(null, ptr);
70                         this.amount_msat = obj.amount_msat;
71                 }
72         }
73         /**
74          * The total capacity of the channel as determined by the funding transaction.
75          */
76         public final static class Total extends EffectiveCapacity {
77                 /**
78                  * The funding amount denominated in millisatoshi.
79                 */
80                 public final long capacity_msat;
81                 /**
82                  * The maximum HTLC amount denominated in millisatoshi.
83                 */
84                 public final org.ldk.structs.Option_u64Z htlc_maximum_msat;
85                 private Total(long ptr, bindings.LDKEffectiveCapacity.Total obj) {
86                         super(null, ptr);
87                         this.capacity_msat = obj.capacity_msat;
88                         long htlc_maximum_msat = obj.htlc_maximum_msat;
89                         org.ldk.structs.Option_u64Z htlc_maximum_msat_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(htlc_maximum_msat);
90                         htlc_maximum_msat_hu_conv.ptrs_to.add(this);
91                         this.htlc_maximum_msat = htlc_maximum_msat_hu_conv;
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          * A capacity that is unknown possibly because either the chain state is unavailable to know
105          * the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network.
106          */
107         public final static class Unknown extends EffectiveCapacity {
108                 private Unknown(long ptr, bindings.LDKEffectiveCapacity.Unknown obj) {
109                         super(null, ptr);
110                 }
111         }
112         long clone_ptr() {
113                 long ret = bindings.EffectiveCapacity_clone_ptr(this.ptr);
114                 Reference.reachabilityFence(this);
115                 return ret;
116         }
117
118         /**
119          * Creates a copy of the EffectiveCapacity
120          */
121         public EffectiveCapacity clone() {
122                 long ret = bindings.EffectiveCapacity_clone(this.ptr);
123                 Reference.reachabilityFence(this);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
126                 ret_hu_conv.ptrs_to.add(this);
127                 return ret_hu_conv;
128         }
129
130         /**
131          * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity
132          */
133         public static EffectiveCapacity exact_liquidity(long liquidity_msat) {
134                 long ret = bindings.EffectiveCapacity_exact_liquidity(liquidity_msat);
135                 Reference.reachabilityFence(liquidity_msat);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
138                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
139                 return ret_hu_conv;
140         }
141
142         /**
143          * Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity
144          */
145         public static EffectiveCapacity maximum_htlc(long amount_msat) {
146                 long ret = bindings.EffectiveCapacity_maximum_htlc(amount_msat);
147                 Reference.reachabilityFence(amount_msat);
148                 if (ret >= 0 && ret <= 4096) { return null; }
149                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
150                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
151                 return ret_hu_conv;
152         }
153
154         /**
155          * Utility method to constructs a new Total-variant EffectiveCapacity
156          */
157         public static EffectiveCapacity total(long capacity_msat, Option_u64Z htlc_maximum_msat) {
158                 long ret = bindings.EffectiveCapacity_total(capacity_msat, htlc_maximum_msat.ptr);
159                 Reference.reachabilityFence(capacity_msat);
160                 Reference.reachabilityFence(htlc_maximum_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                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
164                 return ret_hu_conv;
165         }
166
167         /**
168          * Utility method to constructs a new Infinite-variant EffectiveCapacity
169          */
170         public static EffectiveCapacity infinite() {
171                 long ret = bindings.EffectiveCapacity_infinite();
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
174                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
175                 return ret_hu_conv;
176         }
177
178         /**
179          * Utility method to constructs a new Unknown-variant EffectiveCapacity
180          */
181         public static EffectiveCapacity unknown() {
182                 long ret = bindings.EffectiveCapacity_unknown();
183                 if (ret >= 0 && ret <= 4096) { return null; }
184                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
185                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
186                 return ret_hu_conv;
187         }
188
189         /**
190          * Returns the effective capacity denominated in millisatoshi.
191          */
192         public long as_msat() {
193                 long ret = bindings.EffectiveCapacity_as_msat(this.ptr);
194                 Reference.reachabilityFence(this);
195                 return ret;
196         }
197
198 }