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