[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / ChannelManager.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  * Manager which keeps track of a number of channels and sends messages to the appropriate
13  * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
14  * 
15  * Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through
16  * to individual Channels.
17  * 
18  * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
19  * all peers during write/read (though does not modify this instance, only the instance being
20  * serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e.,
21  * called [`funding_transaction_generated`] for outbound channels) being closed.
22  * 
23  * Note that you can be a bit lazier about writing out `ChannelManager` than you can be with
24  * [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST durably write each
25  * [`ChannelMonitorUpdate`] before returning from
26  * [`chain::Watch::watch_channel`]/[`update_channel`] or before completing async writes. With
27  * `ChannelManager`s, writing updates happens out-of-band (and will prevent any other
28  * `ChannelManager` operations from occurring during the serialization process). If the
29  * deserialized version is out-of-date compared to the [`ChannelMonitor`] passed by reference to
30  * [`read`], those channels will be force-closed based on the `ChannelMonitor` state and no funds
31  * will be lost (modulo on-chain transaction fees).
32  * 
33  * Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which
34  * tells you the last block hash which was connected. You should get the best block tip before using the manager.
35  * See [`chain::Listen`] and [`chain::Confirm`] for more details.
36  * 
37  * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating
38  * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid
39  * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
40  * offline for a full minute. In order to track this, you must call
41  * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect.
42  * 
43  * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and
44  * inbound channels without confirmed funding transactions. This may result in nodes which we do
45  * not have a channel with being unable to connect to us or open new channels with us if we have
46  * many peers with unfunded channels.
47  * 
48  * Because it is an indication of trust, inbound channels which we've accepted as 0conf are
49  * exempted from the count of unfunded channels. Similarly, outbound channels and connections are
50  * never limited. Please ensure you limit the count of such channels yourself.
51  * 
52  * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`]
53  * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but
54  * essentially you should default to using a [`SimpleRefChannelManager`], and use a
55  * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when
56  * you're using lightning-net-tokio.
57  * 
58  * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
59  * [`funding_created`]: msgs::FundingCreated
60  * [`funding_transaction_generated`]: Self::funding_transaction_generated
61  * [`BlockHash`]: bitcoin::hash_types::BlockHash
62  * [`update_channel`]: chain::Watch::update_channel
63  * [`ChannelUpdate`]: msgs::ChannelUpdate
64  * [`timer_tick_occurred`]: Self::timer_tick_occurred
65  * [`read`]: ReadableArgs::read
66  */
67 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
68 public class ChannelManager extends CommonBase {
69         ChannelManager(Object _dummy, long ptr) { super(ptr); }
70         @Override @SuppressWarnings("deprecation")
71         protected void finalize() throws Throwable {
72                 super.finalize();
73                 if (ptr != 0) { bindings.ChannelManager_free(ptr); }
74         }
75
76         /**
77          * Constructs a new `ChannelManager` to hold several channels and route between them.
78          * 
79          * The current time or latest block header time can be provided as the `current_timestamp`.
80          * 
81          * This is the main \"logic hub\" for all channel-related actions, and implements
82          * [`ChannelMessageHandler`].
83          * 
84          * Non-proportional fees are fixed according to our risk using the provided fee estimator.
85          * 
86          * Users need to notify the new `ChannelManager` when a new block is connected or
87          * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting
88          * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for
89          * more details.
90          * 
91          * [`block_connected`]: chain::Listen::block_connected
92          * [`block_disconnected`]: chain::Listen::block_disconnected
93          * [`params.best_block.block_hash`]: chain::BestBlock::block_hash
94          */
95         public static ChannelManager of(org.ldk.structs.FeeEstimator fee_est, org.ldk.structs.Watch chain_monitor, org.ldk.structs.BroadcasterInterface tx_broadcaster, org.ldk.structs.Router router, org.ldk.structs.Logger logger, org.ldk.structs.EntropySource entropy_source, org.ldk.structs.NodeSigner node_signer, org.ldk.structs.SignerProvider signer_provider, org.ldk.structs.UserConfig config, org.ldk.structs.ChainParameters params, int current_timestamp) {
96                 long ret = bindings.ChannelManager_new(fee_est.ptr, chain_monitor.ptr, tx_broadcaster.ptr, router.ptr, logger.ptr, entropy_source.ptr, node_signer.ptr, signer_provider.ptr, config == null ? 0 : config.ptr, params == null ? 0 : params.ptr, current_timestamp);
97                 Reference.reachabilityFence(fee_est);
98                 Reference.reachabilityFence(chain_monitor);
99                 Reference.reachabilityFence(tx_broadcaster);
100                 Reference.reachabilityFence(router);
101                 Reference.reachabilityFence(logger);
102                 Reference.reachabilityFence(entropy_source);
103                 Reference.reachabilityFence(node_signer);
104                 Reference.reachabilityFence(signer_provider);
105                 Reference.reachabilityFence(config);
106                 Reference.reachabilityFence(params);
107                 Reference.reachabilityFence(current_timestamp);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 org.ldk.structs.ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManager(null, ret); }
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_est); };
112                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(chain_monitor); };
113                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(tx_broadcaster); };
114                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(router); };
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
118                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(signer_provider); };
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(config); };
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(params); };
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Gets the current configuration applied to all new channels.
126          */
127         public UserConfig get_current_default_configuration() {
128                 long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
129                 Reference.reachabilityFence(this);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
132                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
133                 return ret_hu_conv;
134         }
135
136         /**
137          * Creates a new outbound channel to the given remote node and with the given value.
138          * 
139          * `user_channel_id` will be provided back as in
140          * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
141          * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
142          * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
143          * is simply copied to events and otherwise ignored.
144          * 
145          * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
146          * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
147          * 
148          * Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to
149          * generate a shutdown scriptpubkey or destination script set by
150          * [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`].
151          * 
152          * Note that we do not check if you are currently connected to the given peer. If no
153          * connection is available, the outbound `open_channel` message may fail to send, resulting in
154          * the channel eventually being silently forgotten (dropped on reload).
155          * 
156          * Returns the new Channel's temporary `channel_id`. This ID will appear as
157          * [`Event::FundingGenerationReady::temporary_channel_id`] and in
158          * [`ChannelDetails::channel_id`] until after
159          * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
160          * one derived from the funding transaction's TXID. If the counterparty rejects the channel
161          * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
162          * 
163          * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
164          * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
165          * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
166          * 
167          * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
168          */
169         public Result_ThirtyTwoBytesAPIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, org.ldk.util.UInt128 user_channel_id, @Nullable org.ldk.structs.UserConfig override_config) {
170                 long ret = bindings.ChannelManager_create_channel(this.ptr, InternalUtils.check_arr_len(their_network_key, 33), channel_value_satoshis, push_msat, user_channel_id.getLEBytes(), override_config == null ? 0 : override_config.ptr);
171                 Reference.reachabilityFence(this);
172                 Reference.reachabilityFence(their_network_key);
173                 Reference.reachabilityFence(channel_value_satoshis);
174                 Reference.reachabilityFence(push_msat);
175                 Reference.reachabilityFence(user_channel_id);
176                 Reference.reachabilityFence(override_config);
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 Result_ThirtyTwoBytesAPIErrorZ ret_hu_conv = Result_ThirtyTwoBytesAPIErrorZ.constr_from_ptr(ret);
179                 if (this != null) { this.ptrs_to.add(override_config); };
180                 return ret_hu_conv;
181         }
182
183         /**
184          * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
185          * more information.
186          */
187         public ChannelDetails[] list_channels() {
188                 long[] ret = bindings.ChannelManager_list_channels(this.ptr);
189                 Reference.reachabilityFence(this);
190                 int ret_conv_16_len = ret.length;
191                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
192                 for (int q = 0; q < ret_conv_16_len; q++) {
193                         long ret_conv_16 = ret[q];
194                         org.ldk.structs.ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new org.ldk.structs.ChannelDetails(null, ret_conv_16); }
195                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
196                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
197                 }
198                 return ret_conv_16_arr;
199         }
200
201         /**
202          * Gets the list of usable channels, in random order. Useful as an argument to
203          * [`Router::find_route`] to ensure non-announced channels are used.
204          * 
205          * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
206          * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
207          * are.
208          */
209         public ChannelDetails[] list_usable_channels() {
210                 long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr);
211                 Reference.reachabilityFence(this);
212                 int ret_conv_16_len = ret.length;
213                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
214                 for (int q = 0; q < ret_conv_16_len; q++) {
215                         long ret_conv_16 = ret[q];
216                         org.ldk.structs.ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new org.ldk.structs.ChannelDetails(null, ret_conv_16); }
217                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
218                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
219                 }
220                 return ret_conv_16_arr;
221         }
222
223         /**
224          * Gets the list of channels we have with a given counterparty, in random order.
225          */
226         public ChannelDetails[] list_channels_with_counterparty(byte[] counterparty_node_id) {
227                 long[] ret = bindings.ChannelManager_list_channels_with_counterparty(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33));
228                 Reference.reachabilityFence(this);
229                 Reference.reachabilityFence(counterparty_node_id);
230                 int ret_conv_16_len = ret.length;
231                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
232                 for (int q = 0; q < ret_conv_16_len; q++) {
233                         long ret_conv_16 = ret[q];
234                         org.ldk.structs.ChannelDetails ret_conv_16_hu_conv = null; if (ret_conv_16 < 0 || ret_conv_16 > 4096) { ret_conv_16_hu_conv = new org.ldk.structs.ChannelDetails(null, ret_conv_16); }
235                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
236                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
237                 }
238                 return ret_conv_16_arr;
239         }
240
241         /**
242          * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
243          * successful path, or have unresolved HTLCs.
244          * 
245          * This can be useful for payments that may have been prepared, but ultimately not sent, as a
246          * result of a crash. If such a payment exists, is not listed here, and an
247          * [`Event::PaymentSent`] has not been received, you may consider resending the payment.
248          * 
249          * [`Event::PaymentSent`]: events::Event::PaymentSent
250          */
251         public RecentPaymentDetails[] list_recent_payments() {
252                 long[] ret = bindings.ChannelManager_list_recent_payments(this.ptr);
253                 Reference.reachabilityFence(this);
254                 int ret_conv_22_len = ret.length;
255                 RecentPaymentDetails[] ret_conv_22_arr = new RecentPaymentDetails[ret_conv_22_len];
256                 for (int w = 0; w < ret_conv_22_len; w++) {
257                         long ret_conv_22 = ret[w];
258                         org.ldk.structs.RecentPaymentDetails ret_conv_22_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret_conv_22);
259                         if (ret_conv_22_hu_conv != null) { ret_conv_22_hu_conv.ptrs_to.add(this); };
260                         ret_conv_22_arr[w] = ret_conv_22_hu_conv;
261                 }
262                 return ret_conv_22_arr;
263         }
264
265         /**
266          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
267          * will be accepted on the given channel, and after additional timeout/the closing of all
268          * pending HTLCs, the channel will be closed on chain.
269          * 
270          * If we are the channel initiator, we will pay between our [`Background`] and
271          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
272          * estimate.
273          * If our counterparty is the channel initiator, we will require a channel closing
274          * transaction feerate of at least our [`Background`] feerate or the feerate which
275          * would appear on a force-closure transaction, whichever is lower. We will allow our
276          * counterparty to pay as much fee as they'd like, however.
277          * 
278          * May generate a [`SendShutdown`] message event on success, which should be relayed.
279          * 
280          * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
281          * generate a shutdown scriptpubkey or destination script set by
282          * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
283          * channel.
284          * 
285          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
286          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
287          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
288          * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
289          */
290         public Result_NoneAPIErrorZ close_channel(byte[] channel_id, byte[] counterparty_node_id) {
291                 long ret = bindings.ChannelManager_close_channel(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
292                 Reference.reachabilityFence(this);
293                 Reference.reachabilityFence(channel_id);
294                 Reference.reachabilityFence(counterparty_node_id);
295                 if (ret >= 0 && ret <= 4096) { return null; }
296                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
297                 return ret_hu_conv;
298         }
299
300         /**
301          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
302          * will be accepted on the given channel, and after additional timeout/the closing of all
303          * pending HTLCs, the channel will be closed on chain.
304          * 
305          * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
306          * the channel being closed or not:
307          * If we are the channel initiator, we will pay at least this feerate on the closing
308          * transaction. The upper-bound is set by
309          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
310          * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
311          * If our counterparty is the channel initiator, we will refuse to accept a channel closure
312          * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
313          * will appear on a force-closure transaction, whichever is lower).
314          * 
315          * The `shutdown_script` provided  will be used as the `scriptPubKey` for the closing transaction.
316          * Will fail if a shutdown script has already been set for this channel by
317          * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must
318          * also be compatible with our and the counterparty's features.
319          * 
320          * May generate a [`SendShutdown`] message event on success, which should be relayed.
321          * 
322          * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
323          * generate a shutdown scriptpubkey or destination script set by
324          * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
325          * channel.
326          * 
327          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
328          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
329          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
330          * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
331          * 
332          * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None
333          */
334         public Result_NoneAPIErrorZ close_channel_with_feerate_and_script(byte[] channel_id, byte[] counterparty_node_id, org.ldk.structs.Option_u32Z target_feerate_sats_per_1000_weight, @Nullable org.ldk.structs.ShutdownScript shutdown_script) {
335                 long ret = bindings.ChannelManager_close_channel_with_feerate_and_script(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), target_feerate_sats_per_1000_weight.ptr, shutdown_script == null ? 0 : shutdown_script.ptr);
336                 Reference.reachabilityFence(this);
337                 Reference.reachabilityFence(channel_id);
338                 Reference.reachabilityFence(counterparty_node_id);
339                 Reference.reachabilityFence(target_feerate_sats_per_1000_weight);
340                 Reference.reachabilityFence(shutdown_script);
341                 if (ret >= 0 && ret <= 4096) { return null; }
342                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
343                 if (this != null) { this.ptrs_to.add(target_feerate_sats_per_1000_weight); };
344                 if (this != null) { this.ptrs_to.add(shutdown_script); };
345                 return ret_hu_conv;
346         }
347
348         /**
349          * Force closes a channel, immediately broadcasting the latest local transaction(s) and
350          * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
351          * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
352          * channel.
353          */
354         public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(byte[] channel_id, byte[] counterparty_node_id) {
355                 long ret = bindings.ChannelManager_force_close_broadcasting_latest_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
356                 Reference.reachabilityFence(this);
357                 Reference.reachabilityFence(channel_id);
358                 Reference.reachabilityFence(counterparty_node_id);
359                 if (ret >= 0 && ret <= 4096) { return null; }
360                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
361                 return ret_hu_conv;
362         }
363
364         /**
365          * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
366          * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
367          * `counterparty_node_id` isn't the counterparty of the corresponding channel.
368          * 
369          * You can always get the latest local transaction(s) to broadcast from
370          * [`ChannelMonitor::get_latest_holder_commitment_txn`].
371          */
372         public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(byte[] channel_id, byte[] counterparty_node_id) {
373                 long ret = bindings.ChannelManager_force_close_without_broadcasting_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
374                 Reference.reachabilityFence(this);
375                 Reference.reachabilityFence(channel_id);
376                 Reference.reachabilityFence(counterparty_node_id);
377                 if (ret >= 0 && ret <= 4096) { return null; }
378                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
379                 return ret_hu_conv;
380         }
381
382         /**
383          * Force close all channels, immediately broadcasting the latest local commitment transaction
384          * for each to the chain and rejecting new HTLCs on each.
385          */
386         public void force_close_all_channels_broadcasting_latest_txn() {
387                 bindings.ChannelManager_force_close_all_channels_broadcasting_latest_txn(this.ptr);
388                 Reference.reachabilityFence(this);
389         }
390
391         /**
392          * Force close all channels rejecting new HTLCs on each but without broadcasting the latest
393          * local transaction(s).
394          */
395         public void force_close_all_channels_without_broadcasting_txn() {
396                 bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr);
397                 Reference.reachabilityFence(this);
398         }
399
400         /**
401          * Sends a payment along a given route.
402          * 
403          * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
404          * fields for more info.
405          * 
406          * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
407          * [`PeerManager::process_events`]).
408          * 
409          * # Avoiding Duplicate Payments
410          * 
411          * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
412          * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
413          * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
414          * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
415          * second payment with the same [`PaymentId`].
416          * 
417          * Thus, in order to ensure duplicate payments are not sent, you should implement your own
418          * tracking of payments, including state to indicate once a payment has completed. Because you
419          * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
420          * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
421          * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
422          * 
423          * Additionally, in the scenario where we begin the process of sending a payment, but crash
424          * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
425          * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
426          * [`ChannelManager::list_recent_payments`] for more information.
427          * 
428          * # Possible Error States on [`PaymentSendFailure`]
429          * 
430          * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
431          * each entry matching the corresponding-index entry in the route paths, see
432          * [`PaymentSendFailure`] for more info.
433          * 
434          * In general, a path may raise:
435          * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
436          * node public key) is specified.
437          * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
438          * closed, doesn't exist, or the peer is currently disconnected.
439          * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
440          * relevant updates.
441          * 
442          * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
443          * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
444          * different route unless you intend to pay twice!
445          * 
446          * [`RouteHop`]: crate::routing::router::RouteHop
447          * [`Event::PaymentSent`]: events::Event::PaymentSent
448          * [`Event::PaymentFailed`]: events::Event::PaymentFailed
449          * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
450          * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
451          * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
452          */
453         public Result_NonePaymentSendFailureZ send_payment_with_route(org.ldk.structs.Route route, byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) {
454                 long ret = bindings.ChannelManager_send_payment_with_route(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_hash, 32), recipient_onion == null ? 0 : recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32));
455                 Reference.reachabilityFence(this);
456                 Reference.reachabilityFence(route);
457                 Reference.reachabilityFence(payment_hash);
458                 Reference.reachabilityFence(recipient_onion);
459                 Reference.reachabilityFence(payment_id);
460                 if (ret >= 0 && ret <= 4096) { return null; }
461                 Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
462                 if (this != null) { this.ptrs_to.add(route); };
463                 if (this != null) { this.ptrs_to.add(recipient_onion); };
464                 return ret_hu_conv;
465         }
466
467         /**
468          * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
469          * `route_params` and retry failed payment paths based on `retry_strategy`.
470          */
471         public Result_NoneRetryableSendFailureZ send_payment(byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id, org.ldk.structs.RouteParameters route_params, org.ldk.structs.Retry retry_strategy) {
472                 long ret = bindings.ChannelManager_send_payment(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), recipient_onion == null ? 0 : recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32), route_params == null ? 0 : route_params.ptr, retry_strategy.ptr);
473                 Reference.reachabilityFence(this);
474                 Reference.reachabilityFence(payment_hash);
475                 Reference.reachabilityFence(recipient_onion);
476                 Reference.reachabilityFence(payment_id);
477                 Reference.reachabilityFence(route_params);
478                 Reference.reachabilityFence(retry_strategy);
479                 if (ret >= 0 && ret <= 4096) { return null; }
480                 Result_NoneRetryableSendFailureZ ret_hu_conv = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret);
481                 if (this != null) { this.ptrs_to.add(recipient_onion); };
482                 if (this != null) { this.ptrs_to.add(route_params); };
483                 if (this != null) { this.ptrs_to.add(retry_strategy); };
484                 return ret_hu_conv;
485         }
486
487         /**
488          * Signals that no further attempts for the given payment should occur. Useful if you have a
489          * pending outbound payment with retries remaining, but wish to stop retrying the payment before
490          * retries are exhausted.
491          * 
492          * # Event Generation
493          * 
494          * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
495          * as there are no remaining pending HTLCs for this payment.
496          * 
497          * Note that calling this method does *not* prevent a payment from succeeding. You must still
498          * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
499          * determine the ultimate status of a payment.
500          * 
501          * # Restart Behavior
502          * 
503          * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
504          * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated.
505          */
506         public void abandon_payment(byte[] payment_id) {
507                 bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.check_arr_len(payment_id, 32));
508                 Reference.reachabilityFence(this);
509                 Reference.reachabilityFence(payment_id);
510         }
511
512         /**
513          * Send a spontaneous payment, which is a payment that does not require the recipient to have
514          * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
515          * the preimage, it must be a cryptographically secure random value that no intermediate node
516          * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
517          * never reach the recipient.
518          * 
519          * See [`send_payment`] documentation for more details on the return value of this function
520          * and idempotency guarantees provided by the [`PaymentId`] key.
521          * 
522          * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
523          * [`send_payment`] for more information about the risks of duplicate preimage usage.
524          * 
525          * [`send_payment`]: Self::send_payment
526          */
527         public Result_ThirtyTwoBytesPaymentSendFailureZ send_spontaneous_payment(org.ldk.structs.Route route, org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) {
528                 long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr, payment_preimage.ptr, recipient_onion == null ? 0 : recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32));
529                 Reference.reachabilityFence(this);
530                 Reference.reachabilityFence(route);
531                 Reference.reachabilityFence(payment_preimage);
532                 Reference.reachabilityFence(recipient_onion);
533                 Reference.reachabilityFence(payment_id);
534                 if (ret >= 0 && ret <= 4096) { return null; }
535                 Result_ThirtyTwoBytesPaymentSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesPaymentSendFailureZ.constr_from_ptr(ret);
536                 if (this != null) { this.ptrs_to.add(route); };
537                 if (this != null) { this.ptrs_to.add(payment_preimage); };
538                 if (this != null) { this.ptrs_to.add(recipient_onion); };
539                 return ret_hu_conv;
540         }
541
542         /**
543          * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
544          * based on `route_params` and retry failed payment paths based on `retry_strategy`.
545          * 
546          * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
547          * payments.
548          * 
549          * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
550          */
551         public Result_ThirtyTwoBytesRetryableSendFailureZ send_spontaneous_payment_with_retry(org.ldk.structs.Option_ThirtyTwoBytesZ payment_preimage, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id, org.ldk.structs.RouteParameters route_params, org.ldk.structs.Retry retry_strategy) {
552                 long ret = bindings.ChannelManager_send_spontaneous_payment_with_retry(this.ptr, payment_preimage.ptr, recipient_onion == null ? 0 : recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32), route_params == null ? 0 : route_params.ptr, retry_strategy.ptr);
553                 Reference.reachabilityFence(this);
554                 Reference.reachabilityFence(payment_preimage);
555                 Reference.reachabilityFence(recipient_onion);
556                 Reference.reachabilityFence(payment_id);
557                 Reference.reachabilityFence(route_params);
558                 Reference.reachabilityFence(retry_strategy);
559                 if (ret >= 0 && ret <= 4096) { return null; }
560                 Result_ThirtyTwoBytesRetryableSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesRetryableSendFailureZ.constr_from_ptr(ret);
561                 if (this != null) { this.ptrs_to.add(payment_preimage); };
562                 if (this != null) { this.ptrs_to.add(recipient_onion); };
563                 if (this != null) { this.ptrs_to.add(route_params); };
564                 if (this != null) { this.ptrs_to.add(retry_strategy); };
565                 return ret_hu_conv;
566         }
567
568         /**
569          * Send a payment that is probing the given route for liquidity. We calculate the
570          * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
571          * us to easily discern them from real payments.
572          */
573         public Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ send_probe(org.ldk.structs.Path path) {
574                 long ret = bindings.ChannelManager_send_probe(this.ptr, path == null ? 0 : path.ptr);
575                 Reference.reachabilityFence(this);
576                 Reference.reachabilityFence(path);
577                 if (ret >= 0 && ret <= 4096) { return null; }
578                 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ.constr_from_ptr(ret);
579                 if (this != null) { this.ptrs_to.add(path); };
580                 return ret_hu_conv;
581         }
582
583         /**
584          * Sends payment probes over all paths of a route that would be used to pay the given
585          * amount to the given `node_id`.
586          * 
587          * See [`ChannelManager::send_preflight_probes`] for more information.
588          */
589         public Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ send_spontaneous_preflight_probes(byte[] node_id, long amount_msat, int final_cltv_expiry_delta, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
590                 long ret = bindings.ChannelManager_send_spontaneous_preflight_probes(this.ptr, InternalUtils.check_arr_len(node_id, 33), amount_msat, final_cltv_expiry_delta, liquidity_limit_multiplier.ptr);
591                 Reference.reachabilityFence(this);
592                 Reference.reachabilityFence(node_id);
593                 Reference.reachabilityFence(amount_msat);
594                 Reference.reachabilityFence(final_cltv_expiry_delta);
595                 Reference.reachabilityFence(liquidity_limit_multiplier);
596                 if (ret >= 0 && ret <= 4096) { return null; }
597                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
598                 if (this != null) { this.ptrs_to.add(liquidity_limit_multiplier); };
599                 return ret_hu_conv;
600         }
601
602         /**
603          * Sends payment probes over all paths of a route that would be used to pay a route found
604          * according to the given [`RouteParameters`].
605          * 
606          * This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting
607          * the actual payment. Note this is only useful if there likely is sufficient time for the
608          * probe to settle before sending out the actual payment, e.g., when waiting for user
609          * confirmation in a wallet UI.
610          * 
611          * Otherwise, there is a chance the probe could take up some liquidity needed to complete the
612          * actual payment. Users should therefore be cautious and might avoid sending probes if
613          * liquidity is scarce and/or they don't expect the probe to return before they send the
614          * payment. To mitigate this issue, channels with available liquidity less than the required
615          * amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight
616          * probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`.
617          */
618         public Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ send_preflight_probes(org.ldk.structs.RouteParameters route_params, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
619                 long ret = bindings.ChannelManager_send_preflight_probes(this.ptr, route_params == null ? 0 : route_params.ptr, liquidity_limit_multiplier.ptr);
620                 Reference.reachabilityFence(this);
621                 Reference.reachabilityFence(route_params);
622                 Reference.reachabilityFence(liquidity_limit_multiplier);
623                 if (ret >= 0 && ret <= 4096) { return null; }
624                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
625                 if (this != null) { this.ptrs_to.add(route_params); };
626                 if (this != null) { this.ptrs_to.add(liquidity_limit_multiplier); };
627                 return ret_hu_conv;
628         }
629
630         /**
631          * Call this upon creation of a funding transaction for the given channel.
632          * 
633          * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
634          * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
635          * 
636          * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
637          * across the p2p network.
638          * 
639          * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
640          * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
641          * 
642          * May panic if the output found in the funding transaction is duplicative with some other
643          * channel (note that this should be trivially prevented by using unique funding transaction
644          * keys per-channel).
645          * 
646          * Do NOT broadcast the funding transaction yourself. When we have safely received our
647          * counterparty's signature the funding transaction will automatically be broadcast via the
648          * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
649          * 
650          * Note that this includes RBF or similar transaction replacement strategies - lightning does
651          * not currently support replacing a funding transaction on an existing channel. Instead,
652          * create a new channel with a conflicting funding transaction.
653          * 
654          * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
655          * the wallet software generating the funding transaction to apply anti-fee sniping as
656          * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
657          * for more details.
658          * 
659          * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
660          * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
661          */
662         public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] counterparty_node_id, byte[] funding_transaction) {
663                 long ret = bindings.ChannelManager_funding_transaction_generated(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), funding_transaction);
664                 Reference.reachabilityFence(this);
665                 Reference.reachabilityFence(temporary_channel_id);
666                 Reference.reachabilityFence(counterparty_node_id);
667                 Reference.reachabilityFence(funding_transaction);
668                 if (ret >= 0 && ret <= 4096) { return null; }
669                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
670                 return ret_hu_conv;
671         }
672
673         /**
674          * Call this upon creation of a batch funding transaction for the given channels.
675          * 
676          * Return values are identical to [`Self::funding_transaction_generated`], respective to
677          * each individual channel and transaction output.
678          * 
679          * Do NOT broadcast the funding transaction yourself. This batch funding transcaction
680          * will only be broadcast when we have safely received and persisted the counterparty's
681          * signature for each channel.
682          * 
683          * If there is an error, all channels in the batch are to be considered closed.
684          */
685         public Result_NoneAPIErrorZ batch_funding_transaction_generated(TwoTuple_ThirtyTwoBytesPublicKeyZ[] temporary_channels, byte[] funding_transaction) {
686                 long ret = bindings.ChannelManager_batch_funding_transaction_generated(this.ptr, temporary_channels != null ? Arrays.stream(temporary_channels).mapToLong(temporary_channels_conv_35 -> temporary_channels_conv_35 != null ? temporary_channels_conv_35.ptr : 0).toArray() : null, funding_transaction);
687                 Reference.reachabilityFence(this);
688                 Reference.reachabilityFence(temporary_channels);
689                 Reference.reachabilityFence(funding_transaction);
690                 if (ret >= 0 && ret <= 4096) { return null; }
691                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
692                 return ret_hu_conv;
693         }
694
695         /**
696          * Atomically applies partial updates to the [`ChannelConfig`] of the given channels.
697          * 
698          * Once the updates are applied, each eligible channel (advertised with a known short channel
699          * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
700          * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
701          * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
702          * 
703          * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
704          * `counterparty_node_id` is provided.
705          * 
706          * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
707          * below [`MIN_CLTV_EXPIRY_DELTA`].
708          * 
709          * If an error is returned, none of the updates should be considered applied.
710          * 
711          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
712          * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
713          * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
714          * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
715          * [`ChannelUpdate`]: msgs::ChannelUpdate
716          * [`ChannelUnavailable`]: APIError::ChannelUnavailable
717          * [`APIMisuseError`]: APIError::APIMisuseError
718          */
719         public Result_NoneAPIErrorZ update_partial_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, org.ldk.structs.ChannelConfigUpdate config_update) {
720                 long ret = bindings.ChannelManager_update_partial_channel_config(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_ids != null ? Arrays.stream(channel_ids).map(channel_ids_conv_8 -> InternalUtils.check_arr_len(channel_ids_conv_8, 32)).toArray(byte[][]::new) : null, config_update == null ? 0 : config_update.ptr);
721                 Reference.reachabilityFence(this);
722                 Reference.reachabilityFence(counterparty_node_id);
723                 Reference.reachabilityFence(channel_ids);
724                 Reference.reachabilityFence(config_update);
725                 if (ret >= 0 && ret <= 4096) { return null; }
726                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
727                 if (this != null) { this.ptrs_to.add(config_update); };
728                 return ret_hu_conv;
729         }
730
731         /**
732          * Atomically updates the [`ChannelConfig`] for the given channels.
733          * 
734          * Once the updates are applied, each eligible channel (advertised with a known short channel
735          * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
736          * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
737          * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
738          * 
739          * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
740          * `counterparty_node_id` is provided.
741          * 
742          * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
743          * below [`MIN_CLTV_EXPIRY_DELTA`].
744          * 
745          * If an error is returned, none of the updates should be considered applied.
746          * 
747          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
748          * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
749          * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
750          * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
751          * [`ChannelUpdate`]: msgs::ChannelUpdate
752          * [`ChannelUnavailable`]: APIError::ChannelUnavailable
753          * [`APIMisuseError`]: APIError::APIMisuseError
754          */
755         public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, org.ldk.structs.ChannelConfig config) {
756                 long ret = bindings.ChannelManager_update_channel_config(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_ids != null ? Arrays.stream(channel_ids).map(channel_ids_conv_8 -> InternalUtils.check_arr_len(channel_ids_conv_8, 32)).toArray(byte[][]::new) : null, config == null ? 0 : config.ptr);
757                 Reference.reachabilityFence(this);
758                 Reference.reachabilityFence(counterparty_node_id);
759                 Reference.reachabilityFence(channel_ids);
760                 Reference.reachabilityFence(config);
761                 if (ret >= 0 && ret <= 4096) { return null; }
762                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
763                 if (this != null) { this.ptrs_to.add(config); };
764                 return ret_hu_conv;
765         }
766
767         /**
768          * Attempts to forward an intercepted HTLC over the provided channel id and with the provided
769          * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
770          * 
771          * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
772          * channel to a receiving node if the node lacks sufficient inbound liquidity.
773          * 
774          * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
775          * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
776          * receiver's invoice route hints. These route hints will signal to LDK to generate an
777          * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
778          * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
779          * 
780          * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
781          * you from forwarding more than you received. See
782          * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount
783          * than expected.
784          * 
785          * Errors if the event was not handled in time, in which case the HTLC was automatically failed
786          * backwards.
787          * 
788          * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
789          * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
790          * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat
791          */
792         public Result_NoneAPIErrorZ forward_intercepted_htlc(byte[] intercept_id, byte[] next_hop_channel_id, byte[] next_node_id, long amt_to_forward_msat) {
793                 long ret = bindings.ChannelManager_forward_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32), InternalUtils.check_arr_len(next_hop_channel_id, 32), InternalUtils.check_arr_len(next_node_id, 33), amt_to_forward_msat);
794                 Reference.reachabilityFence(this);
795                 Reference.reachabilityFence(intercept_id);
796                 Reference.reachabilityFence(next_hop_channel_id);
797                 Reference.reachabilityFence(next_node_id);
798                 Reference.reachabilityFence(amt_to_forward_msat);
799                 if (ret >= 0 && ret <= 4096) { return null; }
800                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
801                 return ret_hu_conv;
802         }
803
804         /**
805          * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
806          * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
807          * 
808          * Errors if the event was not handled in time, in which case the HTLC was automatically failed
809          * backwards.
810          * 
811          * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
812          */
813         public Result_NoneAPIErrorZ fail_intercepted_htlc(byte[] intercept_id) {
814                 long ret = bindings.ChannelManager_fail_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32));
815                 Reference.reachabilityFence(this);
816                 Reference.reachabilityFence(intercept_id);
817                 if (ret >= 0 && ret <= 4096) { return null; }
818                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
819                 return ret_hu_conv;
820         }
821
822         /**
823          * Processes HTLCs which are pending waiting on random forward delay.
824          * 
825          * Should only really ever be called in response to a PendingHTLCsForwardable event.
826          * Will likely generate further events.
827          */
828         public void process_pending_htlc_forwards() {
829                 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
830                 Reference.reachabilityFence(this);
831         }
832
833         /**
834          * Performs actions which should happen on startup and roughly once per minute thereafter.
835          * 
836          * This currently includes:
837          * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
838          * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more
839          * than a minute, informing the network that they should no longer attempt to route over
840          * the channel.
841          * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs
842          * with the current [`ChannelConfig`].
843          * Removing peers which have disconnected but and no longer have any channels.
844          * Force-closing and removing channels which have not completed establishment in a timely manner.
845          * 
846          * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate
847          * estimate fetches.
848          * 
849          * [`ChannelUpdate`]: msgs::ChannelUpdate
850          * [`ChannelConfig`]: crate::util::config::ChannelConfig
851          */
852         public void timer_tick_occurred() {
853                 bindings.ChannelManager_timer_tick_occurred(this.ptr);
854                 Reference.reachabilityFence(this);
855         }
856
857         /**
858          * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
859          * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
860          * along the path (including in our own channel on which we received it).
861          * 
862          * Note that in some cases around unclean shutdown, it is possible the payment may have
863          * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
864          * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
865          * may have already been failed automatically by LDK if it was nearing its expiration time.
866          * 
867          * While LDK will never claim a payment automatically on your behalf (i.e. without you calling
868          * [`ChannelManager::claim_funds`]), you should still monitor for
869          * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
870          * startup during which time claims that were in-progress at shutdown may be replayed.
871          */
872         public void fail_htlc_backwards(byte[] payment_hash) {
873                 bindings.ChannelManager_fail_htlc_backwards(this.ptr, InternalUtils.check_arr_len(payment_hash, 32));
874                 Reference.reachabilityFence(this);
875                 Reference.reachabilityFence(payment_hash);
876         }
877
878         /**
879          * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
880          * reason for the failure.
881          * 
882          * See [`FailureCode`] for valid failure codes.
883          */
884         public void fail_htlc_backwards_with_reason(byte[] payment_hash, org.ldk.structs.FailureCode failure_code) {
885                 bindings.ChannelManager_fail_htlc_backwards_with_reason(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), failure_code.ptr);
886                 Reference.reachabilityFence(this);
887                 Reference.reachabilityFence(payment_hash);
888                 Reference.reachabilityFence(failure_code);
889                 if (this != null) { this.ptrs_to.add(failure_code); };
890         }
891
892         /**
893          * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
894          * [`MessageSendEvent`]s needed to claim the payment.
895          * 
896          * This method is guaranteed to ensure the payment has been claimed but only if the current
897          * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race
898          * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment
899          * successful. It will generally be available in the next [`process_pending_events`] call.
900          * 
901          * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
902          * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
903          * event matches your expectation. If you fail to do so and call this method, you may provide
904          * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
905          * 
906          * This function will fail the payment if it has custom TLVs with even type numbers, as we
907          * will assume they are unknown. If you intend to accept even custom TLVs, you should use
908          * [`claim_funds_with_known_custom_tlvs`].
909          * 
910          * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
911          * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline
912          * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed
913          * [`process_pending_events`]: EventsProvider::process_pending_events
914          * [`create_inbound_payment`]: Self::create_inbound_payment
915          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
916          * [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs
917          */
918         public void claim_funds(byte[] payment_preimage) {
919                 bindings.ChannelManager_claim_funds(this.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
920                 Reference.reachabilityFence(this);
921                 Reference.reachabilityFence(payment_preimage);
922         }
923
924         /**
925          * This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with
926          * even type numbers.
927          * 
928          * # Note
929          * 
930          * You MUST check you've understood all even TLVs before using this to
931          * claim, otherwise you may unintentionally agree to some protocol you do not understand.
932          * 
933          * [`claim_funds`]: Self::claim_funds
934          */
935         public void claim_funds_with_known_custom_tlvs(byte[] payment_preimage) {
936                 bindings.ChannelManager_claim_funds_with_known_custom_tlvs(this.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
937                 Reference.reachabilityFence(this);
938                 Reference.reachabilityFence(payment_preimage);
939         }
940
941         /**
942          * Gets the node_id held by this ChannelManager
943          */
944         public byte[] get_our_node_id() {
945                 byte[] ret = bindings.ChannelManager_get_our_node_id(this.ptr);
946                 Reference.reachabilityFence(this);
947                 return ret;
948         }
949
950         /**
951          * Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
952          * 
953          * The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
954          * and the `counterparty_node_id` parameter is the id of the peer which has requested to open
955          * the channel.
956          * 
957          * The `user_channel_id` parameter will be provided back in
958          * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
959          * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
960          * 
961          * Note that this method will return an error and reject the channel, if it requires support
962          * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
963          * used to accept such channels.
964          * 
965          * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
966          * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
967          */
968         public Result_NoneAPIErrorZ accept_inbound_channel(byte[] temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
969                 long ret = bindings.ChannelManager_accept_inbound_channel(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
970                 Reference.reachabilityFence(this);
971                 Reference.reachabilityFence(temporary_channel_id);
972                 Reference.reachabilityFence(counterparty_node_id);
973                 Reference.reachabilityFence(user_channel_id);
974                 if (ret >= 0 && ret <= 4096) { return null; }
975                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
976                 return ret_hu_conv;
977         }
978
979         /**
980          * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
981          * it as confirmed immediately.
982          * 
983          * The `user_channel_id` parameter will be provided back in
984          * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
985          * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
986          * 
987          * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
988          * and (if the counterparty agrees), enables forwarding of payments immediately.
989          * 
990          * This fully trusts that the counterparty has honestly and correctly constructed the funding
991          * transaction and blindly assumes that it will eventually confirm.
992          * 
993          * If it does not confirm before we decide to close the channel, or if the funding transaction
994          * does not pay to the correct script the correct amount, *you will lose funds*.
995          * 
996          * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
997          * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
998          */
999         public Result_NoneAPIErrorZ accept_inbound_channel_from_trusted_peer_0conf(byte[] temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
1000                 long ret = bindings.ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
1001                 Reference.reachabilityFence(this);
1002                 Reference.reachabilityFence(temporary_channel_id);
1003                 Reference.reachabilityFence(counterparty_node_id);
1004                 Reference.reachabilityFence(user_channel_id);
1005                 if (ret >= 0 && ret <= 4096) { return null; }
1006                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1007                 return ret_hu_conv;
1008         }
1009
1010         /**
1011          * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
1012          * to pay us.
1013          * 
1014          * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
1015          * [`PaymentHash`] and [`PaymentPreimage`] for you.
1016          * 
1017          * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which
1018          * will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with
1019          * its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be
1020          * passed directly to [`claim_funds`].
1021          * 
1022          * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
1023          * 
1024          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
1025          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
1026          * 
1027          * # Note
1028          * 
1029          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
1030          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
1031          * 
1032          * Errors if `min_value_msat` is greater than total bitcoin supply.
1033          * 
1034          * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
1035          * on versions of LDK prior to 0.0.114.
1036          * 
1037          * [`claim_funds`]: Self::claim_funds
1038          * [`PaymentClaimable`]: events::Event::PaymentClaimable
1039          * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose
1040          * [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment
1041          * [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage
1042          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
1043          */
1044         public Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ create_inbound_payment(org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry_delta) {
1045                 long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1046                 Reference.reachabilityFence(this);
1047                 Reference.reachabilityFence(min_value_msat);
1048                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1049                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1050                 if (ret >= 0 && ret <= 4096) { return null; }
1051                 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
1052                 if (this != null) { this.ptrs_to.add(min_value_msat); };
1053                 if (this != null) { this.ptrs_to.add(min_final_cltv_expiry_delta); };
1054                 return ret_hu_conv;
1055         }
1056
1057         /**
1058          * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
1059          * stored external to LDK.
1060          * 
1061          * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
1062          * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
1063          * the `min_value_msat` provided here, if one is provided.
1064          * 
1065          * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
1066          * note that LDK will not stop you from registering duplicate payment hashes for inbound
1067          * payments.
1068          * 
1069          * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
1070          * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
1071          * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
1072          * sender \"proof-of-payment\" unless they have paid the required amount.
1073          * 
1074          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1075          * in excess of the current time. This should roughly match the expiry time set in the invoice.
1076          * After this many seconds, we will remove the inbound payment, resulting in any attempts to
1077          * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
1078          * invoices when no timeout is set.
1079          * 
1080          * Note that we use block header time to time-out pending inbound payments (with some margin
1081          * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
1082          * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
1083          * If you need exact expiry semantics, you should enforce them upon receipt of
1084          * [`PaymentClaimable`].
1085          * 
1086          * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta`
1087          * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1088          * 
1089          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
1090          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
1091          * 
1092          * # Note
1093          * 
1094          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
1095          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
1096          * 
1097          * Errors if `min_value_msat` is greater than total bitcoin supply.
1098          * 
1099          * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
1100          * on versions of LDK prior to 0.0.114.
1101          * 
1102          * [`create_inbound_payment`]: Self::create_inbound_payment
1103          * [`PaymentClaimable`]: events::Event::PaymentClaimable
1104          */
1105         public Result_ThirtyTwoBytesNoneZ create_inbound_payment_for_hash(byte[] payment_hash, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs, org.ldk.structs.Option_u16Z min_final_cltv_expiry) {
1106                 long ret = bindings.ChannelManager_create_inbound_payment_for_hash(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), min_value_msat.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry.ptr);
1107                 Reference.reachabilityFence(this);
1108                 Reference.reachabilityFence(payment_hash);
1109                 Reference.reachabilityFence(min_value_msat);
1110                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1111                 Reference.reachabilityFence(min_final_cltv_expiry);
1112                 if (ret >= 0 && ret <= 4096) { return null; }
1113                 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
1114                 if (this != null) { this.ptrs_to.add(min_value_msat); };
1115                 if (this != null) { this.ptrs_to.add(min_final_cltv_expiry); };
1116                 return ret_hu_conv;
1117         }
1118
1119         /**
1120          * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
1121          * previously returned from [`create_inbound_payment`].
1122          * 
1123          * [`create_inbound_payment`]: Self::create_inbound_payment
1124          */
1125         public Result_ThirtyTwoBytesAPIErrorZ get_payment_preimage(byte[] payment_hash, byte[] payment_secret) {
1126                 long ret = bindings.ChannelManager_get_payment_preimage(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
1127                 Reference.reachabilityFence(this);
1128                 Reference.reachabilityFence(payment_hash);
1129                 Reference.reachabilityFence(payment_secret);
1130                 if (ret >= 0 && ret <= 4096) { return null; }
1131                 Result_ThirtyTwoBytesAPIErrorZ ret_hu_conv = Result_ThirtyTwoBytesAPIErrorZ.constr_from_ptr(ret);
1132                 return ret_hu_conv;
1133         }
1134
1135         /**
1136          * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
1137          * are used when constructing the phantom invoice's route hints.
1138          * 
1139          * [phantom node payments]: crate::sign::PhantomKeysManager
1140          */
1141         public long get_phantom_scid() {
1142                 long ret = bindings.ChannelManager_get_phantom_scid(this.ptr);
1143                 Reference.reachabilityFence(this);
1144                 return ret;
1145         }
1146
1147         /**
1148          * Gets route hints for use in receiving [phantom node payments].
1149          * 
1150          * [phantom node payments]: crate::sign::PhantomKeysManager
1151          */
1152         public PhantomRouteHints get_phantom_route_hints() {
1153                 long ret = bindings.ChannelManager_get_phantom_route_hints(this.ptr);
1154                 Reference.reachabilityFence(this);
1155                 if (ret >= 0 && ret <= 4096) { return null; }
1156                 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
1157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1158                 return ret_hu_conv;
1159         }
1160
1161         /**
1162          * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
1163          * used when constructing the route hints for HTLCs intended to be intercepted. See
1164          * [`ChannelManager::forward_intercepted_htlc`].
1165          * 
1166          * Note that this method is not guaranteed to return unique values, you may need to call it a few
1167          * times to get a unique scid.
1168          */
1169         public long get_intercept_scid() {
1170                 long ret = bindings.ChannelManager_get_intercept_scid(this.ptr);
1171                 Reference.reachabilityFence(this);
1172                 return ret;
1173         }
1174
1175         /**
1176          * Gets inflight HTLC information by processing pending outbound payments that are in
1177          * our channels. May be used during pathfinding to account for in-use channel liquidity.
1178          */
1179         public InFlightHtlcs compute_inflight_htlcs() {
1180                 long ret = bindings.ChannelManager_compute_inflight_htlcs(this.ptr);
1181                 Reference.reachabilityFence(this);
1182                 if (ret >= 0 && ret <= 4096) { return null; }
1183                 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
1184                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1185                 return ret_hu_conv;
1186         }
1187
1188         /**
1189          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
1190          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
1191          */
1192         public MessageSendEventsProvider as_MessageSendEventsProvider() {
1193                 long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
1194                 Reference.reachabilityFence(this);
1195                 if (ret >= 0 && ret <= 4096) { return null; }
1196                 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
1197                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1198                 return ret_hu_conv;
1199         }
1200
1201         /**
1202          * Constructs a new EventsProvider which calls the relevant methods on this_arg.
1203          * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
1204          */
1205         public EventsProvider as_EventsProvider() {
1206                 long ret = bindings.ChannelManager_as_EventsProvider(this.ptr);
1207                 Reference.reachabilityFence(this);
1208                 if (ret >= 0 && ret <= 4096) { return null; }
1209                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
1210                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1211                 return ret_hu_conv;
1212         }
1213
1214         /**
1215          * Constructs a new Listen which calls the relevant methods on this_arg.
1216          * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
1217          */
1218         public Listen as_Listen() {
1219                 long ret = bindings.ChannelManager_as_Listen(this.ptr);
1220                 Reference.reachabilityFence(this);
1221                 if (ret >= 0 && ret <= 4096) { return null; }
1222                 Listen ret_hu_conv = new Listen(null, ret);
1223                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1224                 return ret_hu_conv;
1225         }
1226
1227         /**
1228          * Constructs a new Confirm which calls the relevant methods on this_arg.
1229          * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
1230          */
1231         public Confirm as_Confirm() {
1232                 long ret = bindings.ChannelManager_as_Confirm(this.ptr);
1233                 Reference.reachabilityFence(this);
1234                 if (ret >= 0 && ret <= 4096) { return null; }
1235                 Confirm ret_hu_conv = new Confirm(null, ret);
1236                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1237                 return ret_hu_conv;
1238         }
1239
1240         /**
1241          * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or
1242          * may have events that need processing.
1243          * 
1244          * In order to check if this [`ChannelManager`] needs persisting, call
1245          * [`Self::get_and_clear_needs_persistence`].
1246          * 
1247          * Note that callbacks registered on the [`Future`] MUST NOT call back into this
1248          * [`ChannelManager`] and should instead register actions to be taken later.
1249          */
1250         public Future get_event_or_persistence_needed_future() {
1251                 long ret = bindings.ChannelManager_get_event_or_persistence_needed_future(this.ptr);
1252                 Reference.reachabilityFence(this);
1253                 if (ret >= 0 && ret <= 4096) { return null; }
1254                 org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
1255                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1256                 return ret_hu_conv;
1257         }
1258
1259         /**
1260          * Returns true if this [`ChannelManager`] needs to be persisted.
1261          */
1262         public boolean get_and_clear_needs_persistence() {
1263                 boolean ret = bindings.ChannelManager_get_and_clear_needs_persistence(this.ptr);
1264                 Reference.reachabilityFence(this);
1265                 return ret;
1266         }
1267
1268         /**
1269          * Gets the latest best block which was connected either via the [`chain::Listen`] or
1270          * [`chain::Confirm`] interfaces.
1271          */
1272         public BestBlock current_best_block() {
1273                 long ret = bindings.ChannelManager_current_best_block(this.ptr);
1274                 Reference.reachabilityFence(this);
1275                 if (ret >= 0 && ret <= 4096) { return null; }
1276                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
1277                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1278                 return ret_hu_conv;
1279         }
1280
1281         /**
1282          * Fetches the set of [`NodeFeatures`] flags which are provided by or required by
1283          * [`ChannelManager`].
1284          */
1285         public NodeFeatures node_features() {
1286                 long ret = bindings.ChannelManager_node_features(this.ptr);
1287                 Reference.reachabilityFence(this);
1288                 if (ret >= 0 && ret <= 4096) { return null; }
1289                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
1290                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1291                 return ret_hu_conv;
1292         }
1293
1294         /**
1295          * Fetches the set of [`ChannelFeatures`] flags which are provided by or required by
1296          * [`ChannelManager`].
1297          */
1298         public ChannelFeatures channel_features() {
1299                 long ret = bindings.ChannelManager_channel_features(this.ptr);
1300                 Reference.reachabilityFence(this);
1301                 if (ret >= 0 && ret <= 4096) { return null; }
1302                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
1303                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1304                 return ret_hu_conv;
1305         }
1306
1307         /**
1308          * Fetches the set of [`ChannelTypeFeatures`] flags which are provided by or required by
1309          * [`ChannelManager`].
1310          */
1311         public ChannelTypeFeatures channel_type_features() {
1312                 long ret = bindings.ChannelManager_channel_type_features(this.ptr);
1313                 Reference.reachabilityFence(this);
1314                 if (ret >= 0 && ret <= 4096) { return null; }
1315                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
1316                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1317                 return ret_hu_conv;
1318         }
1319
1320         /**
1321          * Fetches the set of [`InitFeatures`] flags which are provided by or required by
1322          * [`ChannelManager`].
1323          */
1324         public InitFeatures init_features() {
1325                 long ret = bindings.ChannelManager_init_features(this.ptr);
1326                 Reference.reachabilityFence(this);
1327                 if (ret >= 0 && ret <= 4096) { return null; }
1328                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
1329                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1330                 return ret_hu_conv;
1331         }
1332
1333         /**
1334          * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
1335          * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
1336          */
1337         public ChannelMessageHandler as_ChannelMessageHandler() {
1338                 long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
1339                 Reference.reachabilityFence(this);
1340                 if (ret >= 0 && ret <= 4096) { return null; }
1341                 ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
1342                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
1343                 return ret_hu_conv;
1344         }
1345
1346         /**
1347          * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
1348          */
1349         public byte[] write() {
1350                 byte[] ret = bindings.ChannelManager_write(this.ptr);
1351                 Reference.reachabilityFence(this);
1352                 return ret;
1353         }
1354
1355 }