[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Balance.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  * Details about the balance(s) available for spending once the channel appears on chain.
10  * 
11  * See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not
12  * be provided.
13  */
14 public class Balance : CommonBase {
15         protected Balance(object _dummy, long ptr) : base(ptr) { }
16         ~Balance() {
17                 if (ptr != 0) { bindings.Balance_free(ptr); }
18         }
19
20         internal static Balance constr_from_ptr(long ptr) {
21                 long raw_ty = bindings.LDKBalance_ty_from_ptr(ptr);
22                 switch (raw_ty) {
23                         case 0: return new Balance_ClaimableOnChannelClose(ptr);
24                         case 1: return new Balance_ClaimableAwaitingConfirmations(ptr);
25                         case 2: return new Balance_ContentiousClaimable(ptr);
26                         case 3: return new Balance_MaybeTimeoutClaimableHTLC(ptr);
27                         case 4: return new Balance_MaybePreimageClaimableHTLC(ptr);
28                         case 5: return new Balance_CounterpartyRevokedOutputClaimable(ptr);
29                         default:
30                                 throw new ArgumentException("Impossible enum variant");
31                 }
32         }
33
34         /** A Balance of type ClaimableOnChannelClose */
35         public class Balance_ClaimableOnChannelClose : Balance {
36                 /**
37                  * The amount available to claim, in satoshis, excluding the on-chain fees which will be
38                  * required to do so.
39                  */
40                 public long amount_satoshis;
41                 internal Balance_ClaimableOnChannelClose(long ptr) : base(null, ptr) {
42                         this.amount_satoshis = bindings.LDKBalance_ClaimableOnChannelClose_get_amount_satoshis(ptr);
43                 }
44         }
45         /** A Balance of type ClaimableAwaitingConfirmations */
46         public class Balance_ClaimableAwaitingConfirmations : Balance {
47                 /**
48                  * The amount available to claim, in satoshis, possibly excluding the on-chain fees which
49                  * were spent in broadcasting the transaction.
50                  */
51                 public long amount_satoshis;
52                 /**
53                  * The height at which an [`Event::SpendableOutputs`] event will be generated for this
54                  * amount.
55                  */
56                 public int confirmation_height;
57                 internal Balance_ClaimableAwaitingConfirmations(long ptr) : base(null, ptr) {
58                         this.amount_satoshis = bindings.LDKBalance_ClaimableAwaitingConfirmations_get_amount_satoshis(ptr);
59                         this.confirmation_height = bindings.LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(ptr);
60                 }
61         }
62         /** A Balance of type ContentiousClaimable */
63         public class Balance_ContentiousClaimable : Balance {
64                 /**
65                  * The amount available to claim, in satoshis, excluding the on-chain fees which will be
66                  * required to do so.
67                  */
68                 public long amount_satoshis;
69                 /**
70                  * The height at which the counterparty may be able to claim the balance if we have not
71                  * done so.
72                  */
73                 public int timeout_height;
74                 /**
75                  * The payment hash that locks this HTLC.
76                  */
77                 public byte[] payment_hash;
78                 /**
79                  * The preimage that can be used to claim this HTLC.
80                  */
81                 public byte[] payment_preimage;
82                 internal Balance_ContentiousClaimable(long ptr) : base(null, ptr) {
83                         this.amount_satoshis = bindings.LDKBalance_ContentiousClaimable_get_amount_satoshis(ptr);
84                         this.timeout_height = bindings.LDKBalance_ContentiousClaimable_get_timeout_height(ptr);
85                         long payment_hash = bindings.LDKBalance_ContentiousClaimable_get_payment_hash(ptr);
86                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
87                         this.payment_hash = payment_hash_conv;
88                         long payment_preimage = bindings.LDKBalance_ContentiousClaimable_get_payment_preimage(ptr);
89                         byte[] payment_preimage_conv = InternalUtils.decodeUint8Array(payment_preimage);
90                         this.payment_preimage = payment_preimage_conv;
91                 }
92         }
93         /** A Balance of type MaybeTimeoutClaimableHTLC */
94         public class Balance_MaybeTimeoutClaimableHTLC : Balance {
95                 /**
96                  * The amount potentially available to claim, in satoshis, excluding the on-chain fees
97                  * which will be required to do so.
98                  */
99                 public long amount_satoshis;
100                 /**
101                  * The height at which we will be able to claim the balance if our counterparty has not
102                  * done so.
103                  */
104                 public int claimable_height;
105                 /**
106                  * The payment hash whose preimage our counterparty needs to claim this HTLC.
107                  */
108                 public byte[] payment_hash;
109                 internal Balance_MaybeTimeoutClaimableHTLC(long ptr) : base(null, ptr) {
110                         this.amount_satoshis = bindings.LDKBalance_MaybeTimeoutClaimableHTLC_get_amount_satoshis(ptr);
111                         this.claimable_height = bindings.LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_height(ptr);
112                         long payment_hash = bindings.LDKBalance_MaybeTimeoutClaimableHTLC_get_payment_hash(ptr);
113                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
114                         this.payment_hash = payment_hash_conv;
115                 }
116         }
117         /** A Balance of type MaybePreimageClaimableHTLC */
118         public class Balance_MaybePreimageClaimableHTLC : Balance {
119                 /**
120                  * The amount potentially available to claim, in satoshis, excluding the on-chain fees
121                  * which will be required to do so.
122                  */
123                 public long amount_satoshis;
124                 /**
125                  * The height at which our counterparty will be able to claim the balance if we have not
126                  * yet received the preimage and claimed it ourselves.
127                  */
128                 public int expiry_height;
129                 /**
130                  * The payment hash whose preimage we need to claim this HTLC.
131                  */
132                 public byte[] payment_hash;
133                 internal Balance_MaybePreimageClaimableHTLC(long ptr) : base(null, ptr) {
134                         this.amount_satoshis = bindings.LDKBalance_MaybePreimageClaimableHTLC_get_amount_satoshis(ptr);
135                         this.expiry_height = bindings.LDKBalance_MaybePreimageClaimableHTLC_get_expiry_height(ptr);
136                         long payment_hash = bindings.LDKBalance_MaybePreimageClaimableHTLC_get_payment_hash(ptr);
137                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
138                         this.payment_hash = payment_hash_conv;
139                 }
140         }
141         /** A Balance of type CounterpartyRevokedOutputClaimable */
142         public class Balance_CounterpartyRevokedOutputClaimable : Balance {
143                 /**
144                  * The amount, in satoshis, of the output which we can claim.
145                  * 
146                  * Note that for outputs from HTLC balances this may be excluding some on-chain fees that
147                  * were already spent.
148                  */
149                 public long amount_satoshis;
150                 internal Balance_CounterpartyRevokedOutputClaimable(long ptr) : base(null, ptr) {
151                         this.amount_satoshis = bindings.LDKBalance_CounterpartyRevokedOutputClaimable_get_amount_satoshis(ptr);
152                 }
153         }
154         internal long clone_ptr() {
155                 long ret = bindings.Balance_clone_ptr(this.ptr);
156                 GC.KeepAlive(this);
157                 return ret;
158         }
159
160         /**
161          * Creates a copy of the Balance
162          */
163         public Balance clone() {
164                 long ret = bindings.Balance_clone(this.ptr);
165                 GC.KeepAlive(this);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
168                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
169                 return ret_hu_conv;
170         }
171
172         /**
173          * Utility method to constructs a new ClaimableOnChannelClose-variant Balance
174          */
175         public static Balance claimable_on_channel_close(long amount_satoshis) {
176                 long ret = bindings.Balance_claimable_on_channel_close(amount_satoshis);
177                 GC.KeepAlive(amount_satoshis);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
181                 return ret_hu_conv;
182         }
183
184         /**
185          * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance
186          */
187         public static Balance claimable_awaiting_confirmations(long amount_satoshis, int confirmation_height) {
188                 long ret = bindings.Balance_claimable_awaiting_confirmations(amount_satoshis, confirmation_height);
189                 GC.KeepAlive(amount_satoshis);
190                 GC.KeepAlive(confirmation_height);
191                 if (ret >= 0 && ret <= 4096) { return null; }
192                 org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
193                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
194                 return ret_hu_conv;
195         }
196
197         /**
198          * Utility method to constructs a new ContentiousClaimable-variant Balance
199          */
200         public static Balance contentious_claimable(long amount_satoshis, int timeout_height, byte[] payment_hash, byte[] payment_preimage) {
201                 long ret = bindings.Balance_contentious_claimable(amount_satoshis, timeout_height, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32)));
202                 GC.KeepAlive(amount_satoshis);
203                 GC.KeepAlive(timeout_height);
204                 GC.KeepAlive(payment_hash);
205                 GC.KeepAlive(payment_preimage);
206                 if (ret >= 0 && ret <= 4096) { return null; }
207                 org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
208                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
209                 return ret_hu_conv;
210         }
211
212         /**
213          * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance
214          */
215         public static Balance maybe_timeout_claimable_htlc(long amount_satoshis, int claimable_height, byte[] payment_hash) {
216                 long ret = bindings.Balance_maybe_timeout_claimable_htlc(amount_satoshis, claimable_height, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
217                 GC.KeepAlive(amount_satoshis);
218                 GC.KeepAlive(claimable_height);
219                 GC.KeepAlive(payment_hash);
220                 if (ret >= 0 && ret <= 4096) { return null; }
221                 org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
222                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
223                 return ret_hu_conv;
224         }
225
226         /**
227          * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance
228          */
229         public static Balance maybe_preimage_claimable_htlc(long amount_satoshis, int expiry_height, byte[] payment_hash) {
230                 long ret = bindings.Balance_maybe_preimage_claimable_htlc(amount_satoshis, expiry_height, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
231                 GC.KeepAlive(amount_satoshis);
232                 GC.KeepAlive(expiry_height);
233                 GC.KeepAlive(payment_hash);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
236                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
237                 return ret_hu_conv;
238         }
239
240         /**
241          * Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance
242          */
243         public static Balance counterparty_revoked_output_claimable(long amount_satoshis) {
244                 long ret = bindings.Balance_counterparty_revoked_output_claimable(amount_satoshis);
245                 GC.KeepAlive(amount_satoshis);
246                 if (ret >= 0 && ret <= 4096) { return null; }
247                 org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret);
248                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
249                 return ret_hu_conv;
250         }
251
252         /**
253          * Checks if two Balances contain equal inner contents.
254          * This ignores pointers and is_owned flags and looks at the values in fields.
255          */
256         public bool eq(org.ldk.structs.Balance b) {
257                 bool ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr);
258                 GC.KeepAlive(this);
259                 GC.KeepAlive(b);
260                 return ret;
261         }
262
263         public override bool Equals(object o) {
264                 if (!(o is Balance)) return false;
265                 return this.eq((Balance)o);
266         }
267         /**
268          * The amount claimable, in satoshis. This excludes balances that we are unsure if we are able
269          * to claim, this is because we are waiting for a preimage or for a timeout to expire. For more
270          * information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and
271          * [`Balance::MaybePreimageClaimableHTLC`].
272          * 
273          * On-chain fees required to claim the balance are not included in this amount.
274          */
275         public long claimable_amount_satoshis() {
276                 long ret = bindings.Balance_claimable_amount_satoshis(this.ptr);
277                 GC.KeepAlive(this);
278                 return ret;
279         }
280
281 }
282 } } }