[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelMonitor.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 /**
10  * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
11  * on-chain transactions to ensure no loss of funds occurs.
12  * 
13  * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
14  * information and are actively monitoring the chain.
15  * 
16  * Note that the deserializer is only implemented for (BlockHash, ChannelMonitor), which
17  * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
18  * the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
19  * returned block hash and the the current chain and then reconnecting blocks to get to the
20  * best chain) upon deserializing the object!
21  */
22 public class ChannelMonitor : CommonBase {
23         internal ChannelMonitor(object _dummy, long ptr) : base(ptr) { }
24         ~ChannelMonitor() {
25                 if (ptr != 0) { bindings.ChannelMonitor_free(ptr); }
26         }
27
28         internal long clone_ptr() {
29                 long ret = bindings.ChannelMonitor_clone_ptr(this.ptr);
30                 GC.KeepAlive(this);
31                 return ret;
32         }
33
34         /**
35          * Creates a copy of the ChannelMonitor
36          */
37         public ChannelMonitor clone() {
38                 long ret = bindings.ChannelMonitor_clone(this.ptr);
39                 GC.KeepAlive(this);
40                 if (ret >= 0 && ret <= 4096) { return null; }
41                 org.ldk.structs.ChannelMonitor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelMonitor(null, ret); }
42                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
43                 return ret_hu_conv;
44         }
45
46         /**
47          * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read
48          */
49         public byte[] write() {
50                 long ret = bindings.ChannelMonitor_write(this.ptr);
51                 GC.KeepAlive(this);
52                 if (ret >= 0 && ret <= 4096) { return null; }
53                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
54                 return ret_conv;
55         }
56
57         /**
58          * Updates a ChannelMonitor on the basis of some new information provided by the Channel
59          * itself.
60          * 
61          * panics if the given update is not the next update by update_id.
62          */
63         public Result_NoneNoneZ update_monitor(org.ldk.structs.ChannelMonitorUpdate updates, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
64                 long ret = bindings.ChannelMonitor_update_monitor(this.ptr, updates.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
65                 GC.KeepAlive(this);
66                 GC.KeepAlive(updates);
67                 GC.KeepAlive(broadcaster);
68                 GC.KeepAlive(fee_estimator);
69                 GC.KeepAlive(logger);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 Result_NoneNoneZ ret_hu_conv = Result_NoneNoneZ.constr_from_ptr(ret);
72                 if (this != null) { this.ptrs_to.AddLast(updates); };
73                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
74                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
75                 if (this != null) { this.ptrs_to.AddLast(logger); };
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
81          * ChannelMonitor.
82          */
83         public long get_latest_update_id() {
84                 long ret = bindings.ChannelMonitor_get_latest_update_id(this.ptr);
85                 GC.KeepAlive(this);
86                 return ret;
87         }
88
89         /**
90          * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
91          */
92         public TwoTuple_OutPointCVec_u8ZZ get_funding_txo() {
93                 long ret = bindings.ChannelMonitor_get_funding_txo(this.ptr);
94                 GC.KeepAlive(this);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 TwoTuple_OutPointCVec_u8ZZ ret_hu_conv = new TwoTuple_OutPointCVec_u8ZZ(null, ret);
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Gets the channel_id of the channel this ChannelMonitor is monitoring for.
103          */
104         public ChannelId channel_id() {
105                 long ret = bindings.ChannelMonitor_channel_id(this.ptr);
106                 GC.KeepAlive(this);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Gets a list of txids, with their output scripts (in the order they appear in the
115          * transaction), which we must learn about spends of via block_connected().
116          */
117         public TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ[] get_outputs_to_watch() {
118                 long ret = bindings.ChannelMonitor_get_outputs_to_watch(this.ptr);
119                 GC.KeepAlive(this);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 int ret_conv_52_len = InternalUtils.getArrayLength(ret);
122                 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ[] ret_conv_52_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ[ret_conv_52_len];
123                 for (int a = 0; a < ret_conv_52_len; a++) {
124                         long ret_conv_52 = InternalUtils.getU64ArrayElem(ret, a);
125                         TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ ret_conv_52_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ(null, ret_conv_52);
126                         if (ret_conv_52_hu_conv != null) { ret_conv_52_hu_conv.ptrs_to.AddLast(this); };
127                         ret_conv_52_arr[a] = ret_conv_52_hu_conv;
128                 }
129                 bindings.free_buffer(ret);
130                 return ret_conv_52_arr;
131         }
132
133         /**
134          * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly
135          * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs
136          * have been registered.
137          */
138         public void load_outputs_to_watch(org.ldk.structs.Filter filter, org.ldk.structs.Logger logger) {
139                 bindings.ChannelMonitor_load_outputs_to_watch(this.ptr, filter.ptr, logger.ptr);
140                 GC.KeepAlive(this);
141                 GC.KeepAlive(filter);
142                 GC.KeepAlive(logger);
143                 if (this != null) { this.ptrs_to.AddLast(filter); };
144                 if (this != null) { this.ptrs_to.AddLast(logger); };
145         }
146
147         /**
148          * Get the list of HTLCs who's status has been updated on chain. This should be called by
149          * ChannelManager via [`chain::Watch::release_pending_monitor_events`].
150          */
151         public MonitorEvent[] get_and_clear_pending_monitor_events() {
152                 long ret = bindings.ChannelMonitor_get_and_clear_pending_monitor_events(this.ptr);
153                 GC.KeepAlive(this);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 int ret_conv_14_len = InternalUtils.getArrayLength(ret);
156                 MonitorEvent[] ret_conv_14_arr = new MonitorEvent[ret_conv_14_len];
157                 for (int o = 0; o < ret_conv_14_len; o++) {
158                         long ret_conv_14 = InternalUtils.getU64ArrayElem(ret, o);
159                         org.ldk.structs.MonitorEvent ret_conv_14_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret_conv_14);
160                         if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.AddLast(this); };
161                         ret_conv_14_arr[o] = ret_conv_14_hu_conv;
162                 }
163                 bindings.free_buffer(ret);
164                 return ret_conv_14_arr;
165         }
166
167         /**
168          * Processes [`SpendableOutputs`] events produced from each [`ChannelMonitor`] upon maturity.
169          * 
170          * For channels featuring anchor outputs, this method will also process [`BumpTransaction`]
171          * events produced from each [`ChannelMonitor`] while there is a balance to claim onchain
172          * within each channel. As the confirmation of a commitment transaction may be critical to the
173          * safety of funds, we recommend invoking this every 30 seconds, or lower if running in an
174          * environment with spotty connections, like on mobile.
175          * 
176          * An [`EventHandler`] may safely call back to the provider, though this shouldn't be needed in
177          * order to handle these events.
178          * 
179          * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs
180          * [`BumpTransaction`]: crate::events::Event::BumpTransaction
181          */
182         public void process_pending_events(org.ldk.structs.EventHandler handler) {
183                 bindings.ChannelMonitor_process_pending_events(this.ptr, handler.ptr);
184                 GC.KeepAlive(this);
185                 GC.KeepAlive(handler);
186                 if (this != null) { this.ptrs_to.AddLast(handler); };
187         }
188
189         /**
190          * Gets the counterparty's initial commitment transaction. The returned commitment
191          * transaction is unsigned. This is intended to be called during the initial persistence of
192          * the monitor (inside an implementation of [`Persist::persist_new_channel`]), to allow for
193          * watchtowers in the persistence pipeline to have enough data to form justice transactions.
194          * 
195          * This is similar to [`Self::counterparty_commitment_txs_from_update`], except
196          * that for the initial commitment transaction, we don't have a corresponding update.
197          * 
198          * This will only return `Some` for channel monitors that have been created after upgrading
199          * to LDK 0.0.117+.
200          * 
201          * [`Persist::persist_new_channel`]: crate::chain::chainmonitor::Persist::persist_new_channel
202          * 
203          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
204          */
205         public CommitmentTransaction initial_counterparty_commitment_tx() {
206                 long ret = bindings.ChannelMonitor_initial_counterparty_commitment_tx(this.ptr);
207                 GC.KeepAlive(this);
208                 if (ret >= 0 && ret <= 4096) { return null; }
209                 org.ldk.structs.CommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentTransaction(null, ret); }
210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
211                 return ret_hu_conv;
212         }
213
214         /**
215          * Gets all of the counterparty commitment transactions provided by the given update. This
216          * may be empty if the update doesn't include any new counterparty commitments. Returned
217          * commitment transactions are unsigned.
218          * 
219          * This is provided so that watchtower clients in the persistence pipeline are able to build
220          * justice transactions for each counterparty commitment upon each update. It's intended to be
221          * used within an implementation of [`Persist::update_persisted_channel`], which is provided
222          * with a monitor and an update. Once revoked, signing a justice transaction can be done using
223          * [`Self::sign_to_local_justice_tx`].
224          * 
225          * It is expected that a watchtower client may use this method to retrieve the latest counterparty
226          * commitment transaction(s), and then hold the necessary data until a later update in which
227          * the monitor has been updated with the corresponding revocation data, at which point the
228          * monitor can sign the justice transaction.
229          * 
230          * This will only return a non-empty list for monitor updates that have been created after
231          * upgrading to LDK 0.0.117+. Note that no restriction lies on the monitors themselves, which
232          * may have been created prior to upgrading.
233          * 
234          * [`Persist::update_persisted_channel`]: crate::chain::chainmonitor::Persist::update_persisted_channel
235          */
236         public CommitmentTransaction[] counterparty_commitment_txs_from_update(org.ldk.structs.ChannelMonitorUpdate update) {
237                 long ret = bindings.ChannelMonitor_counterparty_commitment_txs_from_update(this.ptr, update.ptr);
238                 GC.KeepAlive(this);
239                 GC.KeepAlive(update);
240                 if (ret >= 0 && ret <= 4096) { return null; }
241                 int ret_conv_23_len = InternalUtils.getArrayLength(ret);
242                 CommitmentTransaction[] ret_conv_23_arr = new CommitmentTransaction[ret_conv_23_len];
243                 for (int x = 0; x < ret_conv_23_len; x++) {
244                         long ret_conv_23 = InternalUtils.getU64ArrayElem(ret, x);
245                         org.ldk.structs.CommitmentTransaction ret_conv_23_hu_conv = null; if (ret_conv_23 < 0 || ret_conv_23 > 4096) { ret_conv_23_hu_conv = new org.ldk.structs.CommitmentTransaction(null, ret_conv_23); }
246                         if (ret_conv_23_hu_conv != null) { ret_conv_23_hu_conv.ptrs_to.AddLast(this); };
247                         ret_conv_23_arr[x] = ret_conv_23_hu_conv;
248                 }
249                 bindings.free_buffer(ret);
250                 if (this != null) { this.ptrs_to.AddLast(update); };
251                 return ret_conv_23_arr;
252         }
253
254         /**
255          * Wrapper around [`EcdsaChannelSigner::sign_justice_revoked_output`] to make
256          * signing the justice transaction easier for implementors of
257          * [`chain::chainmonitor::Persist`]. On success this method returns the provided transaction
258          * signing the input at `input_idx`. This method will only produce a valid signature for
259          * a transaction spending the `to_local` output of a commitment transaction, i.e. this cannot
260          * be used for revoked HTLC outputs.
261          * 
262          * `Value` is the value of the output being spent by the input at `input_idx`, committed
263          * in the BIP 143 signature.
264          * 
265          * This method will only succeed if this monitor has received the revocation secret for the
266          * provided `commitment_number`. If a commitment number is provided that does not correspond
267          * to the commitment transaction being revoked, this will return a signed transaction, but
268          * the signature will not be valid.
269          * 
270          * [`EcdsaChannelSigner::sign_justice_revoked_output`]: crate::sign::ecdsa::EcdsaChannelSigner::sign_justice_revoked_output
271          * [`Persist`]: crate::chain::chainmonitor::Persist
272          */
273         public Result_TransactionNoneZ sign_to_local_justice_tx(byte[] justice_tx, long input_idx, long value, long commitment_number) {
274                 long ret = bindings.ChannelMonitor_sign_to_local_justice_tx(this.ptr, InternalUtils.encodeUint8Array(justice_tx), input_idx, value, commitment_number);
275                 GC.KeepAlive(this);
276                 GC.KeepAlive(justice_tx);
277                 GC.KeepAlive(input_idx);
278                 GC.KeepAlive(value);
279                 GC.KeepAlive(commitment_number);
280                 if (ret >= 0 && ret <= 4096) { return null; }
281                 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
282                 return ret_hu_conv;
283         }
284
285         /**
286          * Gets the `node_id` of the counterparty for this channel.
287          * 
288          * Will be `None` for channels constructed on LDK versions prior to 0.0.110 and always `Some`
289          * otherwise.
290          * 
291          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
292          */
293         public byte[] get_counterparty_node_id() {
294                 long ret = bindings.ChannelMonitor_get_counterparty_node_id(this.ptr);
295                 GC.KeepAlive(this);
296                 if (ret >= 0 && ret <= 4096) { return null; }
297                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
298                 return ret_conv;
299         }
300
301         /**
302          * You may use this to broadcast the latest local commitment transaction, either because
303          * a monitor update failed or because we've fallen behind (i.e. we've received proof that our
304          * counterparty side knows a revocation secret we gave them that they shouldn't know).
305          * 
306          * Broadcasting these transactions in this manner is UNSAFE, as they allow counterparty
307          * side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't
308          * close channel with their commitment transaction after a substantial amount of time. Best
309          * may be to contact the other node operator out-of-band to coordinate other options available
310          * to you.
311          */
312         public void broadcast_latest_holder_commitment_txn(org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
313                 bindings.ChannelMonitor_broadcast_latest_holder_commitment_txn(this.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
314                 GC.KeepAlive(this);
315                 GC.KeepAlive(broadcaster);
316                 GC.KeepAlive(fee_estimator);
317                 GC.KeepAlive(logger);
318                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
319                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
320                 if (this != null) { this.ptrs_to.AddLast(logger); };
321         }
322
323         /**
324          * Processes transactions in a newly connected block, which may result in any of the following:
325          * - update the monitor's state against resolved HTLCs
326          * - punish the counterparty in the case of seeing a revoked commitment transaction
327          * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration
328          * - detect settled outputs for later spending
329          * - schedule and bump any in-flight claims
330          * 
331          * Returns any new outputs to watch from `txdata`; after called, these are also included in
332          * [`get_outputs_to_watch`].
333          * 
334          * [`get_outputs_to_watch`]: #method.get_outputs_to_watch
335          */
336         public TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] block_connected(byte[] header, TwoTuple_usizeTransactionZ[] txdata, int height, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
337                 long ret = bindings.ChannelMonitor_block_connected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28.ptr)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
338                 GC.KeepAlive(this);
339                 GC.KeepAlive(header);
340                 GC.KeepAlive(txdata);
341                 GC.KeepAlive(height);
342                 GC.KeepAlive(broadcaster);
343                 GC.KeepAlive(fee_estimator);
344                 GC.KeepAlive(logger);
345                 if (ret >= 0 && ret <= 4096) { return null; }
346                 int ret_conv_49_len = InternalUtils.getArrayLength(ret);
347                 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] ret_conv_49_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[ret_conv_49_len];
348                 for (int x = 0; x < ret_conv_49_len; x++) {
349                         long ret_conv_49 = InternalUtils.getU64ArrayElem(ret, x);
350                         TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ ret_conv_49_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ(null, ret_conv_49);
351                         if (ret_conv_49_hu_conv != null) { ret_conv_49_hu_conv.ptrs_to.AddLast(this); };
352                         ret_conv_49_arr[x] = ret_conv_49_hu_conv;
353                 }
354                 bindings.free_buffer(ret);
355                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
356                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
357                 if (this != null) { this.ptrs_to.AddLast(logger); };
358                 return ret_conv_49_arr;
359         }
360
361         /**
362          * Determines if the disconnected block contained any transactions of interest and updates
363          * appropriately.
364          */
365         public void block_disconnected(byte[] header, int height, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
366                 bindings.ChannelMonitor_block_disconnected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
367                 GC.KeepAlive(this);
368                 GC.KeepAlive(header);
369                 GC.KeepAlive(height);
370                 GC.KeepAlive(broadcaster);
371                 GC.KeepAlive(fee_estimator);
372                 GC.KeepAlive(logger);
373                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
374                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
375                 if (this != null) { this.ptrs_to.AddLast(logger); };
376         }
377
378         /**
379          * Processes transactions confirmed in a block with the given header and height, returning new
380          * outputs to watch. See [`block_connected`] for details.
381          * 
382          * Used instead of [`block_connected`] by clients that are notified of transactions rather than
383          * blocks. See [`chain::Confirm`] for calling expectations.
384          * 
385          * [`block_connected`]: Self::block_connected
386          */
387         public TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] transactions_confirmed(byte[] header, TwoTuple_usizeTransactionZ[] txdata, int height, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
388                 long ret = bindings.ChannelMonitor_transactions_confirmed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28.ptr)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
389                 GC.KeepAlive(this);
390                 GC.KeepAlive(header);
391                 GC.KeepAlive(txdata);
392                 GC.KeepAlive(height);
393                 GC.KeepAlive(broadcaster);
394                 GC.KeepAlive(fee_estimator);
395                 GC.KeepAlive(logger);
396                 if (ret >= 0 && ret <= 4096) { return null; }
397                 int ret_conv_49_len = InternalUtils.getArrayLength(ret);
398                 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] ret_conv_49_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[ret_conv_49_len];
399                 for (int x = 0; x < ret_conv_49_len; x++) {
400                         long ret_conv_49 = InternalUtils.getU64ArrayElem(ret, x);
401                         TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ ret_conv_49_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ(null, ret_conv_49);
402                         if (ret_conv_49_hu_conv != null) { ret_conv_49_hu_conv.ptrs_to.AddLast(this); };
403                         ret_conv_49_arr[x] = ret_conv_49_hu_conv;
404                 }
405                 bindings.free_buffer(ret);
406                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
407                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
408                 if (this != null) { this.ptrs_to.AddLast(logger); };
409                 return ret_conv_49_arr;
410         }
411
412         /**
413          * Processes a transaction that was reorganized out of the chain.
414          * 
415          * Used instead of [`block_disconnected`] by clients that are notified of transactions rather
416          * than blocks. See [`chain::Confirm`] for calling expectations.
417          * 
418          * [`block_disconnected`]: Self::block_disconnected
419          */
420         public void transaction_unconfirmed(byte[] txid, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
421                 bindings.ChannelMonitor_transaction_unconfirmed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(txid, 32)), broadcaster.ptr, fee_estimator.ptr, logger.ptr);
422                 GC.KeepAlive(this);
423                 GC.KeepAlive(txid);
424                 GC.KeepAlive(broadcaster);
425                 GC.KeepAlive(fee_estimator);
426                 GC.KeepAlive(logger);
427                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
428                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
429                 if (this != null) { this.ptrs_to.AddLast(logger); };
430         }
431
432         /**
433          * Updates the monitor with the current best chain tip, returning new outputs to watch. See
434          * [`block_connected`] for details.
435          * 
436          * Used instead of [`block_connected`] by clients that are notified of transactions rather than
437          * blocks. See [`chain::Confirm`] for calling expectations.
438          * 
439          * [`block_connected`]: Self::block_connected
440          */
441         public TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] best_block_updated(byte[] header, int height, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
442                 long ret = bindings.ChannelMonitor_best_block_updated(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
443                 GC.KeepAlive(this);
444                 GC.KeepAlive(header);
445                 GC.KeepAlive(height);
446                 GC.KeepAlive(broadcaster);
447                 GC.KeepAlive(fee_estimator);
448                 GC.KeepAlive(logger);
449                 if (ret >= 0 && ret <= 4096) { return null; }
450                 int ret_conv_49_len = InternalUtils.getArrayLength(ret);
451                 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] ret_conv_49_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[ret_conv_49_len];
452                 for (int x = 0; x < ret_conv_49_len; x++) {
453                         long ret_conv_49 = InternalUtils.getU64ArrayElem(ret, x);
454                         TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ ret_conv_49_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ(null, ret_conv_49);
455                         if (ret_conv_49_hu_conv != null) { ret_conv_49_hu_conv.ptrs_to.AddLast(this); };
456                         ret_conv_49_arr[x] = ret_conv_49_hu_conv;
457                 }
458                 bindings.free_buffer(ret);
459                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
460                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
461                 if (this != null) { this.ptrs_to.AddLast(logger); };
462                 return ret_conv_49_arr;
463         }
464
465         /**
466          * Returns the set of txids that should be monitored for re-organization out of the chain.
467          */
468         public ThreeTuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ[] get_relevant_txids() {
469                 long ret = bindings.ChannelMonitor_get_relevant_txids(this.ptr);
470                 GC.KeepAlive(this);
471                 if (ret >= 0 && ret <= 4096) { return null; }
472                 int ret_conv_54_len = InternalUtils.getArrayLength(ret);
473                 ThreeTuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ[] ret_conv_54_arr = new ThreeTuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ[ret_conv_54_len];
474                 for (int c = 0; c < ret_conv_54_len; c++) {
475                         long ret_conv_54 = InternalUtils.getU64ArrayElem(ret, c);
476                         ThreeTuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ ret_conv_54_hu_conv = new ThreeTuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ(null, ret_conv_54);
477                         if (ret_conv_54_hu_conv != null) { ret_conv_54_hu_conv.ptrs_to.AddLast(this); };
478                         ret_conv_54_arr[c] = ret_conv_54_hu_conv;
479                 }
480                 bindings.free_buffer(ret);
481                 return ret_conv_54_arr;
482         }
483
484         /**
485          * Gets the latest best block which was connected either via the [`chain::Listen`] or
486          * [`chain::Confirm`] interfaces.
487          */
488         public BestBlock current_best_block() {
489                 long ret = bindings.ChannelMonitor_current_best_block(this.ptr);
490                 GC.KeepAlive(this);
491                 if (ret >= 0 && ret <= 4096) { return null; }
492                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
493                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
494                 return ret_hu_conv;
495         }
496
497         /**
498          * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is
499          * crucial in preventing certain classes of pinning attacks, detecting substantial mempool
500          * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend
501          * invoking this every 30 seconds, or lower if running in an environment with spotty
502          * connections, like on mobile.
503          */
504         public void rebroadcast_pending_claims(org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
505                 bindings.ChannelMonitor_rebroadcast_pending_claims(this.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
506                 GC.KeepAlive(this);
507                 GC.KeepAlive(broadcaster);
508                 GC.KeepAlive(fee_estimator);
509                 GC.KeepAlive(logger);
510                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
511                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
512                 if (this != null) { this.ptrs_to.AddLast(logger); };
513         }
514
515         /**
516          * Triggers rebroadcasts of pending claims from a force-closed channel after a transaction
517          * signature generation failure.
518          */
519         public void signer_unblocked(org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
520                 bindings.ChannelMonitor_signer_unblocked(this.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
521                 GC.KeepAlive(this);
522                 GC.KeepAlive(broadcaster);
523                 GC.KeepAlive(fee_estimator);
524                 GC.KeepAlive(logger);
525                 if (this != null) { this.ptrs_to.AddLast(broadcaster); };
526                 if (this != null) { this.ptrs_to.AddLast(fee_estimator); };
527                 if (this != null) { this.ptrs_to.AddLast(logger); };
528         }
529
530         /**
531          * Returns the descriptors for relevant outputs (i.e., those that we can spend) within the
532          * transaction if they exist and the transaction has at least [`ANTI_REORG_DELAY`]
533          * confirmations. For [`SpendableOutputDescriptor::DelayedPaymentOutput`] descriptors to be
534          * returned, the transaction must have at least `max(ANTI_REORG_DELAY, to_self_delay)`
535          * confirmations.
536          * 
537          * Descriptors returned by this method are primarily exposed via [`Event::SpendableOutputs`]
538          * once they are no longer under reorg risk. This method serves as a way to retrieve these
539          * descriptors at a later time, either for historical purposes, or to replay any
540          * missed/unhandled descriptors. For the purpose of gathering historical records, if the
541          * channel close has fully resolved (i.e., [`ChannelMonitor::get_claimable_balances`] returns
542          * an empty set), you can retrieve all spendable outputs by providing all descendant spending
543          * transactions starting from the channel's funding transaction and going down three levels.
544          * 
545          * `tx` is a transaction we'll scan the outputs of. Any transaction can be provided. If any
546          * outputs which can be spent by us are found, at least one descriptor is returned.
547          * 
548          * `confirmation_height` must be the height of the block in which `tx` was included in.
549          */
550         public SpendableOutputDescriptor[] get_spendable_outputs(byte[] tx, int confirmation_height) {
551                 long ret = bindings.ChannelMonitor_get_spendable_outputs(this.ptr, InternalUtils.encodeUint8Array(tx), confirmation_height);
552                 GC.KeepAlive(this);
553                 GC.KeepAlive(tx);
554                 GC.KeepAlive(confirmation_height);
555                 if (ret >= 0 && ret <= 4096) { return null; }
556                 int ret_conv_27_len = InternalUtils.getArrayLength(ret);
557                 SpendableOutputDescriptor[] ret_conv_27_arr = new SpendableOutputDescriptor[ret_conv_27_len];
558                 for (int b = 0; b < ret_conv_27_len; b++) {
559                         long ret_conv_27 = InternalUtils.getU64ArrayElem(ret, b);
560                         org.ldk.structs.SpendableOutputDescriptor ret_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret_conv_27);
561                         if (ret_conv_27_hu_conv != null) { ret_conv_27_hu_conv.ptrs_to.AddLast(this); };
562                         ret_conv_27_arr[b] = ret_conv_27_hu_conv;
563                 }
564                 bindings.free_buffer(ret);
565                 return ret_conv_27_arr;
566         }
567
568         /**
569          * Checks if the monitor is fully resolved. Resolved monitor is one that has claimed all of
570          * its outputs and balances (i.e. [`Self::get_claimable_balances`] returns an empty set).
571          * 
572          * This function returns true only if [`Self::get_claimable_balances`] has been empty for at least
573          * 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets.
574          */
575         public bool is_fully_resolved(org.ldk.structs.Logger logger) {
576                 bool ret = bindings.ChannelMonitor_is_fully_resolved(this.ptr, logger.ptr);
577                 GC.KeepAlive(this);
578                 GC.KeepAlive(logger);
579                 if (this != null) { this.ptrs_to.AddLast(logger); };
580                 return ret;
581         }
582
583         /**
584          * Gets the balances in this channel which are either claimable by us if we were to
585          * force-close the channel now or which are claimable on-chain (possibly awaiting
586          * confirmation).
587          * 
588          * Any balances in the channel which are available on-chain (excluding on-chain fees) are
589          * included here until an [`Event::SpendableOutputs`] event has been generated for the
590          * balance, or until our counterparty has claimed the balance and accrued several
591          * confirmations on the claim transaction.
592          * 
593          * Note that for `ChannelMonitors` which track a channel which went on-chain with versions of
594          * LDK prior to 0.0.111, not all or excess balances may be included.
595          * 
596          * See [`Balance`] for additional details on the types of claimable balances which
597          * may be returned here and their meanings.
598          */
599         public Balance[] get_claimable_balances() {
600                 long ret = bindings.ChannelMonitor_get_claimable_balances(this.ptr);
601                 GC.KeepAlive(this);
602                 if (ret >= 0 && ret <= 4096) { return null; }
603                 int ret_conv_9_len = InternalUtils.getArrayLength(ret);
604                 Balance[] ret_conv_9_arr = new Balance[ret_conv_9_len];
605                 for (int j = 0; j < ret_conv_9_len; j++) {
606                         long ret_conv_9 = InternalUtils.getU64ArrayElem(ret, j);
607                         org.ldk.structs.Balance ret_conv_9_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret_conv_9);
608                         if (ret_conv_9_hu_conv != null) { ret_conv_9_hu_conv.ptrs_to.AddLast(this); };
609                         ret_conv_9_arr[j] = ret_conv_9_hu_conv;
610                 }
611                 bindings.free_buffer(ret);
612                 return ret_conv_9_arr;
613         }
614
615 }
616 } } }