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