[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / ChannelManager.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A lightning node's channel state machine and payment management logic, which facilitates
13  * sending, forwarding, and receiving payments through lightning channels.
14  * 
15  * [`ChannelManager`] is parameterized by a number of components to achieve this.
16  * - [`chain::Watch`] (typically [`ChainMonitor`]) for on-chain monitoring and enforcement of each
17  * channel
18  * - [`BroadcasterInterface`] for broadcasting transactions related to opening, funding, and
19  * closing channels
20  * - [`EntropySource`] for providing random data needed for cryptographic operations
21  * - [`NodeSigner`] for cryptographic operations scoped to the node
22  * - [`SignerProvider`] for providing signers whose operations are scoped to individual channels
23  * - [`FeeEstimator`] to determine transaction fee rates needed to have a transaction mined in a
24  * timely manner
25  * - [`Router`] for finding payment paths when initiating and retrying payments
26  * - [`Logger`] for logging operational information of varying degrees
27  * 
28  * Additionally, it implements the following traits:
29  * - [`ChannelMessageHandler`] to handle off-chain channel activity from peers
30  * - [`MessageSendEventsProvider`] to similarly send such messages to peers
31  * - [`OffersMessageHandler`] for BOLT 12 message handling and sending
32  * - [`EventsProvider`] to generate user-actionable [`Event`]s
33  * - [`chain::Listen`] and [`chain::Confirm`] for notification of on-chain activity
34  * 
35  * Thus, [`ChannelManager`] is typically used to parameterize a [`MessageHandler`] and an
36  * [`OnionMessenger`]. The latter is required to support BOLT 12 functionality.
37  * 
38  * # `ChannelManager` vs `ChannelMonitor`
39  * 
40  * It's important to distinguish between the *off-chain* management and *on-chain* enforcement of
41  * lightning channels. [`ChannelManager`] exchanges messages with peers to manage the off-chain
42  * state of each channel. During this process, it generates a [`ChannelMonitor`] for each channel
43  * and a [`ChannelMonitorUpdate`] for each relevant change, notifying its parameterized
44  * [`chain::Watch`] of them.
45  * 
46  * An implementation of [`chain::Watch`], such as [`ChainMonitor`], is responsible for aggregating
47  * these [`ChannelMonitor`]s and applying any [`ChannelMonitorUpdate`]s to them. It then monitors
48  * for any pertinent on-chain activity, enforcing claims as needed.
49  * 
50  * This division of off-chain management and on-chain enforcement allows for interesting node
51  * setups. For instance, on-chain enforcement could be moved to a separate host or have added
52  * redundancy, possibly as a watchtower. See [`chain::Watch`] for the relevant interface.
53  * 
54  * # Initialization
55  * 
56  * Use [`ChannelManager::new`] with the most recent [`BlockHash`] when creating a fresh instance.
57  * Otherwise, if restarting, construct [`ChannelManagerReadArgs`] with the necessary parameters and
58  * references to any deserialized [`ChannelMonitor`]s that were previously persisted. Use this to
59  * deserialize the [`ChannelManager`] and feed it any new chain data since it was last online, as
60  * detailed in the [`ChannelManagerReadArgs`] documentation.
61  * 
62  * ```
63  * use bitcoin::BlockHash;
64  * use bitcoin::network::constants::Network;
65  * use lightning::chain::BestBlock;
66  * # use lightning::chain::channelmonitor::ChannelMonitor;
67  * use lightning::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs};
68  * # use lightning::routing::gossip::NetworkGraph;
69  * use lightning::util::config::UserConfig;
70  * use lightning::util::ser::ReadableArgs;
71  * 
72  * # fn read_channel_monitors() -> Vec<ChannelMonitor<lightning::sign::InMemorySigner>> { vec![] }
73  * # fn example<
74  * #     'a,
75  * #     L: lightning::util::logger::Logger,
76  * #     ES: lightning::sign::EntropySource,
77  * #     S: for <'b> lightning::routing::scoring::LockableScore<'b, ScoreLookUp = SL>,
78  * #     SL: lightning::routing::scoring::ScoreLookUp<ScoreParams = SP>,
79  * #     SP: Sized,
80  * #     R: lightning::io::Read,
81  * # >(
82  * #     fee_estimator: &dyn lightning::chain::chaininterface::FeeEstimator,
83  * #     chain_monitor: &dyn lightning::chain::Watch<lightning::sign::InMemorySigner>,
84  * #     tx_broadcaster: &dyn lightning::chain::chaininterface::BroadcasterInterface,
85  * #     router: &lightning::routing::router::DefaultRouter<&NetworkGraph<&'a L>, &'a L, &ES, &S, SP, SL>,
86  * #     logger: &L,
87  * #     entropy_source: &ES,
88  * #     node_signer: &dyn lightning::sign::NodeSigner,
89  * #     signer_provider: &lightning::sign::DynSignerProvider,
90  * #     best_block: lightning::chain::BestBlock,
91  * #     current_timestamp: u32,
92  * #     mut reader: R,
93  * # ) -> Result<(), lightning::ln::msgs::DecodeError> {
94  * Fresh start with no channels
95  * let params = ChainParameters {
96  * network: Network::Bitcoin,
97  * best_block,
98  * };
99  * let default_config = UserConfig::default();
100  * let channel_manager = ChannelManager::new(
101  * fee_estimator, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer,
102  * signer_provider, default_config, params, current_timestamp
103  * );
104  * 
105  * Restart from deserialized data
106  * let mut channel_monitors = read_channel_monitors();
107  * let args = ChannelManagerReadArgs::new(
108  * entropy_source, node_signer, signer_provider, fee_estimator, chain_monitor, tx_broadcaster,
109  * router, logger, default_config, channel_monitors.iter_mut().collect()
110  * );
111  * let (block_hash, channel_manager) =
112  * <(BlockHash, ChannelManager<_, _, _, _, _, _, _, _>)>::read(&mut reader, args)?;
113  * 
114  * Update the ChannelManager and ChannelMonitors with the latest chain data
115  * ...
116  * 
117  * Move the monitors to the ChannelManager's chain::Watch parameter
118  * for monitor in channel_monitors {
119  * chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor);
120  * }
121  * # Ok(())
122  * # }
123  * ```
124  * 
125  * # Operation
126  * 
127  * The following is required for [`ChannelManager`] to function properly:
128  * - Handle messages from peers using its [`ChannelMessageHandler`] implementation (typically
129  * called by [`PeerManager::read_event`] when processing network I/O)
130  * - Send messages to peers obtained via its [`MessageSendEventsProvider`] implementation
131  * (typically initiated when [`PeerManager::process_events`] is called)
132  * - Feed on-chain activity using either its [`chain::Listen`] or [`chain::Confirm`] implementation
133  * as documented by those traits
134  * - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly
135  * every minute
136  * - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a
137  * [`Persister`] such as a [`KVStore`] implementation
138  * - Handle [`Event`]s obtained via its [`EventsProvider`] implementation
139  * 
140  * The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining
141  * when the last two requirements need to be checked.
142  * 
143  * The [`lightning-block-sync`] and [`lightning-transaction-sync`] crates provide utilities that
144  * simplify feeding in on-chain activity using the [`chain::Listen`] and [`chain::Confirm`] traits,
145  * respectively. The remaining requirements can be met using the [`lightning-background-processor`]
146  * crate. For languages other than Rust, the availability of similar utilities may vary.
147  * 
148  * # Channels
149  * 
150  * [`ChannelManager`]'s primary function involves managing a channel state. Without channels,
151  * payments can't be sent. Use [`list_channels`] or [`list_usable_channels`] for a snapshot of the
152  * currently open channels.
153  * 
154  * ```
155  * # use lightning::ln::channelmanager::AChannelManager;
156  * #
157  * # fn example<T: AChannelManager>(channel_manager: T) {
158  * # let channel_manager = channel_manager.get_cm();
159  * let channels = channel_manager.list_usable_channels();
160  * for details in channels {
161  * println!(\"{:?}\", details);
162  * }
163  * # }
164  * ```
165  * 
166  * Each channel is identified using a [`ChannelId`], which will change throughout the channel's
167  * life cycle. Additionally, channels are assigned a `user_channel_id`, which is given in
168  * [`Event`]s associated with the channel and serves as a fixed identifier but is otherwise unused
169  * by [`ChannelManager`].
170  * 
171  * ## Opening Channels
172  * 
173  * To an open a channel with a peer, call [`create_channel`]. This will initiate the process of
174  * opening an outbound channel, which requires self-funding when handling
175  * [`Event::FundingGenerationReady`].
176  * 
177  * ```
178  * # use bitcoin::{ScriptBuf, Transaction};
179  * # use bitcoin::secp256k1::PublicKey;
180  * # use lightning::ln::channelmanager::AChannelManager;
181  * # use lightning::events::{Event, EventsProvider};
182  * #
183  * # trait Wallet {
184  * #     fn create_funding_transaction(
185  * #         &self, _amount_sats: u64, _output_script: ScriptBuf
186  * #     ) -> Transaction;
187  * # }
188  * #
189  * # fn example<T: AChannelManager, W: Wallet>(channel_manager: T, wallet: W, peer_id: PublicKey) {
190  * # let channel_manager = channel_manager.get_cm();
191  * let value_sats = 1_000_000;
192  * let push_msats = 10_000_000;
193  * match channel_manager.create_channel(peer_id, value_sats, push_msats, 42, None, None) {
194  * Ok(channel_id) => println!(\"Opening channel {}\", channel_id),
195  * Err(e) => println!(\"Error opening channel: {:?}\", e),
196  * }
197  * 
198  * On the event processing thread once the peer has responded
199  * channel_manager.process_pending_events(&|event| match event {
200  * Event::FundingGenerationReady {
201  * temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script,
202  * user_channel_id, ..
203  * } => {
204  * assert_eq!(user_channel_id, 42);
205  * let funding_transaction = wallet.create_funding_transaction(
206  * channel_value_satoshis, output_script
207  * );
208  * match channel_manager.funding_transaction_generated(
209  * &temporary_channel_id, &counterparty_node_id, funding_transaction
210  * ) {
211  * Ok(()) => println!(\"Funding channel {}\", temporary_channel_id),
212  * Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e),
213  * }
214  * },
215  * Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => {
216  * assert_eq!(user_channel_id, 42);
217  * println!(
218  * \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id,
219  * former_temporary_channel_id.unwrap()
220  * );
221  * },
222  * Event::ChannelReady { channel_id, user_channel_id, .. } => {
223  * assert_eq!(user_channel_id, 42);
224  * println!(\"Channel {} ready\", channel_id);
225  * },
226  * ...
227  * #     _ => {},
228  * });
229  * # }
230  * ```
231  * 
232  * ## Accepting Channels
233  * 
234  * Inbound channels are initiated by peers and are automatically accepted unless [`ChannelManager`]
235  * has [`UserConfig::manually_accept_inbound_channels`] set. In that case, the channel may be
236  * either accepted or rejected when handling [`Event::OpenChannelRequest`].
237  * 
238  * ```
239  * # use bitcoin::secp256k1::PublicKey;
240  * # use lightning::ln::channelmanager::AChannelManager;
241  * # use lightning::events::{Event, EventsProvider};
242  * #
243  * # fn is_trusted(counterparty_node_id: PublicKey) -> bool {
244  * #     // ...
245  * #     unimplemented!()
246  * # }
247  * #
248  * # fn example<T: AChannelManager>(channel_manager: T) {
249  * # let channel_manager = channel_manager.get_cm();
250  * channel_manager.process_pending_events(&|event| match event {
251  * Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, ..  } => {
252  * if !is_trusted(counterparty_node_id) {
253  * match channel_manager.force_close_without_broadcasting_txn(
254  * &temporary_channel_id, &counterparty_node_id
255  * ) {
256  * Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id),
257  * Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e),
258  * }
259  * return;
260  * }
261  * 
262  * let user_channel_id = 43;
263  * match channel_manager.accept_inbound_channel(
264  * &temporary_channel_id, &counterparty_node_id, user_channel_id
265  * ) {
266  * Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id),
267  * Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e),
268  * }
269  * },
270  * ...
271  * #     _ => {},
272  * });
273  * # }
274  * ```
275  * 
276  * ## Closing Channels
277  * 
278  * There are two ways to close a channel: either cooperatively using [`close_channel`] or
279  * unilaterally using [`force_close_broadcasting_latest_txn`]. The former is ideal as it makes for
280  * lower fees and immediate access to funds. However, the latter may be necessary if the
281  * counterparty isn't behaving properly or has gone offline. [`Event::ChannelClosed`] is generated
282  * once the channel has been closed successfully.
283  * 
284  * ```
285  * # use bitcoin::secp256k1::PublicKey;
286  * # use lightning::ln::types::ChannelId;
287  * # use lightning::ln::channelmanager::AChannelManager;
288  * # use lightning::events::{Event, EventsProvider};
289  * #
290  * # fn example<T: AChannelManager>(
291  * #     channel_manager: T, channel_id: ChannelId, counterparty_node_id: PublicKey
292  * # ) {
293  * # let channel_manager = channel_manager.get_cm();
294  * match channel_manager.close_channel(&channel_id, &counterparty_node_id) {
295  * Ok(()) => println!(\"Closing channel {}\", channel_id),
296  * Err(e) => println!(\"Error closing channel {}: {:?}\", channel_id, e),
297  * }
298  * 
299  * On the event processing thread
300  * channel_manager.process_pending_events(&|event| match event {
301  * Event::ChannelClosed { channel_id, user_channel_id, ..  } => {
302  * assert_eq!(user_channel_id, 42);
303  * println!(\"Channel {} closed\", channel_id);
304  * },
305  * ...
306  * #     _ => {},
307  * });
308  * # }
309  * ```
310  * 
311  * # Payments
312  * 
313  * [`ChannelManager`] is responsible for sending, forwarding, and receiving payments through its
314  * channels. A payment is typically initiated from a [BOLT 11] invoice or a [BOLT 12] offer, though
315  * spontaneous (i.e., keysend) payments are also possible. Incoming payments don't require
316  * maintaining any additional state as [`ChannelManager`] can reconstruct the [`PaymentPreimage`]
317  * from the [`PaymentSecret`]. Sending payments, however, require tracking in order to retry failed
318  * HTLCs.
319  * 
320  * After a payment is initiated, it will appear in [`list_recent_payments`] until a short time
321  * after either an [`Event::PaymentSent`] or [`Event::PaymentFailed`] is handled. Failed HTLCs
322  * for a payment will be retried according to the payment's [`Retry`] strategy or until
323  * [`abandon_payment`] is called.
324  * 
325  * ## BOLT 11 Invoices
326  * 
327  * The [`lightning-invoice`] crate is useful for creating BOLT 11 invoices. Specifically, use the
328  * functions in its `utils` module for constructing invoices that are compatible with
329  * [`ChannelManager`]. These functions serve as a convenience for building invoices with the
330  * [`PaymentHash`] and [`PaymentSecret`] returned from [`create_inbound_payment`]. To provide your
331  * own [`PaymentHash`], use [`create_inbound_payment_for_hash`] or the corresponding functions in
332  * the [`lightning-invoice`] `utils` module.
333  * 
334  * [`ChannelManager`] generates an [`Event::PaymentClaimable`] once the full payment has been
335  * received. Call [`claim_funds`] to release the [`PaymentPreimage`], which in turn will result in
336  * an [`Event::PaymentClaimed`].
337  * 
338  * ```
339  * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
340  * # use lightning::ln::channelmanager::AChannelManager;
341  * #
342  * # fn example<T: AChannelManager>(channel_manager: T) {
343  * # let channel_manager = channel_manager.get_cm();
344  * Or use utils::create_invoice_from_channelmanager
345  * let known_payment_hash = match channel_manager.create_inbound_payment(
346  * Some(10_000_000), 3600, None
347  * ) {
348  * Ok((payment_hash, _payment_secret)) => {
349  * println!(\"Creating inbound payment {}\", payment_hash);
350  * payment_hash
351  * },
352  * Err(()) => panic!(\"Error creating inbound payment\"),
353  * };
354  * 
355  * On the event processing thread
356  * channel_manager.process_pending_events(&|event| match event {
357  * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
358  * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => {
359  * assert_eq!(payment_hash, known_payment_hash);
360  * println!(\"Claiming payment {}\", payment_hash);
361  * channel_manager.claim_funds(payment_preimage);
362  * },
363  * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => {
364  * println!(\"Unknown payment hash: {}\", payment_hash);
365  * },
366  * PaymentPurpose::SpontaneousPayment(payment_preimage) => {
367  * assert_ne!(payment_hash, known_payment_hash);
368  * println!(\"Claiming spontaneous payment {}\", payment_hash);
369  * channel_manager.claim_funds(payment_preimage);
370  * },
371  * ...
372  * #         _ => {},
373  * },
374  * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
375  * assert_eq!(payment_hash, known_payment_hash);
376  * println!(\"Claimed {} msats\", amount_msat);
377  * },
378  * ...
379  * #     _ => {},
380  * });
381  * # }
382  * ```
383  * 
384  * For paying an invoice, [`lightning-invoice`] provides a `payment` module with convenience
385  * functions for use with [`send_payment`].
386  * 
387  * ```
388  * # use lightning::events::{Event, EventsProvider};
389  * # use lightning::ln::types::PaymentHash;
390  * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, RecipientOnionFields, Retry};
391  * # use lightning::routing::router::RouteParameters;
392  * #
393  * # fn example<T: AChannelManager>(
394  * #     channel_manager: T, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
395  * #     route_params: RouteParameters, retry: Retry
396  * # ) {
397  * # let channel_manager = channel_manager.get_cm();
398  * let (payment_hash, recipient_onion, route_params) =
399  * payment::payment_parameters_from_invoice(&invoice);
400  * let payment_id = PaymentId([42; 32]);
401  * match channel_manager.send_payment(
402  * payment_hash, recipient_onion, payment_id, route_params, retry
403  * ) {
404  * Ok(()) => println!(\"Sending payment with hash {}\", payment_hash),
405  * Err(e) => println!(\"Failed sending payment with hash {}: {:?}\", payment_hash, e),
406  * }
407  * 
408  * let expected_payment_id = payment_id;
409  * let expected_payment_hash = payment_hash;
410  * assert!(
411  * channel_manager.list_recent_payments().iter().find(|details| matches!(
412  * details,
413  * RecentPaymentDetails::Pending {
414  * payment_id: expected_payment_id,
415  * payment_hash: expected_payment_hash,
416  * ..
417  * }
418  * )).is_some()
419  * );
420  * 
421  * On the event processing thread
422  * channel_manager.process_pending_events(&|event| match event {
423  * Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash),
424  * Event::PaymentFailed { payment_hash, .. } => println!(\"Failed paying {}\", payment_hash),
425  * ...
426  * #     _ => {},
427  * });
428  * # }
429  * ```
430  * 
431  * ## BOLT 12 Offers
432  * 
433  * The [`offers`] module is useful for creating BOLT 12 offers. An [`Offer`] is a precursor to a
434  * [`Bolt12Invoice`], which must first be requested by the payer. The interchange of these messages
435  * as defined in the specification is handled by [`ChannelManager`] and its implementation of
436  * [`OffersMessageHandler`]. However, this only works with an [`Offer`] created using a builder
437  * returned by [`create_offer_builder`]. With this approach, BOLT 12 offers and invoices are
438  * stateless just as BOLT 11 invoices are.
439  * 
440  * ```
441  * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
442  * # use lightning::ln::channelmanager::AChannelManager;
443  * # use lightning::offers::parse::Bolt12SemanticError;
444  * #
445  * # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
446  * # let channel_manager = channel_manager.get_cm();
447  * let offer = channel_manager
448  * .create_offer_builder()?
449  * # ;
450  * # // Needed for compiling for c_bindings
451  * # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
452  * # let offer = builder
453  * .description(\"coffee\".to_string())
454  * .amount_msats(10_000_000)
455  * .build()?;
456  * let bech32_offer = offer.to_string();
457  * 
458  * On the event processing thread
459  * channel_manager.process_pending_events(&|event| match event {
460  * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
461  * PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => {
462  * println!(\"Claiming payment {}\", payment_hash);
463  * channel_manager.claim_funds(payment_preimage);
464  * },
465  * PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => {
466  * println!(\"Unknown payment hash: {}\", payment_hash);
467  * },
468  * ...
469  * #         _ => {},
470  * },
471  * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
472  * println!(\"Claimed {} msats\", amount_msat);
473  * },
474  * ...
475  * #     _ => {},
476  * });
477  * # Ok(())
478  * # }
479  * ```
480  * 
481  * Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`]
482  * and pays the [`Bolt12Invoice`] response. In addition to success and failure events,
483  * [`ChannelManager`] may also generate an [`Event::InvoiceRequestFailed`].
484  * 
485  * ```
486  * # use lightning::events::{Event, EventsProvider};
487  * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
488  * # use lightning::offers::offer::Offer;
489  * #
490  * # fn example<T: AChannelManager>(
491  * #     channel_manager: T, offer: &Offer, quantity: Option<u64>, amount_msats: Option<u64>,
492  * #     payer_note: Option<String>, retry: Retry, max_total_routing_fee_msat: Option<u64>
493  * # ) {
494  * # let channel_manager = channel_manager.get_cm();
495  * let payment_id = PaymentId([42; 32]);
496  * match channel_manager.pay_for_offer(
497  * offer, quantity, amount_msats, payer_note, payment_id, retry, max_total_routing_fee_msat
498  * ) {
499  * Ok(()) => println!(\"Requesting invoice for offer\"),
500  * Err(e) => println!(\"Unable to request invoice for offer: {:?}\", e),
501  * }
502  * 
503  * First the payment will be waiting on an invoice
504  * let expected_payment_id = payment_id;
505  * assert!(
506  * channel_manager.list_recent_payments().iter().find(|details| matches!(
507  * details,
508  * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id }
509  * )).is_some()
510  * );
511  * 
512  * Once the invoice is received, a payment will be sent
513  * assert!(
514  * channel_manager.list_recent_payments().iter().find(|details| matches!(
515  * details,
516  * RecentPaymentDetails::Pending { payment_id: expected_payment_id, ..  }
517  * )).is_some()
518  * );
519  * 
520  * On the event processing thread
521  * channel_manager.process_pending_events(&|event| match event {
522  * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id),
523  * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
524  * Event::InvoiceRequestFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
525  * ...
526  * #     _ => {},
527  * });
528  * # }
529  * ```
530  * 
531  * ## BOLT 12 Refunds
532  * 
533  * A [`Refund`] is a request for an invoice to be paid. Like *paying* for an [`Offer`], *creating*
534  * a [`Refund`] involves maintaining state since it represents a future outbound payment.
535  * Therefore, use [`create_refund_builder`] when creating one, otherwise [`ChannelManager`] will
536  * refuse to pay any corresponding [`Bolt12Invoice`] that it receives.
537  * 
538  * ```
539  * # use core::time::Duration;
540  * # use lightning::events::{Event, EventsProvider};
541  * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
542  * # use lightning::offers::parse::Bolt12SemanticError;
543  * #
544  * # fn example<T: AChannelManager>(
545  * #     channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry,
546  * #     max_total_routing_fee_msat: Option<u64>
547  * # ) -> Result<(), Bolt12SemanticError> {
548  * # let channel_manager = channel_manager.get_cm();
549  * let payment_id = PaymentId([42; 32]);
550  * let refund = channel_manager
551  * .create_refund_builder(
552  * amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
553  * )?
554  * # ;
555  * # // Needed for compiling for c_bindings
556  * # let builder: lightning::offers::refund::RefundBuilder<_> = refund.into();
557  * # let refund = builder
558  * .description(\"coffee\".to_string())
559  * .payer_note(\"refund for order 1234\".to_string())
560  * .build()?;
561  * let bech32_refund = refund.to_string();
562  * 
563  * First the payment will be waiting on an invoice
564  * let expected_payment_id = payment_id;
565  * assert!(
566  * channel_manager.list_recent_payments().iter().find(|details| matches!(
567  * details,
568  * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id }
569  * )).is_some()
570  * );
571  * 
572  * Once the invoice is received, a payment will be sent
573  * assert!(
574  * channel_manager.list_recent_payments().iter().find(|details| matches!(
575  * details,
576  * RecentPaymentDetails::Pending { payment_id: expected_payment_id, ..  }
577  * )).is_some()
578  * );
579  * 
580  * On the event processing thread
581  * channel_manager.process_pending_events(&|event| match event {
582  * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id),
583  * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
584  * ...
585  * #     _ => {},
586  * });
587  * # Ok(())
588  * # }
589  * ```
590  * 
591  * Use [`request_refund_payment`] to send a [`Bolt12Invoice`] for receiving the refund. Similar to
592  * creating* an [`Offer`], this is stateless as it represents an inbound payment.
593  * 
594  * ```
595  * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
596  * # use lightning::ln::channelmanager::AChannelManager;
597  * # use lightning::offers::refund::Refund;
598  * #
599  * # fn example<T: AChannelManager>(channel_manager: T, refund: &Refund) {
600  * # let channel_manager = channel_manager.get_cm();
601  * let known_payment_hash = match channel_manager.request_refund_payment(refund) {
602  * Ok(invoice) => {
603  * let payment_hash = invoice.payment_hash();
604  * println!(\"Requesting refund payment {}\", payment_hash);
605  * payment_hash
606  * },
607  * Err(e) => panic!(\"Unable to request payment for refund: {:?}\", e),
608  * };
609  * 
610  * On the event processing thread
611  * channel_manager.process_pending_events(&|event| match event {
612  * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
613  * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => {
614  * assert_eq!(payment_hash, known_payment_hash);
615  * println!(\"Claiming payment {}\", payment_hash);
616  * channel_manager.claim_funds(payment_preimage);
617  * },
618  * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => {
619  * println!(\"Unknown payment hash: {}\", payment_hash);
620  * \t},
621  * ...
622  * #         _ => {},
623  * },
624  * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
625  * assert_eq!(payment_hash, known_payment_hash);
626  * println!(\"Claimed {} msats\", amount_msat);
627  * },
628  * ...
629  * #     _ => {},
630  * });
631  * # }
632  * ```
633  * 
634  * # Persistence
635  * 
636  * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
637  * all peers during write/read (though does not modify this instance, only the instance being
638  * serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e.,
639  * called [`funding_transaction_generated`] for outbound channels) being closed.
640  * 
641  * Note that you can be a bit lazier about writing out `ChannelManager` than you can be with
642  * [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST durably write each
643  * [`ChannelMonitorUpdate`] before returning from
644  * [`chain::Watch::watch_channel`]/[`update_channel`] or before completing async writes. With
645  * `ChannelManager`s, writing updates happens out-of-band (and will prevent any other
646  * `ChannelManager` operations from occurring during the serialization process). If the
647  * deserialized version is out-of-date compared to the [`ChannelMonitor`] passed by reference to
648  * [`read`], those channels will be force-closed based on the `ChannelMonitor` state and no funds
649  * will be lost (modulo on-chain transaction fees).
650  * 
651  * Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which
652  * tells you the last block hash which was connected. You should get the best block tip before using the manager.
653  * See [`chain::Listen`] and [`chain::Confirm`] for more details.
654  * 
655  * # `ChannelUpdate` Messages
656  * 
657  * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating
658  * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid
659  * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
660  * offline for a full minute. In order to track this, you must call
661  * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect.
662  * 
663  * # DoS Mitigation
664  * 
665  * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and
666  * inbound channels without confirmed funding transactions. This may result in nodes which we do
667  * not have a channel with being unable to connect to us or open new channels with us if we have
668  * many peers with unfunded channels.
669  * 
670  * Because it is an indication of trust, inbound channels which we've accepted as 0conf are
671  * exempted from the count of unfunded channels. Similarly, outbound channels and connections are
672  * never limited. Please ensure you limit the count of such channels yourself.
673  * 
674  * # Type Aliases
675  * 
676  * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`]
677  * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but
678  * essentially you should default to using a [`SimpleRefChannelManager`], and use a
679  * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when
680  * you're using lightning-net-tokio.
681  * 
682  * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
683  * [`MessageHandler`]: crate::ln::peer_handler::MessageHandler
684  * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
685  * [`PeerManager::read_event`]: crate::ln::peer_handler::PeerManager::read_event
686  * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
687  * [`timer_tick_occurred`]: Self::timer_tick_occurred
688  * [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
689  * [`Persister`]: crate::util::persist::Persister
690  * [`KVStore`]: crate::util::persist::KVStore
691  * [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future
692  * [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
693  * [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync
694  * [`lightning-background-processor`]: https://docs.rs/lightning_background_processor/lightning_background_processor
695  * [`list_channels`]: Self::list_channels
696  * [`list_usable_channels`]: Self::list_usable_channels
697  * [`create_channel`]: Self::create_channel
698  * [`close_channel`]: Self::force_close_broadcasting_latest_txn
699  * [`force_close_broadcasting_latest_txn`]: Self::force_close_broadcasting_latest_txn
700  * [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
701  * [BOLT 12]: https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md
702  * [`list_recent_payments`]: Self::list_recent_payments
703  * [`abandon_payment`]: Self::abandon_payment
704  * [`lightning-invoice`]: https://docs.rs/lightning_invoice/latest/lightning_invoice
705  * [`create_inbound_payment`]: Self::create_inbound_payment
706  * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
707  * [`claim_funds`]: Self::claim_funds
708  * [`send_payment`]: Self::send_payment
709  * [`offers`]: crate::offers
710  * [`create_offer_builder`]: Self::create_offer_builder
711  * [`pay_for_offer`]: Self::pay_for_offer
712  * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
713  * [`create_refund_builder`]: Self::create_refund_builder
714  * [`request_refund_payment`]: Self::request_refund_payment
715  * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
716  * [`funding_created`]: msgs::FundingCreated
717  * [`funding_transaction_generated`]: Self::funding_transaction_generated
718  * [`BlockHash`]: bitcoin::hash_types::BlockHash
719  * [`update_channel`]: chain::Watch::update_channel
720  * [`ChannelUpdate`]: msgs::ChannelUpdate
721  * [`read`]: ReadableArgs::read
722  */
723 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
724 public class ChannelManager extends CommonBase {
725         ChannelManager(Object _dummy, long ptr) { super(ptr); }
726         @Override @SuppressWarnings("deprecation")
727         protected void finalize() throws Throwable {
728                 super.finalize();
729                 if (ptr != 0) { bindings.ChannelManager_free(ptr); }
730         }
731
732         /**
733          * Constructs a new `ChannelManager` to hold several channels and route between them.
734          * 
735          * The current time or latest block header time can be provided as the `current_timestamp`.
736          * 
737          * This is the main \"logic hub\" for all channel-related actions, and implements
738          * [`ChannelMessageHandler`].
739          * 
740          * Non-proportional fees are fixed according to our risk using the provided fee estimator.
741          * 
742          * Users need to notify the new `ChannelManager` when a new block is connected or
743          * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting
744          * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for
745          * more details.
746          * 
747          * [`block_connected`]: chain::Listen::block_connected
748          * [`block_disconnected`]: chain::Listen::block_disconnected
749          * [`params.best_block.block_hash`]: chain::BestBlock::block_hash
750          */
751         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) {
752                 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.ptr, params.ptr, current_timestamp);
753                 Reference.reachabilityFence(fee_est);
754                 Reference.reachabilityFence(chain_monitor);
755                 Reference.reachabilityFence(tx_broadcaster);
756                 Reference.reachabilityFence(router);
757                 Reference.reachabilityFence(logger);
758                 Reference.reachabilityFence(entropy_source);
759                 Reference.reachabilityFence(node_signer);
760                 Reference.reachabilityFence(signer_provider);
761                 Reference.reachabilityFence(config);
762                 Reference.reachabilityFence(params);
763                 Reference.reachabilityFence(current_timestamp);
764                 if (ret >= 0 && ret <= 4096) { return null; }
765                 org.ldk.structs.ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManager(null, ret); }
766                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
767                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_est); };
768                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(chain_monitor); };
769                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(tx_broadcaster); };
770                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(router); };
771                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
772                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
773                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(node_signer); };
774                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(signer_provider); };
775                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(config); };
776                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(params); };
777                 return ret_hu_conv;
778         }
779
780         /**
781          * Gets the current configuration applied to all new channels.
782          */
783         public UserConfig get_current_default_configuration() {
784                 long ret = bindings.ChannelManager_get_current_default_configuration(this.ptr);
785                 Reference.reachabilityFence(this);
786                 if (ret >= 0 && ret <= 4096) { return null; }
787                 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
788                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
789                 return ret_hu_conv;
790         }
791
792         /**
793          * Creates a new outbound channel to the given remote node and with the given value.
794          * 
795          * `user_channel_id` will be provided back as in
796          * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events
797          * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a
798          * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it
799          * is simply copied to events and otherwise ignored.
800          * 
801          * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
802          * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
803          * 
804          * Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to
805          * generate a shutdown scriptpubkey or destination script set by
806          * [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`].
807          * 
808          * Note that we do not check if you are currently connected to the given peer. If no
809          * connection is available, the outbound `open_channel` message may fail to send, resulting in
810          * the channel eventually being silently forgotten (dropped on reload).
811          * 
812          * If `temporary_channel_id` is specified, it will be used as the temporary channel ID of the
813          * channel. Otherwise, a random one will be generated for you.
814          * 
815          * Returns the new Channel's temporary `channel_id`. This ID will appear as
816          * [`Event::FundingGenerationReady::temporary_channel_id`] and in
817          * [`ChannelDetails::channel_id`] until after
818          * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
819          * one derived from the funding transaction's TXID. If the counterparty rejects the channel
820          * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
821          * 
822          * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id
823          * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
824          * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
825          * 
826          * Note that temporary_channel_id (or a relevant inner pointer) may be NULL or all-0s to represent None
827          * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
828          */
829         public Result_ChannelIdAPIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, org.ldk.util.UInt128 user_channel_id, @Nullable org.ldk.structs.ChannelId temporary_channel_id, @Nullable org.ldk.structs.UserConfig override_config) {
830                 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(), temporary_channel_id == null ? 0 : temporary_channel_id.ptr, override_config == null ? 0 : override_config.ptr);
831                 Reference.reachabilityFence(this);
832                 Reference.reachabilityFence(their_network_key);
833                 Reference.reachabilityFence(channel_value_satoshis);
834                 Reference.reachabilityFence(push_msat);
835                 Reference.reachabilityFence(user_channel_id);
836                 Reference.reachabilityFence(temporary_channel_id);
837                 Reference.reachabilityFence(override_config);
838                 if (ret >= 0 && ret <= 4096) { return null; }
839                 Result_ChannelIdAPIErrorZ ret_hu_conv = Result_ChannelIdAPIErrorZ.constr_from_ptr(ret);
840                 if (this != null) { this.ptrs_to.add(temporary_channel_id); };
841                 if (this != null) { this.ptrs_to.add(override_config); };
842                 return ret_hu_conv;
843         }
844
845         /**
846          * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
847          * more information.
848          */
849         public ChannelDetails[] list_channels() {
850                 long[] ret = bindings.ChannelManager_list_channels(this.ptr);
851                 Reference.reachabilityFence(this);
852                 int ret_conv_16_len = ret.length;
853                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
854                 for (int q = 0; q < ret_conv_16_len; q++) {
855                         long ret_conv_16 = ret[q];
856                         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); }
857                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
858                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
859                 }
860                 return ret_conv_16_arr;
861         }
862
863         /**
864          * Gets the list of usable channels, in random order. Useful as an argument to
865          * [`Router::find_route`] to ensure non-announced channels are used.
866          * 
867          * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
868          * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
869          * are.
870          */
871         public ChannelDetails[] list_usable_channels() {
872                 long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr);
873                 Reference.reachabilityFence(this);
874                 int ret_conv_16_len = ret.length;
875                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
876                 for (int q = 0; q < ret_conv_16_len; q++) {
877                         long ret_conv_16 = ret[q];
878                         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); }
879                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
880                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
881                 }
882                 return ret_conv_16_arr;
883         }
884
885         /**
886          * Gets the list of channels we have with a given counterparty, in random order.
887          */
888         public ChannelDetails[] list_channels_with_counterparty(byte[] counterparty_node_id) {
889                 long[] ret = bindings.ChannelManager_list_channels_with_counterparty(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33));
890                 Reference.reachabilityFence(this);
891                 Reference.reachabilityFence(counterparty_node_id);
892                 int ret_conv_16_len = ret.length;
893                 ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
894                 for (int q = 0; q < ret_conv_16_len; q++) {
895                         long ret_conv_16 = ret[q];
896                         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); }
897                         if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.add(this); };
898                         ret_conv_16_arr[q] = ret_conv_16_hu_conv;
899                 }
900                 return ret_conv_16_arr;
901         }
902
903         /**
904          * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
905          * successful path, or have unresolved HTLCs.
906          * 
907          * This can be useful for payments that may have been prepared, but ultimately not sent, as a
908          * result of a crash. If such a payment exists, is not listed here, and an
909          * [`Event::PaymentSent`] has not been received, you may consider resending the payment.
910          * 
911          * [`Event::PaymentSent`]: events::Event::PaymentSent
912          */
913         public RecentPaymentDetails[] list_recent_payments() {
914                 long[] ret = bindings.ChannelManager_list_recent_payments(this.ptr);
915                 Reference.reachabilityFence(this);
916                 int ret_conv_22_len = ret.length;
917                 RecentPaymentDetails[] ret_conv_22_arr = new RecentPaymentDetails[ret_conv_22_len];
918                 for (int w = 0; w < ret_conv_22_len; w++) {
919                         long ret_conv_22 = ret[w];
920                         org.ldk.structs.RecentPaymentDetails ret_conv_22_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret_conv_22);
921                         if (ret_conv_22_hu_conv != null) { ret_conv_22_hu_conv.ptrs_to.add(this); };
922                         ret_conv_22_arr[w] = ret_conv_22_hu_conv;
923                 }
924                 return ret_conv_22_arr;
925         }
926
927         /**
928          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
929          * will be accepted on the given channel, and after additional timeout/the closing of all
930          * pending HTLCs, the channel will be closed on chain.
931          * 
932          * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and
933          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
934          * fee estimate.
935          * If our counterparty is the channel initiator, we will require a channel closing
936          * transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which
937          * would appear on a force-closure transaction, whichever is lower. We will allow our
938          * counterparty to pay as much fee as they'd like, however.
939          * 
940          * May generate a [`SendShutdown`] message event on success, which should be relayed.
941          * 
942          * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
943          * generate a shutdown scriptpubkey or destination script set by
944          * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
945          * channel.
946          * 
947          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
948          * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
949          * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
950          * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
951          */
952         public Result_NoneAPIErrorZ close_channel(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id) {
953                 long ret = bindings.ChannelManager_close_channel(this.ptr, channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33));
954                 Reference.reachabilityFence(this);
955                 Reference.reachabilityFence(channel_id);
956                 Reference.reachabilityFence(counterparty_node_id);
957                 if (ret >= 0 && ret <= 4096) { return null; }
958                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
959                 if (this != null) { this.ptrs_to.add(channel_id); };
960                 return ret_hu_conv;
961         }
962
963         /**
964          * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
965          * will be accepted on the given channel, and after additional timeout/the closing of all
966          * pending HTLCs, the channel will be closed on chain.
967          * 
968          * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated
969          * the channel being closed or not:
970          * If we are the channel initiator, we will pay at least this feerate on the closing
971          * transaction. The upper-bound is set by
972          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
973          * fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
974          * If our counterparty is the channel initiator, we will refuse to accept a channel closure
975          * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
976          * will appear on a force-closure transaction, whichever is lower).
977          * 
978          * The `shutdown_script` provided  will be used as the `scriptPubKey` for the closing transaction.
979          * Will fail if a shutdown script has already been set for this channel by
980          * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must
981          * also be compatible with our and the counterparty's features.
982          * 
983          * May generate a [`SendShutdown`] message event on success, which should be relayed.
984          * 
985          * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
986          * generate a shutdown scriptpubkey or destination script set by
987          * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
988          * channel.
989          * 
990          * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
991          * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
992          * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
993          * 
994          * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None
995          */
996         public Result_NoneAPIErrorZ close_channel_with_feerate_and_script(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id, org.ldk.structs.Option_u32Z target_feerate_sats_per_1000_weight, @Nullable org.ldk.structs.ShutdownScript shutdown_script) {
997                 long ret = bindings.ChannelManager_close_channel_with_feerate_and_script(this.ptr, channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), target_feerate_sats_per_1000_weight.ptr, shutdown_script == null ? 0 : shutdown_script.ptr);
998                 Reference.reachabilityFence(this);
999                 Reference.reachabilityFence(channel_id);
1000                 Reference.reachabilityFence(counterparty_node_id);
1001                 Reference.reachabilityFence(target_feerate_sats_per_1000_weight);
1002                 Reference.reachabilityFence(shutdown_script);
1003                 if (ret >= 0 && ret <= 4096) { return null; }
1004                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1005                 if (this != null) { this.ptrs_to.add(channel_id); };
1006                 if (this != null) { this.ptrs_to.add(target_feerate_sats_per_1000_weight); };
1007                 if (this != null) { this.ptrs_to.add(shutdown_script); };
1008                 return ret_hu_conv;
1009         }
1010
1011         /**
1012          * Force closes a channel, immediately broadcasting the latest local transaction(s) and
1013          * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to
1014          * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
1015          * channel.
1016          */
1017         public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id) {
1018                 long ret = bindings.ChannelManager_force_close_broadcasting_latest_txn(this.ptr, channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33));
1019                 Reference.reachabilityFence(this);
1020                 Reference.reachabilityFence(channel_id);
1021                 Reference.reachabilityFence(counterparty_node_id);
1022                 if (ret >= 0 && ret <= 4096) { return null; }
1023                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1024                 if (this != null) { this.ptrs_to.add(channel_id); };
1025                 return ret_hu_conv;
1026         }
1027
1028         /**
1029          * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting
1030          * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
1031          * `counterparty_node_id` isn't the counterparty of the corresponding channel.
1032          * 
1033          * You can always broadcast the latest local transaction(s) via
1034          * [`ChannelMonitor::broadcast_latest_holder_commitment_txn`].
1035          */
1036         public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id) {
1037                 long ret = bindings.ChannelManager_force_close_without_broadcasting_txn(this.ptr, channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33));
1038                 Reference.reachabilityFence(this);
1039                 Reference.reachabilityFence(channel_id);
1040                 Reference.reachabilityFence(counterparty_node_id);
1041                 if (ret >= 0 && ret <= 4096) { return null; }
1042                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1043                 if (this != null) { this.ptrs_to.add(channel_id); };
1044                 return ret_hu_conv;
1045         }
1046
1047         /**
1048          * Force close all channels, immediately broadcasting the latest local commitment transaction
1049          * for each to the chain and rejecting new HTLCs on each.
1050          */
1051         public void force_close_all_channels_broadcasting_latest_txn() {
1052                 bindings.ChannelManager_force_close_all_channels_broadcasting_latest_txn(this.ptr);
1053                 Reference.reachabilityFence(this);
1054         }
1055
1056         /**
1057          * Force close all channels rejecting new HTLCs on each but without broadcasting the latest
1058          * local transaction(s).
1059          */
1060         public void force_close_all_channels_without_broadcasting_txn() {
1061                 bindings.ChannelManager_force_close_all_channels_without_broadcasting_txn(this.ptr);
1062                 Reference.reachabilityFence(this);
1063         }
1064
1065         /**
1066          * Sends a payment along a given route.
1067          * 
1068          * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
1069          * fields for more info.
1070          * 
1071          * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
1072          * [`PeerManager::process_events`]).
1073          * 
1074          * # Avoiding Duplicate Payments
1075          * 
1076          * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
1077          * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
1078          * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
1079          * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
1080          * second payment with the same [`PaymentId`].
1081          * 
1082          * Thus, in order to ensure duplicate payments are not sent, you should implement your own
1083          * tracking of payments, including state to indicate once a payment has completed. Because you
1084          * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should
1085          * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
1086          * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
1087          * 
1088          * Additionally, in the scenario where we begin the process of sending a payment, but crash
1089          * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
1090          * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
1091          * [`ChannelManager::list_recent_payments`] for more information.
1092          * 
1093          * # Possible Error States on [`PaymentSendFailure`]
1094          * 
1095          * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
1096          * each entry matching the corresponding-index entry in the route paths, see
1097          * [`PaymentSendFailure`] for more info.
1098          * 
1099          * In general, a path may raise:
1100          * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
1101          * node public key) is specified.
1102          * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
1103          * closed, doesn't exist, or the peer is currently disconnected.
1104          * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
1105          * relevant updates.
1106          * 
1107          * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
1108          * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
1109          * different route unless you intend to pay twice!
1110          * 
1111          * [`RouteHop`]: crate::routing::router::RouteHop
1112          * [`Event::PaymentSent`]: events::Event::PaymentSent
1113          * [`Event::PaymentFailed`]: events::Event::PaymentFailed
1114          * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
1115          * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
1116          * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
1117          */
1118         public Result_NonePaymentSendFailureZ send_payment_with_route(org.ldk.structs.Route route, byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) {
1119                 long ret = bindings.ChannelManager_send_payment_with_route(this.ptr, route.ptr, InternalUtils.check_arr_len(payment_hash, 32), recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32));
1120                 Reference.reachabilityFence(this);
1121                 Reference.reachabilityFence(route);
1122                 Reference.reachabilityFence(payment_hash);
1123                 Reference.reachabilityFence(recipient_onion);
1124                 Reference.reachabilityFence(payment_id);
1125                 if (ret >= 0 && ret <= 4096) { return null; }
1126                 Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
1127                 if (this != null) { this.ptrs_to.add(route); };
1128                 if (this != null) { this.ptrs_to.add(recipient_onion); };
1129                 return ret_hu_conv;
1130         }
1131
1132         /**
1133          * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
1134          * `route_params` and retry failed payment paths based on `retry_strategy`.
1135          */
1136         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) {
1137                 long ret = bindings.ChannelManager_send_payment(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32), route_params.ptr, retry_strategy.ptr);
1138                 Reference.reachabilityFence(this);
1139                 Reference.reachabilityFence(payment_hash);
1140                 Reference.reachabilityFence(recipient_onion);
1141                 Reference.reachabilityFence(payment_id);
1142                 Reference.reachabilityFence(route_params);
1143                 Reference.reachabilityFence(retry_strategy);
1144                 if (ret >= 0 && ret <= 4096) { return null; }
1145                 Result_NoneRetryableSendFailureZ ret_hu_conv = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret);
1146                 if (this != null) { this.ptrs_to.add(recipient_onion); };
1147                 if (this != null) { this.ptrs_to.add(route_params); };
1148                 if (this != null) { this.ptrs_to.add(retry_strategy); };
1149                 return ret_hu_conv;
1150         }
1151
1152         /**
1153          * Signals that no further attempts for the given payment should occur. Useful if you have a
1154          * pending outbound payment with retries remaining, but wish to stop retrying the payment before
1155          * retries are exhausted.
1156          * 
1157          * # Event Generation
1158          * 
1159          * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
1160          * as there are no remaining pending HTLCs for this payment.
1161          * 
1162          * Note that calling this method does *not* prevent a payment from succeeding. You must still
1163          * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
1164          * determine the ultimate status of a payment.
1165          * 
1166          * # Requested Invoices
1167          * 
1168          * In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning
1169          * the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`]
1170          * and prevent any attempts at paying it once received. The other events may only be generated
1171          * once the invoice has been received.
1172          * 
1173          * # Restart Behavior
1174          * 
1175          * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
1176          * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
1177          * [`Event::InvoiceRequestFailed`].
1178          * 
1179          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1180          */
1181         public void abandon_payment(byte[] payment_id) {
1182                 bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.check_arr_len(payment_id, 32));
1183                 Reference.reachabilityFence(this);
1184                 Reference.reachabilityFence(payment_id);
1185         }
1186
1187         /**
1188          * Send a spontaneous payment, which is a payment that does not require the recipient to have
1189          * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify
1190          * the preimage, it must be a cryptographically secure random value that no intermediate node
1191          * would be able to guess -- otherwise, an intermediate node may claim the payment and it will
1192          * never reach the recipient.
1193          * 
1194          * See [`send_payment`] documentation for more details on the return value of this function
1195          * and idempotency guarantees provided by the [`PaymentId`] key.
1196          * 
1197          * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
1198          * [`send_payment`] for more information about the risks of duplicate preimage usage.
1199          * 
1200          * [`send_payment`]: Self::send_payment
1201          */
1202         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) {
1203                 long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route.ptr, payment_preimage.ptr, recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32));
1204                 Reference.reachabilityFence(this);
1205                 Reference.reachabilityFence(route);
1206                 Reference.reachabilityFence(payment_preimage);
1207                 Reference.reachabilityFence(recipient_onion);
1208                 Reference.reachabilityFence(payment_id);
1209                 if (ret >= 0 && ret <= 4096) { return null; }
1210                 Result_ThirtyTwoBytesPaymentSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesPaymentSendFailureZ.constr_from_ptr(ret);
1211                 if (this != null) { this.ptrs_to.add(route); };
1212                 if (this != null) { this.ptrs_to.add(payment_preimage); };
1213                 if (this != null) { this.ptrs_to.add(recipient_onion); };
1214                 return ret_hu_conv;
1215         }
1216
1217         /**
1218          * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
1219          * based on `route_params` and retry failed payment paths based on `retry_strategy`.
1220          * 
1221          * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
1222          * payments.
1223          * 
1224          * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
1225          */
1226         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) {
1227                 long ret = bindings.ChannelManager_send_spontaneous_payment_with_retry(this.ptr, payment_preimage.ptr, recipient_onion.ptr, InternalUtils.check_arr_len(payment_id, 32), route_params.ptr, retry_strategy.ptr);
1228                 Reference.reachabilityFence(this);
1229                 Reference.reachabilityFence(payment_preimage);
1230                 Reference.reachabilityFence(recipient_onion);
1231                 Reference.reachabilityFence(payment_id);
1232                 Reference.reachabilityFence(route_params);
1233                 Reference.reachabilityFence(retry_strategy);
1234                 if (ret >= 0 && ret <= 4096) { return null; }
1235                 Result_ThirtyTwoBytesRetryableSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesRetryableSendFailureZ.constr_from_ptr(ret);
1236                 if (this != null) { this.ptrs_to.add(payment_preimage); };
1237                 if (this != null) { this.ptrs_to.add(recipient_onion); };
1238                 if (this != null) { this.ptrs_to.add(route_params); };
1239                 if (this != null) { this.ptrs_to.add(retry_strategy); };
1240                 return ret_hu_conv;
1241         }
1242
1243         /**
1244          * Send a payment that is probing the given route for liquidity. We calculate the
1245          * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
1246          * us to easily discern them from real payments.
1247          */
1248         public Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ send_probe(org.ldk.structs.Path path) {
1249                 long ret = bindings.ChannelManager_send_probe(this.ptr, path.ptr);
1250                 Reference.reachabilityFence(this);
1251                 Reference.reachabilityFence(path);
1252                 if (ret >= 0 && ret <= 4096) { return null; }
1253                 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ.constr_from_ptr(ret);
1254                 if (this != null) { this.ptrs_to.add(path); };
1255                 return ret_hu_conv;
1256         }
1257
1258         /**
1259          * Sends payment probes over all paths of a route that would be used to pay the given
1260          * amount to the given `node_id`.
1261          * 
1262          * See [`ChannelManager::send_preflight_probes`] for more information.
1263          */
1264         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) {
1265                 long ret = bindings.ChannelManager_send_spontaneous_preflight_probes(this.ptr, InternalUtils.check_arr_len(node_id, 33), amount_msat, final_cltv_expiry_delta, liquidity_limit_multiplier.ptr);
1266                 Reference.reachabilityFence(this);
1267                 Reference.reachabilityFence(node_id);
1268                 Reference.reachabilityFence(amount_msat);
1269                 Reference.reachabilityFence(final_cltv_expiry_delta);
1270                 Reference.reachabilityFence(liquidity_limit_multiplier);
1271                 if (ret >= 0 && ret <= 4096) { return null; }
1272                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
1273                 if (this != null) { this.ptrs_to.add(liquidity_limit_multiplier); };
1274                 return ret_hu_conv;
1275         }
1276
1277         /**
1278          * Sends payment probes over all paths of a route that would be used to pay a route found
1279          * according to the given [`RouteParameters`].
1280          * 
1281          * This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting
1282          * the actual payment. Note this is only useful if there likely is sufficient time for the
1283          * probe to settle before sending out the actual payment, e.g., when waiting for user
1284          * confirmation in a wallet UI.
1285          * 
1286          * Otherwise, there is a chance the probe could take up some liquidity needed to complete the
1287          * actual payment. Users should therefore be cautious and might avoid sending probes if
1288          * liquidity is scarce and/or they don't expect the probe to return before they send the
1289          * payment. To mitigate this issue, channels with available liquidity less than the required
1290          * amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight
1291          * probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`.
1292          */
1293         public Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ send_preflight_probes(org.ldk.structs.RouteParameters route_params, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
1294                 long ret = bindings.ChannelManager_send_preflight_probes(this.ptr, route_params.ptr, liquidity_limit_multiplier.ptr);
1295                 Reference.reachabilityFence(this);
1296                 Reference.reachabilityFence(route_params);
1297                 Reference.reachabilityFence(liquidity_limit_multiplier);
1298                 if (ret >= 0 && ret <= 4096) { return null; }
1299                 Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
1300                 if (this != null) { this.ptrs_to.add(route_params); };
1301                 if (this != null) { this.ptrs_to.add(liquidity_limit_multiplier); };
1302                 return ret_hu_conv;
1303         }
1304
1305         /**
1306          * Call this upon creation of a funding transaction for the given channel.
1307          * 
1308          * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs
1309          * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`].
1310          * 
1311          * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation
1312          * across the p2p network.
1313          * 
1314          * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided
1315          * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`].
1316          * 
1317          * May panic if the output found in the funding transaction is duplicative with some other
1318          * channel (note that this should be trivially prevented by using unique funding transaction
1319          * keys per-channel).
1320          * 
1321          * Do NOT broadcast the funding transaction yourself. When we have safely received our
1322          * counterparty's signature the funding transaction will automatically be broadcast via the
1323          * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed.
1324          * 
1325          * Note that this includes RBF or similar transaction replacement strategies - lightning does
1326          * not currently support replacing a funding transaction on an existing channel. Instead,
1327          * create a new channel with a conflicting funding transaction.
1328          * 
1329          * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend
1330          * the wallet software generating the funding transaction to apply anti-fee sniping as
1331          * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
1332          * for more details.
1333          * 
1334          * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
1335          * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
1336          */
1337         public Result_NoneAPIErrorZ funding_transaction_generated(org.ldk.structs.ChannelId temporary_channel_id, byte[] counterparty_node_id, byte[] funding_transaction) {
1338                 long ret = bindings.ChannelManager_funding_transaction_generated(this.ptr, temporary_channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), funding_transaction);
1339                 Reference.reachabilityFence(this);
1340                 Reference.reachabilityFence(temporary_channel_id);
1341                 Reference.reachabilityFence(counterparty_node_id);
1342                 Reference.reachabilityFence(funding_transaction);
1343                 if (ret >= 0 && ret <= 4096) { return null; }
1344                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1345                 if (this != null) { this.ptrs_to.add(temporary_channel_id); };
1346                 return ret_hu_conv;
1347         }
1348
1349         /**
1350          * Call this upon creation of a batch funding transaction for the given channels.
1351          * 
1352          * Return values are identical to [`Self::funding_transaction_generated`], respective to
1353          * each individual channel and transaction output.
1354          * 
1355          * Do NOT broadcast the funding transaction yourself. This batch funding transaction
1356          * will only be broadcast when we have safely received and persisted the counterparty's
1357          * signature for each channel.
1358          * 
1359          * If there is an error, all channels in the batch are to be considered closed.
1360          */
1361         public Result_NoneAPIErrorZ batch_funding_transaction_generated(TwoTuple_ChannelIdPublicKeyZ[] temporary_channels, byte[] funding_transaction) {
1362                 long ret = bindings.ChannelManager_batch_funding_transaction_generated(this.ptr, temporary_channels != null ? Arrays.stream(temporary_channels).mapToLong(temporary_channels_conv_30 -> temporary_channels_conv_30.ptr).toArray() : null, funding_transaction);
1363                 Reference.reachabilityFence(this);
1364                 Reference.reachabilityFence(temporary_channels);
1365                 Reference.reachabilityFence(funding_transaction);
1366                 if (ret >= 0 && ret <= 4096) { return null; }
1367                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1368                 return ret_hu_conv;
1369         }
1370
1371         /**
1372          * Atomically applies partial updates to the [`ChannelConfig`] of the given channels.
1373          * 
1374          * Once the updates are applied, each eligible channel (advertised with a known short channel
1375          * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
1376          * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
1377          * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
1378          * 
1379          * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
1380          * `counterparty_node_id` is provided.
1381          * 
1382          * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
1383          * below [`MIN_CLTV_EXPIRY_DELTA`].
1384          * 
1385          * If an error is returned, none of the updates should be considered applied.
1386          * 
1387          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
1388          * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
1389          * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
1390          * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
1391          * [`ChannelUpdate`]: msgs::ChannelUpdate
1392          * [`ChannelUnavailable`]: APIError::ChannelUnavailable
1393          * [`APIMisuseError`]: APIError::APIMisuseError
1394          */
1395         public Result_NoneAPIErrorZ update_partial_channel_config(byte[] counterparty_node_id, ChannelId[] channel_ids, org.ldk.structs.ChannelConfigUpdate config_update) {
1396                 long ret = bindings.ChannelManager_update_partial_channel_config(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_ids != null ? Arrays.stream(channel_ids).mapToLong(channel_ids_conv_11 -> channel_ids_conv_11.ptr).toArray() : null, config_update.ptr);
1397                 Reference.reachabilityFence(this);
1398                 Reference.reachabilityFence(counterparty_node_id);
1399                 Reference.reachabilityFence(channel_ids);
1400                 Reference.reachabilityFence(config_update);
1401                 if (ret >= 0 && ret <= 4096) { return null; }
1402                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1403                 for (ChannelId channel_ids_conv_11: channel_ids) { if (this != null) { this.ptrs_to.add(channel_ids_conv_11); }; };
1404                 if (this != null) { this.ptrs_to.add(config_update); };
1405                 return ret_hu_conv;
1406         }
1407
1408         /**
1409          * Atomically updates the [`ChannelConfig`] for the given channels.
1410          * 
1411          * Once the updates are applied, each eligible channel (advertised with a known short channel
1412          * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
1413          * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
1414          * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
1415          * 
1416          * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
1417          * `counterparty_node_id` is provided.
1418          * 
1419          * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
1420          * below [`MIN_CLTV_EXPIRY_DELTA`].
1421          * 
1422          * If an error is returned, none of the updates should be considered applied.
1423          * 
1424          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
1425          * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
1426          * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
1427          * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
1428          * [`ChannelUpdate`]: msgs::ChannelUpdate
1429          * [`ChannelUnavailable`]: APIError::ChannelUnavailable
1430          * [`APIMisuseError`]: APIError::APIMisuseError
1431          */
1432         public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, ChannelId[] channel_ids, org.ldk.structs.ChannelConfig config) {
1433                 long ret = bindings.ChannelManager_update_channel_config(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_ids != null ? Arrays.stream(channel_ids).mapToLong(channel_ids_conv_11 -> channel_ids_conv_11.ptr).toArray() : null, config.ptr);
1434                 Reference.reachabilityFence(this);
1435                 Reference.reachabilityFence(counterparty_node_id);
1436                 Reference.reachabilityFence(channel_ids);
1437                 Reference.reachabilityFence(config);
1438                 if (ret >= 0 && ret <= 4096) { return null; }
1439                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1440                 for (ChannelId channel_ids_conv_11: channel_ids) { if (this != null) { this.ptrs_to.add(channel_ids_conv_11); }; };
1441                 if (this != null) { this.ptrs_to.add(config); };
1442                 return ret_hu_conv;
1443         }
1444
1445         /**
1446          * Attempts to forward an intercepted HTLC over the provided channel id and with the provided
1447          * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event.
1448          * 
1449          * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time
1450          * channel to a receiving node if the node lacks sufficient inbound liquidity.
1451          * 
1452          * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use
1453          * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the
1454          * receiver's invoice route hints. These route hints will signal to LDK to generate an
1455          * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or
1456          * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
1457          * 
1458          * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
1459          * you from forwarding more than you received. See
1460          * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount
1461          * than expected.
1462          * 
1463          * Errors if the event was not handled in time, in which case the HTLC was automatically failed
1464          * backwards.
1465          * 
1466          * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
1467          * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
1468          * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat
1469          */
1470         public Result_NoneAPIErrorZ forward_intercepted_htlc(byte[] intercept_id, org.ldk.structs.ChannelId next_hop_channel_id, byte[] next_node_id, long amt_to_forward_msat) {
1471                 long ret = bindings.ChannelManager_forward_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32), next_hop_channel_id.ptr, InternalUtils.check_arr_len(next_node_id, 33), amt_to_forward_msat);
1472                 Reference.reachabilityFence(this);
1473                 Reference.reachabilityFence(intercept_id);
1474                 Reference.reachabilityFence(next_hop_channel_id);
1475                 Reference.reachabilityFence(next_node_id);
1476                 Reference.reachabilityFence(amt_to_forward_msat);
1477                 if (ret >= 0 && ret <= 4096) { return null; }
1478                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1479                 if (this != null) { this.ptrs_to.add(next_hop_channel_id); };
1480                 return ret_hu_conv;
1481         }
1482
1483         /**
1484          * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to
1485          * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`].
1486          * 
1487          * Errors if the event was not handled in time, in which case the HTLC was automatically failed
1488          * backwards.
1489          * 
1490          * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
1491          */
1492         public Result_NoneAPIErrorZ fail_intercepted_htlc(byte[] intercept_id) {
1493                 long ret = bindings.ChannelManager_fail_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32));
1494                 Reference.reachabilityFence(this);
1495                 Reference.reachabilityFence(intercept_id);
1496                 if (ret >= 0 && ret <= 4096) { return null; }
1497                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1498                 return ret_hu_conv;
1499         }
1500
1501         /**
1502          * Processes HTLCs which are pending waiting on random forward delay.
1503          * 
1504          * Should only really ever be called in response to a PendingHTLCsForwardable event.
1505          * Will likely generate further events.
1506          */
1507         public void process_pending_htlc_forwards() {
1508                 bindings.ChannelManager_process_pending_htlc_forwards(this.ptr);
1509                 Reference.reachabilityFence(this);
1510         }
1511
1512         /**
1513          * Performs actions which should happen on startup and roughly once per minute thereafter.
1514          * 
1515          * This currently includes:
1516          * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
1517          * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more
1518          * than a minute, informing the network that they should no longer attempt to route over
1519          * the channel.
1520          * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs
1521          * with the current [`ChannelConfig`].
1522          * Removing peers which have disconnected but and no longer have any channels.
1523          * Force-closing and removing channels which have not completed establishment in a timely manner.
1524          * Forgetting about stale outbound payments, either those that have already been fulfilled
1525          * or those awaiting an invoice that hasn't been delivered in the necessary amount of time.
1526          * The latter is determined using the system clock in `std` and the highest seen block time
1527          * minus two hours in `no-std`.
1528          * 
1529          * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate
1530          * estimate fetches.
1531          * 
1532          * [`ChannelUpdate`]: msgs::ChannelUpdate
1533          * [`ChannelConfig`]: crate::util::config::ChannelConfig
1534          */
1535         public void timer_tick_occurred() {
1536                 bindings.ChannelManager_timer_tick_occurred(this.ptr);
1537                 Reference.reachabilityFence(this);
1538         }
1539
1540         /**
1541          * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
1542          * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources
1543          * along the path (including in our own channel on which we received it).
1544          * 
1545          * Note that in some cases around unclean shutdown, it is possible the payment may have
1546          * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a
1547          * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment
1548          * may have already been failed automatically by LDK if it was nearing its expiration time.
1549          * 
1550          * While LDK will never claim a payment automatically on your behalf (i.e. without you calling
1551          * [`ChannelManager::claim_funds`]), you should still monitor for
1552          * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
1553          * startup during which time claims that were in-progress at shutdown may be replayed.
1554          */
1555         public void fail_htlc_backwards(byte[] payment_hash) {
1556                 bindings.ChannelManager_fail_htlc_backwards(this.ptr, InternalUtils.check_arr_len(payment_hash, 32));
1557                 Reference.reachabilityFence(this);
1558                 Reference.reachabilityFence(payment_hash);
1559         }
1560
1561         /**
1562          * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
1563          * reason for the failure.
1564          * 
1565          * See [`FailureCode`] for valid failure codes.
1566          */
1567         public void fail_htlc_backwards_with_reason(byte[] payment_hash, org.ldk.structs.FailureCode failure_code) {
1568                 bindings.ChannelManager_fail_htlc_backwards_with_reason(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), failure_code.ptr);
1569                 Reference.reachabilityFence(this);
1570                 Reference.reachabilityFence(payment_hash);
1571                 Reference.reachabilityFence(failure_code);
1572                 if (this != null) { this.ptrs_to.add(failure_code); };
1573         }
1574
1575         /**
1576          * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
1577          * [`MessageSendEvent`]s needed to claim the payment.
1578          * 
1579          * This method is guaranteed to ensure the payment has been claimed but only if the current
1580          * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race
1581          * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment
1582          * successful. It will generally be available in the next [`process_pending_events`] call.
1583          * 
1584          * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
1585          * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
1586          * event matches your expectation. If you fail to do so and call this method, you may provide
1587          * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
1588          * 
1589          * This function will fail the payment if it has custom TLVs with even type numbers, as we
1590          * will assume they are unknown. If you intend to accept even custom TLVs, you should use
1591          * [`claim_funds_with_known_custom_tlvs`].
1592          * 
1593          * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
1594          * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline
1595          * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed
1596          * [`process_pending_events`]: EventsProvider::process_pending_events
1597          * [`create_inbound_payment`]: Self::create_inbound_payment
1598          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
1599          * [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs
1600          */
1601         public void claim_funds(byte[] payment_preimage) {
1602                 bindings.ChannelManager_claim_funds(this.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
1603                 Reference.reachabilityFence(this);
1604                 Reference.reachabilityFence(payment_preimage);
1605         }
1606
1607         /**
1608          * This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with
1609          * even type numbers.
1610          * 
1611          * # Note
1612          * 
1613          * You MUST check you've understood all even TLVs before using this to
1614          * claim, otherwise you may unintentionally agree to some protocol you do not understand.
1615          * 
1616          * [`claim_funds`]: Self::claim_funds
1617          */
1618         public void claim_funds_with_known_custom_tlvs(byte[] payment_preimage) {
1619                 bindings.ChannelManager_claim_funds_with_known_custom_tlvs(this.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
1620                 Reference.reachabilityFence(this);
1621                 Reference.reachabilityFence(payment_preimage);
1622         }
1623
1624         /**
1625          * Gets the node_id held by this ChannelManager
1626          */
1627         public byte[] get_our_node_id() {
1628                 byte[] ret = bindings.ChannelManager_get_our_node_id(this.ptr);
1629                 Reference.reachabilityFence(this);
1630                 return ret;
1631         }
1632
1633         /**
1634          * Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
1635          * 
1636          * The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
1637          * and the `counterparty_node_id` parameter is the id of the peer which has requested to open
1638          * the channel.
1639          * 
1640          * The `user_channel_id` parameter will be provided back in
1641          * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
1642          * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
1643          * 
1644          * Note that this method will return an error and reject the channel, if it requires support
1645          * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be
1646          * used to accept such channels.
1647          * 
1648          * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
1649          * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
1650          */
1651         public Result_NoneAPIErrorZ accept_inbound_channel(org.ldk.structs.ChannelId temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
1652                 long ret = bindings.ChannelManager_accept_inbound_channel(this.ptr, temporary_channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
1653                 Reference.reachabilityFence(this);
1654                 Reference.reachabilityFence(temporary_channel_id);
1655                 Reference.reachabilityFence(counterparty_node_id);
1656                 Reference.reachabilityFence(user_channel_id);
1657                 if (ret >= 0 && ret <= 4096) { return null; }
1658                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1659                 if (this != null) { this.ptrs_to.add(temporary_channel_id); };
1660                 return ret_hu_conv;
1661         }
1662
1663         /**
1664          * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
1665          * it as confirmed immediately.
1666          * 
1667          * The `user_channel_id` parameter will be provided back in
1668          * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
1669          * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
1670          * 
1671          * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
1672          * and (if the counterparty agrees), enables forwarding of payments immediately.
1673          * 
1674          * This fully trusts that the counterparty has honestly and correctly constructed the funding
1675          * transaction and blindly assumes that it will eventually confirm.
1676          * 
1677          * If it does not confirm before we decide to close the channel, or if the funding transaction
1678          * does not pay to the correct script the correct amount, *you will lose funds*.
1679          * 
1680          * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
1681          * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
1682          */
1683         public Result_NoneAPIErrorZ accept_inbound_channel_from_trusted_peer_0conf(org.ldk.structs.ChannelId temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
1684                 long ret = bindings.ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this.ptr, temporary_channel_id.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
1685                 Reference.reachabilityFence(this);
1686                 Reference.reachabilityFence(temporary_channel_id);
1687                 Reference.reachabilityFence(counterparty_node_id);
1688                 Reference.reachabilityFence(user_channel_id);
1689                 if (ret >= 0 && ret <= 4096) { return null; }
1690                 Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
1691                 if (this != null) { this.ptrs_to.add(temporary_channel_id); };
1692                 return ret_hu_conv;
1693         }
1694
1695         /**
1696          * Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
1697          * [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer will
1698          * not have an expiration unless otherwise set on the builder.
1699          * 
1700          * # Privacy
1701          * 
1702          * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the offer.
1703          * However, if one is not found, uses a one-hop [`BlindedPath`] with
1704          * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case,
1705          * the node must be announced, otherwise, there is no way to find a path to the introduction in
1706          * order to send the [`InvoiceRequest`].
1707          * 
1708          * Also, uses a derived signing pubkey in the offer for recipient privacy.
1709          * 
1710          * # Limitations
1711          * 
1712          * Requires a direct connection to the introduction node in the responding [`InvoiceRequest`]'s
1713          * reply path.
1714          * 
1715          * # Errors
1716          * 
1717          * Errors if the parameterized [`Router`] is unable to create a blinded path for the offer.
1718          * 
1719          * [`Offer`]: crate::offers::offer::Offer
1720          * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
1721          */
1722         public Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ create_offer_builder() {
1723                 long ret = bindings.ChannelManager_create_offer_builder(this.ptr);
1724                 Reference.reachabilityFence(this);
1725                 if (ret >= 0 && ret <= 4096) { return null; }
1726                 Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ ret_hu_conv = Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
1727                 return ret_hu_conv;
1728         }
1729
1730         /**
1731          * Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
1732          * [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund.
1733          * 
1734          * # Payment
1735          * 
1736          * The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
1737          * See [Avoiding Duplicate Payments] for other requirements once the payment has been sent.
1738          * 
1739          * The builder will have the provided expiration set. Any changes to the expiration on the
1740          * returned builder will not be honored by [`ChannelManager`]. For `no-std`, the highest seen
1741          * block time minus two hours is used for the current time when determining if the refund has
1742          * expired.
1743          * 
1744          * To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the
1745          * invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail
1746          * with an [`Event::InvoiceRequestFailed`].
1747          * 
1748          * If `max_total_routing_fee_msat` is not specified, The default from
1749          * [`RouteParameters::from_payment_params_and_value`] is applied.
1750          * 
1751          * # Privacy
1752          * 
1753          * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the refund.
1754          * However, if one is not found, uses a one-hop [`BlindedPath`] with
1755          * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case,
1756          * the node must be announced, otherwise, there is no way to find a path to the introduction in
1757          * order to send the [`Bolt12Invoice`].
1758          * 
1759          * Also, uses a derived payer id in the refund for payer privacy.
1760          * 
1761          * # Limitations
1762          * 
1763          * Requires a direct connection to an introduction node in the responding
1764          * [`Bolt12Invoice::payment_paths`].
1765          * 
1766          * # Errors
1767          * 
1768          * Errors if:
1769          * - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
1770          * - `amount_msats` is invalid, or
1771          * - the parameterized [`Router`] is unable to create a blinded path for the refund.
1772          * 
1773          * [`Refund`]: crate::offers::refund::Refund
1774          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1775          * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
1776          * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
1777          */
1778         public Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ create_refund_builder(long amount_msats, long absolute_expiry, byte[] payment_id, org.ldk.structs.Retry retry_strategy, org.ldk.structs.Option_u64Z max_total_routing_fee_msat) {
1779                 long ret = bindings.ChannelManager_create_refund_builder(this.ptr, amount_msats, absolute_expiry, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, max_total_routing_fee_msat.ptr);
1780                 Reference.reachabilityFence(this);
1781                 Reference.reachabilityFence(amount_msats);
1782                 Reference.reachabilityFence(absolute_expiry);
1783                 Reference.reachabilityFence(payment_id);
1784                 Reference.reachabilityFence(retry_strategy);
1785                 Reference.reachabilityFence(max_total_routing_fee_msat);
1786                 if (ret >= 0 && ret <= 4096) { return null; }
1787                 Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ ret_hu_conv = Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
1788                 if (this != null) { this.ptrs_to.add(retry_strategy); };
1789                 if (this != null) { this.ptrs_to.add(max_total_routing_fee_msat); };
1790                 return ret_hu_conv;
1791         }
1792
1793         /**
1794          * Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and
1795          * enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual
1796          * [`Bolt12Invoice`] once it is received.
1797          * 
1798          * Uses [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is recognized by
1799          * the [`ChannelManager`] when handling a [`Bolt12Invoice`] message in response to the request.
1800          * The optional parameters are used in the builder, if `Some`:
1801          * - `quantity` for [`InvoiceRequest::quantity`] which must be set if
1802          * [`Offer::expects_quantity`] is `true`.
1803          * - `amount_msats` if overpaying what is required for the given `quantity` is desired, and
1804          * - `payer_note` for [`InvoiceRequest::payer_note`].
1805          * 
1806          * If `max_total_routing_fee_msat` is not specified, The default from
1807          * [`RouteParameters::from_payment_params_and_value`] is applied.
1808          * 
1809          * # Payment
1810          * 
1811          * The provided `payment_id` is used to ensure that only one invoice is paid for the request
1812          * when received. See [Avoiding Duplicate Payments] for other requirements once the payment has
1813          * been sent.
1814          * 
1815          * To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the
1816          * invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the
1817          * payment will fail with an [`Event::InvoiceRequestFailed`].
1818          * 
1819          * # Privacy
1820          * 
1821          * Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`]
1822          * as the introduction node and a derived payer id for payer privacy. As such, currently, the
1823          * node must be announced. Otherwise, there is no way to find a path to the introduction node
1824          * in order to send the [`Bolt12Invoice`].
1825          * 
1826          * # Limitations
1827          * 
1828          * Requires a direct connection to an introduction node in [`Offer::paths`] or to
1829          * [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding
1830          * [`Bolt12Invoice::payment_paths`].
1831          * 
1832          * # Errors
1833          * 
1834          * Errors if:
1835          * - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
1836          * - the provided parameters are invalid for the offer,
1837          * - the offer is for an unsupported chain, or
1838          * - the parameterized [`Router`] is unable to create a blinded reply path for the invoice
1839          * request.
1840          * 
1841          * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
1842          * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
1843          * [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note
1844          * [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder
1845          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1846          * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
1847          * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
1848          */
1849         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) {
1850                 long ret = bindings.ChannelManager_pay_for_offer(this.ptr, offer.ptr, quantity.ptr, amount_msats.ptr, payer_note.ptr, InternalUtils.check_arr_len(payment_id, 32), retry_strategy.ptr, max_total_routing_fee_msat.ptr);
1851                 Reference.reachabilityFence(this);
1852                 Reference.reachabilityFence(offer);
1853                 Reference.reachabilityFence(quantity);
1854                 Reference.reachabilityFence(amount_msats);
1855                 Reference.reachabilityFence(payer_note);
1856                 Reference.reachabilityFence(payment_id);
1857                 Reference.reachabilityFence(retry_strategy);
1858                 Reference.reachabilityFence(max_total_routing_fee_msat);
1859                 if (ret >= 0 && ret <= 4096) { return null; }
1860                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
1861                 if (this != null) { this.ptrs_to.add(offer); };
1862                 if (this != null) { this.ptrs_to.add(quantity); };
1863                 if (this != null) { this.ptrs_to.add(amount_msats); };
1864                 if (this != null) { this.ptrs_to.add(payer_note); };
1865                 if (this != null) { this.ptrs_to.add(retry_strategy); };
1866                 if (this != null) { this.ptrs_to.add(max_total_routing_fee_msat); };
1867                 return ret_hu_conv;
1868         }
1869
1870         /**
1871          * Creates a [`Bolt12Invoice`] for a [`Refund`] and enqueues it to be sent via an onion
1872          * message.
1873          * 
1874          * The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a
1875          * [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding
1876          * [`PaymentPreimage`]. It is returned purely for informational purposes.
1877          * 
1878          * # Limitations
1879          * 
1880          * Requires a direct connection to an introduction node in [`Refund::paths`] or to
1881          * [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
1882          * node meeting the aforementioned criteria, but there's no guarantee that they will be
1883          * received and no retries will be made.
1884          * 
1885          * # Errors
1886          * 
1887          * Errors if:
1888          * - the refund is for an unsupported chain, or
1889          * - the parameterized [`Router`] is unable to create a blinded payment path or reply path for
1890          * the invoice.
1891          * 
1892          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
1893          */
1894         public Result_Bolt12InvoiceBolt12SemanticErrorZ request_refund_payment(org.ldk.structs.Refund refund) {
1895                 long ret = bindings.ChannelManager_request_refund_payment(this.ptr, refund.ptr);
1896                 Reference.reachabilityFence(this);
1897                 Reference.reachabilityFence(refund);
1898                 if (ret >= 0 && ret <= 4096) { return null; }
1899                 Result_Bolt12InvoiceBolt12SemanticErrorZ ret_hu_conv = Result_Bolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret);
1900                 if (this != null) { this.ptrs_to.add(refund); };
1901                 return ret_hu_conv;
1902         }
1903
1904         /**
1905          * Gets a payment secret and payment hash for use in an invoice given to a third party wishing
1906          * to pay us.
1907          * 
1908          * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
1909          * [`PaymentHash`] and [`PaymentPreimage`] for you.
1910          * 
1911          * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`] event, which
1912          * will have the [`PaymentClaimable::purpose`] return `Some` for [`PaymentPurpose::preimage`]. That
1913          * should then be passed directly to [`claim_funds`].
1914          * 
1915          * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
1916          * 
1917          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
1918          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
1919          * 
1920          * # Note
1921          * 
1922          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
1923          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
1924          * 
1925          * Errors if `min_value_msat` is greater than total bitcoin supply.
1926          * 
1927          * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
1928          * on versions of LDK prior to 0.0.114.
1929          * 
1930          * [`claim_funds`]: Self::claim_funds
1931          * [`PaymentClaimable`]: events::Event::PaymentClaimable
1932          * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose
1933          * [`PaymentPurpose::preimage`]: events::PaymentPurpose::preimage
1934          * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
1935          */
1936         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) {
1937                 long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
1938                 Reference.reachabilityFence(this);
1939                 Reference.reachabilityFence(min_value_msat);
1940                 Reference.reachabilityFence(invoice_expiry_delta_secs);
1941                 Reference.reachabilityFence(min_final_cltv_expiry_delta);
1942                 if (ret >= 0 && ret <= 4096) { return null; }
1943                 Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
1944                 if (this != null) { this.ptrs_to.add(min_value_msat); };
1945                 if (this != null) { this.ptrs_to.add(min_final_cltv_expiry_delta); };
1946                 return ret_hu_conv;
1947         }
1948
1949         /**
1950          * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is
1951          * stored external to LDK.
1952          * 
1953          * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a
1954          * payment secret fetched via this method or [`create_inbound_payment`], and which is at least
1955          * the `min_value_msat` provided here, if one is provided.
1956          * 
1957          * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though
1958          * note that LDK will not stop you from registering duplicate payment hashes for inbound
1959          * payments.
1960          * 
1961          * `min_value_msat` should be set if the invoice being generated contains a value. Any payment
1962          * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
1963          * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the
1964          * sender \"proof-of-payment\" unless they have paid the required amount.
1965          * 
1966          * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for
1967          * in excess of the current time. This should roughly match the expiry time set in the invoice.
1968          * After this many seconds, we will remove the inbound payment, resulting in any attempts to
1969          * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for
1970          * invoices when no timeout is set.
1971          * 
1972          * Note that we use block header time to time-out pending inbound payments (with some margin
1973          * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will
1974          * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry.
1975          * If you need exact expiry semantics, you should enforce them upon receipt of
1976          * [`PaymentClaimable`].
1977          * 
1978          * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta`
1979          * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
1980          * 
1981          * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
1982          * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
1983          * 
1984          * # Note
1985          * 
1986          * If you register an inbound payment with this method, then serialize the `ChannelManager`, then
1987          * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received.
1988          * 
1989          * Errors if `min_value_msat` is greater than total bitcoin supply.
1990          * 
1991          * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
1992          * on versions of LDK prior to 0.0.114.
1993          * 
1994          * [`create_inbound_payment`]: Self::create_inbound_payment
1995          * [`PaymentClaimable`]: events::Event::PaymentClaimable
1996          */
1997         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) {
1998                 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, min_final_cltv_expiry.ptr);
1999                 Reference.reachabilityFence(this);
2000                 Reference.reachabilityFence(payment_hash);
2001                 Reference.reachabilityFence(min_value_msat);
2002                 Reference.reachabilityFence(invoice_expiry_delta_secs);
2003                 Reference.reachabilityFence(min_final_cltv_expiry);
2004                 if (ret >= 0 && ret <= 4096) { return null; }
2005                 Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
2006                 if (this != null) { this.ptrs_to.add(min_value_msat); };
2007                 if (this != null) { this.ptrs_to.add(min_final_cltv_expiry); };
2008                 return ret_hu_conv;
2009         }
2010
2011         /**
2012          * Gets an LDK-generated payment preimage from a payment hash and payment secret that were
2013          * previously returned from [`create_inbound_payment`].
2014          * 
2015          * [`create_inbound_payment`]: Self::create_inbound_payment
2016          */
2017         public Result_ThirtyTwoBytesAPIErrorZ get_payment_preimage(byte[] payment_hash, byte[] payment_secret) {
2018                 long ret = bindings.ChannelManager_get_payment_preimage(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
2019                 Reference.reachabilityFence(this);
2020                 Reference.reachabilityFence(payment_hash);
2021                 Reference.reachabilityFence(payment_secret);
2022                 if (ret >= 0 && ret <= 4096) { return null; }
2023                 Result_ThirtyTwoBytesAPIErrorZ ret_hu_conv = Result_ThirtyTwoBytesAPIErrorZ.constr_from_ptr(ret);
2024                 return ret_hu_conv;
2025         }
2026
2027         /**
2028          * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
2029          * are used when constructing the phantom invoice's route hints.
2030          * 
2031          * [phantom node payments]: crate::sign::PhantomKeysManager
2032          */
2033         public long get_phantom_scid() {
2034                 long ret = bindings.ChannelManager_get_phantom_scid(this.ptr);
2035                 Reference.reachabilityFence(this);
2036                 return ret;
2037         }
2038
2039         /**
2040          * Gets route hints for use in receiving [phantom node payments].
2041          * 
2042          * [phantom node payments]: crate::sign::PhantomKeysManager
2043          */
2044         public PhantomRouteHints get_phantom_route_hints() {
2045                 long ret = bindings.ChannelManager_get_phantom_route_hints(this.ptr);
2046                 Reference.reachabilityFence(this);
2047                 if (ret >= 0 && ret <= 4096) { return null; }
2048                 org.ldk.structs.PhantomRouteHints ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PhantomRouteHints(null, ret); }
2049                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2050                 return ret_hu_conv;
2051         }
2052
2053         /**
2054          * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are
2055          * used when constructing the route hints for HTLCs intended to be intercepted. See
2056          * [`ChannelManager::forward_intercepted_htlc`].
2057          * 
2058          * Note that this method is not guaranteed to return unique values, you may need to call it a few
2059          * times to get a unique scid.
2060          */
2061         public long get_intercept_scid() {
2062                 long ret = bindings.ChannelManager_get_intercept_scid(this.ptr);
2063                 Reference.reachabilityFence(this);
2064                 return ret;
2065         }
2066
2067         /**
2068          * Gets inflight HTLC information by processing pending outbound payments that are in
2069          * our channels. May be used during pathfinding to account for in-use channel liquidity.
2070          */
2071         public InFlightHtlcs compute_inflight_htlcs() {
2072                 long ret = bindings.ChannelManager_compute_inflight_htlcs(this.ptr);
2073                 Reference.reachabilityFence(this);
2074                 if (ret >= 0 && ret <= 4096) { return null; }
2075                 org.ldk.structs.InFlightHtlcs ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InFlightHtlcs(null, ret); }
2076                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2077                 return ret_hu_conv;
2078         }
2079
2080         /**
2081          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
2082          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
2083          */
2084         public MessageSendEventsProvider as_MessageSendEventsProvider() {
2085                 long ret = bindings.ChannelManager_as_MessageSendEventsProvider(this.ptr);
2086                 Reference.reachabilityFence(this);
2087                 if (ret >= 0 && ret <= 4096) { return null; }
2088                 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
2089                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2090                 return ret_hu_conv;
2091         }
2092
2093         /**
2094          * Constructs a new EventsProvider which calls the relevant methods on this_arg.
2095          * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is
2096          */
2097         public EventsProvider as_EventsProvider() {
2098                 long ret = bindings.ChannelManager_as_EventsProvider(this.ptr);
2099                 Reference.reachabilityFence(this);
2100                 if (ret >= 0 && ret <= 4096) { return null; }
2101                 EventsProvider ret_hu_conv = new EventsProvider(null, ret);
2102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2103                 return ret_hu_conv;
2104         }
2105
2106         /**
2107          * Constructs a new Listen which calls the relevant methods on this_arg.
2108          * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is
2109          */
2110         public Listen as_Listen() {
2111                 long ret = bindings.ChannelManager_as_Listen(this.ptr);
2112                 Reference.reachabilityFence(this);
2113                 if (ret >= 0 && ret <= 4096) { return null; }
2114                 Listen ret_hu_conv = new Listen(null, ret);
2115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2116                 return ret_hu_conv;
2117         }
2118
2119         /**
2120          * Constructs a new Confirm which calls the relevant methods on this_arg.
2121          * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is
2122          */
2123         public Confirm as_Confirm() {
2124                 long ret = bindings.ChannelManager_as_Confirm(this.ptr);
2125                 Reference.reachabilityFence(this);
2126                 if (ret >= 0 && ret <= 4096) { return null; }
2127                 Confirm ret_hu_conv = new Confirm(null, ret);
2128                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2129                 return ret_hu_conv;
2130         }
2131
2132         /**
2133          * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or
2134          * may have events that need processing.
2135          * 
2136          * In order to check if this [`ChannelManager`] needs persisting, call
2137          * [`Self::get_and_clear_needs_persistence`].
2138          * 
2139          * Note that callbacks registered on the [`Future`] MUST NOT call back into this
2140          * [`ChannelManager`] and should instead register actions to be taken later.
2141          */
2142         public Future get_event_or_persistence_needed_future() {
2143                 long ret = bindings.ChannelManager_get_event_or_persistence_needed_future(this.ptr);
2144                 Reference.reachabilityFence(this);
2145                 if (ret >= 0 && ret <= 4096) { return null; }
2146                 org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
2147                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2148                 return ret_hu_conv;
2149         }
2150
2151         /**
2152          * Returns true if this [`ChannelManager`] needs to be persisted.
2153          * 
2154          * See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that
2155          * indicates this should be checked.
2156          */
2157         public boolean get_and_clear_needs_persistence() {
2158                 boolean ret = bindings.ChannelManager_get_and_clear_needs_persistence(this.ptr);
2159                 Reference.reachabilityFence(this);
2160                 return ret;
2161         }
2162
2163         /**
2164          * Gets the latest best block which was connected either via the [`chain::Listen`] or
2165          * [`chain::Confirm`] interfaces.
2166          */
2167         public BestBlock current_best_block() {
2168                 long ret = bindings.ChannelManager_current_best_block(this.ptr);
2169                 Reference.reachabilityFence(this);
2170                 if (ret >= 0 && ret <= 4096) { return null; }
2171                 org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
2172                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2173                 return ret_hu_conv;
2174         }
2175
2176         /**
2177          * Fetches the set of [`NodeFeatures`] flags that are provided by or required by
2178          * [`ChannelManager`].
2179          */
2180         public NodeFeatures node_features() {
2181                 long ret = bindings.ChannelManager_node_features(this.ptr);
2182                 Reference.reachabilityFence(this);
2183                 if (ret >= 0 && ret <= 4096) { return null; }
2184                 org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
2185                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2186                 return ret_hu_conv;
2187         }
2188
2189         /**
2190          * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by
2191          * [`ChannelManager`].
2192          */
2193         public ChannelFeatures channel_features() {
2194                 long ret = bindings.ChannelManager_channel_features(this.ptr);
2195                 Reference.reachabilityFence(this);
2196                 if (ret >= 0 && ret <= 4096) { return null; }
2197                 org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
2198                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2199                 return ret_hu_conv;
2200         }
2201
2202         /**
2203          * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by
2204          * [`ChannelManager`].
2205          */
2206         public ChannelTypeFeatures channel_type_features() {
2207                 long ret = bindings.ChannelManager_channel_type_features(this.ptr);
2208                 Reference.reachabilityFence(this);
2209                 if (ret >= 0 && ret <= 4096) { return null; }
2210                 org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
2211                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2212                 return ret_hu_conv;
2213         }
2214
2215         /**
2216          * Fetches the set of [`InitFeatures`] flags that are provided by or required by
2217          * [`ChannelManager`].
2218          */
2219         public InitFeatures init_features() {
2220                 long ret = bindings.ChannelManager_init_features(this.ptr);
2221                 Reference.reachabilityFence(this);
2222                 if (ret >= 0 && ret <= 4096) { return null; }
2223                 org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
2224                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2225                 return ret_hu_conv;
2226         }
2227
2228         /**
2229          * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg.
2230          * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is
2231          */
2232         public ChannelMessageHandler as_ChannelMessageHandler() {
2233                 long ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr);
2234                 Reference.reachabilityFence(this);
2235                 if (ret >= 0 && ret <= 4096) { return null; }
2236                 ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret);
2237                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2238                 return ret_hu_conv;
2239         }
2240
2241         /**
2242          * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg.
2243          * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is
2244          */
2245         public OffersMessageHandler as_OffersMessageHandler() {
2246                 long ret = bindings.ChannelManager_as_OffersMessageHandler(this.ptr);
2247                 Reference.reachabilityFence(this);
2248                 if (ret >= 0 && ret <= 4096) { return null; }
2249                 OffersMessageHandler ret_hu_conv = new OffersMessageHandler(null, ret);
2250                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2251                 return ret_hu_conv;
2252         }
2253
2254         /**
2255          * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg.
2256          * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is
2257          */
2258         public NodeIdLookUp as_NodeIdLookUp() {
2259                 long ret = bindings.ChannelManager_as_NodeIdLookUp(this.ptr);
2260                 Reference.reachabilityFence(this);
2261                 if (ret >= 0 && ret <= 4096) { return null; }
2262                 NodeIdLookUp ret_hu_conv = new NodeIdLookUp(null, ret);
2263                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
2264                 return ret_hu_conv;
2265         }
2266
2267         /**
2268          * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
2269          */
2270         public byte[] write() {
2271                 byte[] ret = bindings.ChannelManager_write(this.ptr);
2272                 Reference.reachabilityFence(this);
2273                 return ret;
2274         }
2275
2276 }