[Java] Update auto-generated Java bindings
[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 (ie
21  * called funding_transaction_generated for outbound channels).
22  * 
23  * Note that you can be a bit lazier about writing out ChannelManager than you can be with
24  * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
25  * returning from chain::Watch::watch_/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  * ChannelMonitors 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 block_connect()ed. You MUST rescan any blocks along
33  * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
34  * block_connected() to step towards your best block) upon deserialization before using the
35  * object!
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  * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
44  * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
45  * essentially you should default to using a SimpleRefChannelManager, and use a
46  * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
47  * you're using lightning-net-tokio.
48  */
49 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
50 public class ChannelManager extends CommonBase {
51         ChannelManager(Object _dummy, long ptr) { super(ptr); }
52         @Override @SuppressWarnings("deprecation")
53         protected void finalize() throws Throwable {
54                 super.finalize();
55                 if (ptr != 0) { bindings.ChannelManager_free(ptr); }
56         }
57
58         /**
59          * Constructs a new ChannelManager to hold several channels and route between them.
60          * 
61          * This is the main \"logic hub\" for all channel-related actions, and implements
62          * ChannelMessageHandler.
63          * 
64          * Non-proportional fees are fixed according to our risk using the provided fee estimator.
65          * 
66          * Users need to notify the new ChannelManager when a new block is connected or
67          * disconnected using its `block_connected` and `block_disconnected` methods, starting
68          * from after `params.latest_hash`.
69          */
70         public static ChannelManager of(FeeEstimator fee_est, Watch chain_monitor, BroadcasterInterface tx_broadcaster, Logger logger, KeysInterface keys_manager, UserConfig config, ChainParameters params) {
71                 long ret = bindings.ChannelManager_new(fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr & ~1, params == null ? 0 : params.ptr & ~1);
72                 Reference.reachabilityFence(fee_est);
73                 Reference.reachabilityFence(chain_monitor);
74                 Reference.reachabilityFence(tx_broadcaster);
75                 Reference.reachabilityFence(logger);
76                 Reference.reachabilityFence(keys_manager);
77                 Reference.reachabilityFence(config);
78                 Reference.reachabilityFence(params);
79                 if (ret >= 0 && ret <= 4096) { return null; }
80                 org.ldk.structs.ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManager(null, ret); }
81                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_est); };
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(chain_monitor); };
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(tx_broadcaster); };
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(keys_manager); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Gets the current configuration applied to all new channels,  as
92          */
93         public UserConfig get_current_default_configuration() {
94                 long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
95                 Reference.reachabilityFence(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Creates a new outbound channel to the given remote node and with the given value.
104          * 
105          * `user_channel_id` will be provided back as in
106          * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
107          * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to 0
108          * for inbound channels, so you may wish to avoid using 0 for `user_channel_id` here.
109          * `user_channel_id` has no meaning inside of LDK, it is simply copied to events and otherwise
110          * ignored.
111          * 
112          * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
113          * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
114          * 
115          * Note that we do not check if you are currently connected to the given peer. If no
116          * connection is available, the outbound `open_channel` message may fail to send, resulting in
117          * the channel eventually being silently forgotten (dropped on reload).
118          * 
119          * Returns the new Channel's temporary `channel_id`. This ID will appear as
120          * [`Event::FundingGenerationReady::temporary_channel_id`] and in
121          * [`ChannelDetails::channel_id`] until after
122          * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
123          * one derived from the funding transaction's TXID. If the counterparty rejects the channel
124          * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
125          * 
126          * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
127          * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
128          * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
129          * 
130          * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
131          */
132         public Result__u832APIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_channel_id, @Nullable UserConfig override_config) {
133                 long ret = bindings.ChannelManager_create_channel(this.ptr, InternalUtils.check_arr_len(their_network_key, 33), channel_value_satoshis, push_msat, user_channel_id, override_config == null ? 0 : override_config.ptr & ~1);
134                 Reference.reachabilityFence(this);
135                 Reference.reachabilityFence(their_network_key);
136                 Reference.reachabilityFence(channel_value_satoshis);
137                 Reference.reachabilityFence(push_msat);
138                 Reference.reachabilityFence(user_channel_id);
139                 Reference.reachabilityFence(override_config);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
142                 return ret_hu_conv;
143         }
144
145         /**
146          * Gets the list of open channels, in random order. See ChannelDetail field documentation for
147          * more information.
148          */
149         public ChannelDetails[] list_channels() {
150                 long[] ret = bindings.ChannelManager_list_channels(this.ptr);
151                 Reference.reachabilityFence(this);
152                 int ret_conv_16_len = ret.length;
153                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
154                 for (int q = 0; q < ret_conv_16_len; q++) {
155                         long ret_conv_16 = ret[q];
156                         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); }
157                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
158                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
159                 }
160                 return ret_conv_16_arr;
161         }
162
163         /**
164          * Gets the list of usable channels, in random order. Useful as an argument to [`find_route`]
165          * to ensure non-announced channels are used.
166          * 
167          * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
168          * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
169          * are.
170          * 
171          * [`find_route`]: crate::routing::router::find_route
172          */
173         public ChannelDetails[] list_usable_channels() {
174                 long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr);
175                 Reference.reachabilityFence(this);
176                 int ret_conv_16_len = ret.length;
177                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
178                 for (int q = 0; q < ret_conv_16_len; q++) {
179                         long ret_conv_16 = ret[q];
180                         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); }
181                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
182                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
183                 }
184                 return ret_conv_16_arr;
185         }
186
187         /**
188          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
189          * will be accepted on the given channel, and after additional timeout/the closing of all
190          * pending HTLCs, the channel will be closed on chain.
191          * 
192          * If we are the channel initiator, we will pay between our [`Background`] and
193          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
194          * estimate.
195          * If our counterparty is the channel initiator, we will require a channel closing
196          * transaction feerate of at least our [`Background`] feerate or the feerate which
197          * would appear on a force-closure transaction, whichever is lower. We will allow our
198          * counterparty to pay as much fee as they'd like, however.
199          * 
200          * May generate a SendShutdown message event on success, which should be relayed.
201          * 
202          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
203          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
204          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
205          */
206         public Result_NoneAPIErrorZ close_channel(byte[] channel_id, byte[] counterparty_node_id) {
207                 long ret = bindings.ChannelManager_close_channel(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
208                 Reference.reachabilityFence(this);
209                 Reference.reachabilityFence(channel_id);
210                 Reference.reachabilityFence(counterparty_node_id);
211                 if (ret >= 0 && ret <= 4096) { return null; }
212                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
213                 return ret_hu_conv;
214         }
215
216         /**
217          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
218          * will be accepted on the given channel, and after additional timeout/the closing of all
219          * pending HTLCs, the channel will be closed on chain.
220          * 
221          * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
222          * the channel being closed or not:
223          * If we are the channel initiator, we will pay at least this feerate on the closing
224          * transaction. The upper-bound is set by
225          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
226          * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
227          * If our counterparty is the channel initiator, we will refuse to accept a channel closure
228          * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
229          * will appear on a force-closure transaction, whichever is lower).
230          * 
231          * May generate a SendShutdown message event on success, which should be relayed.
232          * 
233          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
234          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
235          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
236          */
237         public Result_NoneAPIErrorZ close_channel_with_target_feerate(byte[] channel_id, byte[] counterparty_node_id, int target_feerate_sats_per_1000_weight) {
238                 long ret = bindings.ChannelManager_close_channel_with_target_feerate(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), target_feerate_sats_per_1000_weight);
239                 Reference.reachabilityFence(this);
240                 Reference.reachabilityFence(channel_id);
241                 Reference.reachabilityFence(counterparty_node_id);
242                 Reference.reachabilityFence(target_feerate_sats_per_1000_weight);
243                 if (ret >= 0 && ret <= 4096) { return null; }
244                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
245                 return ret_hu_conv;
246         }
247
248         /**
249          * Force closes a channel, immediately broadcasting the latest local transaction(s) and
250          * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
251          * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
252          * channel.
253          */
254         public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(byte[] channel_id, byte[] counterparty_node_id) {
255                 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));
256                 Reference.reachabilityFence(this);
257                 Reference.reachabilityFence(channel_id);
258                 Reference.reachabilityFence(counterparty_node_id);
259                 if (ret >= 0 && ret <= 4096) { return null; }
260                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
261                 return ret_hu_conv;
262         }
263
264         /**
265          * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
266          * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
267          * `counterparty_node_id` isn't the counterparty of the corresponding channel.
268          * 
269          * You can always get the latest local transaction(s) to broadcast from
270          * [`ChannelMonitor::get_latest_holder_commitment_txn`].
271          */
272         public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(byte[] channel_id, byte[] counterparty_node_id) {
273                 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));
274                 Reference.reachabilityFence(this);
275                 Reference.reachabilityFence(channel_id);
276                 Reference.reachabilityFence(counterparty_node_id);
277                 if (ret >= 0 && ret <= 4096) { return null; }
278                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
279                 return ret_hu_conv;
280         }
281
282         /**
283          * Force close all channels, immediately broadcasting the latest local commitment transaction
284          * for each to the chain and rejecting new HTLCs on each.
285          */
286         public void force_close_all_channels_broadcasting_latest_txn() {
287                 bindings.ChannelManager_force_close_all_channels_broadcasting_latest_txn(this.ptr);
288                 Reference.reachabilityFence(this);
289         }
290
291         /**
292          * Force close all channels rejecting new HTLCs on each but without broadcasting the latest
293          * local transaction(s).
294          */
295         public void force_close_all_channels_without_broadcasting_txn() {
296                 bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr);
297                 Reference.reachabilityFence(this);
298         }
299
300         /**
301          * Sends a payment along a given route.
302          * 
303          * Value parameters are provided via the last hop in route, see documentation for RouteHop
304          * fields for more info.
305          * 
306          * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
307          * payment), we don't do anything to stop you! We always try to ensure that if the provided
308          * next hop knows the preimage to payment_hash they can claim an additional amount as
309          * specified in the last hop in the route! Thus, you should probably do your own
310          * payment_preimage tracking (which you should already be doing as they represent \"proof of
311          * payment\") and prevent double-sends yourself.
312          * 
313          * May generate SendHTLCs message(s) event on success, which should be relayed.
314          * 
315          * Each path may have a different return value, and PaymentSendValue may return a Vec with
316          * each entry matching the corresponding-index entry in the route paths, see
317          * PaymentSendFailure for more info.
318          * 
319          * In general, a path may raise:
320          * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
321          * node public key) is specified.
322          * APIError::ChannelUnavailable if the next-hop channel is not available for updates
323          * (including due to previous monitor update failure or new permanent monitor update
324          * failure).
325          * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
326          * relevant updates.
327          * 
328          * Note that depending on the type of the PaymentSendFailure the HTLC may have been
329          * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
330          * different route unless you intend to pay twice!
331          * 
332          * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
333          * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
334          * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
335          * must not contain multiple paths as multi-path payments require a recipient-provided
336          * payment_secret.
337          * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
338          * bit set (either as required or as available). If multiple paths are present in the Route,
339          * we assume the invoice had the basic_mpp feature set.
340          * 
341          * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
342          */
343         public Result_PaymentIdPaymentSendFailureZ send_payment(Route route, byte[] payment_hash, @Nullable byte[] payment_secret) {
344                 long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr & ~1, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
345                 Reference.reachabilityFence(this);
346                 Reference.reachabilityFence(route);
347                 Reference.reachabilityFence(payment_hash);
348                 Reference.reachabilityFence(payment_secret);
349                 if (ret >= 0 && ret <= 4096) { return null; }
350                 Result_PaymentIdPaymentSendFailureZ ret_hu_conv = Result_PaymentIdPaymentSendFailureZ.constr_from_ptr(ret);
351                 if (this != null) { this.ptrs_to.add(route); };
352                 return ret_hu_conv;
353         }
354
355         /**
356          * Retries a payment along the given [`Route`].
357          * 
358          * Errors returned are a superset of those returned from [`send_payment`], so see
359          * [`send_payment`] documentation for more details on errors. This method will also error if the
360          * retry amount puts the payment more than 10% over the payment's total amount, if the payment
361          * for the given `payment_id` cannot be found (likely due to timeout or success), or if
362          * further retries have been disabled with [`abandon_payment`].
363          * 
364          * [`send_payment`]: [`ChannelManager::send_payment`]
365          * [`abandon_payment`]: [`ChannelManager::abandon_payment`]
366          */
367         public Result_NonePaymentSendFailureZ retry_payment(Route route, byte[] payment_id) {
368                 long ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr & ~1, InternalUtils.check_arr_len(payment_id, 32));
369                 Reference.reachabilityFence(this);
370                 Reference.reachabilityFence(route);
371                 Reference.reachabilityFence(payment_id);
372                 if (ret >= 0 && ret <= 4096) { return null; }
373                 Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
374                 if (this != null) { this.ptrs_to.add(route); };
375                 return ret_hu_conv;
376         }
377
378         /**
379          * Signals that no further retries for the given payment will occur.
380          * 
381          * After this method returns, any future calls to [`retry_payment`] for the given `payment_id`
382          * will fail with [`PaymentSendFailure::ParameterError`]. If no such event has been generated,
383          * an [`Event::PaymentFailed`] event will be generated as soon as there are no remaining
384          * pending HTLCs for this payment.
385          * 
386          * Note that calling this method does *not* prevent a payment from succeeding. You must still
387          * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
388          * determine the ultimate status of a payment.
389          * 
390          * [`retry_payment`]: Self::retry_payment
391          * [`Event::PaymentFailed`]: events::Event::PaymentFailed
392          * [`Event::PaymentSent`]: events::Event::PaymentSent
393          */
394         public void abandon_payment(byte[] payment_id) {
395                 bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.check_arr_len(payment_id, 32));
396                 Reference.reachabilityFence(this);
397                 Reference.reachabilityFence(payment_id);
398         }
399
400         /**
401          * Send a spontaneous payment, which is a payment that does not require the recipient to have
402          * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
403          * the preimage, it must be a cryptographically secure random value that no intermediate node
404          * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
405          * never reach the recipient.
406          * 
407          * See [`send_payment`] documentation for more details on the return value of this function.
408          * 
409          * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
410          * [`send_payment`] for more information about the risks of duplicate preimage usage.
411          * 
412          * Note that `route` must have exactly one path.
413          * 
414          * [`send_payment`]: Self::send_payment
415          * 
416          * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
417          */
418         public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ send_spontaneous_payment(Route route, @Nullable byte[] payment_preimage) {
419                 long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr & ~1, InternalUtils.check_arr_len(payment_preimage, 32));
420                 Reference.reachabilityFence(this);
421                 Reference.reachabilityFence(route);
422                 Reference.reachabilityFence(payment_preimage);
423                 if (ret >= 0 && ret <= 4096) { return null; }
424                 Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
425                 if (this != null) { this.ptrs_to.add(route); };
426                 return ret_hu_conv;
427         }
428
429         /**
430          * Send a payment that is probing the given route for liquidity. We calculate the
431          * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
432          * us to easily discern them from real payments.
433          */
434         public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ send_probe(RouteHop[] hops) {
435                 long ret = bindings.ChannelManager_send_probe(this.ptr, hops != null ? Arrays.stream(hops).mapToLong(hops_conv_10 -> hops_conv_10 == null ? 0 : hops_conv_10.ptr & ~1).toArray() : null);
436                 Reference.reachabilityFence(this);
437                 Reference.reachabilityFence(hops);
438                 if (ret >= 0 && ret <= 4096) { return null; }
439                 Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
440                 return ret_hu_conv;
441         }
442
443         /**
444          * Call this upon creation of a funding transaction for the given channel.
445          * 
446          * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
447          * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
448          * 
449          * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
450          * across the p2p network.
451          * 
452          * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
453          * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
454          * 
455          * May panic if the output found in the funding transaction is duplicative with some other
456          * channel (note that this should be trivially prevented by using unique funding transaction
457          * keys per-channel).
458          * 
459          * Do NOT broadcast the funding transaction yourself. When we have safely received our
460          * counterparty's signature the funding transaction will automatically be broadcast via the
461          * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
462          * 
463          * Note that this includes RBF or similar transaction replacement strategies - lightning does
464          * not currently support replacing a funding transaction on an existing channel. Instead,
465          * create a new channel with a conflicting funding transaction.
466          * 
467          * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
468          * the wallet software generating the funding transaction to apply anti-fee sniping as
469          * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
470          * for more details.
471          * 
472          * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
473          * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
474          */
475         public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] counterparty_node_id, byte[] funding_transaction) {
476                 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);
477                 Reference.reachabilityFence(this);
478                 Reference.reachabilityFence(temporary_channel_id);
479                 Reference.reachabilityFence(counterparty_node_id);
480                 Reference.reachabilityFence(funding_transaction);
481                 if (ret >= 0 && ret <= 4096) { return null; }
482                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
483                 return ret_hu_conv;
484         }
485
486         /**
487          * Regenerates channel_announcements and generates a signed node_announcement from the given
488          * arguments, providing them in corresponding events via
489          * [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
490          * on-chain. This effectively re-broadcasts all channel announcements and sends our node
491          * announcement to ensure that the lightning P2P network is aware of the channels we have and
492          * our network addresses.
493          * 
494          * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
495          * node to humans. They carry no in-protocol meaning.
496          * 
497          * `addresses` represent the set (possibly empty) of socket addresses on which this node
498          * accepts incoming connections. These will be included in the node_announcement, publicly
499          * tying these addresses together and to this node. If you wish to preserve user privacy,
500          * addresses should likely contain only Tor Onion addresses.
501          * 
502          * Panics if `addresses` is absurdly large (more than 100).
503          * 
504          * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
505          */
506         public void broadcast_node_announcement(byte[] rgb, byte[] alias, NetAddress[] addresses) {
507                 bindings.ChannelManager_broadcast_node_announcement(this.ptr, InternalUtils.check_arr_len(rgb, 3), InternalUtils.check_arr_len(alias, 32), addresses != null ? Arrays.stream(addresses).mapToLong(addresses_conv_12 -> addresses_conv_12.ptr).toArray() : null);
508                 Reference.reachabilityFence(this);
509                 Reference.reachabilityFence(rgb);
510                 Reference.reachabilityFence(alias);
511                 Reference.reachabilityFence(addresses);
512         }
513
514         /**
515          * Atomically updates the [`ChannelConfig`] for the given channels.
516          * 
517          * Once the updates are applied, each eligible channel (advertised with a known short channel
518          * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
519          * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
520          * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
521          * 
522          * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
523          * `counterparty_node_id` is provided.
524          * 
525          * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
526          * below [`MIN_CLTV_EXPIRY_DELTA`].
527          * 
528          * If an error is returned, none of the updates should be considered applied.
529          * 
530          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
531          * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
532          * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
533          * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
534          * [`ChannelUpdate`]: msgs::ChannelUpdate
535          * [`ChannelUnavailable`]: APIError::ChannelUnavailable
536          * [`APIMisuseError`]: APIError::APIMisuseError
537          */
538         public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, ChannelConfig config) {
539                 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 & ~1);
540                 Reference.reachabilityFence(this);
541                 Reference.reachabilityFence(counterparty_node_id);
542                 Reference.reachabilityFence(channel_ids);
543                 Reference.reachabilityFence(config);
544                 if (ret >= 0 && ret <= 4096) { return null; }
545                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
546                 if (this != null) { this.ptrs_to.add(config); };
547                 return ret_hu_conv;
548         }
549
550         /**
551          * Processes HTLCs which are pending waiting on random forward delay.
552          * 
553          * Should only really ever be called in response to a PendingHTLCsForwardable event.
554          * Will likely generate further events.
555          */
556         public void process_pending_htlc_forwards() {
557                 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
558                 Reference.reachabilityFence(this);
559         }
560
561         /**
562          * Performs actions which should happen on startup and roughly once per minute thereafter.
563          * 
564          * This currently includes:
565          * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
566          * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
567          * than a minute, informing the network that they should no longer attempt to route over
568          * the channel.
569          * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs
570          * with the current `ChannelConfig`.
571          * 
572          * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
573          * estimate fetches.
574          */
575         public void timer_tick_occurred() {
576                 bindings.ChannelManager_timer_tick_occurred(this.ptr);
577                 Reference.reachabilityFence(this);
578         }
579
580         /**
581          * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
582          * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
583          * along the path (including in our own channel on which we received it).
584          * 
585          * Note that in some cases around unclean shutdown, it is possible the payment may have
586          * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
587          * second copy of) the [`events::Event::PaymentReceived`] event. Alternatively, the payment
588          * may have already been failed automatically by LDK if it was nearing its expiration time.
589          * 
590          * While LDK will never claim a payment automatically on your behalf (i.e. without you calling
591          * [`ChannelManager::claim_funds`]), you should still monitor for
592          * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
593          * startup during which time claims that were in-progress at shutdown may be replayed.
594          */
595         public void fail_htlc_backwards(byte[] payment_hash) {
596                 bindings.ChannelManager_fail_htlc_backwards(this.ptr, InternalUtils.check_arr_len(payment_hash, 32));
597                 Reference.reachabilityFence(this);
598                 Reference.reachabilityFence(payment_hash);
599         }
600
601         /**
602          * Provides a payment preimage in response to [`Event::PaymentReceived`], generating any
603          * [`MessageSendEvent`]s needed to claim the payment.
604          * 
605          * Note that calling this method does *not* guarantee that the payment has been claimed. You
606          * must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be
607          * provided to your [`EventHandler`] when [`process_pending_events`] is next called.
608          * 
609          * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
610          * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived`
611          * event matches your expectation. If you fail to do so and call this method, you may provide
612          * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
613          * 
614          * [`Event::PaymentReceived`]: crate::util::events::Event::PaymentReceived
615          * [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed
616          * [`process_pending_events`]: EventsProvider::process_pending_events
617          * [`create_inbound_payment`]: Self::create_inbound_payment
618          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
619          * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
620          */
621         public void claim_funds(byte[] payment_preimage) {
622                 bindings.ChannelManager_claim_funds(this.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
623                 Reference.reachabilityFence(this);
624                 Reference.reachabilityFence(payment_preimage);
625         }
626
627         /**
628          * Gets the node_id held by this ChannelManager
629          */
630         public byte[] get_our_node_id() {
631                 byte[] ret = bindings.ChannelManager_get_our_node_id(this.ptr);
632                 Reference.reachabilityFence(this);
633                 return ret;
634         }
635
636         /**
637          * Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
638          * 
639          * The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
640          * and the `counterparty_node_id` parameter is the id of the peer which has requested to open
641          * the channel.
642          * 
643          * The `user_channel_id` parameter will be provided back in
644          * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
645          * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
646          * 
647          * Note that this method will return an error and reject the channel, if it requires support
648          * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
649          * used to accept such channels.
650          * 
651          * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
652          * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
653          */
654         public Result_NoneAPIErrorZ accept_inbound_channel(byte[] temporary_channel_id, byte[] counterparty_node_id, long user_channel_id) {
655                 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);
656                 Reference.reachabilityFence(this);
657                 Reference.reachabilityFence(temporary_channel_id);
658                 Reference.reachabilityFence(counterparty_node_id);
659                 Reference.reachabilityFence(user_channel_id);
660                 if (ret >= 0 && ret <= 4096) { return null; }
661                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
662                 return ret_hu_conv;
663         }
664
665         /**
666          * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
667          * it as confirmed immediately.
668          * 
669          * The `user_channel_id` parameter will be provided back in
670          * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
671          * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
672          * 
673          * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
674          * and (if the counterparty agrees), enables forwarding of payments immediately.
675          * 
676          * This fully trusts that the counterparty has honestly and correctly constructed the funding
677          * transaction and blindly assumes that it will eventually confirm.
678          * 
679          * If it does not confirm before we decide to close the channel, or if the funding transaction
680          * does not pay to the correct script the correct amount, *you will lose funds*.
681          * 
682          * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
683          * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
684          */
685         public Result_NoneAPIErrorZ accept_inbound_channel_from_trusted_peer_0conf(byte[] temporary_channel_id, byte[] counterparty_node_id, long user_channel_id) {
686                 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);
687                 Reference.reachabilityFence(this);
688                 Reference.reachabilityFence(temporary_channel_id);
689                 Reference.reachabilityFence(counterparty_node_id);
690                 Reference.reachabilityFence(user_channel_id);
691                 if (ret >= 0 && ret <= 4096) { return null; }
692                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
693                 return ret_hu_conv;
694         }
695
696         /**
697          * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
698          * to pay us.
699          * 
700          * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
701          * [`PaymentHash`] and [`PaymentPreimage`] for you.
702          * 
703          * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which
704          * will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be
705          * passed directly to [`claim_funds`].
706          * 
707          * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
708          * 
709          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
710          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
711          * 
712          * # Note
713          * 
714          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
715          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
716          * 
717          * Errors if `min_value_msat` is greater than total bitcoin supply.
718          * 
719          * [`claim_funds`]: Self::claim_funds
720          * [`PaymentReceived`]: events::Event::PaymentReceived
721          * [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage
722          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
723          */
724         public Result_C2Tuple_PaymentHashPaymentSecretZNoneZ create_inbound_payment(Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
725                 long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs);
726                 Reference.reachabilityFence(this);
727                 Reference.reachabilityFence(min_value_msat);
728                 Reference.reachabilityFence(invoice_expiry_delta_secs);
729                 if (ret >= 0 && ret <= 4096) { return null; }
730                 Result_C2Tuple_PaymentHashPaymentSecretZNoneZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
731                 return ret_hu_conv;
732         }
733
734         /**
735          * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
736          * serialized state with LDK node(s) running 0.0.103 and earlier.
737          * 
738          * May panic if `invoice_expiry_delta_secs` is greater than one year.
739          * 
740          * # Note
741          * This method is deprecated and will be removed soon.
742          * 
743          * [`create_inbound_payment`]: Self::create_inbound_payment
744          */
745         public Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ create_inbound_payment_legacy(Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
746                 long ret = bindings.ChannelManager_create_inbound_payment_legacy(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs);
747                 Reference.reachabilityFence(this);
748                 Reference.reachabilityFence(min_value_msat);
749                 Reference.reachabilityFence(invoice_expiry_delta_secs);
750                 if (ret >= 0 && ret <= 4096) { return null; }
751                 Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ.constr_from_ptr(ret);
752                 return ret_hu_conv;
753         }
754
755         /**
756          * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
757          * stored external to LDK.
758          * 
759          * A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a
760          * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
761          * the `min_value_msat` provided here, if one is provided.
762          * 
763          * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
764          * note that LDK will not stop you from registering duplicate payment hashes for inbound
765          * payments.
766          * 
767          * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
768          * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
769          * before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
770          * sender \"proof-of-payment\" unless they have paid the required amount.
771          * 
772          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
773          * in excess of the current time. This should roughly match the expiry time set in the invoice.
774          * After this many seconds, we will remove the inbound payment, resulting in any attempts to
775          * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
776          * invoices when no timeout is set.
777          * 
778          * Note that we use block header time to time-out pending inbound payments (with some margin
779          * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
780          * accept a payment and generate a [`PaymentReceived`] event for some time after the expiry.
781          * If you need exact expiry semantics, you should enforce them upon receipt of
782          * [`PaymentReceived`].
783          * 
784          * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
785          * set to at least [`MIN_FINAL_CLTV_EXPIRY`].
786          * 
787          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
788          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
789          * 
790          * # Note
791          * 
792          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
793          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
794          * 
795          * Errors if `min_value_msat` is greater than total bitcoin supply.
796          * 
797          * [`create_inbound_payment`]: Self::create_inbound_payment
798          * [`PaymentReceived`]: events::Event::PaymentReceived
799          */
800         public Result_PaymentSecretNoneZ create_inbound_payment_for_hash(byte[] payment_hash, Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
801                 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);
802                 Reference.reachabilityFence(this);
803                 Reference.reachabilityFence(payment_hash);
804                 Reference.reachabilityFence(min_value_msat);
805                 Reference.reachabilityFence(invoice_expiry_delta_secs);
806                 if (ret >= 0 && ret <= 4096) { return null; }
807                 Result_PaymentSecretNoneZ ret_hu_conv = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
808                 return ret_hu_conv;
809         }
810
811         /**
812          * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
813          * serialized state with LDK node(s) running 0.0.103 and earlier.
814          * 
815          * May panic if `invoice_expiry_delta_secs` is greater than one year.
816          * 
817          * # Note
818          * This method is deprecated and will be removed soon.
819          * 
820          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
821          */
822         public Result_PaymentSecretAPIErrorZ create_inbound_payment_for_hash_legacy(byte[] payment_hash, Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
823                 long ret = bindings.ChannelManager_create_inbound_payment_for_hash_legacy(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), min_value_msat.ptr, invoice_expiry_delta_secs);
824                 Reference.reachabilityFence(this);
825                 Reference.reachabilityFence(payment_hash);
826                 Reference.reachabilityFence(min_value_msat);
827                 Reference.reachabilityFence(invoice_expiry_delta_secs);
828                 if (ret >= 0 && ret <= 4096) { return null; }
829                 Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
830                 return ret_hu_conv;
831         }
832
833         /**
834          * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
835          * previously returned from [`create_inbound_payment`].
836          * 
837          * [`create_inbound_payment`]: Self::create_inbound_payment
838          */
839         public Result_PaymentPreimageAPIErrorZ get_payment_preimage(byte[] payment_hash, byte[] payment_secret) {
840                 long ret = bindings.ChannelManager_get_payment_preimage(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
841                 Reference.reachabilityFence(this);
842                 Reference.reachabilityFence(payment_hash);
843                 Reference.reachabilityFence(payment_secret);
844                 if (ret >= 0 && ret <= 4096) { return null; }
845                 Result_PaymentPreimageAPIErrorZ ret_hu_conv = Result_PaymentPreimageAPIErrorZ.constr_from_ptr(ret);
846                 return ret_hu_conv;
847         }
848
849         /**
850          * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
851          * are used when constructing the phantom invoice's route hints.
852          * 
853          * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
854          */
855         public long get_phantom_scid() {
856                 long ret = bindings.ChannelManager_get_phantom_scid(this.ptr);
857                 Reference.reachabilityFence(this);
858                 return ret;
859         }
860
861         /**
862          * Gets route hints for use in receiving [phantom node payments].
863          * 
864          * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
865          */
866         public PhantomRouteHints get_phantom_route_hints() {
867                 long ret = bindings.ChannelManager_get_phantom_route_hints(this.ptr);
868                 Reference.reachabilityFence(this);
869                 if (ret >= 0 && ret <= 4096) { return null; }
870                 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
871                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
872                 return ret_hu_conv;
873         }
874
875         /**
876          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
877          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
878          */
879         public MessageSendEventsProvider as_MessageSendEventsProvider() {
880                 long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
881                 Reference.reachabilityFence(this);
882                 if (ret >= 0 && ret <= 4096) { return null; }
883                 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
884                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
885                 return ret_hu_conv;
886         }
887
888         /**
889          * Constructs a new EventsProvider which calls the relevant methods on this_arg.
890          * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
891          */
892         public EventsProvider as_EventsProvider() {
893                 long ret = bindings.ChannelManager_as_EventsProvider(this.ptr);
894                 Reference.reachabilityFence(this);
895                 if (ret >= 0 && ret <= 4096) { return null; }
896                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
897                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
898                 return ret_hu_conv;
899         }
900
901         /**
902          * Constructs a new Listen which calls the relevant methods on this_arg.
903          * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
904          */
905         public Listen as_Listen() {
906                 long ret = bindings.ChannelManager_as_Listen(this.ptr);
907                 Reference.reachabilityFence(this);
908                 if (ret >= 0 && ret <= 4096) { return null; }
909                 Listen ret_hu_conv = new Listen(null, ret);
910                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
911                 return ret_hu_conv;
912         }
913
914         /**
915          * Constructs a new Confirm which calls the relevant methods on this_arg.
916          * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
917          */
918         public Confirm as_Confirm() {
919                 long ret = bindings.ChannelManager_as_Confirm(this.ptr);
920                 Reference.reachabilityFence(this);
921                 if (ret >= 0 && ret <= 4096) { return null; }
922                 Confirm ret_hu_conv = new Confirm(null, ret);
923                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
924                 return ret_hu_conv;
925         }
926
927         /**
928          * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
929          * indicating whether persistence is necessary. Only one listener on
930          * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
931          * up.
932          * 
933          * Note that this method is not available with the `no-std` feature.
934          */
935         public boolean await_persistable_update_timeout(long max_wait) {
936                 boolean ret = bindings.ChannelManager_await_persistable_update_timeout(this.ptr, max_wait);
937                 Reference.reachabilityFence(this);
938                 Reference.reachabilityFence(max_wait);
939                 return ret;
940         }
941
942         /**
943          * Blocks until ChannelManager needs to be persisted. Only one listener on
944          * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
945          * up.
946          */
947         public void await_persistable_update() {
948                 bindings.ChannelManager_await_persistable_update(this.ptr);
949                 Reference.reachabilityFence(this);
950         }
951
952         /**
953          * Gets the latest best block which was connected either via the [`chain::Listen`] or
954          * [`chain::Confirm`] interfaces.
955          */
956         public BestBlock current_best_block() {
957                 long ret = bindings.ChannelManager_current_best_block(this.ptr);
958                 Reference.reachabilityFence(this);
959                 if (ret >= 0 && ret <= 4096) { return null; }
960                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
961                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
962                 return ret_hu_conv;
963         }
964
965         /**
966          * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
967          * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
968          */
969         public ChannelMessageHandler as_ChannelMessageHandler() {
970                 long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
971                 Reference.reachabilityFence(this);
972                 if (ret >= 0 && ret <= 4096) { return null; }
973                 ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
974                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
975                 return ret_hu_conv;
976         }
977
978         /**
979          * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
980          */
981         public byte[] write() {
982                 byte[] ret = bindings.ChannelManager_write(this.ptr);
983                 Reference.reachabilityFence(this);
984                 return ret;
985         }
986
987         /**
988          * Constructs a new Payer which calls the relevant methods on this_arg.
989          * This copies the `inner` pointer in this_arg and thus the returned Payer must be freed before this_arg is
990          */
991         public Payer as_Payer() {
992                 long ret = bindings.ChannelManager_as_Payer(this.ptr);
993                 Reference.reachabilityFence(this);
994                 if (ret >= 0 && ret <= 4096) { return null; }
995                 Payer ret_hu_conv = new Payer(null, ret);
996                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
997                 return ret_hu_conv;
998         }
999
1000 }