1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
13 * on-chain transactions to ensure no loss of funds occurs.
15 * You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
16 * information and are actively monitoring the chain.
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!
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 {
30 if (ptr != 0) { bindings.ChannelMonitor_free(ptr); }
34 long ret = bindings.ChannelMonitor_clone_ptr(this.ptr);
35 Reference.reachabilityFence(this);
40 * Creates a copy of the ChannelMonitor
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); };
52 * Serialize the ChannelMonitor object into a byte array which can be read by ChannelMonitor_read
54 public byte[] write() {
55 byte[] ret = bindings.ChannelMonitor_write(this.ptr);
56 Reference.reachabilityFence(this);
61 * Updates a ChannelMonitor on the basis of some new information provided by the Channel
64 * panics if the given update is not the next update by update_id.
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 == null ? 0 : 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); };
83 * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
86 public long get_latest_update_id() {
87 long ret = bindings.ChannelMonitor_get_latest_update_id(this.ptr);
88 Reference.reachabilityFence(this);
93 * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
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); };
105 * Gets a list of txids, with their output scripts (in the order they appear in the
106 * transaction), which we must learn about spends of via block_connected().
108 public TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ[] get_outputs_to_watch() {
109 long[] ret = bindings.ChannelMonitor_get_outputs_to_watch(this.ptr);
110 Reference.reachabilityFence(this);
111 int ret_conv_52_len = ret.length;
112 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ[] ret_conv_52_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ[ret_conv_52_len];
113 for (int a = 0; a < ret_conv_52_len; a++) {
114 long ret_conv_52 = ret[a];
115 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ ret_conv_52_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ(null, ret_conv_52);
116 if (ret_conv_52_hu_conv != null) { ret_conv_52_hu_conv.ptrs_to.add(this); };
117 ret_conv_52_arr[a] = ret_conv_52_hu_conv;
119 return ret_conv_52_arr;
123 * Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly
124 * calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs
125 * have been registered.
127 public void load_outputs_to_watch(org.ldk.structs.Filter filter) {
128 bindings.ChannelMonitor_load_outputs_to_watch(this.ptr, filter.ptr);
129 Reference.reachabilityFence(this);
130 Reference.reachabilityFence(filter);
131 if (this != null) { this.ptrs_to.add(filter); };
135 * Get the list of HTLCs who's status has been updated on chain. This should be called by
136 * ChannelManager via [`chain::Watch::release_pending_monitor_events`].
138 public MonitorEvent[] get_and_clear_pending_monitor_events() {
139 long[] ret = bindings.ChannelMonitor_get_and_clear_pending_monitor_events(this.ptr);
140 Reference.reachabilityFence(this);
141 int ret_conv_14_len = ret.length;
142 MonitorEvent[] ret_conv_14_arr = new MonitorEvent[ret_conv_14_len];
143 for (int o = 0; o < ret_conv_14_len; o++) {
144 long ret_conv_14 = ret[o];
145 org.ldk.structs.MonitorEvent ret_conv_14_hu_conv = org.ldk.structs.MonitorEvent.constr_from_ptr(ret_conv_14);
146 if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.add(this); };
147 ret_conv_14_arr[o] = ret_conv_14_hu_conv;
149 return ret_conv_14_arr;
153 * Processes [`SpendableOutputs`] events produced from each [`ChannelMonitor`] upon maturity.
155 * For channels featuring anchor outputs, this method will also process [`BumpTransaction`]
156 * events produced from each [`ChannelMonitor`] while there is a balance to claim onchain
157 * within each channel. As the confirmation of a commitment transaction may be critical to the
158 * safety of funds, we recommend invoking this every 30 seconds, or lower if running in an
159 * environment with spotty connections, like on mobile.
161 * An [`EventHandler`] may safely call back to the provider, though this shouldn't be needed in
162 * order to handle these events.
164 * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs
165 * [`BumpTransaction`]: crate::events::Event::BumpTransaction
167 public void process_pending_events(org.ldk.structs.EventHandler handler) {
168 bindings.ChannelMonitor_process_pending_events(this.ptr, handler.ptr);
169 Reference.reachabilityFence(this);
170 Reference.reachabilityFence(handler);
171 if (this != null) { this.ptrs_to.add(handler); };
175 * Gets the counterparty's initial commitment transaction. The returned commitment
176 * transaction is unsigned. This is intended to be called during the initial persistence of
177 * the monitor (inside an implementation of [`Persist::persist_new_channel`]), to allow for
178 * watchtowers in the persistence pipeline to have enough data to form justice transactions.
180 * This is similar to [`Self::counterparty_commitment_txs_from_update`], except
181 * that for the initial commitment transaction, we don't have a corresponding update.
183 * This will only return `Some` for channel monitors that have been created after upgrading
186 * [`Persist::persist_new_channel`]: crate::chain::chainmonitor::Persist::persist_new_channel
188 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
191 public CommitmentTransaction initial_counterparty_commitment_tx() {
192 long ret = bindings.ChannelMonitor_initial_counterparty_commitment_tx(this.ptr);
193 Reference.reachabilityFence(this);
194 if (ret >= 0 && ret <= 4096) { return null; }
195 org.ldk.structs.CommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentTransaction(null, ret); }
196 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
201 * Gets all of the counterparty commitment transactions provided by the given update. This
202 * may be empty if the update doesn't include any new counterparty commitments. Returned
203 * commitment transactions are unsigned.
205 * This is provided so that watchtower clients in the persistence pipeline are able to build
206 * justice transactions for each counterparty commitment upon each update. It's intended to be
207 * used within an implementation of [`Persist::update_persisted_channel`], which is provided
208 * with a monitor and an update. Once revoked, signing a justice transaction can be done using
209 * [`Self::sign_to_local_justice_tx`].
211 * It is expected that a watchtower client may use this method to retrieve the latest counterparty
212 * commitment transaction(s), and then hold the necessary data until a later update in which
213 * the monitor has been updated with the corresponding revocation data, at which point the
214 * monitor can sign the justice transaction.
216 * This will only return a non-empty list for monitor updates that have been created after
217 * upgrading to LDK 0.0.117+. Note that no restriction lies on the monitors themselves, which
218 * may have been created prior to upgrading.
220 * [`Persist::update_persisted_channel`]: crate::chain::chainmonitor::Persist::update_persisted_channel
222 public CommitmentTransaction[] counterparty_commitment_txs_from_update(org.ldk.structs.ChannelMonitorUpdate update) {
223 long[] ret = bindings.ChannelMonitor_counterparty_commitment_txs_from_update(this.ptr, update == null ? 0 : update.ptr);
224 Reference.reachabilityFence(this);
225 Reference.reachabilityFence(update);
226 int ret_conv_23_len = ret.length;
227 CommitmentTransaction[] ret_conv_23_arr = new CommitmentTransaction[ret_conv_23_len];
228 for (int x = 0; x < ret_conv_23_len; x++) {
229 long ret_conv_23 = ret[x];
230 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); }
231 if (ret_conv_23_hu_conv != null) { ret_conv_23_hu_conv.ptrs_to.add(this); };
232 ret_conv_23_arr[x] = ret_conv_23_hu_conv;
234 if (this != null) { this.ptrs_to.add(update); };
235 return ret_conv_23_arr;
239 * Wrapper around [`EcdsaChannelSigner::sign_justice_revoked_output`] to make
240 * signing the justice transaction easier for implementors of
241 * [`chain::chainmonitor::Persist`]. On success this method returns the provided transaction
242 * signing the input at `input_idx`. This method will only produce a valid signature for
243 * a transaction spending the `to_local` output of a commitment transaction, i.e. this cannot
244 * be used for revoked HTLC outputs.
246 * `Value` is the value of the output being spent by the input at `input_idx`, committed
247 * in the BIP 143 signature.
249 * This method will only succeed if this monitor has received the revocation secret for the
250 * provided `commitment_number`. If a commitment number is provided that does not correspond
251 * to the commitment transaction being revoked, this will return a signed transaction, but
252 * the signature will not be valid.
254 * [`EcdsaChannelSigner::sign_justice_revoked_output`]: crate::sign::EcdsaChannelSigner::sign_justice_revoked_output
255 * [`Persist`]: crate::chain::chainmonitor::Persist
257 public Result_TransactionNoneZ sign_to_local_justice_tx(byte[] justice_tx, long input_idx, long value, long commitment_number) {
258 long ret = bindings.ChannelMonitor_sign_to_local_justice_tx(this.ptr, justice_tx, input_idx, value, commitment_number);
259 Reference.reachabilityFence(this);
260 Reference.reachabilityFence(justice_tx);
261 Reference.reachabilityFence(input_idx);
262 Reference.reachabilityFence(value);
263 Reference.reachabilityFence(commitment_number);
264 if (ret >= 0 && ret <= 4096) { return null; }
265 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
270 * Gets the `node_id` of the counterparty for this channel.
272 * Will be `None` for channels constructed on LDK versions prior to 0.0.110 and always `Some`
275 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
278 public byte[] get_counterparty_node_id() {
279 byte[] ret = bindings.ChannelMonitor_get_counterparty_node_id(this.ptr);
280 Reference.reachabilityFence(this);
285 * Used by [`ChannelManager`] deserialization to broadcast the latest holder state if its copy
286 * of the channel state was out-of-date.
288 * You may also use this to broadcast the latest local commitment transaction, either because
289 * a monitor update failed or because we've fallen behind (i.e. we've received proof that our
290 * counterparty side knows a revocation secret we gave them that they shouldn't know).
292 * Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty
293 * side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't
294 * close channel with their commitment transaction after a substantial amount of time. Best
295 * may be to contact the other node operator out-of-band to coordinate other options available
298 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
300 public byte[][] get_latest_holder_commitment_txn(org.ldk.structs.Logger logger) {
301 byte[][] ret = bindings.ChannelMonitor_get_latest_holder_commitment_txn(this.ptr, logger.ptr);
302 Reference.reachabilityFence(this);
303 Reference.reachabilityFence(logger);
304 if (this != null) { this.ptrs_to.add(logger); };
309 * Processes transactions in a newly connected block, which may result in any of the following:
310 * - update the monitor's state against resolved HTLCs
311 * - punish the counterparty in the case of seeing a revoked commitment transaction
312 * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration
313 * - detect settled outputs for later spending
314 * - schedule and bump any in-flight claims
316 * Returns any new outputs to watch from `txdata`; after called, these are also included in
317 * [`get_outputs_to_watch`].
319 * [`get_outputs_to_watch`]: #method.get_outputs_to_watch
321 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) {
322 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 != null ? txdata_conv_28.ptr : 0).toArray() : null, height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
323 Reference.reachabilityFence(this);
324 Reference.reachabilityFence(header);
325 Reference.reachabilityFence(txdata);
326 Reference.reachabilityFence(height);
327 Reference.reachabilityFence(broadcaster);
328 Reference.reachabilityFence(fee_estimator);
329 Reference.reachabilityFence(logger);
330 int ret_conv_49_len = ret.length;
331 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] ret_conv_49_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[ret_conv_49_len];
332 for (int x = 0; x < ret_conv_49_len; x++) {
333 long ret_conv_49 = ret[x];
334 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ ret_conv_49_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ(null, ret_conv_49);
335 if (ret_conv_49_hu_conv != null) { ret_conv_49_hu_conv.ptrs_to.add(this); };
336 ret_conv_49_arr[x] = ret_conv_49_hu_conv;
338 if (this != null) { this.ptrs_to.add(broadcaster); };
339 if (this != null) { this.ptrs_to.add(fee_estimator); };
340 if (this != null) { this.ptrs_to.add(logger); };
341 return ret_conv_49_arr;
345 * Determines if the disconnected block contained any transactions of interest and updates
348 public void block_disconnected(byte[] header, int height, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
349 bindings.ChannelMonitor_block_disconnected(this.ptr, InternalUtils.check_arr_len(header, 80), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
350 Reference.reachabilityFence(this);
351 Reference.reachabilityFence(header);
352 Reference.reachabilityFence(height);
353 Reference.reachabilityFence(broadcaster);
354 Reference.reachabilityFence(fee_estimator);
355 Reference.reachabilityFence(logger);
356 if (this != null) { this.ptrs_to.add(broadcaster); };
357 if (this != null) { this.ptrs_to.add(fee_estimator); };
358 if (this != null) { this.ptrs_to.add(logger); };
362 * Processes transactions confirmed in a block with the given header and height, returning new
363 * outputs to watch. See [`block_connected`] for details.
365 * Used instead of [`block_connected`] by clients that are notified of transactions rather than
366 * blocks. See [`chain::Confirm`] for calling expectations.
368 * [`block_connected`]: Self::block_connected
370 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) {
371 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 != null ? txdata_conv_28.ptr : 0).toArray() : null, height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
372 Reference.reachabilityFence(this);
373 Reference.reachabilityFence(header);
374 Reference.reachabilityFence(txdata);
375 Reference.reachabilityFence(height);
376 Reference.reachabilityFence(broadcaster);
377 Reference.reachabilityFence(fee_estimator);
378 Reference.reachabilityFence(logger);
379 int ret_conv_49_len = ret.length;
380 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] ret_conv_49_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[ret_conv_49_len];
381 for (int x = 0; x < ret_conv_49_len; x++) {
382 long ret_conv_49 = ret[x];
383 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ ret_conv_49_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ(null, ret_conv_49);
384 if (ret_conv_49_hu_conv != null) { ret_conv_49_hu_conv.ptrs_to.add(this); };
385 ret_conv_49_arr[x] = ret_conv_49_hu_conv;
387 if (this != null) { this.ptrs_to.add(broadcaster); };
388 if (this != null) { this.ptrs_to.add(fee_estimator); };
389 if (this != null) { this.ptrs_to.add(logger); };
390 return ret_conv_49_arr;
394 * Processes a transaction that was reorganized out of the chain.
396 * Used instead of [`block_disconnected`] by clients that are notified of transactions rather
397 * than blocks. See [`chain::Confirm`] for calling expectations.
399 * [`block_disconnected`]: Self::block_disconnected
401 public void transaction_unconfirmed(byte[] txid, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
402 bindings.ChannelMonitor_transaction_unconfirmed(this.ptr, InternalUtils.check_arr_len(txid, 32), broadcaster.ptr, fee_estimator.ptr, logger.ptr);
403 Reference.reachabilityFence(this);
404 Reference.reachabilityFence(txid);
405 Reference.reachabilityFence(broadcaster);
406 Reference.reachabilityFence(fee_estimator);
407 Reference.reachabilityFence(logger);
408 if (this != null) { this.ptrs_to.add(broadcaster); };
409 if (this != null) { this.ptrs_to.add(fee_estimator); };
410 if (this != null) { this.ptrs_to.add(logger); };
414 * Updates the monitor with the current best chain tip, returning new outputs to watch. See
415 * [`block_connected`] for details.
417 * Used instead of [`block_connected`] by clients that are notified of transactions rather than
418 * blocks. See [`chain::Confirm`] for calling expectations.
420 * [`block_connected`]: Self::block_connected
422 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) {
423 long[] ret = bindings.ChannelMonitor_best_block_updated(this.ptr, InternalUtils.check_arr_len(header, 80), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
424 Reference.reachabilityFence(this);
425 Reference.reachabilityFence(header);
426 Reference.reachabilityFence(height);
427 Reference.reachabilityFence(broadcaster);
428 Reference.reachabilityFence(fee_estimator);
429 Reference.reachabilityFence(logger);
430 int ret_conv_49_len = ret.length;
431 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] ret_conv_49_arr = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[ret_conv_49_len];
432 for (int x = 0; x < ret_conv_49_len; x++) {
433 long ret_conv_49 = ret[x];
434 TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ ret_conv_49_hu_conv = new TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ(null, ret_conv_49);
435 if (ret_conv_49_hu_conv != null) { ret_conv_49_hu_conv.ptrs_to.add(this); };
436 ret_conv_49_arr[x] = ret_conv_49_hu_conv;
438 if (this != null) { this.ptrs_to.add(broadcaster); };
439 if (this != null) { this.ptrs_to.add(fee_estimator); };
440 if (this != null) { this.ptrs_to.add(logger); };
441 return ret_conv_49_arr;
445 * Returns the set of txids that should be monitored for re-organization out of the chain.
447 public TwoTuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ[] get_relevant_txids() {
448 long[] ret = bindings.ChannelMonitor_get_relevant_txids(this.ptr);
449 Reference.reachabilityFence(this);
450 int ret_conv_49_len = ret.length;
451 TwoTuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ[] ret_conv_49_arr = new TwoTuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ[ret_conv_49_len];
452 for (int x = 0; x < ret_conv_49_len; x++) {
453 long ret_conv_49 = ret[x];
454 TwoTuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ ret_conv_49_hu_conv = new TwoTuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ(null, ret_conv_49);
455 if (ret_conv_49_hu_conv != null) { ret_conv_49_hu_conv.ptrs_to.add(this); };
456 ret_conv_49_arr[x] = ret_conv_49_hu_conv;
458 return ret_conv_49_arr;
462 * Gets the latest best block which was connected either via the [`chain::Listen`] or
463 * [`chain::Confirm`] interfaces.
465 public BestBlock current_best_block() {
466 long ret = bindings.ChannelMonitor_current_best_block(this.ptr);
467 Reference.reachabilityFence(this);
468 if (ret >= 0 && ret <= 4096) { return null; }
469 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
470 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
475 * Triggers rebroadcasts/fee-bumps of pending claims from a force-closed channel. This is
476 * crucial in preventing certain classes of pinning attacks, detecting substantial mempool
477 * feerate changes between blocks, and ensuring reliability if broadcasting fails. We recommend
478 * invoking this every 30 seconds, or lower if running in an environment with spotty
479 * connections, like on mobile.
481 public void rebroadcast_pending_claims(org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) {
482 bindings.ChannelMonitor_rebroadcast_pending_claims(this.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr);
483 Reference.reachabilityFence(this);
484 Reference.reachabilityFence(broadcaster);
485 Reference.reachabilityFence(fee_estimator);
486 Reference.reachabilityFence(logger);
487 if (this != null) { this.ptrs_to.add(broadcaster); };
488 if (this != null) { this.ptrs_to.add(fee_estimator); };
489 if (this != null) { this.ptrs_to.add(logger); };
493 * Returns the descriptors for relevant outputs (i.e., those that we can spend) within the
494 * transaction if they exist and the transaction has at least [`ANTI_REORG_DELAY`]
495 * confirmations. For [`SpendableOutputDescriptor::DelayedPaymentOutput`] descriptors to be
496 * returned, the transaction must have at least `max(ANTI_REORG_DELAY, to_self_delay)`
499 * Descriptors returned by this method are primarily exposed via [`Event::SpendableOutputs`]
500 * once they are no longer under reorg risk. This method serves as a way to retrieve these
501 * descriptors at a later time, either for historical purposes, or to replay any
502 * missed/unhandled descriptors. For the purpose of gathering historical records, if the
503 * channel close has fully resolved (i.e., [`ChannelMonitor::get_claimable_balances`] returns
504 * an empty set), you can retrieve all spendable outputs by providing all descendant spending
505 * transactions starting from the channel's funding transaction and going down three levels.
507 * `tx` is a transaction we'll scan the outputs of. Any transaction can be provided. If any
508 * outputs which can be spent by us are found, at least one descriptor is returned.
510 * `confirmation_height` must be the height of the block in which `tx` was included in.
512 public SpendableOutputDescriptor[] get_spendable_outputs(byte[] tx, int confirmation_height) {
513 long[] ret = bindings.ChannelMonitor_get_spendable_outputs(this.ptr, tx, confirmation_height);
514 Reference.reachabilityFence(this);
515 Reference.reachabilityFence(tx);
516 Reference.reachabilityFence(confirmation_height);
517 int ret_conv_27_len = ret.length;
518 SpendableOutputDescriptor[] ret_conv_27_arr = new SpendableOutputDescriptor[ret_conv_27_len];
519 for (int b = 0; b < ret_conv_27_len; b++) {
520 long ret_conv_27 = ret[b];
521 org.ldk.structs.SpendableOutputDescriptor ret_conv_27_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret_conv_27);
522 if (ret_conv_27_hu_conv != null) { ret_conv_27_hu_conv.ptrs_to.add(this); };
523 ret_conv_27_arr[b] = ret_conv_27_hu_conv;
525 return ret_conv_27_arr;
529 * Gets the balances in this channel which are either claimable by us if we were to
530 * force-close the channel now or which are claimable on-chain (possibly awaiting
533 * Any balances in the channel which are available on-chain (excluding on-chain fees) are
534 * included here until an [`Event::SpendableOutputs`] event has been generated for the
535 * balance, or until our counterparty has claimed the balance and accrued several
536 * confirmations on the claim transaction.
538 * Note that for `ChannelMonitors` which track a channel which went on-chain with versions of
539 * LDK prior to 0.0.111, not all or excess balances may be included.
541 * See [`Balance`] for additional details on the types of claimable balances which
542 * may be returned here and their meanings.
544 public Balance[] get_claimable_balances() {
545 long[] ret = bindings.ChannelMonitor_get_claimable_balances(this.ptr);
546 Reference.reachabilityFence(this);
547 int ret_conv_9_len = ret.length;
548 Balance[] ret_conv_9_arr = new Balance[ret_conv_9_len];
549 for (int j = 0; j < ret_conv_9_len; j++) {
550 long ret_conv_9 = ret[j];
551 org.ldk.structs.Balance ret_conv_9_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret_conv_9);
552 if (ret_conv_9_hu_conv != null) { ret_conv_9_hu_conv.ptrs_to.add(this); };
553 ret_conv_9_arr[j] = ret_conv_9_hu_conv;
555 return ret_conv_9_arr;