c7aa0e4f24416399d674ffc65f44a4042a19085f
[ldk-java] / c_sharp / src / org / ldk / structs / EffectiveCapacity.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * The effective capacity of a channel for routing purposes.
10  * 
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.
13  */
14 public class EffectiveCapacity : CommonBase {
15         protected EffectiveCapacity(object _dummy, long ptr) : base(ptr) { }
16         ~EffectiveCapacity() {
17                 if (ptr != 0) { bindings.EffectiveCapacity_free(ptr); }
18         }
19
20         internal static EffectiveCapacity constr_from_ptr(long ptr) {
21                 long raw_ty = bindings.LDKEffectiveCapacity_ty_from_ptr(ptr);
22                 switch (raw_ty) {
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);
28                         default:
29                                 throw new ArgumentException("Impossible enum variant");
30                 }
31         }
32
33         /** A EffectiveCapacity of type ExactLiquidity */
34         public class EffectiveCapacity_ExactLiquidity : EffectiveCapacity {
35                 /**
36                  * Either the inbound or outbound liquidity depending on the direction, denominated in
37                  * millisatoshi.
38                  */
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);
42                 }
43         }
44         /** A EffectiveCapacity of type MaximumHTLC */
45         public class EffectiveCapacity_MaximumHTLC : EffectiveCapacity {
46                 /**
47                  * The maximum HTLC amount denominated in millisatoshi.
48                  */
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);
52                 }
53         }
54         /** A EffectiveCapacity of type Total */
55         public class EffectiveCapacity_Total : EffectiveCapacity {
56                 /**
57                  * The funding amount denominated in millisatoshi.
58                  */
59                 public long capacity_msat;
60                 /**
61                  * The maximum HTLC amount denominated in millisatoshi.
62                  */
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);
67                 }
68         }
69         /** A EffectiveCapacity of type Infinite */
70         public class EffectiveCapacity_Infinite : EffectiveCapacity {
71                 internal EffectiveCapacity_Infinite(long ptr) : base(null, ptr) {
72                 }
73         }
74         /** A EffectiveCapacity of type Unknown */
75         public class EffectiveCapacity_Unknown : EffectiveCapacity {
76                 internal EffectiveCapacity_Unknown(long ptr) : base(null, ptr) {
77                 }
78         }
79         internal long clone_ptr() {
80                 long ret = bindings.EffectiveCapacity_clone_ptr(this.ptr);
81                 GC.KeepAlive(this);
82                 return ret;
83         }
84
85         /**
86          * Creates a copy of the EffectiveCapacity
87          */
88         public EffectiveCapacity clone() {
89                 long ret = bindings.EffectiveCapacity_clone(this.ptr);
90                 GC.KeepAlive(this);
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); };
94                 return ret_hu_conv;
95         }
96
97         /**
98          * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity
99          */
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); };
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Utility method to constructs a new MaximumHTLC-variant EffectiveCapacity
111          */
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); };
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Utility method to constructs a new Total-variant EffectiveCapacity
123          */
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); };
131                 return ret_hu_conv;
132         }
133
134         /**
135          * Utility method to constructs a new Infinite-variant EffectiveCapacity
136          */
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); };
142                 return ret_hu_conv;
143         }
144
145         /**
146          * Utility method to constructs a new Unknown-variant EffectiveCapacity
147          */
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); };
153                 return ret_hu_conv;
154         }
155
156         /**
157          * Returns the effective capacity denominated in millisatoshi.
158          */
159         public long as_msat() {
160                 long ret = bindings.EffectiveCapacity_as_msat(this.ptr);
161                 GC.KeepAlive(this);
162                 return ret;
163         }
164
165 }
166 } } }