[Java] Update auto-generated 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                 private Total(long ptr, bindings.LDKEffectiveCapacity.Total obj) {
82                         super(null, ptr);
83                         this.capacity_msat = obj.capacity_msat;
84                 }
85         }
86         /**
87          * A capacity sufficient to route any payment, typically used for private channels provided by
88          * an invoice.
89          */
90         public final static class Infinite extends EffectiveCapacity {
91                 private Infinite(long ptr, bindings.LDKEffectiveCapacity.Infinite obj) {
92                         super(null, ptr);
93                 }
94         }
95         /**
96          * A capacity that is unknown possibly because either the chain state is unavailable to know
97          * the total capacity or the `htlc_maximum_msat` was not advertised on the gossip network.
98          */
99         public final static class Unknown extends EffectiveCapacity {
100                 private Unknown(long ptr, bindings.LDKEffectiveCapacity.Unknown obj) {
101                         super(null, ptr);
102                 }
103         }
104         long clone_ptr() {
105                 long ret = bindings.EffectiveCapacity_clone_ptr(this.ptr);
106                 Reference.reachabilityFence(this);
107                 return ret;
108         }
109
110         /**
111          * Creates a copy of the EffectiveCapacity
112          */
113         public EffectiveCapacity clone() {
114                 long ret = bindings.EffectiveCapacity_clone(this.ptr);
115                 Reference.reachabilityFence(this);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
118                 ret_hu_conv.ptrs_to.add(this);
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity
124          */
125         public static EffectiveCapacity exact_liquidity(long liquidity_msat) {
126                 long ret = bindings.EffectiveCapacity_exact_liquidity(liquidity_msat);
127                 Reference.reachabilityFence(liquidity_msat);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
130                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity
136          */
137         public static EffectiveCapacity maximum_htlc(long amount_msat) {
138                 long ret = bindings.EffectiveCapacity_maximum_htlc(amount_msat);
139                 Reference.reachabilityFence(amount_msat);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
142                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
143                 return ret_hu_conv;
144         }
145
146         /**
147          * Utility method to constructs a new Total-variant EffectiveCapacity
148          */
149         public static EffectiveCapacity total(long capacity_msat) {
150                 long ret = bindings.EffectiveCapacity_total(capacity_msat);
151                 Reference.reachabilityFence(capacity_msat);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
154                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
155                 return ret_hu_conv;
156         }
157
158         /**
159          * Utility method to constructs a new Infinite-variant EffectiveCapacity
160          */
161         public static EffectiveCapacity infinite() {
162                 long ret = bindings.EffectiveCapacity_infinite();
163                 if (ret >= 0 && ret <= 4096) { return null; }
164                 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
165                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
166                 return ret_hu_conv;
167         }
168
169         /**
170          * Utility method to constructs a new Unknown-variant EffectiveCapacity
171          */
172         public static EffectiveCapacity unknown() {
173                 long ret = bindings.EffectiveCapacity_unknown();
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                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Returns the effective capacity denominated in millisatoshi.
182          */
183         public long as_msat() {
184                 long ret = bindings.EffectiveCapacity_as_msat(this.ptr);
185                 Reference.reachabilityFence(this);
186                 return ret;
187         }
188
189 }