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