6 namespace org { namespace ldk { namespace structs {
9 * The effective capacity of a channel for routing purposes.
11 * While this may be smaller than the actual channel capacity, amounts greater than
12 * [`Self::as_msat`] should not be routed through the channel.
14 public class EffectiveCapacity : CommonBase {
15 protected EffectiveCapacity(object _dummy, long ptr) : base(ptr) { }
16 ~EffectiveCapacity() {
17 if (ptr != 0) { bindings.EffectiveCapacity_free(ptr); }
20 internal static EffectiveCapacity constr_from_ptr(long ptr) {
21 long raw_ty = bindings.LDKEffectiveCapacity_ty_from_ptr(ptr);
23 case 0: return new EffectiveCapacity_ExactLiquidity(ptr);
24 case 1: return new EffectiveCapacity_AdvertisedMaxHTLC(ptr);
25 case 2: return new EffectiveCapacity_Total(ptr);
26 case 3: return new EffectiveCapacity_Infinite(ptr);
27 case 4: return new EffectiveCapacity_HintMaxHTLC(ptr);
28 case 5: return new EffectiveCapacity_Unknown(ptr);
30 throw new ArgumentException("Impossible enum variant");
34 /** A EffectiveCapacity of type ExactLiquidity */
35 public class EffectiveCapacity_ExactLiquidity : EffectiveCapacity {
37 * Either the inbound or outbound liquidity depending on the direction, denominated in
40 public long liquidity_msat;
41 internal EffectiveCapacity_ExactLiquidity(long ptr) : base(null, ptr) {
42 this.liquidity_msat = bindings.LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(ptr);
45 /** A EffectiveCapacity of type AdvertisedMaxHTLC */
46 public class EffectiveCapacity_AdvertisedMaxHTLC : EffectiveCapacity {
48 * The maximum HTLC amount denominated in millisatoshi.
50 public long amount_msat;
51 internal EffectiveCapacity_AdvertisedMaxHTLC(long ptr) : base(null, ptr) {
52 this.amount_msat = bindings.LDKEffectiveCapacity_AdvertisedMaxHTLC_get_amount_msat(ptr);
55 /** A EffectiveCapacity of type Total */
56 public class EffectiveCapacity_Total : EffectiveCapacity {
58 * The funding amount denominated in millisatoshi.
60 public long capacity_msat;
62 * The maximum HTLC amount denominated in millisatoshi.
64 public long htlc_maximum_msat;
65 internal EffectiveCapacity_Total(long ptr) : base(null, ptr) {
66 this.capacity_msat = bindings.LDKEffectiveCapacity_Total_get_capacity_msat(ptr);
67 this.htlc_maximum_msat = bindings.LDKEffectiveCapacity_Total_get_htlc_maximum_msat(ptr);
70 /** A EffectiveCapacity of type Infinite */
71 public class EffectiveCapacity_Infinite : EffectiveCapacity {
72 internal EffectiveCapacity_Infinite(long ptr) : base(null, ptr) {
75 /** A EffectiveCapacity of type HintMaxHTLC */
76 public class EffectiveCapacity_HintMaxHTLC : EffectiveCapacity {
78 * The maximum HTLC amount denominated in millisatoshi.
80 public long amount_msat;
81 internal EffectiveCapacity_HintMaxHTLC(long ptr) : base(null, ptr) {
82 this.amount_msat = bindings.LDKEffectiveCapacity_HintMaxHTLC_get_amount_msat(ptr);
85 /** A EffectiveCapacity of type Unknown */
86 public class EffectiveCapacity_Unknown : EffectiveCapacity {
87 internal EffectiveCapacity_Unknown(long ptr) : base(null, ptr) {
90 internal long clone_ptr() {
91 long ret = bindings.EffectiveCapacity_clone_ptr(this.ptr);
97 * Creates a copy of the EffectiveCapacity
99 public EffectiveCapacity clone() {
100 long ret = bindings.EffectiveCapacity_clone(this.ptr);
102 if (ret >= 0 && ret <= 4096) { return null; }
103 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109 * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity
111 public static EffectiveCapacity exact_liquidity(long liquidity_msat) {
112 long ret = bindings.EffectiveCapacity_exact_liquidity(liquidity_msat);
113 GC.KeepAlive(liquidity_msat);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
116 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
121 * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity
123 public static EffectiveCapacity advertised_max_htlc(long amount_msat) {
124 long ret = bindings.EffectiveCapacity_advertised_max_htlc(amount_msat);
125 GC.KeepAlive(amount_msat);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
133 * Utility method to constructs a new Total-variant EffectiveCapacity
135 public static EffectiveCapacity total(long capacity_msat, long htlc_maximum_msat) {
136 long ret = bindings.EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
137 GC.KeepAlive(capacity_msat);
138 GC.KeepAlive(htlc_maximum_msat);
139 if (ret >= 0 && ret <= 4096) { return null; }
140 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
141 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
146 * Utility method to constructs a new Infinite-variant EffectiveCapacity
148 public static EffectiveCapacity infinite() {
149 long ret = bindings.EffectiveCapacity_infinite();
150 if (ret >= 0 && ret <= 4096) { return null; }
151 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
152 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
157 * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity
159 public static EffectiveCapacity hint_max_htlc(long amount_msat) {
160 long ret = bindings.EffectiveCapacity_hint_max_htlc(amount_msat);
161 GC.KeepAlive(amount_msat);
162 if (ret >= 0 && ret <= 4096) { return null; }
163 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
164 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
169 * Utility method to constructs a new Unknown-variant EffectiveCapacity
171 public static EffectiveCapacity unknown() {
172 long ret = bindings.EffectiveCapacity_unknown();
173 if (ret >= 0 && ret <= 4096) { return null; }
174 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
175 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
180 * Returns the effective capacity denominated in millisatoshi.
182 public long as_msat() {
183 long ret = bindings.EffectiveCapacity_as_msat(this.ptr);