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_MaximumHTLC(ptr);
25 case 2: return new EffectiveCapacity_Total(ptr);
26 case 3: return new EffectiveCapacity_Infinite(ptr);
27 case 4: return new EffectiveCapacity_Unknown(ptr);
29 throw new ArgumentException("Impossible enum variant");
33 /** A EffectiveCapacity of type ExactLiquidity */
34 public class EffectiveCapacity_ExactLiquidity : EffectiveCapacity {
36 * Either the inbound or outbound liquidity depending on the direction, denominated in
39 public long liquidity_msat;
40 internal EffectiveCapacity_ExactLiquidity(long ptr) : base(null, ptr) {
41 this.liquidity_msat = bindings.LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(ptr);
44 /** A EffectiveCapacity of type MaximumHTLC */
45 public class EffectiveCapacity_MaximumHTLC : EffectiveCapacity {
47 * The maximum HTLC amount denominated in millisatoshi.
49 public long amount_msat;
50 internal EffectiveCapacity_MaximumHTLC(long ptr) : base(null, ptr) {
51 this.amount_msat = bindings.LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(ptr);
54 /** A EffectiveCapacity of type Total */
55 public class EffectiveCapacity_Total : EffectiveCapacity {
57 * The funding amount denominated in millisatoshi.
59 public long capacity_msat;
61 * The maximum HTLC amount denominated in millisatoshi.
63 public long htlc_maximum_msat;
64 internal EffectiveCapacity_Total(long ptr) : base(null, ptr) {
65 this.capacity_msat = bindings.LDKEffectiveCapacity_Total_get_capacity_msat(ptr);
66 this.htlc_maximum_msat = bindings.LDKEffectiveCapacity_Total_get_htlc_maximum_msat(ptr);
69 /** A EffectiveCapacity of type Infinite */
70 public class EffectiveCapacity_Infinite : EffectiveCapacity {
71 internal EffectiveCapacity_Infinite(long ptr) : base(null, ptr) {
74 /** A EffectiveCapacity of type Unknown */
75 public class EffectiveCapacity_Unknown : EffectiveCapacity {
76 internal EffectiveCapacity_Unknown(long ptr) : base(null, ptr) {
79 internal long clone_ptr() {
80 long ret = bindings.EffectiveCapacity_clone_ptr(this.ptr);
86 * Creates a copy of the EffectiveCapacity
88 public EffectiveCapacity clone() {
89 long ret = bindings.EffectiveCapacity_clone(this.ptr);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
98 * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity
100 public static EffectiveCapacity exact_liquidity(long liquidity_msat) {
101 long ret = bindings.EffectiveCapacity_exact_liquidity(liquidity_msat);
102 GC.KeepAlive(liquidity_msat);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
105 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110 * Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity
112 public static EffectiveCapacity maximum_htlc(long amount_msat) {
113 long ret = bindings.EffectiveCapacity_maximum_htlc(amount_msat);
114 GC.KeepAlive(amount_msat);
115 if (ret >= 0 && ret <= 4096) { return null; }
116 org.ldk.structs.EffectiveCapacity ret_hu_conv = org.ldk.structs.EffectiveCapacity.constr_from_ptr(ret);
117 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
122 * Utility method to constructs a new Total-variant EffectiveCapacity
124 public static EffectiveCapacity total(long capacity_msat, long htlc_maximum_msat) {
125 long ret = bindings.EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
126 GC.KeepAlive(capacity_msat);
127 GC.KeepAlive(htlc_maximum_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 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
135 * Utility method to constructs a new Infinite-variant EffectiveCapacity
137 public static EffectiveCapacity infinite() {
138 long ret = bindings.EffectiveCapacity_infinite();
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 Unknown-variant EffectiveCapacity
148 public static EffectiveCapacity unknown() {
149 long ret = bindings.EffectiveCapacity_unknown();
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 * Returns the effective capacity denominated in millisatoshi.
159 public long as_msat() {
160 long ret = bindings.EffectiveCapacity_as_msat(this.ptr);