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