Update auto-generated 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
8
9 /**
10  * Manager which keeps track of a number of channels and sends messages to the appropriate
11  * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
12  * 
13  * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
14  * to individual Channels.
15  * 
16  * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
17  * all peers during write/read (though does not modify this instance, only the instance being
18  * serialized). This will result in any channels which have not yet exchanged funding_created (ie
19  * called funding_transaction_generated for outbound channels).
20  * 
21  * Note that you can be a bit lazier about writing out ChannelManager than you can be with
22  * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
23  * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
24  * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
25  * the serialization process). If the deserialized version is out-of-date compared to the
26  * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
27  * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
28  * 
29  * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
30  * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
31  * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
32  * block_connected() to step towards your best block) upon deserialization before using the
33  * object!
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  * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
42  * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
43  * essentially you should default to using a SimpleRefChannelManager, and use a
44  * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
45  * you're using lightning-net-tokio.
46  */
47 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
48 public class ChannelManager extends CommonBase {
49         ChannelManager(Object _dummy, long ptr) { super(ptr); }
50         @Override @SuppressWarnings("deprecation")
51         protected void finalize() throws Throwable {
52                 super.finalize();
53                 if (ptr != 0) { bindings.ChannelManager_free(ptr); }
54         }
55
56         /**
57          * Constructs a new ChannelManager to hold several channels and route between them.
58          * 
59          * This is the main \"logic hub\" for all channel-related actions, and implements
60          * ChannelMessageHandler.
61          * 
62          * Non-proportional fees are fixed according to our risk using the provided fee estimator.
63          * 
64          * panics if channel_value_satoshis is >= `MAX_FUNDING_SATOSHIS`!
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                 ChannelManager ret_hu_conv = new ChannelManager(null, ret);
73                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
74                 ret_hu_conv.ptrs_to.add(fee_est);
75                 ret_hu_conv.ptrs_to.add(chain_monitor);
76                 ret_hu_conv.ptrs_to.add(tx_broadcaster);
77                 ret_hu_conv.ptrs_to.add(logger);
78                 ret_hu_conv.ptrs_to.add(keys_manager);
79                 ret_hu_conv.ptrs_to.add(config);
80                 ret_hu_conv.ptrs_to.add(params);
81                 return ret_hu_conv;
82         }
83
84         /**
85          * Gets the current configuration applied to all new channels,  as
86          */
87         public UserConfig get_current_default_configuration() {
88                 long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
89                 UserConfig ret_hu_conv = new UserConfig(null, ret);
90                 ret_hu_conv.ptrs_to.add(this);
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Creates a new outbound channel to the given remote node and with the given value.
96          * 
97          * user_id will be provided back as user_channel_id in FundingGenerationReady events to allow
98          * tracking of which events correspond with which create_channel call. Note that the
99          * user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for
100          * user_id here. user_id has no meaning inside of LDK, it is simply copied to events and
101          * otherwise ignored.
102          * 
103          * If successful, will generate a SendOpenChannel message event, so you should probably poll
104          * PeerManager::process_events afterwards.
105          * 
106          * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
107          * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
108          */
109         public Result_NoneAPIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_id, UserConfig override_config) {
110                 long ret = bindings.ChannelManager_create_channel(this.ptr, their_network_key, channel_value_satoshis, push_msat, user_id, override_config == null ? 0 : override_config.ptr & ~1);
111                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
112                 this.ptrs_to.add(override_config);
113                 return ret_hu_conv;
114         }
115
116         /**
117          * Gets the list of open channels, in random order. See ChannelDetail field documentation for
118          * more information.
119          */
120         public ChannelDetails[] list_channels() {
121                 long[] ret = bindings.ChannelManager_list_channels(this.ptr);
122                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length];
123                 for (int q = 0; q < ret.length; q++) {
124                         long ret_conv_16 = ret[q];
125                         ChannelDetails ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16);
126                         ret_conv_16_hu_conv.ptrs_to.add(this);
127                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
128                 }
129                 return ret_conv_16_arr;
130         }
131
132         /**
133          * Gets the list of usable channels, in random order. Useful as an argument to
134          * get_route to ensure non-announced channels are used.
135          * 
136          * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
137          * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
138          * are.
139          */
140         public ChannelDetails[] list_usable_channels() {
141                 long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr);
142                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret.length];
143                 for (int q = 0; q < ret.length; q++) {
144                         long ret_conv_16 = ret[q];
145                         ChannelDetails ret_conv_16_hu_conv = new ChannelDetails(null, ret_conv_16);
146                         ret_conv_16_hu_conv.ptrs_to.add(this);
147                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
148                 }
149                 return ret_conv_16_arr;
150         }
151
152         /**
153          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
154          * will be accepted on the given channel, and after additional timeout/the closing of all
155          * pending HTLCs, the channel will be closed on chain.
156          * 
157          * May generate a SendShutdown message event on success, which should be relayed.
158          */
159         public Result_NoneAPIErrorZ close_channel(byte[] channel_id) {
160                 long ret = bindings.ChannelManager_close_channel(this.ptr, channel_id);
161                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
162                 return ret_hu_conv;
163         }
164
165         /**
166          * Force closes a channel, immediately broadcasting the latest local commitment transaction to
167          * the chain and rejecting new HTLCs on the given channel. Fails if channel_id is unknown to the manager.
168          */
169         public Result_NoneAPIErrorZ force_close_channel(byte[] channel_id) {
170                 long ret = bindings.ChannelManager_force_close_channel(this.ptr, channel_id);
171                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
172                 return ret_hu_conv;
173         }
174
175         /**
176          * Force close all channels, immediately broadcasting the latest local commitment transaction
177          * for each to the chain and rejecting new HTLCs on each.
178          */
179         public void force_close_all_channels() {
180                 bindings.ChannelManager_force_close_all_channels(this.ptr);
181         }
182
183         /**
184          * Sends a payment along a given route.
185          * 
186          * Value parameters are provided via the last hop in route, see documentation for RouteHop
187          * fields for more info.
188          * 
189          * Note that if the payment_hash already exists elsewhere (eg you're sending a duplicative
190          * payment), we don't do anything to stop you! We always try to ensure that if the provided
191          * next hop knows the preimage to payment_hash they can claim an additional amount as
192          * specified in the last hop in the route! Thus, you should probably do your own
193          * payment_preimage tracking (which you should already be doing as they represent \"proof of
194          * payment\") and prevent double-sends yourself.
195          * 
196          * May generate SendHTLCs message(s) event on success, which should be relayed.
197          * 
198          * Each path may have a different return value, and PaymentSendValue may return a Vec with
199          * each entry matching the corresponding-index entry in the route paths, see
200          * PaymentSendFailure for more info.
201          * 
202          * In general, a path may raise:
203          * APIError::RouteError when an invalid route or forwarding parameter (cltv_delta, fee,
204          * node public key) is specified.
205          * APIError::ChannelUnavailable if the next-hop channel is not available for updates
206          * (including due to previous monitor update failure or new permanent monitor update
207          * failure).
208          * APIError::MonitorUpdateFailed if a new monitor update failure prevented sending the
209          * relevant updates.
210          * 
211          * Note that depending on the type of the PaymentSendFailure the HTLC may have been
212          * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
213          * different route unless you intend to pay twice!
214          * 
215          * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
216          * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
217          * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
218          * must not contain multiple paths as multi-path payments require a recipient-provided
219          * payment_secret.
220          * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
221          * bit set (either as required or as available). If multiple paths are present in the Route,
222          * we assume the invoice had the basic_mpp feature set.
223          */
224         public Result_NonePaymentSendFailureZ send_payment(Route route, byte[] payment_hash, byte[] payment_secret) {
225                 long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_hash, payment_secret);
226                 Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
227                 this.ptrs_to.add(route);
228                 return ret_hu_conv;
229         }
230
231         /**
232          * Call this upon creation of a funding transaction for the given channel.
233          * 
234          * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
235          * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
236          * 
237          * Panics if a funding transaction has already been provided for this channel.
238          * 
239          * May panic if the output found in the funding transaction is duplicative with some other
240          * channel (note that this should be trivially prevented by using unique funding transaction
241          * keys per-channel).
242          * 
243          * Do NOT broadcast the funding transaction yourself. When we have safely received our
244          * counterparty's signature the funding transaction will automatically be broadcast via the
245          * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
246          * 
247          * Note that this includes RBF or similar transaction replacement strategies - lightning does
248          * not currently support replacing a funding transaction on an existing channel. Instead,
249          * create a new channel with a conflicting funding transaction.
250          * 
251          * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
252          */
253         public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] funding_transaction) {
254                 long ret = bindings.ChannelManager_funding_transaction_generated(this.ptr, temporary_channel_id, funding_transaction);
255                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
256                 return ret_hu_conv;
257         }
258
259         /**
260          * Regenerates channel_announcements and generates a signed node_announcement from the given
261          * arguments, providing them in corresponding events via
262          * [`get_and_clear_pending_msg_events`], if at least one public channel has been confirmed
263          * on-chain. This effectively re-broadcasts all channel announcements and sends our node
264          * announcement to ensure that the lightning P2P network is aware of the channels we have and
265          * our network addresses.
266          * 
267          * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this
268          * node to humans. They carry no in-protocol meaning.
269          * 
270          * `addresses` represent the set (possibly empty) of socket addresses on which this node
271          * accepts incoming connections. These will be included in the node_announcement, publicly
272          * tying these addresses together and to this node. If you wish to preserve user privacy,
273          * addresses should likely contain only Tor Onion addresses.
274          * 
275          * Panics if `addresses` is absurdly large (more than 500).
276          * 
277          * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
278          */
279         public void broadcast_node_announcement(byte[] rgb, byte[] alias, NetAddress[] addresses) {
280                 bindings.ChannelManager_broadcast_node_announcement(this.ptr, rgb, alias, Arrays.stream(addresses).mapToLong(addresses_conv_12 -> addresses_conv_12.ptr).toArray());
281                 /* TODO 2 NetAddress  */;
282         }
283
284         /**
285          * Processes HTLCs which are pending waiting on random forward delay.
286          * 
287          * Should only really ever be called in response to a PendingHTLCsForwardable event.
288          * Will likely generate further events.
289          */
290         public void process_pending_htlc_forwards() {
291                 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
292         }
293
294         /**
295          * If a peer is disconnected we mark any channels with that peer as 'disabled'.
296          * After some time, if channels are still disabled we need to broadcast a ChannelUpdate
297          * to inform the network about the uselessness of these channels.
298          * 
299          * This method handles all the details, and must be called roughly once per minute.
300          * 
301          * Note that in some rare cases this may generate a `chain::Watch::update_channel` call.
302          */
303         public void timer_tick_occurred() {
304                 bindings.ChannelManager_timer_tick_occurred(this.ptr);
305         }
306
307         /**
308          * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
309          * after a PaymentReceived event, failing the HTLC back to its origin and freeing resources
310          * along the path (including in our own channel on which we received it).
311          * Returns false if no payment was found to fail backwards, true if the process of failing the
312          * HTLC backwards has been started.
313          */
314         public boolean fail_htlc_backwards(byte[] payment_hash) {
315                 boolean ret = bindings.ChannelManager_fail_htlc_backwards(this.ptr, payment_hash);
316                 return ret;
317         }
318
319         /**
320          * Provides a payment preimage in response to a PaymentReceived event, returning true and
321          * generating message events for the net layer to claim the payment, if possible. Thus, you
322          * should probably kick the net layer to go send messages if this returns true!
323          * 
324          * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
325          * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentReceived`
326          * event matches your expectation. If you fail to do so and call this method, you may provide
327          * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
328          * 
329          * May panic if called except in response to a PaymentReceived event.
330          * 
331          * [`create_inbound_payment`]: Self::create_inbound_payment
332          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
333          */
334         public boolean claim_funds(byte[] payment_preimage) {
335                 boolean ret = bindings.ChannelManager_claim_funds(this.ptr, payment_preimage);
336                 return ret;
337         }
338
339         /**
340          * Gets the node_id held by this ChannelManager
341          */
342         public byte[] get_our_node_id() {
343                 byte[] ret = bindings.ChannelManager_get_our_node_id(this.ptr);
344                 return ret;
345         }
346
347         /**
348          * Restores a single, given channel to normal operation after a
349          * ChannelMonitorUpdateErr::TemporaryFailure was returned from a channel monitor update
350          * operation.
351          * 
352          * All ChannelMonitor updates up to and including highest_applied_update_id must have been
353          * fully committed in every copy of the given channels' ChannelMonitors.
354          * 
355          * Note that there is no effect to calling with a highest_applied_update_id other than the
356          * current latest ChannelMonitorUpdate and one call to this function after multiple
357          * ChannelMonitorUpdateErr::TemporaryFailures is fine. The highest_applied_update_id field
358          * exists largely only to prevent races between this and concurrent update_monitor calls.
359          * 
360          * Thus, the anticipated use is, at a high level:
361          * 1) You register a chain::Watch with this ChannelManager,
362          * 2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
363          * said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
364          * any time it cannot do so instantly,
365          * 3) update(s) are applied to each remote copy of a ChannelMonitor,
366          * 4) once all remote copies are updated, you call this function with the update_id that
367          * completed, and once it is the latest the Channel will be re-enabled.
368          */
369         public void channel_monitor_updated(OutPoint funding_txo, long highest_applied_update_id) {
370                 bindings.ChannelManager_channel_monitor_updated(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, highest_applied_update_id);
371                 this.ptrs_to.add(funding_txo);
372         }
373
374         /**
375          * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
376          * to pay us.
377          * 
378          * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
379          * [`PaymentHash`] and [`PaymentPreimage`] for you, returning the first and storing the second.
380          * 
381          * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentReceived`], which
382          * will have the [`PaymentReceived::payment_preimage`] field filled in. That should then be
383          * passed directly to [`claim_funds`].
384          * 
385          * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
386          * 
387          * [`claim_funds`]: Self::claim_funds
388          * [`PaymentReceived`]: events::Event::PaymentReceived
389          * [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage
390          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
391          */
392         public TwoTuple<byte[], byte[]> create_inbound_payment(Option_u64Z min_value_msat, int invoice_expiry_delta_secs, long user_payment_id) {
393                 long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, user_payment_id);
394                 byte[] ret_a = bindings.LDKC2Tuple_PaymentHashPaymentSecretZ_get_a(ret);
395                 byte[] ret_b = bindings.LDKC2Tuple_PaymentHashPaymentSecretZ_get_b(ret);
396                 TwoTuple<byte[], byte[]> ret_conv = new TwoTuple<byte[], byte[]>(ret_a, ret_b, () -> {
397                         bindings.C2Tuple_PaymentHashPaymentSecretZ_free(ret);
398                 });
399                 return ret_conv;
400         }
401
402         /**
403          * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
404          * stored external to LDK.
405          * 
406          * A [`PaymentReceived`] event will only be generated if the [`PaymentSecret`] matches a
407          * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
408          * the `min_value_msat` provided here, if one is provided.
409          * 
410          * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This
411          * method may return an Err if another payment with the same payment_hash is still pending.
412          * 
413          * `user_payment_id` will be provided back in [`PaymentReceived::user_payment_id`] events to
414          * allow tracking of which events correspond with which calls to this and
415          * [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply
416          * copied to events and otherwise ignored. It may be used to correlate PaymentReceived events
417          * with invoice metadata stored elsewhere.
418          * 
419          * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
420          * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
421          * before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
422          * sender \"proof-of-payment\" unless they have paid the required amount.
423          * 
424          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
425          * in excess of the current time. This should roughly match the expiry time set in the invoice.
426          * After this many seconds, we will remove the inbound payment, resulting in any attempts to
427          * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
428          * invoices when no timeout is set.
429          * 
430          * Note that we use block header time to time-out pending inbound payments (with some margin
431          * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
432          * accept a payment and generate a [`PaymentReceived`] event for some time after the expiry.
433          * If you need exact expiry semantics, you should enforce them upon receipt of
434          * [`PaymentReceived`].
435          * 
436          * Pending inbound payments are stored in memory and in serialized versions of this
437          * [`ChannelManager`]. If potentially unbounded numbers of inbound payments may exist and
438          * space is limited, you may wish to rate-limit inbound payment creation.
439          * 
440          * May panic if `invoice_expiry_delta_secs` is greater than one year.
441          * 
442          * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
443          * set to at least [`MIN_FINAL_CLTV_EXPIRY`].
444          * 
445          * [`create_inbound_payment`]: Self::create_inbound_payment
446          * [`PaymentReceived`]: events::Event::PaymentReceived
447          * [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id
448          */
449         public Result_PaymentSecretAPIErrorZ create_inbound_payment_for_hash(byte[] payment_hash, Option_u64Z min_value_msat, int invoice_expiry_delta_secs, long user_payment_id) {
450                 long ret = bindings.ChannelManager_create_inbound_payment_for_hash(this.ptr, payment_hash, min_value_msat.ptr, invoice_expiry_delta_secs, user_payment_id);
451                 Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
452                 return ret_hu_conv;
453         }
454
455         /**
456          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
457          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
458          */
459         public MessageSendEventsProvider as_MessageSendEventsProvider() {
460                 long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
461                 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
462                 ret_hu_conv.ptrs_to.add(this);
463                 return ret_hu_conv;
464         }
465
466         /**
467          * Constructs a new EventsProvider which calls the relevant methods on this_arg.
468          * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
469          */
470         public EventsProvider as_EventsProvider() {
471                 long ret = bindings.ChannelManager_as_EventsProvider(this.ptr);
472                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
473                 ret_hu_conv.ptrs_to.add(this);
474                 return ret_hu_conv;
475         }
476
477         /**
478          * Constructs a new Listen which calls the relevant methods on this_arg.
479          * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
480          */
481         public Listen as_Listen() {
482                 long ret = bindings.ChannelManager_as_Listen(this.ptr);
483                 Listen ret_hu_conv = new Listen(null, ret);
484                 ret_hu_conv.ptrs_to.add(this);
485                 return ret_hu_conv;
486         }
487
488         /**
489          * Constructs a new Confirm which calls the relevant methods on this_arg.
490          * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
491          */
492         public Confirm as_Confirm() {
493                 long ret = bindings.ChannelManager_as_Confirm(this.ptr);
494                 Confirm ret_hu_conv = new Confirm(null, ret);
495                 ret_hu_conv.ptrs_to.add(this);
496                 return ret_hu_conv;
497         }
498
499         /**
500          * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
501          * indicating whether persistence is necessary. Only one listener on
502          * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
503          * up.
504          * Note that the feature `allow_wallclock_use` must be enabled to use this function.
505          */
506         public boolean await_persistable_update_timeout(long max_wait) {
507                 boolean ret = bindings.ChannelManager_await_persistable_update_timeout(this.ptr, max_wait);
508                 return ret;
509         }
510
511         /**
512          * Blocks until ChannelManager needs to be persisted. Only one listener on
513          * `await_persistable_update` or `await_persistable_update_timeout` is guaranteed to be woken
514          * up.
515          */
516         public void await_persistable_update() {
517                 bindings.ChannelManager_await_persistable_update(this.ptr);
518         }
519
520         /**
521          * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
522          * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
523          */
524         public ChannelMessageHandler as_ChannelMessageHandler() {
525                 long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
526                 ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
527                 ret_hu_conv.ptrs_to.add(this);
528                 return ret_hu_conv;
529         }
530
531         /**
532          * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
533          */
534         public byte[] write() {
535                 byte[] ret = bindings.ChannelManager_write(this.ptr);
536                 return ret;
537         }
538
539 }