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