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 (ie
19 * called funding_transaction_generated for outbound channels).
21 * Note that you can be a bit lazier about writing out ChannelManager than you can be with
22 * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
23 * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
24 * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
25 * the serialization process). If the deserialized version is out-of-date compared to the
26 * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
27 * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
29 * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
30 * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
31 * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
32 * block_connected() to step towards your best block) upon deserialization before using the
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 * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
42 * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
43 * essentially you should default to using a SimpleRefChannelManager, and use a
44 * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
45 * you're using lightning-net-tokio.
47 public class ChannelManager : CommonBase {
48 internal ChannelManager(object _dummy, long ptr) : base(ptr) { }
50 if (ptr != 0) { bindings.ChannelManager_free(ptr); }
54 * Constructs a new ChannelManager to hold several channels and route between them.
56 * This is the main \"logic hub\" for all channel-related actions, and implements
57 * ChannelMessageHandler.
59 * Non-proportional fees are fixed according to our risk using the provided fee estimator.
61 * Users need to notify the new ChannelManager when a new block is connected or
62 * disconnected using its `block_connected` and `block_disconnected` methods, starting
63 * from after `params.latest_hash`.
65 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.Logger logger, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.UserConfig config, org.ldk.structs.ChainParameters _params) {
66 long ret = bindings.ChannelManager_new(fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr, _params == null ? 0 : _params.ptr);
67 GC.KeepAlive(fee_est);
68 GC.KeepAlive(chain_monitor);
69 GC.KeepAlive(tx_broadcaster);
71 GC.KeepAlive(keys_manager);
73 GC.KeepAlive(_params);
74 if (ret >= 0 && ret <= 4096) { return null; }
75 org.ldk.structs.ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManager(null, ret); }
76 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
77 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_est); };
78 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(chain_monitor); };
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(tx_broadcaster); };
80 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
81 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
82 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(config); };
83 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(_params); };
88 * Gets the current configuration applied to all new channels.
90 public UserConfig get_current_default_configuration() {
91 long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
93 if (ret >= 0 && ret <= 4096) { return null; }
94 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
95 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
100 * Creates a new outbound channel to the given remote node and with the given value.
102 * `user_channel_id` will be provided back as in
103 * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
104 * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
105 * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
106 * is simply copied to events and otherwise ignored.
108 * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
109 * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
111 * Note that we do not check if you are currently connected to the given peer. If no
112 * connection is available, the outbound `open_channel` message may fail to send, resulting in
113 * the channel eventually being silently forgotten (dropped on reload).
115 * Returns the new Channel's temporary `channel_id`. This ID will appear as
116 * [`Event::FundingGenerationReady::temporary_channel_id`] and in
117 * [`ChannelDetails::channel_id`] until after
118 * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
119 * one derived from the funding transaction's TXID. If the counterparty rejects the channel
120 * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
122 * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
123 * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
124 * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
126 * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
128 public Result__u832APIErrorZ 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) {
129 long ret = bindings.ChannelManager_create_channel(this.ptr, InternalUtils.check_arr_len(their_network_key, 33), channel_value_satoshis, push_msat, user_channel_id.getLEBytes(), override_config == null ? 0 : override_config.ptr);
131 GC.KeepAlive(their_network_key);
132 GC.KeepAlive(channel_value_satoshis);
133 GC.KeepAlive(push_msat);
134 GC.KeepAlive(user_channel_id);
135 GC.KeepAlive(override_config);
136 if (ret >= 0 && ret <= 4096) { return null; }
137 Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
138 if (this != null) { this.ptrs_to.AddLast(override_config); };
143 * Gets the list of open channels, in random order. See ChannelDetail field documentation for
146 public ChannelDetails[] list_channels() {
147 long[] ret = bindings.ChannelManager_list_channels(this.ptr);
149 int ret_conv_16_len = ret.Length;
150 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
151 for (int q = 0; q < ret_conv_16_len; q++) {
152 long ret_conv_16 = ret[q];
153 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); }
154 if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
155 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
157 return ret_conv_16_arr;
161 * Gets the list of usable channels, in random order. Useful as an argument to [`find_route`]
162 * to ensure non-announced channels are used.
164 * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
165 * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
168 * [`find_route`]: crate::routing::router::find_route
170 public ChannelDetails[] list_usable_channels() {
171 long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr);
173 int ret_conv_16_len = ret.Length;
174 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
175 for (int q = 0; q < ret_conv_16_len; q++) {
176 long ret_conv_16 = ret[q];
177 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); }
178 if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
179 ret_conv_16_arr[q] = ret_conv_16_hu_conv;
181 return ret_conv_16_arr;
185 * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
186 * will be accepted on the given channel, and after additional timeout/the closing of all
187 * pending HTLCs, the channel will be closed on chain.
189 * If we are the channel initiator, we will pay between our [`Background`] and
190 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
192 * If our counterparty is the channel initiator, we will require a channel closing
193 * transaction feerate of at least our [`Background`] feerate or the feerate which
194 * would appear on a force-closure transaction, whichever is lower. We will allow our
195 * counterparty to pay as much fee as they'd like, however.
197 * May generate a SendShutdown message event on success, which should be relayed.
199 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
200 * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
201 * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
203 public Result_NoneAPIErrorZ close_channel(byte[] channel_id, byte[] counterparty_node_id) {
204 long ret = bindings.ChannelManager_close_channel(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
206 GC.KeepAlive(channel_id);
207 GC.KeepAlive(counterparty_node_id);
208 if (ret >= 0 && ret <= 4096) { return null; }
209 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
214 * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
215 * will be accepted on the given channel, and after additional timeout/the closing of all
216 * pending HTLCs, the channel will be closed on chain.
218 * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
219 * the channel being closed or not:
220 * If we are the channel initiator, we will pay at least this feerate on the closing
221 * transaction. The upper-bound is set by
222 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
223 * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
224 * If our counterparty is the channel initiator, we will refuse to accept a channel closure
225 * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
226 * will appear on a force-closure transaction, whichever is lower).
228 * May generate a SendShutdown message event on success, which should be relayed.
230 * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
231 * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
232 * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
234 public Result_NoneAPIErrorZ close_channel_with_target_feerate(byte[] channel_id, byte[] counterparty_node_id, int target_feerate_sats_per_1000_weight) {
235 long ret = bindings.ChannelManager_close_channel_with_target_feerate(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), target_feerate_sats_per_1000_weight);
237 GC.KeepAlive(channel_id);
238 GC.KeepAlive(counterparty_node_id);
239 GC.KeepAlive(target_feerate_sats_per_1000_weight);
240 if (ret >= 0 && ret <= 4096) { return null; }
241 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
246 * Force closes a channel, immediately broadcasting the latest local transaction(s) and
247 * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
248 * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
251 public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(byte[] channel_id, byte[] counterparty_node_id) {
252 long ret = bindings.ChannelManager_force_close_broadcasting_latest_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
254 GC.KeepAlive(channel_id);
255 GC.KeepAlive(counterparty_node_id);
256 if (ret >= 0 && ret <= 4096) { return null; }
257 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
262 * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
263 * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
264 * `counterparty_node_id` isn't the counterparty of the corresponding channel.
266 * You can always get the latest local transaction(s) to broadcast from
267 * [`ChannelMonitor::get_latest_holder_commitment_txn`].
269 public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(byte[] channel_id, byte[] counterparty_node_id) {
270 long ret = bindings.ChannelManager_force_close_without_broadcasting_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
272 GC.KeepAlive(channel_id);
273 GC.KeepAlive(counterparty_node_id);
274 if (ret >= 0 && ret <= 4096) { return null; }
275 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
280 * Force close all channels, immediately broadcasting the latest local commitment transaction
281 * for each to the chain and rejecting new HTLCs on each.
283 public void force_close_all_channels_broadcasting_latest_txn() {
284 bindings.ChannelManager_force_close_all_channels_broadcasting_latest_txn(this.ptr);
289 * Force close all channels rejecting new HTLCs on each but without broadcasting the latest
290 * local transaction(s).
292 public void force_close_all_channels_without_broadcasting_txn() {
293 bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr);
298 * Sends a payment along a given route.
300 * Value parameters are provided via the last hop in route, see documentation for RouteHop
301 * fields for more info.
303 * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
304 * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
305 * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
306 * [`Event::PaymentSent`]) LDK will not stop you from sending a second payment with the same
309 * Thus, in order to ensure duplicate payments are not sent, you should implement your own
310 * tracking of payments, including state to indicate once a payment has completed. Because you
311 * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
312 * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
313 * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
315 * May generate SendHTLCs message(s) event on success, which should be relayed (e.g. via
316 * [`PeerManager::process_events`]).
318 * Each path may have a different return value, and PaymentSendValue may return a Vec with
319 * each entry matching the corresponding-index entry in the route paths, see
320 * PaymentSendFailure for more info.
322 * In general, a path may raise:
323 * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
324 * node public key) is specified.
325 * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates
326 * (including due to previous monitor update failure or new permanent monitor update
328 * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
331 * Note that depending on the type of the PaymentSendFailure the HTLC may have been
332 * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
333 * different route unless you intend to pay twice!
335 * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
336 * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
337 * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
338 * must not contain multiple paths as multi-path payments require a recipient-provided
341 * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
342 * bit set (either as required or as available). If multiple paths are present in the Route,
343 * we assume the invoice had the basic_mpp feature set.
345 * [`Event::PaymentSent`]: events::Event::PaymentSent
346 * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
348 * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
350 public Result_NonePaymentSendFailureZ send_payment(org.ldk.structs.Route route, byte[] payment_hash, byte[] payment_secret, byte[] payment_id) {
351 long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32), InternalUtils.check_arr_len(payment_id, 32));
354 GC.KeepAlive(payment_hash);
355 GC.KeepAlive(payment_secret);
356 GC.KeepAlive(payment_id);
357 if (ret >= 0 && ret <= 4096) { return null; }
358 Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
359 if (this != null) { this.ptrs_to.AddLast(route); };
364 * Retries a payment along the given [`Route`].
366 * Errors returned are a superset of those returned from [`send_payment`], so see
367 * [`send_payment`] documentation for more details on errors. This method will also error if the
368 * retry amount puts the payment more than 10% over the payment's total amount, if the payment
369 * for the given `payment_id` cannot be found (likely due to timeout or success), or if
370 * further retries have been disabled with [`abandon_payment`].
372 * [`send_payment`]: [`ChannelManager::send_payment`]
373 * [`abandon_payment`]: [`ChannelManager::abandon_payment`]
375 public Result_NonePaymentSendFailureZ retry_payment(org.ldk.structs.Route route, byte[] payment_id) {
376 long ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_id, 32));
379 GC.KeepAlive(payment_id);
380 if (ret >= 0 && ret <= 4096) { return null; }
381 Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
382 if (this != null) { this.ptrs_to.AddLast(route); };
387 * Signals that no further retries for the given payment will occur.
389 * After this method returns, no future calls to [`retry_payment`] for the given `payment_id`
390 * are allowed. If no [`Event::PaymentFailed`] event had been generated before, one will be
391 * generated as soon as there are no remaining pending HTLCs for this payment.
393 * Note that calling this method does *not* prevent a payment from succeeding. You must still
394 * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
395 * determine the ultimate status of a payment.
397 * If an [`Event::PaymentFailed`] event is generated and we restart without this
398 * [`ChannelManager`] having been persisted, the payment may still be in the pending state
399 * upon restart. This allows further calls to [`retry_payment`] (and requiring a second call
400 * to [`abandon_payment`] to mark the payment as failed again). Otherwise, future calls to
401 * [`retry_payment`] will fail with [`PaymentSendFailure::ParameterError`].
403 * [`abandon_payment`]: Self::abandon_payment
404 * [`retry_payment`]: Self::retry_payment
405 * [`Event::PaymentFailed`]: events::Event::PaymentFailed
406 * [`Event::PaymentSent`]: events::Event::PaymentSent
408 public void abandon_payment(byte[] payment_id) {
409 bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.check_arr_len(payment_id, 32));
411 GC.KeepAlive(payment_id);
415 * Send a spontaneous payment, which is a payment that does not require the recipient to have
416 * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
417 * the preimage, it must be a cryptographically secure random value that no intermediate node
418 * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
419 * never reach the recipient.
421 * See [`send_payment`] documentation for more details on the return value of this function
422 * and idempotency guarantees provided by the [`PaymentId`] key.
424 * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
425 * [`send_payment`] for more information about the risks of duplicate preimage usage.
427 * Note that `route` must have exactly one path.
429 * [`send_payment`]: Self::send_payment
431 * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
433 public Result_PaymentHashPaymentSendFailureZ send_spontaneous_payment(org.ldk.structs.Route route, byte[] payment_preimage, byte[] payment_id) {
434 long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_id, 32));
437 GC.KeepAlive(payment_preimage);
438 GC.KeepAlive(payment_id);
439 if (ret >= 0 && ret <= 4096) { return null; }
440 Result_PaymentHashPaymentSendFailureZ ret_hu_conv = Result_PaymentHashPaymentSendFailureZ.constr_from_ptr(ret);
441 if (this != null) { this.ptrs_to.AddLast(route); };
446 * Send a payment that is probing the given route for liquidity. We calculate the
447 * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
448 * us to easily discern them from real payments.
450 public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ send_probe(RouteHop[] hops) {
451 long ret = bindings.ChannelManager_send_probe(this.ptr, hops != null ? InternalUtils.mapArray(hops, hops_conv_10 => hops_conv_10 == null ? 0 : hops_conv_10.ptr) : null);
454 if (ret >= 0 && ret <= 4096) { return null; }
455 Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
456 foreach (RouteHop hops_conv_10 in hops) { if (this != null) { this.ptrs_to.AddLast(hops_conv_10); }; };
461 * Call this upon creation of a funding transaction for the given channel.
463 * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
464 * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
466 * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
467 * across the p2p network.
469 * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
470 * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
472 * May panic if the output found in the funding transaction is duplicative with some other
473 * channel (note that this should be trivially prevented by using unique funding transaction
476 * Do NOT broadcast the funding transaction yourself. When we have safely received our
477 * counterparty's signature the funding transaction will automatically be broadcast via the
478 * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
480 * Note that this includes RBF or similar transaction replacement strategies - lightning does
481 * not currently support replacing a funding transaction on an existing channel. Instead,
482 * create a new channel with a conflicting funding transaction.
484 * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
485 * the wallet software generating the funding transaction to apply anti-fee sniping as
486 * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
489 * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
490 * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
492 public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] counterparty_node_id, byte[] funding_transaction) {
493 long ret = bindings.ChannelManager_funding_transaction_generated(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), funding_transaction);
495 GC.KeepAlive(temporary_channel_id);
496 GC.KeepAlive(counterparty_node_id);
497 GC.KeepAlive(funding_transaction);
498 if (ret >= 0 && ret <= 4096) { return null; }
499 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
504 * Atomically updates the [`ChannelConfig`] for the given channels.
506 * Once the updates are applied, each eligible channel (advertised with a known short channel
507 * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
508 * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
509 * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
511 * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
512 * `counterparty_node_id` is provided.
514 * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
515 * below [`MIN_CLTV_EXPIRY_DELTA`].
517 * If an error is returned, none of the updates should be considered applied.
519 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
520 * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
521 * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
522 * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
523 * [`ChannelUpdate`]: msgs::ChannelUpdate
524 * [`ChannelUnavailable`]: APIError::ChannelUnavailable
525 * [`APIMisuseError`]: APIError::APIMisuseError
527 public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, org.ldk.structs.ChannelConfig config) {
528 long ret = bindings.ChannelManager_update_channel_config(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_ids != null ? InternalUtils.mapArray(channel_ids, channel_ids_conv_8 => InternalUtils.check_arr_len(channel_ids_conv_8, 32)) : null, config == null ? 0 : config.ptr);
530 GC.KeepAlive(counterparty_node_id);
531 GC.KeepAlive(channel_ids);
532 GC.KeepAlive(config);
533 if (ret >= 0 && ret <= 4096) { return null; }
534 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
535 if (this != null) { this.ptrs_to.AddLast(config); };
540 * Attempts to forward an intercepted HTLC over the provided channel id and with the provided
541 * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
543 * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
544 * channel to a receiving node if the node lacks sufficient inbound liquidity.
546 * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
547 * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
548 * receiver's invoice route hints. These route hints will signal to LDK to generate an
549 * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
550 * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
552 * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
553 * you from forwarding more than you received.
555 * Errors if the event was not handled in time, in which case the HTLC was automatically failed
558 * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
559 * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
561 public Result_NoneAPIErrorZ forward_intercepted_htlc(byte[] intercept_id, byte[] next_hop_channel_id, byte[] _next_node_id, long amt_to_forward_msat) {
562 long ret = bindings.ChannelManager_forward_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32), InternalUtils.check_arr_len(next_hop_channel_id, 32), InternalUtils.check_arr_len(_next_node_id, 33), amt_to_forward_msat);
564 GC.KeepAlive(intercept_id);
565 GC.KeepAlive(next_hop_channel_id);
566 GC.KeepAlive(_next_node_id);
567 GC.KeepAlive(amt_to_forward_msat);
568 if (ret >= 0 && ret <= 4096) { return null; }
569 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
574 * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
575 * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
577 * Errors if the event was not handled in time, in which case the HTLC was automatically failed
580 * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
582 public Result_NoneAPIErrorZ fail_intercepted_htlc(byte[] intercept_id) {
583 long ret = bindings.ChannelManager_fail_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32));
585 GC.KeepAlive(intercept_id);
586 if (ret >= 0 && ret <= 4096) { return null; }
587 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
592 * Processes HTLCs which are pending waiting on random forward delay.
594 * Should only really ever be called in response to a PendingHTLCsForwardable event.
595 * Will likely generate further events.
597 public void process_pending_htlc_forwards() {
598 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
603 * Performs actions which should happen on startup and roughly once per minute thereafter.
605 * This currently includes:
606 * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
607 * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
608 * than a minute, informing the network that they should no longer attempt to route over
610 * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs
611 * with the current `ChannelConfig`.
613 * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
616 public void timer_tick_occurred() {
617 bindings.ChannelManager_timer_tick_occurred(this.ptr);
622 * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
623 * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
624 * along the path (including in our own channel on which we received it).
626 * Note that in some cases around unclean shutdown, it is possible the payment may have
627 * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
628 * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
629 * may have already been failed automatically by LDK if it was nearing its expiration time.
631 * While LDK will never claim a payment automatically on your behalf (i.e. without you calling
632 * [`ChannelManager::claim_funds`]), you should still monitor for
633 * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
634 * startup during which time claims that were in-progress at shutdown may be replayed.
636 public void fail_htlc_backwards(byte[] payment_hash) {
637 bindings.ChannelManager_fail_htlc_backwards(this.ptr, InternalUtils.check_arr_len(payment_hash, 32));
639 GC.KeepAlive(payment_hash);
643 * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
644 * [`MessageSendEvent`]s needed to claim the payment.
646 * Note that calling this method does *not* guarantee that the payment has been claimed. You
647 * must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be
648 * provided to your [`EventHandler`] when [`process_pending_events`] is next called.
650 * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
651 * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
652 * event matches your expectation. If you fail to do so and call this method, you may provide
653 * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
655 * [`Event::PaymentClaimable`]: crate::util::events::Event::PaymentClaimable
656 * [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed
657 * [`process_pending_events`]: EventsProvider::process_pending_events
658 * [`create_inbound_payment`]: Self::create_inbound_payment
659 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
661 public void claim_funds(byte[] payment_preimage) {
662 bindings.ChannelManager_claim_funds(this.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
664 GC.KeepAlive(payment_preimage);
668 * Gets the node_id held by this ChannelManager
670 public byte[] get_our_node_id() {
671 byte[] ret = bindings.ChannelManager_get_our_node_id(this.ptr);
677 * Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
679 * The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
680 * and the `counterparty_node_id` parameter is the id of the peer which has requested to open
683 * The `user_channel_id` parameter will be provided back in
684 * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
685 * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
687 * Note that this method will return an error and reject the channel, if it requires support
688 * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
689 * used to accept such channels.
691 * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
692 * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
694 public Result_NoneAPIErrorZ accept_inbound_channel(byte[] temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
695 long ret = bindings.ChannelManager_accept_inbound_channel(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
697 GC.KeepAlive(temporary_channel_id);
698 GC.KeepAlive(counterparty_node_id);
699 GC.KeepAlive(user_channel_id);
700 if (ret >= 0 && ret <= 4096) { return null; }
701 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
706 * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
707 * it as confirmed immediately.
709 * The `user_channel_id` parameter will be provided back in
710 * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
711 * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
713 * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
714 * and (if the counterparty agrees), enables forwarding of payments immediately.
716 * This fully trusts that the counterparty has honestly and correctly constructed the funding
717 * transaction and blindly assumes that it will eventually confirm.
719 * If it does not confirm before we decide to close the channel, or if the funding transaction
720 * does not pay to the correct script the correct amount, *you will lose funds*.
722 * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
723 * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
725 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) {
726 long ret = bindings.ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
728 GC.KeepAlive(temporary_channel_id);
729 GC.KeepAlive(counterparty_node_id);
730 GC.KeepAlive(user_channel_id);
731 if (ret >= 0 && ret <= 4096) { return null; }
732 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
737 * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
740 * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
741 * [`PaymentHash`] and [`PaymentPreimage`] for you.
743 * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which
744 * will have the [`PaymentClaimable::payment_preimage`] field filled in. That should then be
745 * passed directly to [`claim_funds`].
747 * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
749 * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
750 * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
754 * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
755 * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
757 * Errors if `min_value_msat` is greater than total bitcoin supply.
759 * [`claim_funds`]: Self::claim_funds
760 * [`PaymentClaimable`]: events::Event::PaymentClaimable
761 * [`PaymentClaimable::payment_preimage`]: events::Event::PaymentClaimable::payment_preimage
762 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
764 public Result_C2Tuple_PaymentHashPaymentSecretZNoneZ create_inbound_payment(org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
765 long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs);
767 GC.KeepAlive(min_value_msat);
768 GC.KeepAlive(invoice_expiry_delta_secs);
769 if (ret >= 0 && ret <= 4096) { return null; }
770 Result_C2Tuple_PaymentHashPaymentSecretZNoneZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
775 * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
776 * serialized state with LDK node(s) running 0.0.103 and earlier.
778 * May panic if `invoice_expiry_delta_secs` is greater than one year.
781 * This method is deprecated and will be removed soon.
783 * [`create_inbound_payment`]: Self::create_inbound_payment
785 public Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ create_inbound_payment_legacy(org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
786 long ret = bindings.ChannelManager_create_inbound_payment_legacy(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs);
788 GC.KeepAlive(min_value_msat);
789 GC.KeepAlive(invoice_expiry_delta_secs);
790 if (ret >= 0 && ret <= 4096) { return null; }
791 Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ.constr_from_ptr(ret);
796 * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
797 * stored external to LDK.
799 * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
800 * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
801 * the `min_value_msat` provided here, if one is provided.
803 * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
804 * note that LDK will not stop you from registering duplicate payment hashes for inbound
807 * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
808 * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
809 * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
810 * sender \"proof-of-payment\" unless they have paid the required amount.
812 * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
813 * in excess of the current time. This should roughly match the expiry time set in the invoice.
814 * After this many seconds, we will remove the inbound payment, resulting in any attempts to
815 * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
816 * invoices when no timeout is set.
818 * Note that we use block header time to time-out pending inbound payments (with some margin
819 * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
820 * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
821 * If you need exact expiry semantics, you should enforce them upon receipt of
822 * [`PaymentClaimable`].
824 * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
825 * set to at least [`MIN_FINAL_CLTV_EXPIRY`].
827 * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
828 * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
832 * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
833 * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
835 * Errors if `min_value_msat` is greater than total bitcoin supply.
837 * [`create_inbound_payment`]: Self::create_inbound_payment
838 * [`PaymentClaimable`]: events::Event::PaymentClaimable
840 public Result_PaymentSecretNoneZ create_inbound_payment_for_hash(byte[] payment_hash, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
841 long ret = bindings.ChannelManager_create_inbound_payment_for_hash(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), min_value_msat.ptr, invoice_expiry_delta_secs);
843 GC.KeepAlive(payment_hash);
844 GC.KeepAlive(min_value_msat);
845 GC.KeepAlive(invoice_expiry_delta_secs);
846 if (ret >= 0 && ret <= 4096) { return null; }
847 Result_PaymentSecretNoneZ ret_hu_conv = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
852 * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
853 * serialized state with LDK node(s) running 0.0.103 and earlier.
855 * May panic if `invoice_expiry_delta_secs` is greater than one year.
858 * This method is deprecated and will be removed soon.
860 * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
862 public Result_PaymentSecretAPIErrorZ create_inbound_payment_for_hash_legacy(byte[] payment_hash, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
863 long ret = bindings.ChannelManager_create_inbound_payment_for_hash_legacy(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), min_value_msat.ptr, invoice_expiry_delta_secs);
865 GC.KeepAlive(payment_hash);
866 GC.KeepAlive(min_value_msat);
867 GC.KeepAlive(invoice_expiry_delta_secs);
868 if (ret >= 0 && ret <= 4096) { return null; }
869 Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
874 * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
875 * previously returned from [`create_inbound_payment`].
877 * [`create_inbound_payment`]: Self::create_inbound_payment
879 public Result_PaymentPreimageAPIErrorZ get_payment_preimage(byte[] payment_hash, byte[] payment_secret) {
880 long ret = bindings.ChannelManager_get_payment_preimage(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
882 GC.KeepAlive(payment_hash);
883 GC.KeepAlive(payment_secret);
884 if (ret >= 0 && ret <= 4096) { return null; }
885 Result_PaymentPreimageAPIErrorZ ret_hu_conv = Result_PaymentPreimageAPIErrorZ.constr_from_ptr(ret);
890 * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
891 * are used when constructing the phantom invoice's route hints.
893 * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
895 public long get_phantom_scid() {
896 long ret = bindings.ChannelManager_get_phantom_scid(this.ptr);
902 * Gets route hints for use in receiving [phantom node payments].
904 * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
906 public PhantomRouteHints get_phantom_route_hints() {
907 long ret = bindings.ChannelManager_get_phantom_route_hints(this.ptr);
909 if (ret >= 0 && ret <= 4096) { return null; }
910 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
911 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
916 * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
917 * used when constructing the route hints for HTLCs intended to be intercepted. See
918 * [`ChannelManager::forward_intercepted_htlc`].
920 * Note that this method is not guaranteed to return unique values, you may need to call it a few
921 * times to get a unique scid.
923 public long get_intercept_scid() {
924 long ret = bindings.ChannelManager_get_intercept_scid(this.ptr);
930 * Gets inflight HTLC information by processing pending outbound payments that are in
931 * our channels. May be used during pathfinding to account for in-use channel liquidity.
933 public InFlightHtlcs compute_inflight_htlcs() {
934 long ret = bindings.ChannelManager_compute_inflight_htlcs(this.ptr);
936 if (ret >= 0 && ret <= 4096) { return null; }
937 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
938 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
943 * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
944 * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
946 public MessageSendEventsProvider as_MessageSendEventsProvider() {
947 long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
949 if (ret >= 0 && ret <= 4096) { return null; }
950 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
951 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
956 * Constructs a new EventsProvider which calls the relevant methods on this_arg.
957 * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
959 public EventsProvider as_EventsProvider() {
960 long ret = bindings.ChannelManager_as_EventsProvider(this.ptr);
962 if (ret >= 0 && ret <= 4096) { return null; }
963 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
964 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
969 * Constructs a new Listen which calls the relevant methods on this_arg.
970 * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
972 public Listen as_Listen() {
973 long ret = bindings.ChannelManager_as_Listen(this.ptr);
975 if (ret >= 0 && ret <= 4096) { return null; }
976 Listen ret_hu_conv = new Listen(null, ret);
977 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
982 * Constructs a new Confirm which calls the relevant methods on this_arg.
983 * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
985 public Confirm as_Confirm() {
986 long ret = bindings.ChannelManager_as_Confirm(this.ptr);
988 if (ret >= 0 && ret <= 4096) { return null; }
989 Confirm ret_hu_conv = new Confirm(null, ret);
990 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
995 * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
996 * indicating whether persistence is necessary. Only one listener on
997 * [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by
998 * [`get_persistable_update_future`] is guaranteed to be woken up.
1000 * Note that this method is not available with the `no-std` feature.
1002 * [`await_persistable_update`]: Self::await_persistable_update
1003 * [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout
1004 * [`get_persistable_update_future`]: Self::get_persistable_update_future
1006 public bool await_persistable_update_timeout(long max_wait) {
1007 bool ret = bindings.ChannelManager_await_persistable_update_timeout(this.ptr, max_wait);
1009 GC.KeepAlive(max_wait);
1014 * Blocks until ChannelManager needs to be persisted. Only one listener on
1015 * [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by
1016 * [`get_persistable_update_future`] is guaranteed to be woken up.
1018 * [`await_persistable_update`]: Self::await_persistable_update
1019 * [`get_persistable_update_future`]: Self::get_persistable_update_future
1021 public void await_persistable_update() {
1022 bindings.ChannelManager_await_persistable_update(this.ptr);
1027 * Gets a [`Future`] that completes when a persistable update is available. Note that
1028 * callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
1029 * should instead register actions to be taken later.
1031 public Future get_persistable_update_future() {
1032 long ret = bindings.ChannelManager_get_persistable_update_future(this.ptr);
1034 if (ret >= 0 && ret <= 4096) { return null; }
1035 org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
1036 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1041 * Gets the latest best block which was connected either via the [`chain::Listen`] or
1042 * [`chain::Confirm`] interfaces.
1044 public BestBlock current_best_block() {
1045 long ret = bindings.ChannelManager_current_best_block(this.ptr);
1047 if (ret >= 0 && ret <= 4096) { return null; }
1048 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
1049 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1054 * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
1055 * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
1057 public ChannelMessageHandler as_ChannelMessageHandler() {
1058 long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
1060 if (ret >= 0 && ret <= 4096) { return null; }
1061 ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
1062 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
1067 * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
1069 public byte[] write() {
1070 byte[] ret = bindings.ChannelManager_write(this.ptr);
1076 * Constructs a new Payer which calls the relevant methods on this_arg.
1077 * This copies the `inner` pointer in this_arg and thus the returned Payer must be freed before this_arg is
1079 public Payer as_Payer() {
1080 long ret = bindings.ChannelManager_as_Payer(this.ptr);
1082 if (ret >= 0 && ret <= 4096) { return null; }
1083 Payer ret_hu_conv = new Payer(null, ret);
1084 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };