6 namespace org { namespace ldk { namespace structs {
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.
13 * Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through
14 * to individual Channels.
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.
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).
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.
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.
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.
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.
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.
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
65 public class ChannelManager : CommonBase {
66 internal ChannelManager(object _dummy, long ptr) : base(ptr) { }
68 if (ptr != 0) { bindings.ChannelManager_free(ptr); }
72 * Constructs a new `ChannelManager` to hold several channels and route between them.
74 * The current time or latest block header time can be provided as the `current_timestamp`.
76 * This is the main \"logic hub\" for all channel-related actions, and implements
77 * [`ChannelMessageHandler`].
79 * Non-proportional fees are fixed according to our risk using the provided fee estimator.
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
86 * [`block_connected`]: chain::Listen::block_connected
87 * [`block_disconnected`]: chain::Listen::block_disconnected
88 * [`params.best_block.block_hash`]: chain::BestBlock::block_hash
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);
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); };
120 * Gets the current configuration applied to all new channels.
122 public UserConfig get_current_default_configuration() {
123 long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
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); };
132 * Creates a new outbound channel to the given remote node and with the given value.
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.
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`.
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`].
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).
151 * If `temporary_channel_id` is specified, it will be used as the temporary channel ID of the
152 * channel. Otherwise, a random one will be generated for you.
154 * Returns the new Channel's temporary `channel_id`. This ID will appear as
155 * [`Event::FundingGenerationReady::temporary_channel_id`] and in
156 * [`ChannelDetails::channel_id`] until after
157 * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
158 * one derived from the funding transaction's TXID. If the counterparty rejects the channel
159 * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
161 * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
162 * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
163 * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
165 * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
167 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.Option_ThirtyTwoBytesZ temporary_channel_id, org.ldk.structs.UserConfig override_config) {
168 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()), temporary_channel_id.ptr, override_config == null ? 0 : override_config.ptr);
170 GC.KeepAlive(their_network_key);
171 GC.KeepAlive(channel_value_satoshis);
172 GC.KeepAlive(push_msat);
173 GC.KeepAlive(user_channel_id);
174 GC.KeepAlive(temporary_channel_id);
175 GC.KeepAlive(override_config);
176 if (ret >= 0 && ret <= 4096) { return null; }
177 Result_ThirtyTwoBytesAPIErrorZ ret_hu_conv = Result_ThirtyTwoBytesAPIErrorZ.constr_from_ptr(ret);
178 if (this != null) { this.ptrs_to.AddLast(temporary_channel_id); };
179 if (this != null) { this.ptrs_to.AddLast(override_config); };
184 * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
187 public ChannelDetails[] list_channels() {
188 long ret = bindings.ChannelManager_list_channels(this.ptr);
190 if (ret >= 0 && ret <= 4096) { return null; }
191 int ret_conv_16_len = InternalUtils.getArrayLength(ret);
192 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
193 for (int q = 0; q < ret_conv_16_len; q++) {
194 long ret_conv_16 = InternalUtils.getU64ArrayElem(ret, q);
195 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); }
196 if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
197 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
199 bindings.free_buffer(ret);
200 return ret_conv_16_arr;
204 * Gets the list of usable channels, in random order. Useful as an argument to
205 * [`Router::find_route`] to ensure non-announced channels are used.
207 * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
208 * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
211 public ChannelDetails[] list_usable_channels() {
212 long ret = bindings.ChannelManager_list_usable_channels(this.ptr);
214 if (ret >= 0 && ret <= 4096) { return null; }
215 int ret_conv_16_len = InternalUtils.getArrayLength(ret);
216 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
217 for (int q = 0; q < ret_conv_16_len; q++) {
218 long ret_conv_16 = InternalUtils.getU64ArrayElem(ret, q);
219 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); }
220 if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
221 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
223 bindings.free_buffer(ret);
224 return ret_conv_16_arr;
228 * Gets the list of channels we have with a given counterparty, in random order.
230 public ChannelDetails[] list_channels_with_counterparty(byte[] counterparty_node_id) {
231 long ret = bindings.ChannelManager_list_channels_with_counterparty(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)));
233 GC.KeepAlive(counterparty_node_id);
234 if (ret >= 0 && ret <= 4096) { return null; }
235 int ret_conv_16_len = InternalUtils.getArrayLength(ret);
236 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
237 for (int q = 0; q < ret_conv_16_len; q++) {
238 long ret_conv_16 = InternalUtils.getU64ArrayElem(ret, q);
239 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); }
240 if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
241 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
243 bindings.free_buffer(ret);
244 return ret_conv_16_arr;
248 * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
249 * successful path, or have unresolved HTLCs.
251 * This can be useful for payments that may have been prepared, but ultimately not sent, as a
252 * result of a crash. If such a payment exists, is not listed here, and an
253 * [`Event::PaymentSent`] has not been received, you may consider resending the payment.
255 * [`Event::PaymentSent`]: events::Event::PaymentSent
257 public RecentPaymentDetails[] list_recent_payments() {
258 long ret = bindings.ChannelManager_list_recent_payments(this.ptr);
260 if (ret >= 0 && ret <= 4096) { return null; }
261 int ret_conv_22_len = InternalUtils.getArrayLength(ret);
262 RecentPaymentDetails[] ret_conv_22_arr = new RecentPaymentDetails[ret_conv_22_len];
263 for (int w = 0; w < ret_conv_22_len; w++) {
264 long ret_conv_22 = InternalUtils.getU64ArrayElem(ret, w);
265 org.ldk.structs.RecentPaymentDetails ret_conv_22_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret_conv_22);
266 if (ret_conv_22_hu_conv != null) { ret_conv_22_hu_conv.ptrs_to.AddLast(this); };
267 ret_conv_22_arr[w] = ret_conv_22_hu_conv;
269 bindings.free_buffer(ret);
270 return ret_conv_22_arr;
274 * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
275 * will be accepted on the given channel, and after additional timeout/the closing of all
276 * pending HTLCs, the channel will be closed on chain.
278 * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and
279 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
281 * If our counterparty is the channel initiator, we will require a channel closing
282 * transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which
283 * would appear on a force-closure transaction, whichever is lower. We will allow our
284 * counterparty to pay as much fee as they'd like, however.
286 * May generate a [`SendShutdown`] message event on success, which should be relayed.
288 * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
289 * generate a shutdown scriptpubkey or destination script set by
290 * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
293 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
294 * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
295 * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
296 * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
298 public Result_NoneAPIErrorZ close_channel(byte[] channel_id, byte[] counterparty_node_id) {
299 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)));
301 GC.KeepAlive(channel_id);
302 GC.KeepAlive(counterparty_node_id);
303 if (ret >= 0 && ret <= 4096) { return null; }
304 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
309 * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
310 * will be accepted on the given channel, and after additional timeout/the closing of all
311 * pending HTLCs, the channel will be closed on chain.
313 * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
314 * the channel being closed or not:
315 * If we are the channel initiator, we will pay at least this feerate on the closing
316 * transaction. The upper-bound is set by
317 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
318 * fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
319 * If our counterparty is the channel initiator, we will refuse to accept a channel closure
320 * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
321 * will appear on a force-closure transaction, whichever is lower).
323 * The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction.
324 * Will fail if a shutdown script has already been set for this channel by
325 * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must
326 * also be compatible with our and the counterparty's features.
328 * May generate a [`SendShutdown`] message event on success, which should be relayed.
330 * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
331 * generate a shutdown scriptpubkey or destination script set by
332 * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
335 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
336 * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
337 * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
339 * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None
341 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) {
342 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);
344 GC.KeepAlive(channel_id);
345 GC.KeepAlive(counterparty_node_id);
346 GC.KeepAlive(target_feerate_sats_per_1000_weight);
347 GC.KeepAlive(shutdown_script);
348 if (ret >= 0 && ret <= 4096) { return null; }
349 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
350 if (this != null) { this.ptrs_to.AddLast(target_feerate_sats_per_1000_weight); };
351 if (this != null) { this.ptrs_to.AddLast(shutdown_script); };
356 * Force closes a channel, immediately broadcasting the latest local transaction(s) and
357 * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
358 * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
361 public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(byte[] channel_id, byte[] counterparty_node_id) {
362 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)));
364 GC.KeepAlive(channel_id);
365 GC.KeepAlive(counterparty_node_id);
366 if (ret >= 0 && ret <= 4096) { return null; }
367 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
372 * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
373 * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
374 * `counterparty_node_id` isn't the counterparty of the corresponding channel.
376 * You can always get the latest local transaction(s) to broadcast from
377 * [`ChannelMonitor::get_latest_holder_commitment_txn`].
379 public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(byte[] channel_id, byte[] counterparty_node_id) {
380 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)));
382 GC.KeepAlive(channel_id);
383 GC.KeepAlive(counterparty_node_id);
384 if (ret >= 0 && ret <= 4096) { return null; }
385 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
390 * Force close all channels, immediately broadcasting the latest local commitment transaction
391 * for each to the chain and rejecting new HTLCs on each.
393 public void force_close_all_channels_broadcasting_latest_txn() {
394 bindings.ChannelManager_force_close_all_channels_broadcasting_latest_txn(this.ptr);
399 * Force close all channels rejecting new HTLCs on each but without broadcasting the latest
400 * local transaction(s).
402 public void force_close_all_channels_without_broadcasting_txn() {
403 bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr);
408 * Sends a payment along a given route.
410 * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
411 * fields for more info.
413 * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
414 * [`PeerManager::process_events`]).
416 * # Avoiding Duplicate Payments
418 * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
419 * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
420 * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
421 * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
422 * second payment with the same [`PaymentId`].
424 * Thus, in order to ensure duplicate payments are not sent, you should implement your own
425 * tracking of payments, including state to indicate once a payment has completed. Because you
426 * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
427 * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
428 * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
430 * Additionally, in the scenario where we begin the process of sending a payment, but crash
431 * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
432 * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
433 * [`ChannelManager::list_recent_payments`] for more information.
435 * # Possible Error States on [`PaymentSendFailure`]
437 * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
438 * each entry matching the corresponding-index entry in the route paths, see
439 * [`PaymentSendFailure`] for more info.
441 * In general, a path may raise:
442 * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
443 * node public key) is specified.
444 * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
445 * closed, doesn't exist, or the peer is currently disconnected.
446 * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
449 * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
450 * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
451 * different route unless you intend to pay twice!
453 * [`RouteHop`]: crate::routing::router::RouteHop
454 * [`Event::PaymentSent`]: events::Event::PaymentSent
455 * [`Event::PaymentFailed`]: events::Event::PaymentFailed
456 * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
457 * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
458 * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
460 public Result_NonePaymentSendFailureZ send_payment_with_route(org.ldk.structs.Route route, byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) {
461 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)));
464 GC.KeepAlive(payment_hash);
465 GC.KeepAlive(recipient_onion);
466 GC.KeepAlive(payment_id);
467 if (ret >= 0 && ret <= 4096) { return null; }
468 Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
469 if (this != null) { this.ptrs_to.AddLast(route); };
470 if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
475 * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
476 * `route_params` and retry failed payment paths based on `retry_strategy`.
478 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) {
479 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);
481 GC.KeepAlive(payment_hash);
482 GC.KeepAlive(recipient_onion);
483 GC.KeepAlive(payment_id);
484 GC.KeepAlive(route_params);
485 GC.KeepAlive(retry_strategy);
486 if (ret >= 0 && ret <= 4096) { return null; }
487 Result_NoneRetryableSendFailureZ ret_hu_conv = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret);
488 if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
489 if (this != null) { this.ptrs_to.AddLast(route_params); };
490 if (this != null) { this.ptrs_to.AddLast(retry_strategy); };
495 * Signals that no further attempts for the given payment should occur. Useful if you have a
496 * pending outbound payment with retries remaining, but wish to stop retrying the payment before
497 * retries are exhausted.
501 * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
502 * as there are no remaining pending HTLCs for this payment.
504 * Note that calling this method does *not* prevent a payment from succeeding. You must still
505 * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
506 * determine the ultimate status of a payment.
508 * # Requested Invoices
510 * In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning
511 * the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`]
512 * and prevent any attempts at paying it once received. The other events may only be generated
513 * once the invoice has been received.
517 * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
518 * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
519 * [`Event::InvoiceRequestFailed`].
521 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
523 public void abandon_payment(byte[] payment_id) {
524 bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)));
526 GC.KeepAlive(payment_id);
530 * Send a spontaneous payment, which is a payment that does not require the recipient to have
531 * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
532 * the preimage, it must be a cryptographically secure random value that no intermediate node
533 * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
534 * never reach the recipient.
536 * See [`send_payment`] documentation for more details on the return value of this function
537 * and idempotency guarantees provided by the [`PaymentId`] key.
539 * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
540 * [`send_payment`] for more information about the risks of duplicate preimage usage.
542 * [`send_payment`]: Self::send_payment
544 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) {
545 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)));
548 GC.KeepAlive(payment_preimage);
549 GC.KeepAlive(recipient_onion);
550 GC.KeepAlive(payment_id);
551 if (ret >= 0 && ret <= 4096) { return null; }
552 Result_ThirtyTwoBytesPaymentSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesPaymentSendFailureZ.constr_from_ptr(ret);
553 if (this != null) { this.ptrs_to.AddLast(route); };
554 if (this != null) { this.ptrs_to.AddLast(payment_preimage); };
555 if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
560 * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
561 * based on `route_params` and retry failed payment paths based on `retry_strategy`.
563 * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
566 * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
568 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) {
569 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);
571 GC.KeepAlive(payment_preimage);
572 GC.KeepAlive(recipient_onion);
573 GC.KeepAlive(payment_id);
574 GC.KeepAlive(route_params);
575 GC.KeepAlive(retry_strategy);
576 if (ret >= 0 && ret <= 4096) { return null; }
577 Result_ThirtyTwoBytesRetryableSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesRetryableSendFailureZ.constr_from_ptr(ret);
578 if (this != null) { this.ptrs_to.AddLast(payment_preimage); };
579 if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
580 if (this != null) { this.ptrs_to.AddLast(route_params); };
581 if (this != null) { this.ptrs_to.AddLast(retry_strategy); };
586 * Send a payment that is probing the given route for liquidity. We calculate the
587 * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
588 * us to easily discern them from real payments.
590 public Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ send_probe(org.ldk.structs.Path path) {
591 long ret = bindings.ChannelManager_send_probe(this.ptr, path == null ? 0 : path.ptr);
594 if (ret >= 0 && ret <= 4096) { return null; }
595 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ.constr_from_ptr(ret);
596 if (this != null) { this.ptrs_to.AddLast(path); };
601 * Sends payment probes over all paths of a route that would be used to pay the given
602 * amount to the given `node_id`.
604 * See [`ChannelManager::send_preflight_probes`] for more information.
606 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) {
607 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);
609 GC.KeepAlive(node_id);
610 GC.KeepAlive(amount_msat);
611 GC.KeepAlive(final_cltv_expiry_delta);
612 GC.KeepAlive(liquidity_limit_multiplier);
613 if (ret >= 0 && ret <= 4096) { return null; }
614 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
615 if (this != null) { this.ptrs_to.AddLast(liquidity_limit_multiplier); };
620 * Sends payment probes over all paths of a route that would be used to pay a route found
621 * according to the given [`RouteParameters`].
623 * This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting
624 * the actual payment. Note this is only useful if there likely is sufficient time for the
625 * probe to settle before sending out the actual payment, e.g., when waiting for user
626 * confirmation in a wallet UI.
628 * Otherwise, there is a chance the probe could take up some liquidity needed to complete the
629 * actual payment. Users should therefore be cautious and might avoid sending probes if
630 * liquidity is scarce and/or they don't expect the probe to return before they send the
631 * payment. To mitigate this issue, channels with available liquidity less than the required
632 * amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight
633 * probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`.
635 public Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ send_preflight_probes(org.ldk.structs.RouteParameters route_params, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
636 long ret = bindings.ChannelManager_send_preflight_probes(this.ptr, route_params == null ? 0 : route_params.ptr, liquidity_limit_multiplier.ptr);
638 GC.KeepAlive(route_params);
639 GC.KeepAlive(liquidity_limit_multiplier);
640 if (ret >= 0 && ret <= 4096) { return null; }
641 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
642 if (this != null) { this.ptrs_to.AddLast(route_params); };
643 if (this != null) { this.ptrs_to.AddLast(liquidity_limit_multiplier); };
648 * Call this upon creation of a funding transaction for the given channel.
650 * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
651 * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
653 * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
654 * across the p2p network.
656 * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
657 * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
659 * May panic if the output found in the funding transaction is duplicative with some other
660 * channel (note that this should be trivially prevented by using unique funding transaction
663 * Do NOT broadcast the funding transaction yourself. When we have safely received our
664 * counterparty's signature the funding transaction will automatically be broadcast via the
665 * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
667 * Note that this includes RBF or similar transaction replacement strategies - lightning does
668 * not currently support replacing a funding transaction on an existing channel. Instead,
669 * create a new channel with a conflicting funding transaction.
671 * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
672 * the wallet software generating the funding transaction to apply anti-fee sniping as
673 * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
676 * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
677 * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
679 public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] counterparty_node_id, byte[] funding_transaction) {
680 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));
682 GC.KeepAlive(temporary_channel_id);
683 GC.KeepAlive(counterparty_node_id);
684 GC.KeepAlive(funding_transaction);
685 if (ret >= 0 && ret <= 4096) { return null; }
686 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
691 * Call this upon creation of a batch funding transaction for the given channels.
693 * Return values are identical to [`Self::funding_transaction_generated`], respective to
694 * each individual channel and transaction output.
696 * Do NOT broadcast the funding transaction yourself. This batch funding transaction
697 * will only be broadcast when we have safely received and persisted the counterparty's
698 * signature for each channel.
700 * If there is an error, all channels in the batch are to be considered closed.
702 public Result_NoneAPIErrorZ batch_funding_transaction_generated(TwoTuple_ThirtyTwoBytesPublicKeyZ[] temporary_channels, byte[] funding_transaction) {
703 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));
705 GC.KeepAlive(temporary_channels);
706 GC.KeepAlive(funding_transaction);
707 if (ret >= 0 && ret <= 4096) { return null; }
708 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
713 * Atomically applies partial updates to the [`ChannelConfig`] of the given channels.
715 * Once the updates are applied, each eligible channel (advertised with a known short channel
716 * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
717 * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
718 * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
720 * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
721 * `counterparty_node_id` is provided.
723 * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
724 * below [`MIN_CLTV_EXPIRY_DELTA`].
726 * If an error is returned, none of the updates should be considered applied.
728 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
729 * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
730 * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
731 * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
732 * [`ChannelUpdate`]: msgs::ChannelUpdate
733 * [`ChannelUnavailable`]: APIError::ChannelUnavailable
734 * [`APIMisuseError`]: APIError::APIMisuseError
736 public Result_NoneAPIErrorZ update_partial_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, org.ldk.structs.ChannelConfigUpdate config_update) {
737 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);
739 GC.KeepAlive(counterparty_node_id);
740 GC.KeepAlive(channel_ids);
741 GC.KeepAlive(config_update);
742 if (ret >= 0 && ret <= 4096) { return null; }
743 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
744 if (this != null) { this.ptrs_to.AddLast(config_update); };
749 * Atomically updates the [`ChannelConfig`] for the given channels.
751 * Once the updates are applied, each eligible channel (advertised with a known short channel
752 * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
753 * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
754 * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
756 * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
757 * `counterparty_node_id` is provided.
759 * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
760 * below [`MIN_CLTV_EXPIRY_DELTA`].
762 * If an error is returned, none of the updates should be considered applied.
764 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
765 * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
766 * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
767 * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
768 * [`ChannelUpdate`]: msgs::ChannelUpdate
769 * [`ChannelUnavailable`]: APIError::ChannelUnavailable
770 * [`APIMisuseError`]: APIError::APIMisuseError
772 public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, org.ldk.structs.ChannelConfig config) {
773 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);
775 GC.KeepAlive(counterparty_node_id);
776 GC.KeepAlive(channel_ids);
777 GC.KeepAlive(config);
778 if (ret >= 0 && ret <= 4096) { return null; }
779 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
780 if (this != null) { this.ptrs_to.AddLast(config); };
785 * Attempts to forward an intercepted HTLC over the provided channel id and with the provided
786 * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
788 * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
789 * channel to a receiving node if the node lacks sufficient inbound liquidity.
791 * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
792 * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
793 * receiver's invoice route hints. These route hints will signal to LDK to generate an
794 * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
795 * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
797 * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
798 * you from forwarding more than you received. See
799 * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount
802 * Errors if the event was not handled in time, in which case the HTLC was automatically failed
805 * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
806 * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
807 * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat
809 public Result_NoneAPIErrorZ forward_intercepted_htlc(byte[] intercept_id, byte[] next_hop_channel_id, byte[] next_node_id, long amt_to_forward_msat) {
810 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);
812 GC.KeepAlive(intercept_id);
813 GC.KeepAlive(next_hop_channel_id);
814 GC.KeepAlive(next_node_id);
815 GC.KeepAlive(amt_to_forward_msat);
816 if (ret >= 0 && ret <= 4096) { return null; }
817 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
822 * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
823 * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
825 * Errors if the event was not handled in time, in which case the HTLC was automatically failed
828 * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
830 public Result_NoneAPIErrorZ fail_intercepted_htlc(byte[] intercept_id) {
831 long ret = bindings.ChannelManager_fail_intercepted_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(intercept_id, 32)));
833 GC.KeepAlive(intercept_id);
834 if (ret >= 0 && ret <= 4096) { return null; }
835 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
840 * Processes HTLCs which are pending waiting on random forward delay.
842 * Should only really ever be called in response to a PendingHTLCsForwardable event.
843 * Will likely generate further events.
845 public void process_pending_htlc_forwards() {
846 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
851 * Performs actions which should happen on startup and roughly once per minute thereafter.
853 * This currently includes:
854 * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
855 * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more
856 * than a minute, informing the network that they should no longer attempt to route over
858 * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs
859 * with the current [`ChannelConfig`].
860 * Removing peers which have disconnected but and no longer have any channels.
861 * Force-closing and removing channels which have not completed establishment in a timely manner.
862 * Forgetting about stale outbound payments, either those that have already been fulfilled
863 * or those awaiting an invoice that hasn't been delivered in the necessary amount of time.
864 * The latter is determined using the system clock in `std` and the highest seen block time
865 * minus two hours in `no-std`.
867 * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate
870 * [`ChannelUpdate`]: msgs::ChannelUpdate
871 * [`ChannelConfig`]: crate::util::config::ChannelConfig
873 public void timer_tick_occurred() {
874 bindings.ChannelManager_timer_tick_occurred(this.ptr);
879 * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
880 * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
881 * along the path (including in our own channel on which we received it).
883 * Note that in some cases around unclean shutdown, it is possible the payment may have
884 * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
885 * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
886 * may have already been failed automatically by LDK if it was nearing its expiration time.
888 * While LDK will never claim a payment automatically on your behalf (i.e. without you calling
889 * [`ChannelManager::claim_funds`]), you should still monitor for
890 * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
891 * startup during which time claims that were in-progress at shutdown may be replayed.
893 public void fail_htlc_backwards(byte[] payment_hash) {
894 bindings.ChannelManager_fail_htlc_backwards(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
896 GC.KeepAlive(payment_hash);
900 * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
901 * reason for the failure.
903 * See [`FailureCode`] for valid failure codes.
905 public void fail_htlc_backwards_with_reason(byte[] payment_hash, org.ldk.structs.FailureCode failure_code) {
906 bindings.ChannelManager_fail_htlc_backwards_with_reason(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), failure_code.ptr);
908 GC.KeepAlive(payment_hash);
909 GC.KeepAlive(failure_code);
910 if (this != null) { this.ptrs_to.AddLast(failure_code); };
914 * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
915 * [`MessageSendEvent`]s needed to claim the payment.
917 * This method is guaranteed to ensure the payment has been claimed but only if the current
918 * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race
919 * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment
920 * successful. It will generally be available in the next [`process_pending_events`] call.
922 * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
923 * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
924 * event matches your expectation. If you fail to do so and call this method, you may provide
925 * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
927 * This function will fail the payment if it has custom TLVs with even type numbers, as we
928 * will assume they are unknown. If you intend to accept even custom TLVs, you should use
929 * [`claim_funds_with_known_custom_tlvs`].
931 * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
932 * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline
933 * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed
934 * [`process_pending_events`]: EventsProvider::process_pending_events
935 * [`create_inbound_payment`]: Self::create_inbound_payment
936 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
937 * [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs
939 public void claim_funds(byte[] payment_preimage) {
940 bindings.ChannelManager_claim_funds(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32)));
942 GC.KeepAlive(payment_preimage);
946 * This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with
951 * You MUST check you've understood all even TLVs before using this to
952 * claim, otherwise you may unintentionally agree to some protocol you do not understand.
954 * [`claim_funds`]: Self::claim_funds
956 public void claim_funds_with_known_custom_tlvs(byte[] payment_preimage) {
957 bindings.ChannelManager_claim_funds_with_known_custom_tlvs(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32)));
959 GC.KeepAlive(payment_preimage);
963 * Gets the node_id held by this ChannelManager
965 public byte[] get_our_node_id() {
966 long ret = bindings.ChannelManager_get_our_node_id(this.ptr);
968 if (ret >= 0 && ret <= 4096) { return null; }
969 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
974 * Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
976 * The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
977 * and the `counterparty_node_id` parameter is the id of the peer which has requested to open
980 * The `user_channel_id` parameter will be provided back in
981 * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
982 * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
984 * Note that this method will return an error and reject the channel, if it requires support
985 * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
986 * used to accept such channels.
988 * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
989 * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
991 public Result_NoneAPIErrorZ accept_inbound_channel(byte[] temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
992 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()));
994 GC.KeepAlive(temporary_channel_id);
995 GC.KeepAlive(counterparty_node_id);
996 GC.KeepAlive(user_channel_id);
997 if (ret >= 0 && ret <= 4096) { return null; }
998 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1003 * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
1004 * it as confirmed immediately.
1006 * The `user_channel_id` parameter will be provided back in
1007 * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
1008 * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
1010 * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
1011 * and (if the counterparty agrees), enables forwarding of payments immediately.
1013 * This fully trusts that the counterparty has honestly and correctly constructed the funding
1014 * transaction and blindly assumes that it will eventually confirm.
1016 * If it does not confirm before we decide to close the channel, or if the funding transaction
1017 * does not pay to the correct script the correct amount, *you will lose funds*.
1019 * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
1020 * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
1022 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) {
1023 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()));
1025 GC.KeepAlive(temporary_channel_id);
1026 GC.KeepAlive(counterparty_node_id);
1027 GC.KeepAlive(user_channel_id);
1028 if (ret >= 0 && ret <= 4096) { return null; }
1029 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1034 * Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and
1035 * enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual
1036 * [`Bolt12Invoice`] once it is received.
1038 * Uses [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is recognized by
1039 * the [`ChannelManager`] when handling a [`Bolt12Invoice`] message in response to the request.
1040 * The optional parameters are used in the builder, if `Some`:
1041 * - `quantity` for [`InvoiceRequest::quantity`] which must be set if
1042 * [`Offer::expects_quantity`] is `true`.
1043 * - `amount_msats` if overpaying what is required for the given `quantity` is desired, and
1044 * - `payer_note` for [`InvoiceRequest::payer_note`].
1046 * If `max_total_routing_fee_msat` is not specified, The default from
1047 * [`RouteParameters::from_payment_params_and_value`] is applied.
1051 * The provided `payment_id` is used to ensure that only one invoice is paid for the request
1052 * when received. See [Avoiding Duplicate Payments] for other requirements once the payment has
1055 * To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the
1056 * invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the
1057 * payment will fail with an [`Event::InvoiceRequestFailed`].
1061 * Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`]
1062 * as the introduction node and a derived payer id for payer privacy. As such, currently, the
1063 * node must be announced. Otherwise, there is no way to find a path to the introduction node
1064 * in order to send the [`Bolt12Invoice`].
1068 * Requires a direct connection to an introduction node in [`Offer::paths`] or to
1069 * [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding
1070 * [`Bolt12Invoice::payment_paths`].
1075 * - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
1076 * - the provided parameters are invalid for the offer,
1077 * - the parameterized [`Router`] is unable to create a blinded reply path for the invoice
1080 * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
1081 * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
1082 * [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note
1083 * [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder
1084 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1085 * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
1086 * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
1088 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) {
1089 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);
1091 GC.KeepAlive(offer);
1092 GC.KeepAlive(quantity);
1093 GC.KeepAlive(amount_msats);
1094 GC.KeepAlive(payer_note);
1095 GC.KeepAlive(payment_id);
1096 GC.KeepAlive(retry_strategy);
1097 GC.KeepAlive(max_total_routing_fee_msat);
1098 if (ret >= 0 && ret <= 4096) { return null; }
1099 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
1100 if (this != null) { this.ptrs_to.AddLast(offer); };
1101 if (this != null) { this.ptrs_to.AddLast(quantity); };
1102 if (this != null) { this.ptrs_to.AddLast(amount_msats); };
1103 if (this != null) { this.ptrs_to.AddLast(payer_note); };
1104 if (this != null) { this.ptrs_to.AddLast(retry_strategy); };
1105 if (this != null) { this.ptrs_to.AddLast(max_total_routing_fee_msat); };
1110 * Creates a [`Bolt12Invoice`] for a [`Refund`] and enqueues it to be sent via an onion
1113 * The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a
1114 * [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding
1115 * [`PaymentPreimage`].
1119 * Requires a direct connection to an introduction node in [`Refund::paths`] or to
1120 * [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
1121 * node meeting the aforementioned criteria, but there's no guarantee that they will be
1122 * received and no retries will be made.
1126 * Errors if the parameterized [`Router`] is unable to create a blinded payment path or reply
1127 * path for the invoice.
1129 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1131 public Result_NoneBolt12SemanticErrorZ request_refund_payment(org.ldk.structs.Refund refund) {
1132 long ret = bindings.ChannelManager_request_refund_payment(this.ptr, refund == null ? 0 : refund.ptr);
1134 GC.KeepAlive(refund);
1135 if (ret >= 0 && ret <= 4096) { return null; }
1136 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
1137 if (this != null) { this.ptrs_to.AddLast(refund); };
1142 * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
1145 * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
1146 * [`PaymentHash`] and [`PaymentPreimage`] for you.
1148 * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which
1149 * will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with
1150 * its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be
1151 * passed directly to [`claim_funds`].
1153 * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
1155 * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
1156 * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
1160 * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
1161 * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
1163 * Errors if `min_value_msat` is greater than total bitcoin supply.
1165 * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
1166 * on versions of LDK prior to 0.0.114.
1168 * [`claim_funds`]: Self::claim_funds
1169 * [`PaymentClaimable`]: events::Event::PaymentClaimable
1170 * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose
1171 * [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment
1172 * [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage
1173 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
1175 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) {
1176 long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1178 GC.KeepAlive(min_value_msat);
1179 GC.KeepAlive(invoice_expiry_delta_secs);
1180 GC.KeepAlive(min_final_cltv_expiry_delta);
1181 if (ret >= 0 && ret <= 4096) { return null; }
1182 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
1183 if (this != null) { this.ptrs_to.AddLast(min_value_msat); };
1184 if (this != null) { this.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
1189 * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
1190 * stored external to LDK.
1192 * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
1193 * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
1194 * the `min_value_msat` provided here, if one is provided.
1196 * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
1197 * note that LDK will not stop you from registering duplicate payment hashes for inbound
1200 * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
1201 * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
1202 * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
1203 * sender \"proof-of-payment\" unless they have paid the required amount.
1205 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1206 * in excess of the current time. This should roughly match the expiry time set in the invoice.
1207 * After this many seconds, we will remove the inbound payment, resulting in any attempts to
1208 * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
1209 * invoices when no timeout is set.
1211 * Note that we use block header time to time-out pending inbound payments (with some margin
1212 * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
1213 * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
1214 * If you need exact expiry semantics, you should enforce them upon receipt of
1215 * [`PaymentClaimable`].
1217 * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta`
1218 * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1220 * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
1221 * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
1225 * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
1226 * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
1228 * Errors if `min_value_msat` is greater than total bitcoin supply.
1230 * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
1231 * on versions of LDK prior to 0.0.114.
1233 * [`create_inbound_payment`]: Self::create_inbound_payment
1234 * [`PaymentClaimable`]: events::Event::PaymentClaimable
1236 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) {
1237 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);
1239 GC.KeepAlive(payment_hash);
1240 GC.KeepAlive(min_value_msat);
1241 GC.KeepAlive(invoice_expiry_delta_secs);
1242 GC.KeepAlive(min_final_cltv_expiry);
1243 if (ret >= 0 && ret <= 4096) { return null; }
1244 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
1245 if (this != null) { this.ptrs_to.AddLast(min_value_msat); };
1246 if (this != null) { this.ptrs_to.AddLast(min_final_cltv_expiry); };
1251 * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
1252 * previously returned from [`create_inbound_payment`].
1254 * [`create_inbound_payment`]: Self::create_inbound_payment
1256 public Result_ThirtyTwoBytesAPIErrorZ get_payment_preimage(byte[] payment_hash, byte[] payment_secret) {
1257 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)));
1259 GC.KeepAlive(payment_hash);
1260 GC.KeepAlive(payment_secret);
1261 if (ret >= 0 && ret <= 4096) { return null; }
1262 Result_ThirtyTwoBytesAPIErrorZ ret_hu_conv = Result_ThirtyTwoBytesAPIErrorZ.constr_from_ptr(ret);
1267 * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
1268 * are used when constructing the phantom invoice's route hints.
1270 * [phantom node payments]: crate::sign::PhantomKeysManager
1272 public long get_phantom_scid() {
1273 long ret = bindings.ChannelManager_get_phantom_scid(this.ptr);
1279 * Gets route hints for use in receiving [phantom node payments].
1281 * [phantom node payments]: crate::sign::PhantomKeysManager
1283 public PhantomRouteHints get_phantom_route_hints() {
1284 long ret = bindings.ChannelManager_get_phantom_route_hints(this.ptr);
1286 if (ret >= 0 && ret <= 4096) { return null; }
1287 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
1288 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1293 * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
1294 * used when constructing the route hints for HTLCs intended to be intercepted. See
1295 * [`ChannelManager::forward_intercepted_htlc`].
1297 * Note that this method is not guaranteed to return unique values, you may need to call it a few
1298 * times to get a unique scid.
1300 public long get_intercept_scid() {
1301 long ret = bindings.ChannelManager_get_intercept_scid(this.ptr);
1307 * Gets inflight HTLC information by processing pending outbound payments that are in
1308 * our channels. May be used during pathfinding to account for in-use channel liquidity.
1310 public InFlightHtlcs compute_inflight_htlcs() {
1311 long ret = bindings.ChannelManager_compute_inflight_htlcs(this.ptr);
1313 if (ret >= 0 && ret <= 4096) { return null; }
1314 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
1315 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1320 * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
1321 * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
1323 public MessageSendEventsProvider as_MessageSendEventsProvider() {
1324 long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
1326 if (ret >= 0 && ret <= 4096) { return null; }
1327 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
1328 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1333 * Constructs a new EventsProvider which calls the relevant methods on this_arg.
1334 * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
1336 public EventsProvider as_EventsProvider() {
1337 long ret = bindings.ChannelManager_as_EventsProvider(this.ptr);
1339 if (ret >= 0 && ret <= 4096) { return null; }
1340 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
1341 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1346 * Constructs a new Listen which calls the relevant methods on this_arg.
1347 * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
1349 public Listen as_Listen() {
1350 long ret = bindings.ChannelManager_as_Listen(this.ptr);
1352 if (ret >= 0 && ret <= 4096) { return null; }
1353 Listen ret_hu_conv = new Listen(null, ret);
1354 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1359 * Constructs a new Confirm which calls the relevant methods on this_arg.
1360 * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
1362 public Confirm as_Confirm() {
1363 long ret = bindings.ChannelManager_as_Confirm(this.ptr);
1365 if (ret >= 0 && ret <= 4096) { return null; }
1366 Confirm ret_hu_conv = new Confirm(null, ret);
1367 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1372 * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or
1373 * may have events that need processing.
1375 * In order to check if this [`ChannelManager`] needs persisting, call
1376 * [`Self::get_and_clear_needs_persistence`].
1378 * Note that callbacks registered on the [`Future`] MUST NOT call back into this
1379 * [`ChannelManager`] and should instead register actions to be taken later.
1381 public Future get_event_or_persistence_needed_future() {
1382 long ret = bindings.ChannelManager_get_event_or_persistence_needed_future(this.ptr);
1384 if (ret >= 0 && ret <= 4096) { return null; }
1385 org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
1386 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1391 * Returns true if this [`ChannelManager`] needs to be persisted.
1393 public bool get_and_clear_needs_persistence() {
1394 bool ret = bindings.ChannelManager_get_and_clear_needs_persistence(this.ptr);
1400 * Gets the latest best block which was connected either via the [`chain::Listen`] or
1401 * [`chain::Confirm`] interfaces.
1403 public BestBlock current_best_block() {
1404 long ret = bindings.ChannelManager_current_best_block(this.ptr);
1406 if (ret >= 0 && ret <= 4096) { return null; }
1407 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
1408 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1413 * Fetches the set of [`NodeFeatures`] flags that are provided by or required by
1414 * [`ChannelManager`].
1416 public NodeFeatures node_features() {
1417 long ret = bindings.ChannelManager_node_features(this.ptr);
1419 if (ret >= 0 && ret <= 4096) { return null; }
1420 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
1421 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1426 * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by
1427 * [`ChannelManager`].
1429 public ChannelFeatures channel_features() {
1430 long ret = bindings.ChannelManager_channel_features(this.ptr);
1432 if (ret >= 0 && ret <= 4096) { return null; }
1433 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
1434 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1439 * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by
1440 * [`ChannelManager`].
1442 public ChannelTypeFeatures channel_type_features() {
1443 long ret = bindings.ChannelManager_channel_type_features(this.ptr);
1445 if (ret >= 0 && ret <= 4096) { return null; }
1446 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
1447 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1452 * Fetches the set of [`InitFeatures`] flags that are provided by or required by
1453 * [`ChannelManager`].
1455 public InitFeatures init_features() {
1456 long ret = bindings.ChannelManager_init_features(this.ptr);
1458 if (ret >= 0 && ret <= 4096) { return null; }
1459 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
1460 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1465 * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
1466 * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
1468 public ChannelMessageHandler as_ChannelMessageHandler() {
1469 long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
1471 if (ret >= 0 && ret <= 4096) { return null; }
1472 ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
1473 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1478 * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg.
1479 * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is
1481 public OffersMessageHandler as_OffersMessageHandler() {
1482 long ret = bindings.ChannelManager_as_OffersMessageHandler(this.ptr);
1484 if (ret >= 0 && ret <= 4096) { return null; }
1485 OffersMessageHandler ret_hu_conv = new OffersMessageHandler(null, ret);
1486 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1491 * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
1493 public byte[] write() {
1494 long ret = bindings.ChannelManager_write(this.ptr);
1496 if (ret >= 0 && ret <= 4096) { return null; }
1497 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);