[C#] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelManager.cs
index afb6d30b9e715c8adbb8f38cec6ab12038d78c1e..0382bd758d0c30bc706848599917930dab733218 100644 (file)
@@ -7,42 +7,716 @@ namespace org { namespace ldk { namespace structs {
 
 
 /**
- * Manager which keeps track of a number of channels and sends messages to the appropriate
- * channel, also tracking HTLC preimages and forwarding onion packets appropriately.
+ * A lightning node's channel state machine and payment management logic, which facilitates
+ * sending, forwarding, and receiving payments through lightning channels.
  * 
- * Implements ChannelMessageHandler, handling the multi-channel parts and passing things through
- * to individual Channels.
+ * [`ChannelManager`] is parameterized by a number of components to achieve this.
+ * - [`chain::Watch`] (typically [`ChainMonitor`]) for on-chain monitoring and enforcement of each
+ * channel
+ * - [`BroadcasterInterface`] for broadcasting transactions related to opening, funding, and
+ * closing channels
+ * - [`EntropySource`] for providing random data needed for cryptographic operations
+ * - [`NodeSigner`] for cryptographic operations scoped to the node
+ * - [`SignerProvider`] for providing signers whose operations are scoped to individual channels
+ * - [`FeeEstimator`] to determine transaction fee rates needed to have a transaction mined in a
+ * timely manner
+ * - [`Router`] for finding payment paths when initiating and retrying payments
+ * - [`Logger`] for logging operational information of varying degrees
  * 
- * Implements Writeable to write out all channel state to disk. Implies peer_disconnected() for
+ * Additionally, it implements the following traits:
+ * - [`ChannelMessageHandler`] to handle off-chain channel activity from peers
+ * - [`MessageSendEventsProvider`] to similarly send such messages to peers
+ * - [`OffersMessageHandler`] for BOLT 12 message handling and sending
+ * - [`EventsProvider`] to generate user-actionable [`Event`]s
+ * - [`chain::Listen`] and [`chain::Confirm`] for notification of on-chain activity
+ * 
+ * Thus, [`ChannelManager`] is typically used to parameterize a [`MessageHandler`] and an
+ * [`OnionMessenger`]. The latter is required to support BOLT 12 functionality.
+ * 
+ * # `ChannelManager` vs `ChannelMonitor`
+ * 
+ * It's important to distinguish between the *off-chain* management and *on-chain* enforcement of
+ * lightning channels. [`ChannelManager`] exchanges messages with peers to manage the off-chain
+ * state of each channel. During this process, it generates a [`ChannelMonitor`] for each channel
+ * and a [`ChannelMonitorUpdate`] for each relevant change, notifying its parameterized
+ * [`chain::Watch`] of them.
+ * 
+ * An implementation of [`chain::Watch`], such as [`ChainMonitor`], is responsible for aggregating
+ * these [`ChannelMonitor`]s and applying any [`ChannelMonitorUpdate`]s to them. It then monitors
+ * for any pertinent on-chain activity, enforcing claims as needed.
+ * 
+ * This division of off-chain management and on-chain enforcement allows for interesting node
+ * setups. For instance, on-chain enforcement could be moved to a separate host or have added
+ * redundancy, possibly as a watchtower. See [`chain::Watch`] for the relevant interface.
+ * 
+ * # Initialization
+ * 
+ * Use [`ChannelManager::new`] with the most recent [`BlockHash`] when creating a fresh instance.
+ * Otherwise, if restarting, construct [`ChannelManagerReadArgs`] with the necessary parameters and
+ * references to any deserialized [`ChannelMonitor`]s that were previously persisted. Use this to
+ * deserialize the [`ChannelManager`] and feed it any new chain data since it was last online, as
+ * detailed in the [`ChannelManagerReadArgs`] documentation.
+ * 
+ * ```
+ * use bitcoin::BlockHash;
+ * use bitcoin::network::constants::Network;
+ * use lightning::chain::BestBlock;
+ * # use lightning::chain::channelmonitor::ChannelMonitor;
+ * use lightning::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs};
+ * # use lightning::routing::gossip::NetworkGraph;
+ * use lightning::util::config::UserConfig;
+ * use lightning::util::ser::ReadableArgs;
+ * 
+ * # fn read_channel_monitors() -> Vec<ChannelMonitor<lightning::sign::InMemorySigner>> { vec![] }
+ * # fn example<
+ * #     'a,
+ * #     L: lightning::util::logger::Logger,
+ * #     ES: lightning::sign::EntropySource,
+ * #     S: for <'b> lightning::routing::scoring::LockableScore<'b, ScoreLookUp = SL>,
+ * #     SL: lightning::routing::scoring::ScoreLookUp<ScoreParams = SP>,
+ * #     SP: Sized,
+ * #     R: lightning::io::Read,
+ * # >(
+ * #     fee_estimator: &dyn lightning::chain::chaininterface::FeeEstimator,
+ * #     chain_monitor: &dyn lightning::chain::Watch<lightning::sign::InMemorySigner>,
+ * #     tx_broadcaster: &dyn lightning::chain::chaininterface::BroadcasterInterface,
+ * #     router: &lightning::routing::router::DefaultRouter<&NetworkGraph<&'a L>, &'a L, &ES, &S, SP, SL>,
+ * #     logger: &L,
+ * #     entropy_source: &ES,
+ * #     node_signer: &dyn lightning::sign::NodeSigner,
+ * #     signer_provider: &lightning::sign::DynSignerProvider,
+ * #     best_block: lightning::chain::BestBlock,
+ * #     current_timestamp: u32,
+ * #     mut reader: R,
+ * # ) -> Result<(), lightning::ln::msgs::DecodeError> {
+ * Fresh start with no channels
+ * let params = ChainParameters {
+ * network: Network::Bitcoin,
+ * best_block,
+ * };
+ * let default_config = UserConfig::default();
+ * let channel_manager = ChannelManager::new(
+ * fee_estimator, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer,
+ * signer_provider, default_config, params, current_timestamp
+ * );
+ * 
+ * Restart from deserialized data
+ * let mut channel_monitors = read_channel_monitors();
+ * let args = ChannelManagerReadArgs::new(
+ * entropy_source, node_signer, signer_provider, fee_estimator, chain_monitor, tx_broadcaster,
+ * router, logger, default_config, channel_monitors.iter_mut().collect()
+ * );
+ * let (block_hash, channel_manager) =
+ * <(BlockHash, ChannelManager<_, _, _, _, _, _, _, _>)>::read(&mut reader, args)?;
+ * 
+ * Update the ChannelManager and ChannelMonitors with the latest chain data
+ * ...
+ * 
+ * Move the monitors to the ChannelManager's chain::Watch parameter
+ * for monitor in channel_monitors {
+ * chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor);
+ * }
+ * # Ok(())
+ * # }
+ * ```
+ * 
+ * # Operation
+ * 
+ * The following is required for [`ChannelManager`] to function properly:
+ * - Handle messages from peers using its [`ChannelMessageHandler`] implementation (typically
+ * called by [`PeerManager::read_event`] when processing network I/O)
+ * - Send messages to peers obtained via its [`MessageSendEventsProvider`] implementation
+ * (typically initiated when [`PeerManager::process_events`] is called)
+ * - Feed on-chain activity using either its [`chain::Listen`] or [`chain::Confirm`] implementation
+ * as documented by those traits
+ * - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly
+ * every minute
+ * - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a
+ * [`Persister`] such as a [`KVStore`] implementation
+ * - Handle [`Event`]s obtained via its [`EventsProvider`] implementation
+ * 
+ * The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining
+ * when the last two requirements need to be checked.
+ * 
+ * The [`lightning-block-sync`] and [`lightning-transaction-sync`] crates provide utilities that
+ * simplify feeding in on-chain activity using the [`chain::Listen`] and [`chain::Confirm`] traits,
+ * respectively. The remaining requirements can be met using the [`lightning-background-processor`]
+ * crate. For languages other than Rust, the availability of similar utilities may vary.
+ * 
+ * # Channels
+ * 
+ * [`ChannelManager`]'s primary function involves managing a channel state. Without channels,
+ * payments can't be sent. Use [`list_channels`] or [`list_usable_channels`] for a snapshot of the
+ * currently open channels.
+ * 
+ * ```
+ * # use lightning::ln::channelmanager::AChannelManager;
+ * #
+ * # fn example<T: AChannelManager>(channel_manager: T) {
+ * # let channel_manager = channel_manager.get_cm();
+ * let channels = channel_manager.list_usable_channels();
+ * for details in channels {
+ * println!(\"{:?}\", details);
+ * }
+ * # }
+ * ```
+ * 
+ * Each channel is identified using a [`ChannelId`], which will change throughout the channel's
+ * life cycle. Additionally, channels are assigned a `user_channel_id`, which is given in
+ * [`Event`]s associated with the channel and serves as a fixed identifier but is otherwise unused
+ * by [`ChannelManager`].
+ * 
+ * ## Opening Channels
+ * 
+ * To an open a channel with a peer, call [`create_channel`]. This will initiate the process of
+ * opening an outbound channel, which requires self-funding when handling
+ * [`Event::FundingGenerationReady`].
+ * 
+ * ```
+ * # use bitcoin::{ScriptBuf, Transaction};
+ * # use bitcoin::secp256k1::PublicKey;
+ * # use lightning::ln::channelmanager::AChannelManager;
+ * # use lightning::events::{Event, EventsProvider};
+ * #
+ * # trait Wallet {
+ * #     fn create_funding_transaction(
+ * #         &self, _amount_sats: u64, _output_script: ScriptBuf
+ * #     ) -> Transaction;
+ * # }
+ * #
+ * # fn example<T: AChannelManager, W: Wallet>(channel_manager: T, wallet: W, peer_id: PublicKey) {
+ * # let channel_manager = channel_manager.get_cm();
+ * let value_sats = 1_000_000;
+ * let push_msats = 10_000_000;
+ * match channel_manager.create_channel(peer_id, value_sats, push_msats, 42, None, None) {
+ * Ok(channel_id) => println!(\"Opening channel {}\", channel_id),
+ * Err(e) => println!(\"Error opening channel: {:?}\", e),
+ * }
+ * 
+ * On the event processing thread once the peer has responded
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::FundingGenerationReady {
+ * temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script,
+ * user_channel_id, ..
+ * } => {
+ * assert_eq!(user_channel_id, 42);
+ * let funding_transaction = wallet.create_funding_transaction(
+ * channel_value_satoshis, output_script
+ * );
+ * match channel_manager.funding_transaction_generated(
+ * &temporary_channel_id, &counterparty_node_id, funding_transaction
+ * ) {
+ * Ok(()) => println!(\"Funding channel {}\", temporary_channel_id),
+ * Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e),
+ * }
+ * },
+ * Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => {
+ * assert_eq!(user_channel_id, 42);
+ * println!(
+ * \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id,
+ * former_temporary_channel_id.unwrap()
+ * );
+ * },
+ * Event::ChannelReady { channel_id, user_channel_id, .. } => {
+ * assert_eq!(user_channel_id, 42);
+ * println!(\"Channel {} ready\", channel_id);
+ * },
+ * ...
+ * #     _ => {},
+ * });
+ * # }
+ * ```
+ * 
+ * ## Accepting Channels
+ * 
+ * Inbound channels are initiated by peers and are automatically accepted unless [`ChannelManager`]
+ * has [`UserConfig::manually_accept_inbound_channels`] set. In that case, the channel may be
+ * either accepted or rejected when handling [`Event::OpenChannelRequest`].
+ * 
+ * ```
+ * # use bitcoin::secp256k1::PublicKey;
+ * # use lightning::ln::channelmanager::AChannelManager;
+ * # use lightning::events::{Event, EventsProvider};
+ * #
+ * # fn is_trusted(counterparty_node_id: PublicKey) -> bool {
+ * #     // ...
+ * #     unimplemented!()
+ * # }
+ * #
+ * # fn example<T: AChannelManager>(channel_manager: T) {
+ * # let channel_manager = channel_manager.get_cm();
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, ..  } => {
+ * if !is_trusted(counterparty_node_id) {
+ * match channel_manager.force_close_without_broadcasting_txn(
+ * &temporary_channel_id, &counterparty_node_id
+ * ) {
+ * Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id),
+ * Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e),
+ * }
+ * return;
+ * }
+ * 
+ * let user_channel_id = 43;
+ * match channel_manager.accept_inbound_channel(
+ * &temporary_channel_id, &counterparty_node_id, user_channel_id
+ * ) {
+ * Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id),
+ * Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e),
+ * }
+ * },
+ * ...
+ * #     _ => {},
+ * });
+ * # }
+ * ```
+ * 
+ * ## Closing Channels
+ * 
+ * There are two ways to close a channel: either cooperatively using [`close_channel`] or
+ * unilaterally using [`force_close_broadcasting_latest_txn`]. The former is ideal as it makes for
+ * lower fees and immediate access to funds. However, the latter may be necessary if the
+ * counterparty isn't behaving properly or has gone offline. [`Event::ChannelClosed`] is generated
+ * once the channel has been closed successfully.
+ * 
+ * ```
+ * # use bitcoin::secp256k1::PublicKey;
+ * # use lightning::ln::types::ChannelId;
+ * # use lightning::ln::channelmanager::AChannelManager;
+ * # use lightning::events::{Event, EventsProvider};
+ * #
+ * # fn example<T: AChannelManager>(
+ * #     channel_manager: T, channel_id: ChannelId, counterparty_node_id: PublicKey
+ * # ) {
+ * # let channel_manager = channel_manager.get_cm();
+ * match channel_manager.close_channel(&channel_id, &counterparty_node_id) {
+ * Ok(()) => println!(\"Closing channel {}\", channel_id),
+ * Err(e) => println!(\"Error closing channel {}: {:?}\", channel_id, e),
+ * }
+ * 
+ * On the event processing thread
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::ChannelClosed { channel_id, user_channel_id, ..  } => {
+ * assert_eq!(user_channel_id, 42);
+ * println!(\"Channel {} closed\", channel_id);
+ * },
+ * ...
+ * #     _ => {},
+ * });
+ * # }
+ * ```
+ * 
+ * # Payments
+ * 
+ * [`ChannelManager`] is responsible for sending, forwarding, and receiving payments through its
+ * channels. A payment is typically initiated from a [BOLT 11] invoice or a [BOLT 12] offer, though
+ * spontaneous (i.e., keysend) payments are also possible. Incoming payments don't require
+ * maintaining any additional state as [`ChannelManager`] can reconstruct the [`PaymentPreimage`]
+ * from the [`PaymentSecret`]. Sending payments, however, require tracking in order to retry failed
+ * HTLCs.
+ * 
+ * After a payment is initiated, it will appear in [`list_recent_payments`] until a short time
+ * after either an [`Event::PaymentSent`] or [`Event::PaymentFailed`] is handled. Failed HTLCs
+ * for a payment will be retried according to the payment's [`Retry`] strategy or until
+ * [`abandon_payment`] is called.
+ * 
+ * ## BOLT 11 Invoices
+ * 
+ * The [`lightning-invoice`] crate is useful for creating BOLT 11 invoices. Specifically, use the
+ * functions in its `utils` module for constructing invoices that are compatible with
+ * [`ChannelManager`]. These functions serve as a convenience for building invoices with the
+ * [`PaymentHash`] and [`PaymentSecret`] returned from [`create_inbound_payment`]. To provide your
+ * own [`PaymentHash`], use [`create_inbound_payment_for_hash`] or the corresponding functions in
+ * the [`lightning-invoice`] `utils` module.
+ * 
+ * [`ChannelManager`] generates an [`Event::PaymentClaimable`] once the full payment has been
+ * received. Call [`claim_funds`] to release the [`PaymentPreimage`], which in turn will result in
+ * an [`Event::PaymentClaimed`].
+ * 
+ * ```
+ * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
+ * # use lightning::ln::channelmanager::AChannelManager;
+ * #
+ * # fn example<T: AChannelManager>(channel_manager: T) {
+ * # let channel_manager = channel_manager.get_cm();
+ * Or use utils::create_invoice_from_channelmanager
+ * let known_payment_hash = match channel_manager.create_inbound_payment(
+ * Some(10_000_000), 3600, None
+ * ) {
+ * Ok((payment_hash, _payment_secret)) => {
+ * println!(\"Creating inbound payment {}\", payment_hash);
+ * payment_hash
+ * },
+ * Err(()) => panic!(\"Error creating inbound payment\"),
+ * };
+ * 
+ * On the event processing thread
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
+ * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => {
+ * assert_eq!(payment_hash, known_payment_hash);
+ * println!(\"Claiming payment {}\", payment_hash);
+ * channel_manager.claim_funds(payment_preimage);
+ * },
+ * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => {
+ * println!(\"Unknown payment hash: {}\", payment_hash);
+ * },
+ * PaymentPurpose::SpontaneousPayment(payment_preimage) => {
+ * assert_ne!(payment_hash, known_payment_hash);
+ * println!(\"Claiming spontaneous payment {}\", payment_hash);
+ * channel_manager.claim_funds(payment_preimage);
+ * },
+ * ...
+ * #         _ => {},
+ * },
+ * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
+ * assert_eq!(payment_hash, known_payment_hash);
+ * println!(\"Claimed {} msats\", amount_msat);
+ * },
+ * ...
+ * #     _ => {},
+ * });
+ * # }
+ * ```
+ * 
+ * For paying an invoice, [`lightning-invoice`] provides a `payment` module with convenience
+ * functions for use with [`send_payment`].
+ * 
+ * ```
+ * # use lightning::events::{Event, EventsProvider};
+ * # use lightning::ln::types::PaymentHash;
+ * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, RecipientOnionFields, Retry};
+ * # use lightning::routing::router::RouteParameters;
+ * #
+ * # fn example<T: AChannelManager>(
+ * #     channel_manager: T, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields,
+ * #     route_params: RouteParameters, retry: Retry
+ * # ) {
+ * # let channel_manager = channel_manager.get_cm();
+ * let (payment_hash, recipient_onion, route_params) =
+ * payment::payment_parameters_from_invoice(&invoice);
+ * let payment_id = PaymentId([42; 32]);
+ * match channel_manager.send_payment(
+ * payment_hash, recipient_onion, payment_id, route_params, retry
+ * ) {
+ * Ok(()) => println!(\"Sending payment with hash {}\", payment_hash),
+ * Err(e) => println!(\"Failed sending payment with hash {}: {:?}\", payment_hash, e),
+ * }
+ * 
+ * let expected_payment_id = payment_id;
+ * let expected_payment_hash = payment_hash;
+ * assert!(
+ * channel_manager.list_recent_payments().iter().find(|details| matches!(
+ * details,
+ * RecentPaymentDetails::Pending {
+ * payment_id: expected_payment_id,
+ * payment_hash: expected_payment_hash,
+ * ..
+ * }
+ * )).is_some()
+ * );
+ * 
+ * On the event processing thread
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash),
+ * Event::PaymentFailed { payment_hash, .. } => println!(\"Failed paying {}\", payment_hash),
+ * ...
+ * #     _ => {},
+ * });
+ * # }
+ * ```
+ * 
+ * ## BOLT 12 Offers
+ * 
+ * The [`offers`] module is useful for creating BOLT 12 offers. An [`Offer`] is a precursor to a
+ * [`Bolt12Invoice`], which must first be requested by the payer. The interchange of these messages
+ * as defined in the specification is handled by [`ChannelManager`] and its implementation of
+ * [`OffersMessageHandler`]. However, this only works with an [`Offer`] created using a builder
+ * returned by [`create_offer_builder`]. With this approach, BOLT 12 offers and invoices are
+ * stateless just as BOLT 11 invoices are.
+ * 
+ * ```
+ * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
+ * # use lightning::ln::channelmanager::AChannelManager;
+ * # use lightning::offers::parse::Bolt12SemanticError;
+ * #
+ * # fn example<T: AChannelManager>(channel_manager: T) -> Result<(), Bolt12SemanticError> {
+ * # let channel_manager = channel_manager.get_cm();
+ * let offer = channel_manager
+ * .create_offer_builder()?
+ * # ;
+ * # // Needed for compiling for c_bindings
+ * # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into();
+ * # let offer = builder
+ * .description(\"coffee\".to_string())
+ * .amount_msats(10_000_000)
+ * .build()?;
+ * let bech32_offer = offer.to_string();
+ * 
+ * On the event processing thread
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
+ * PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => {
+ * println!(\"Claiming payment {}\", payment_hash);
+ * channel_manager.claim_funds(payment_preimage);
+ * },
+ * PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => {
+ * println!(\"Unknown payment hash: {}\", payment_hash);
+ * },
+ * ...
+ * #         _ => {},
+ * },
+ * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
+ * println!(\"Claimed {} msats\", amount_msat);
+ * },
+ * ...
+ * #     _ => {},
+ * });
+ * # Ok(())
+ * # }
+ * ```
+ * 
+ * Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`]
+ * and pays the [`Bolt12Invoice`] response. In addition to success and failure events,
+ * [`ChannelManager`] may also generate an [`Event::InvoiceRequestFailed`].
+ * 
+ * ```
+ * # use lightning::events::{Event, EventsProvider};
+ * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
+ * # use lightning::offers::offer::Offer;
+ * #
+ * # fn example<T: AChannelManager>(
+ * #     channel_manager: T, offer: &Offer, quantity: Option<u64>, amount_msats: Option<u64>,
+ * #     payer_note: Option<String>, retry: Retry, max_total_routing_fee_msat: Option<u64>
+ * # ) {
+ * # let channel_manager = channel_manager.get_cm();
+ * let payment_id = PaymentId([42; 32]);
+ * match channel_manager.pay_for_offer(
+ * offer, quantity, amount_msats, payer_note, payment_id, retry, max_total_routing_fee_msat
+ * ) {
+ * Ok(()) => println!(\"Requesting invoice for offer\"),
+ * Err(e) => println!(\"Unable to request invoice for offer: {:?}\", e),
+ * }
+ * 
+ * First the payment will be waiting on an invoice
+ * let expected_payment_id = payment_id;
+ * assert!(
+ * channel_manager.list_recent_payments().iter().find(|details| matches!(
+ * details,
+ * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id }
+ * )).is_some()
+ * );
+ * 
+ * Once the invoice is received, a payment will be sent
+ * assert!(
+ * channel_manager.list_recent_payments().iter().find(|details| matches!(
+ * details,
+ * RecentPaymentDetails::Pending { payment_id: expected_payment_id, ..  }
+ * )).is_some()
+ * );
+ * 
+ * On the event processing thread
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id),
+ * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
+ * Event::InvoiceRequestFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
+ * ...
+ * #     _ => {},
+ * });
+ * # }
+ * ```
+ * 
+ * ## BOLT 12 Refunds
+ * 
+ * A [`Refund`] is a request for an invoice to be paid. Like *paying* for an [`Offer`], *creating*
+ * a [`Refund`] involves maintaining state since it represents a future outbound payment.
+ * Therefore, use [`create_refund_builder`] when creating one, otherwise [`ChannelManager`] will
+ * refuse to pay any corresponding [`Bolt12Invoice`] that it receives.
+ * 
+ * ```
+ * # use core::time::Duration;
+ * # use lightning::events::{Event, EventsProvider};
+ * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry};
+ * # use lightning::offers::parse::Bolt12SemanticError;
+ * #
+ * # fn example<T: AChannelManager>(
+ * #     channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry,
+ * #     max_total_routing_fee_msat: Option<u64>
+ * # ) -> Result<(), Bolt12SemanticError> {
+ * # let channel_manager = channel_manager.get_cm();
+ * let payment_id = PaymentId([42; 32]);
+ * let refund = channel_manager
+ * .create_refund_builder(
+ * amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat
+ * )?
+ * # ;
+ * # // Needed for compiling for c_bindings
+ * # let builder: lightning::offers::refund::RefundBuilder<_> = refund.into();
+ * # let refund = builder
+ * .description(\"coffee\".to_string())
+ * .payer_note(\"refund for order 1234\".to_string())
+ * .build()?;
+ * let bech32_refund = refund.to_string();
+ * 
+ * First the payment will be waiting on an invoice
+ * let expected_payment_id = payment_id;
+ * assert!(
+ * channel_manager.list_recent_payments().iter().find(|details| matches!(
+ * details,
+ * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id }
+ * )).is_some()
+ * );
+ * 
+ * Once the invoice is received, a payment will be sent
+ * assert!(
+ * channel_manager.list_recent_payments().iter().find(|details| matches!(
+ * details,
+ * RecentPaymentDetails::Pending { payment_id: expected_payment_id, ..  }
+ * )).is_some()
+ * );
+ * 
+ * On the event processing thread
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id),
+ * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id),
+ * ...
+ * #     _ => {},
+ * });
+ * # Ok(())
+ * # }
+ * ```
+ * 
+ * Use [`request_refund_payment`] to send a [`Bolt12Invoice`] for receiving the refund. Similar to
+ * creating* an [`Offer`], this is stateless as it represents an inbound payment.
+ * 
+ * ```
+ * # use lightning::events::{Event, EventsProvider, PaymentPurpose};
+ * # use lightning::ln::channelmanager::AChannelManager;
+ * # use lightning::offers::refund::Refund;
+ * #
+ * # fn example<T: AChannelManager>(channel_manager: T, refund: &Refund) {
+ * # let channel_manager = channel_manager.get_cm();
+ * let known_payment_hash = match channel_manager.request_refund_payment(refund) {
+ * Ok(invoice) => {
+ * let payment_hash = invoice.payment_hash();
+ * println!(\"Requesting refund payment {}\", payment_hash);
+ * payment_hash
+ * },
+ * Err(e) => panic!(\"Unable to request payment for refund: {:?}\", e),
+ * };
+ * 
+ * On the event processing thread
+ * channel_manager.process_pending_events(&|event| match event {
+ * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose {
+ * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => {
+ * assert_eq!(payment_hash, known_payment_hash);
+ * println!(\"Claiming payment {}\", payment_hash);
+ * channel_manager.claim_funds(payment_preimage);
+ * },
+ * \tPaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => {
+ * println!(\"Unknown payment hash: {}\", payment_hash);
+ * \t},
+ * ...
+ * #         _ => {},
+ * },
+ * Event::PaymentClaimed { payment_hash, amount_msat, .. } => {
+ * assert_eq!(payment_hash, known_payment_hash);
+ * println!(\"Claimed {} msats\", amount_msat);
+ * },
+ * ...
+ * #     _ => {},
+ * });
+ * # }
+ * ```
+ * 
+ * # Persistence
+ * 
+ * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for
  * all peers during write/read (though does not modify this instance, only the instance being
- * serialized). This will result in any channels which have not yet exchanged funding_created (ie
- * called funding_transaction_generated for outbound channels).
- * 
- * Note that you can be a bit lazier about writing out ChannelManager than you can be with
- * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
- * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
- * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
- * the serialization process). If the deserialized version is out-of-date compared to the
- * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
- * ChannelMonitor state and no funds will be lost (mod on-chain transaction fees).
- * 
- * Note that the deserializer is only implemented for (BlockHash, ChannelManager), which
- * tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
- * the \"reorg path\" (ie call block_disconnected() until you get to a common block and then call
- * block_connected() to step towards your best block) upon deserialization before using the
- * object!
- * 
- * Note that ChannelManager is responsible for tracking liveness of its channels and generating
- * ChannelUpdate messages informing peers that the channel is temporarily disabled. To avoid
+ * serialized). This will result in any channels which have not yet exchanged [`funding_created`] (i.e.,
+ * called [`funding_transaction_generated`] for outbound channels) being closed.
+ * 
+ * Note that you can be a bit lazier about writing out `ChannelManager` than you can be with
+ * [`ChannelMonitor`]. With [`ChannelMonitor`] you MUST durably write each
+ * [`ChannelMonitorUpdate`] before returning from
+ * [`chain::Watch::watch_channel`]/[`update_channel`] or before completing async writes. With
+ * `ChannelManager`s, writing updates happens out-of-band (and will prevent any other
+ * `ChannelManager` operations from occurring during the serialization process). If the
+ * deserialized version is out-of-date compared to the [`ChannelMonitor`] passed by reference to
+ * [`read`], those channels will be force-closed based on the `ChannelMonitor` state and no funds
+ * will be lost (modulo on-chain transaction fees).
+ * 
+ * Note that the deserializer is only implemented for `(`[`BlockHash`]`, `[`ChannelManager`]`)`, which
+ * tells you the last block hash which was connected. You should get the best block tip before using the manager.
+ * See [`chain::Listen`] and [`chain::Confirm`] for more details.
+ * 
+ * # `ChannelUpdate` Messages
+ * 
+ * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating
+ * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid
  * spam due to quick disconnection/reconnection, updates are not sent until the channel has been
  * offline for a full minute. In order to track this, you must call
- * timer_tick_occurred roughly once per minute, though it doesn't have to be perfect.
+ * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect.
+ * 
+ * # DoS Mitigation
+ * 
+ * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and
+ * inbound channels without confirmed funding transactions. This may result in nodes which we do
+ * not have a channel with being unable to connect to us or open new channels with us if we have
+ * many peers with unfunded channels.
  * 
- * Rather than using a plain ChannelManager, it is preferable to use either a SimpleArcChannelManager
- * a SimpleRefChannelManager, for conciseness. See their documentation for more details, but
- * essentially you should default to using a SimpleRefChannelManager, and use a
- * SimpleArcChannelManager when you require a ChannelManager with a static lifetime, such as when
+ * Because it is an indication of trust, inbound channels which we've accepted as 0conf are
+ * exempted from the count of unfunded channels. Similarly, outbound channels and connections are
+ * never limited. Please ensure you limit the count of such channels yourself.
+ * 
+ * # Type Aliases
+ * 
+ * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`]
+ * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but
+ * essentially you should default to using a [`SimpleRefChannelManager`], and use a
+ * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when
  * you're using lightning-net-tokio.
+ * 
+ * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor
+ * [`MessageHandler`]: crate::ln::peer_handler::MessageHandler
+ * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger
+ * [`PeerManager::read_event`]: crate::ln::peer_handler::PeerManager::read_event
+ * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
+ * [`timer_tick_occurred`]: Self::timer_tick_occurred
+ * [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
+ * [`Persister`]: crate::util::persist::Persister
+ * [`KVStore`]: crate::util::persist::KVStore
+ * [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future
+ * [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
+ * [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync
+ * [`lightning-background-processor`]: https://docs.rs/lightning_background_processor/lightning_background_processor
+ * [`list_channels`]: Self::list_channels
+ * [`list_usable_channels`]: Self::list_usable_channels
+ * [`create_channel`]: Self::create_channel
+ * [`close_channel`]: Self::force_close_broadcasting_latest_txn
+ * [`force_close_broadcasting_latest_txn`]: Self::force_close_broadcasting_latest_txn
+ * [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md
+ * [BOLT 12]: https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md
+ * [`list_recent_payments`]: Self::list_recent_payments
+ * [`abandon_payment`]: Self::abandon_payment
+ * [`lightning-invoice`]: https://docs.rs/lightning_invoice/latest/lightning_invoice
+ * [`create_inbound_payment`]: Self::create_inbound_payment
+ * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
+ * [`claim_funds`]: Self::claim_funds
+ * [`send_payment`]: Self::send_payment
+ * [`offers`]: crate::offers
+ * [`create_offer_builder`]: Self::create_offer_builder
+ * [`pay_for_offer`]: Self::pay_for_offer
+ * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+ * [`create_refund_builder`]: Self::create_refund_builder
+ * [`request_refund_payment`]: Self::request_refund_payment
+ * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected
+ * [`funding_created`]: msgs::FundingCreated
+ * [`funding_transaction_generated`]: Self::funding_transaction_generated
+ * [`BlockHash`]: bitcoin::hash_types::BlockHash
+ * [`update_channel`]: chain::Watch::update_channel
+ * [`ChannelUpdate`]: msgs::ChannelUpdate
+ * [`read`]: ReadableArgs::read
  */
 public class ChannelManager : CommonBase {
        internal ChannelManager(object _dummy, long ptr) : base(ptr) { }
@@ -51,34 +725,48 @@ public class ChannelManager : CommonBase {
        }
 
        /**
-        * Constructs a new ChannelManager to hold several channels and route between them.
+        * Constructs a new `ChannelManager` to hold several channels and route between them.
+        * 
+        * The current time or latest block header time can be provided as the `current_timestamp`.
         * 
         * This is the main \"logic hub\" for all channel-related actions, and implements
-        * ChannelMessageHandler.
+        * [`ChannelMessageHandler`].
         * 
         * Non-proportional fees are fixed according to our risk using the provided fee estimator.
         * 
-        * Users need to notify the new ChannelManager when a new block is connected or
-        * disconnected using its `block_connected` and `block_disconnected` methods, starting
-        * from after `params.latest_hash`.
+        * Users need to notify the new `ChannelManager` when a new block is connected or
+        * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting
+        * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for
+        * more details.
+        * 
+        * [`block_connected`]: chain::Listen::block_connected
+        * [`block_disconnected`]: chain::Listen::block_disconnected
+        * [`params.best_block.block_hash`]: chain::BestBlock::block_hash
         */
-       public static ChannelManager of(org.ldk.structs.FeeEstimator fee_est, org.ldk.structs.Watch chain_monitor, org.ldk.structs.BroadcasterInterface tx_broadcaster, org.ldk.structs.Logger logger, org.ldk.structs.KeysInterface keys_manager, org.ldk.structs.UserConfig config, org.ldk.structs.ChainParameters _params) {
-               long ret = bindings.ChannelManager_new(fee_est == null ? 0 : fee_est.ptr, chain_monitor == null ? 0 : chain_monitor.ptr, tx_broadcaster == null ? 0 : tx_broadcaster.ptr, logger == null ? 0 : logger.ptr, keys_manager == null ? 0 : keys_manager.ptr, config == null ? 0 : config.ptr, _params == null ? 0 : _params.ptr);
+       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) {
+               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);
                GC.KeepAlive(fee_est);
                GC.KeepAlive(chain_monitor);
                GC.KeepAlive(tx_broadcaster);
+               GC.KeepAlive(router);
                GC.KeepAlive(logger);
-               GC.KeepAlive(keys_manager);
+               GC.KeepAlive(entropy_source);
+               GC.KeepAlive(node_signer);
+               GC.KeepAlive(signer_provider);
                GC.KeepAlive(config);
                GC.KeepAlive(_params);
+               GC.KeepAlive(current_timestamp);
                if (ret >= 0 && ret <= 4096) { return null; }
                org.ldk.structs.ChannelManager ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelManager(null, ret); }
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_est); };
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(chain_monitor); };
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(tx_broadcaster); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(router); };
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(logger); };
-               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(keys_manager); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(node_signer); };
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(signer_provider); };
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(config); };
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(_params); };
                return ret_hu_conv;
@@ -108,10 +796,17 @@ public class ChannelManager : CommonBase {
         * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
         * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
         * 
+        * Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to
+        * generate a shutdown scriptpubkey or destination script set by
+        * [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`].
+        * 
         * Note that we do not check if you are currently connected to the given peer. If no
         * connection is available, the outbound `open_channel` message may fail to send, resulting in
         * the channel eventually being silently forgotten (dropped on reload).
         * 
+        * If `temporary_channel_id` is specified, it will be used as the temporary channel ID of the
+        * channel. Otherwise, a random one will be generated for you.
+        * 
         * Returns the new Channel's temporary `channel_id`. This ID will appear as
         * [`Event::FundingGenerationReady::temporary_channel_id`] and in
         * [`ChannelDetails::channel_id`] until after
@@ -123,90 +818,148 @@ public class ChannelManager : CommonBase {
         * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
         * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
         * 
+        * Note that temporary_channel_id (or a relevant inner pointer) may be NULL or all-0s to represent None
         * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public Result__u832APIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, org.ldk.util.UInt128 user_channel_id, org.ldk.structs.UserConfig override_config) {
-               long ret = bindings.ChannelManager_create_channel(this.ptr, InternalUtils.check_arr_len(their_network_key, 33), channel_value_satoshis, push_msat, user_channel_id.getLEBytes(), override_config == null ? 0 : override_config.ptr);
+       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) {
+               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);
                GC.KeepAlive(this);
                GC.KeepAlive(their_network_key);
                GC.KeepAlive(channel_value_satoshis);
                GC.KeepAlive(push_msat);
                GC.KeepAlive(user_channel_id);
+               GC.KeepAlive(temporary_channel_id);
                GC.KeepAlive(override_config);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result__u832APIErrorZ ret_hu_conv = Result__u832APIErrorZ.constr_from_ptr(ret);
+               Result_ChannelIdAPIErrorZ ret_hu_conv = Result_ChannelIdAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(temporary_channel_id); };
                if (this != null) { this.ptrs_to.AddLast(override_config); };
                return ret_hu_conv;
        }
 
        /**
-        * Gets the list of open channels, in random order. See ChannelDetail field documentation for
+        * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for
         * more information.
         */
        public ChannelDetails[] list_channels() {
-               long[] ret = bindings.ChannelManager_list_channels(this.ptr);
+               long ret = bindings.ChannelManager_list_channels(this.ptr);
                GC.KeepAlive(this);
-               int ret_conv_16_len = ret.Length;
+               if (ret >= 0 && ret <= 4096) { return null; }
+               int ret_conv_16_len = InternalUtils.getArrayLength(ret);
                ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
                for (int q = 0; q < ret_conv_16_len; q++) {
-                       long ret_conv_16 = ret[q];
+                       long ret_conv_16 = InternalUtils.getU64ArrayElem(ret, q);
                        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); }
                        if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
                        ret_conv_16_arr[q] = ret_conv_16_hu_conv;
                }
+               bindings.free_buffer(ret);
                return ret_conv_16_arr;
        }
 
        /**
-        * Gets the list of usable channels, in random order. Useful as an argument to [`find_route`]
-        * to ensure non-announced channels are used.
+        * Gets the list of usable channels, in random order. Useful as an argument to
+        * [`Router::find_route`] to ensure non-announced channels are used.
         * 
         * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the
         * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria
         * are.
-        * 
-        * [`find_route`]: crate::routing::router::find_route
         */
        public ChannelDetails[] list_usable_channels() {
-               long[] ret = bindings.ChannelManager_list_usable_channels(this.ptr);
+               long ret = bindings.ChannelManager_list_usable_channels(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               int ret_conv_16_len = InternalUtils.getArrayLength(ret);
+               ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
+               for (int q = 0; q < ret_conv_16_len; q++) {
+                       long ret_conv_16 = InternalUtils.getU64ArrayElem(ret, q);
+                       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); }
+                       if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
+                       ret_conv_16_arr[q] = ret_conv_16_hu_conv;
+               }
+               bindings.free_buffer(ret);
+               return ret_conv_16_arr;
+       }
+
+       /**
+        * Gets the list of channels we have with a given counterparty, in random order.
+        */
+       public ChannelDetails[] list_channels_with_counterparty(byte[] counterparty_node_id) {
+               long ret = bindings.ChannelManager_list_channels_with_counterparty(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)));
                GC.KeepAlive(this);
-               int ret_conv_16_len = ret.Length;
+               GC.KeepAlive(counterparty_node_id);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               int ret_conv_16_len = InternalUtils.getArrayLength(ret);
                ChannelDetails[] ret_conv_16_arr = new ChannelDetails[ret_conv_16_len];
                for (int q = 0; q < ret_conv_16_len; q++) {
-                       long ret_conv_16 = ret[q];
+                       long ret_conv_16 = InternalUtils.getU64ArrayElem(ret, q);
                        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); }
                        if (ret_conv_16_hu_conv != null) { ret_conv_16_hu_conv.ptrs_to.AddLast(this); };
                        ret_conv_16_arr[q] = ret_conv_16_hu_conv;
                }
+               bindings.free_buffer(ret);
                return ret_conv_16_arr;
        }
 
+       /**
+        * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a
+        * successful path, or have unresolved HTLCs.
+        * 
+        * This can be useful for payments that may have been prepared, but ultimately not sent, as a
+        * result of a crash. If such a payment exists, is not listed here, and an
+        * [`Event::PaymentSent`] has not been received, you may consider resending the payment.
+        * 
+        * [`Event::PaymentSent`]: events::Event::PaymentSent
+        */
+       public RecentPaymentDetails[] list_recent_payments() {
+               long ret = bindings.ChannelManager_list_recent_payments(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               int ret_conv_22_len = InternalUtils.getArrayLength(ret);
+               RecentPaymentDetails[] ret_conv_22_arr = new RecentPaymentDetails[ret_conv_22_len];
+               for (int w = 0; w < ret_conv_22_len; w++) {
+                       long ret_conv_22 = InternalUtils.getU64ArrayElem(ret, w);
+                       org.ldk.structs.RecentPaymentDetails ret_conv_22_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret_conv_22);
+                       if (ret_conv_22_hu_conv != null) { ret_conv_22_hu_conv.ptrs_to.AddLast(this); };
+                       ret_conv_22_arr[w] = ret_conv_22_hu_conv;
+               }
+               bindings.free_buffer(ret);
+               return ret_conv_22_arr;
+       }
+
        /**
         * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs
         * will be accepted on the given channel, and after additional timeout/the closing of all
         * pending HTLCs, the channel will be closed on chain.
         * 
-        * If we are the channel initiator, we will pay between our [`Background`] and
-        * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
-        * estimate.
+        * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and
+        * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
+        * fee estimate.
         * If our counterparty is the channel initiator, we will require a channel closing
-        * transaction feerate of at least our [`Background`] feerate or the feerate which
+        * transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which
         * would appear on a force-closure transaction, whichever is lower. We will allow our
         * counterparty to pay as much fee as they'd like, however.
         * 
-        * May generate a SendShutdown message event on success, which should be relayed.
+        * May generate a [`SendShutdown`] message event on success, which should be relayed.
+        * 
+        * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
+        * generate a shutdown scriptpubkey or destination script set by
+        * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
+        * channel.
         * 
         * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
-        * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
-        * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
+        * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
+        * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
+        * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
         */
-       public Result_NoneAPIErrorZ close_channel(byte[] channel_id, byte[] counterparty_node_id) {
-               long ret = bindings.ChannelManager_close_channel(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
+       public Result_NoneAPIErrorZ close_channel(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id) {
+               long ret = bindings.ChannelManager_close_channel(this.ptr, channel_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)));
                GC.KeepAlive(this);
                GC.KeepAlive(channel_id);
                GC.KeepAlive(counterparty_node_id);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(channel_id); };
                return ret_hu_conv;
        }
 
@@ -219,26 +972,42 @@ public class ChannelManager : CommonBase {
         * the channel being closed or not:
         * If we are the channel initiator, we will pay at least this feerate on the closing
         * transaction. The upper-bound is set by
-        * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`Normal`] fee
-        * estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
+        * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`]
+        * fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater).
         * If our counterparty is the channel initiator, we will refuse to accept a channel closure
         * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which
         * will appear on a force-closure transaction, whichever is lower).
         * 
-        * May generate a SendShutdown message event on success, which should be relayed.
+        * The `shutdown_script` provided  will be used as the `scriptPubKey` for the closing transaction.
+        * Will fail if a shutdown script has already been set for this channel by
+        * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must
+        * also be compatible with our and the counterparty's features.
+        * 
+        * May generate a [`SendShutdown`] message event on success, which should be relayed.
+        * 
+        * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to
+        * generate a shutdown scriptpubkey or destination script set by
+        * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the
+        * channel.
         * 
         * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis
-        * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
-        * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
+        * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
+        * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown
+        * 
+        * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public Result_NoneAPIErrorZ close_channel_with_target_feerate(byte[] channel_id, byte[] counterparty_node_id, int target_feerate_sats_per_1000_weight) {
-               long ret = bindings.ChannelManager_close_channel_with_target_feerate(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), target_feerate_sats_per_1000_weight);
+       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) {
+               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);
                GC.KeepAlive(this);
                GC.KeepAlive(channel_id);
                GC.KeepAlive(counterparty_node_id);
                GC.KeepAlive(target_feerate_sats_per_1000_weight);
+               GC.KeepAlive(shutdown_script);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(channel_id); };
+               if (this != null) { this.ptrs_to.AddLast(target_feerate_sats_per_1000_weight); };
+               if (this != null) { this.ptrs_to.AddLast(shutdown_script); };
                return ret_hu_conv;
        }
 
@@ -248,13 +1017,14 @@ public class ChannelManager : CommonBase {
         * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding
         * channel.
         */
-       public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(byte[] channel_id, byte[] counterparty_node_id) {
-               long ret = bindings.ChannelManager_force_close_broadcasting_latest_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
+       public Result_NoneAPIErrorZ force_close_broadcasting_latest_txn(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id) {
+               long ret = bindings.ChannelManager_force_close_broadcasting_latest_txn(this.ptr, channel_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)));
                GC.KeepAlive(this);
                GC.KeepAlive(channel_id);
                GC.KeepAlive(counterparty_node_id);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(channel_id); };
                return ret_hu_conv;
        }
 
@@ -263,16 +1033,17 @@ public class ChannelManager : CommonBase {
         * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the
         * `counterparty_node_id` isn't the counterparty of the corresponding channel.
         * 
-        * You can always get the latest local transaction(s) to broadcast from
-        * [`ChannelMonitor::get_latest_holder_commitment_txn`].
+        * You can always broadcast the latest local transaction(s) via
+        * [`ChannelMonitor::broadcast_latest_holder_commitment_txn`].
         */
-       public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(byte[] channel_id, byte[] counterparty_node_id) {
-               long ret = bindings.ChannelManager_force_close_without_broadcasting_txn(this.ptr, InternalUtils.check_arr_len(channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33));
+       public Result_NoneAPIErrorZ force_close_without_broadcasting_txn(org.ldk.structs.ChannelId channel_id, byte[] counterparty_node_id) {
+               long ret = bindings.ChannelManager_force_close_without_broadcasting_txn(this.ptr, channel_id.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_node_id, 33)));
                GC.KeepAlive(this);
                GC.KeepAlive(channel_id);
                GC.KeepAlive(counterparty_node_id);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(channel_id); };
                return ret_hu_conv;
        }
 
@@ -297,14 +1068,19 @@ public class ChannelManager : CommonBase {
        /**
         * Sends a payment along a given route.
         * 
-        * Value parameters are provided via the last hop in route, see documentation for RouteHop
+        * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`]
         * fields for more info.
         * 
+        * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via
+        * [`PeerManager::process_events`]).
+        * 
+        * # Avoiding Duplicate Payments
+        * 
         * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
         * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment
         * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
-        * [`Event::PaymentSent`]) LDK will not stop you from sending a second payment with the same
-        * [`PaymentId`].
+        * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a
+        * second payment with the same [`PaymentId`].
         * 
         * Thus, in order to ensure duplicate payments are not sent, you should implement your own
         * tracking of payments, including state to indicate once a payment has completed. Because you
@@ -312,101 +1088,101 @@ public class ChannelManager : CommonBase {
         * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the
         * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes.
         * 
-        * May generate SendHTLCs message(s) event on success, which should be relayed (e.g. via
-        * [`PeerManager::process_events`]).
+        * Additionally, in the scenario where we begin the process of sending a payment, but crash
+        * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're
+        * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See
+        * [`ChannelManager::list_recent_payments`] for more information.
+        * 
+        * # Possible Error States on [`PaymentSendFailure`]
         * 
-        * Each path may have a different return value, and PaymentSendValue may return a Vec with
+        * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with
         * each entry matching the corresponding-index entry in the route paths, see
-        * PaymentSendFailure for more info.
+        * [`PaymentSendFailure`] for more info.
         * 
         * In general, a path may raise:
         * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee,
         * node public key) is specified.
-        * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates
-        * (including due to previous monitor update failure or new permanent monitor update
-        * failure).
+        * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been
+        * closed, doesn't exist, or the peer is currently disconnected.
         * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the
         * relevant updates.
         * 
-        * Note that depending on the type of the PaymentSendFailure the HTLC may have been
+        * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been
         * irrevocably committed to on our end. In such a case, do NOT retry the payment with a
         * different route unless you intend to pay twice!
         * 
-        * payment_secret is unrelated to payment_hash (or PaymentPreimage) and exists to authenticate
-        * the sender to the recipient and prevent payment-probing (deanonymization) attacks. For
-        * newer nodes, it will be provided to you in the invoice. If you do not have one, the Route
-        * must not contain multiple paths as multi-path payments require a recipient-provided
-        * payment_secret.
-        * 
-        * If a payment_secret *is* provided, we assume that the invoice had the payment_secret feature
-        * bit set (either as required or as available). If multiple paths are present in the Route,
-        * we assume the invoice had the basic_mpp feature set.
-        * 
+        * [`RouteHop`]: crate::routing::router::RouteHop
         * [`Event::PaymentSent`]: events::Event::PaymentSent
+        * [`Event::PaymentFailed`]: events::Event::PaymentFailed
+        * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs
         * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
-        * 
-        * Note that payment_secret (or a relevant inner pointer) may be NULL or all-0s to represent None
+        * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
         */
-       public Result_NonePaymentSendFailureZ send_payment(org.ldk.structs.Route route, byte[] payment_hash, byte[] payment_secret, byte[] payment_id) {
-               long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32), InternalUtils.check_arr_len(payment_id, 32));
+       public Result_NonePaymentSendFailureZ send_payment_with_route(org.ldk.structs.Route route, byte[] payment_hash, org.ldk.structs.RecipientOnionFields recipient_onion, byte[] payment_id) {
+               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)));
                GC.KeepAlive(this);
                GC.KeepAlive(route);
                GC.KeepAlive(payment_hash);
-               GC.KeepAlive(payment_secret);
+               GC.KeepAlive(recipient_onion);
                GC.KeepAlive(payment_id);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
                if (this != null) { this.ptrs_to.AddLast(route); };
+               if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
                return ret_hu_conv;
        }
 
        /**
-        * Retries a payment along the given [`Route`].
-        * 
-        * Errors returned are a superset of those returned from [`send_payment`], so see
-        * [`send_payment`] documentation for more details on errors. This method will also error if the
-        * retry amount puts the payment more than 10% over the payment's total amount, if the payment
-        * for the given `payment_id` cannot be found (likely due to timeout or success), or if
-        * further retries have been disabled with [`abandon_payment`].
-        * 
-        * [`send_payment`]: [`ChannelManager::send_payment`]
-        * [`abandon_payment`]: [`ChannelManager::abandon_payment`]
+        * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on
+        * `route_params` and retry failed payment paths based on `retry_strategy`.
         */
-       public Result_NonePaymentSendFailureZ retry_payment(org.ldk.structs.Route route, byte[] payment_id) {
-               long ret = bindings.ChannelManager_retry_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_id, 32));
+       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) {
+               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);
                GC.KeepAlive(this);
-               GC.KeepAlive(route);
+               GC.KeepAlive(payment_hash);
+               GC.KeepAlive(recipient_onion);
                GC.KeepAlive(payment_id);
+               GC.KeepAlive(route_params);
+               GC.KeepAlive(retry_strategy);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
-               if (this != null) { this.ptrs_to.AddLast(route); };
+               Result_NoneRetryableSendFailureZ ret_hu_conv = Result_NoneRetryableSendFailureZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
+               if (this != null) { this.ptrs_to.AddLast(route_params); };
+               if (this != null) { this.ptrs_to.AddLast(retry_strategy); };
                return ret_hu_conv;
        }
 
        /**
-        * Signals that no further retries for the given payment will occur.
+        * Signals that no further attempts for the given payment should occur. Useful if you have a
+        * pending outbound payment with retries remaining, but wish to stop retrying the payment before
+        * retries are exhausted.
+        * 
+        * # Event Generation
         * 
-        * After this method returns, no future calls to [`retry_payment`] for the given `payment_id`
-        * are allowed. If no [`Event::PaymentFailed`] event had been generated before, one will be
-        * generated as soon as there are no remaining pending HTLCs for this payment.
+        * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon
+        * as there are no remaining pending HTLCs for this payment.
         * 
         * Note that calling this method does *not* prevent a payment from succeeding. You must still
         * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to
         * determine the ultimate status of a payment.
         * 
-        * If an [`Event::PaymentFailed`] event is generated and we restart without this
-        * [`ChannelManager`] having been persisted, the payment may still be in the pending state
-        * upon restart. This allows further calls to [`retry_payment`] (and requiring a second call
-        * to [`abandon_payment`] to mark the payment as failed again). Otherwise, future calls to
-        * [`retry_payment`] will fail with [`PaymentSendFailure::ParameterError`].
+        * # Requested Invoices
         * 
-        * [`abandon_payment`]: Self::abandon_payment
-        * [`retry_payment`]: Self::retry_payment
-        * [`Event::PaymentFailed`]: events::Event::PaymentFailed
-        * [`Event::PaymentSent`]: events::Event::PaymentSent
+        * In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning
+        * the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`]
+        * and prevent any attempts at paying it once received. The other events may only be generated
+        * once the invoice has been received.
+        * 
+        * # Restart Behavior
+        * 
+        * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the
+        * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for
+        * [`Event::InvoiceRequestFailed`].
+        * 
+        * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
         */
        public void abandon_payment(byte[] payment_id) {
-               bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.check_arr_len(payment_id, 32));
+               bindings.ChannelManager_abandon_payment(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_id, 32)));
                GC.KeepAlive(this);
                GC.KeepAlive(payment_id);
        }
@@ -424,21 +1200,46 @@ public class ChannelManager : CommonBase {
         * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See
         * [`send_payment`] for more information about the risks of duplicate preimage usage.
         * 
-        * Note that `route` must have exactly one path.
-        * 
         * [`send_payment`]: Self::send_payment
-        * 
-        * Note that payment_preimage (or a relevant inner pointer) may be NULL or all-0s to represent None
         */
-       public Result_PaymentHashPaymentSendFailureZ send_spontaneous_payment(org.ldk.structs.Route route, byte[] payment_preimage, byte[] payment_id) {
-               long ret = bindings.ChannelManager_send_spontaneous_payment(this.ptr, route == null ? 0 : route.ptr, InternalUtils.check_arr_len(payment_preimage, 32), InternalUtils.check_arr_len(payment_id, 32));
+       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) {
+               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)));
                GC.KeepAlive(this);
                GC.KeepAlive(route);
                GC.KeepAlive(payment_preimage);
+               GC.KeepAlive(recipient_onion);
                GC.KeepAlive(payment_id);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_PaymentHashPaymentSendFailureZ ret_hu_conv = Result_PaymentHashPaymentSendFailureZ.constr_from_ptr(ret);
+               Result_ThirtyTwoBytesPaymentSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesPaymentSendFailureZ.constr_from_ptr(ret);
                if (this != null) { this.ptrs_to.AddLast(route); };
+               if (this != null) { this.ptrs_to.AddLast(payment_preimage); };
+               if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route
+        * based on `route_params` and retry failed payment paths based on `retry_strategy`.
+        * 
+        * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous
+        * payments.
+        * 
+        * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend
+        */
+       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) {
+               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);
+               GC.KeepAlive(this);
+               GC.KeepAlive(payment_preimage);
+               GC.KeepAlive(recipient_onion);
+               GC.KeepAlive(payment_id);
+               GC.KeepAlive(route_params);
+               GC.KeepAlive(retry_strategy);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_ThirtyTwoBytesRetryableSendFailureZ ret_hu_conv = Result_ThirtyTwoBytesRetryableSendFailureZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(payment_preimage); };
+               if (this != null) { this.ptrs_to.AddLast(recipient_onion); };
+               if (this != null) { this.ptrs_to.AddLast(route_params); };
+               if (this != null) { this.ptrs_to.AddLast(retry_strategy); };
                return ret_hu_conv;
        }
 
@@ -447,13 +1248,60 @@ public class ChannelManager : CommonBase {
         * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows
         * us to easily discern them from real payments.
         */
-       public Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ send_probe(RouteHop[] hops) {
-               long ret = bindings.ChannelManager_send_probe(this.ptr, hops != null ? InternalUtils.mapArray(hops, hops_conv_10 => hops_conv_10 == null ? 0 : hops_conv_10.ptr) : null);
+       public Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ send_probe(org.ldk.structs.Path path) {
+               long ret = bindings.ChannelManager_send_probe(this.ptr, path.ptr);
                GC.KeepAlive(this);
-               GC.KeepAlive(hops);
+               GC.KeepAlive(path);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ.constr_from_ptr(ret);
-               foreach (RouteHop hops_conv_10 in hops) { if (this != null) { this.ptrs_to.AddLast(hops_conv_10); }; };
+               Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(path); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Sends payment probes over all paths of a route that would be used to pay the given
+        * amount to the given `node_id`.
+        * 
+        * See [`ChannelManager::send_preflight_probes`] for more information.
+        */
+       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) {
+               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);
+               GC.KeepAlive(this);
+               GC.KeepAlive(node_id);
+               GC.KeepAlive(amount_msat);
+               GC.KeepAlive(final_cltv_expiry_delta);
+               GC.KeepAlive(liquidity_limit_multiplier);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(liquidity_limit_multiplier); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Sends payment probes over all paths of a route that would be used to pay a route found
+        * according to the given [`RouteParameters`].
+        * 
+        * This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting
+        * the actual payment. Note this is only useful if there likely is sufficient time for the
+        * probe to settle before sending out the actual payment, e.g., when waiting for user
+        * confirmation in a wallet UI.
+        * 
+        * Otherwise, there is a chance the probe could take up some liquidity needed to complete the
+        * actual payment. Users should therefore be cautious and might avoid sending probes if
+        * liquidity is scarce and/or they don't expect the probe to return before they send the
+        * payment. To mitigate this issue, channels with available liquidity less than the required
+        * amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight
+        * probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`.
+        */
+       public Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ send_preflight_probes(org.ldk.structs.RouteParameters route_params, org.ldk.structs.Option_u64Z liquidity_limit_multiplier) {
+               long ret = bindings.ChannelManager_send_preflight_probes(this.ptr, route_params.ptr, liquidity_limit_multiplier.ptr);
+               GC.KeepAlive(this);
+               GC.KeepAlive(route_params);
+               GC.KeepAlive(liquidity_limit_multiplier);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ret_hu_conv = Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(route_params); };
+               if (this != null) { this.ptrs_to.AddLast(liquidity_limit_multiplier); };
                return ret_hu_conv;
        }
 
@@ -486,17 +1334,77 @@ public class ChannelManager : CommonBase {
         * implemented by Bitcoin Core wallet. See <https://bitcoinops.org/en/topics/fee-sniping/>
         * for more details.
         * 
-        * [`Event::FundingGenerationReady`]: crate::util::events::Event::FundingGenerationReady
-        * [`Event::ChannelClosed`]: crate::util::events::Event::ChannelClosed
+        * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady
+        * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed
         */
-       public Result_NoneAPIErrorZ funding_transaction_generated(byte[] temporary_channel_id, byte[] counterparty_node_id, byte[] funding_transaction) {
-               long ret = bindings.ChannelManager_funding_transaction_generated(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), funding_transaction);
+       public Result_NoneAPIErrorZ funding_transaction_generated(org.ldk.structs.ChannelId temporary_channel_id, byte[] counterparty_node_id, byte[] funding_transaction) {
+               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));
                GC.KeepAlive(this);
                GC.KeepAlive(temporary_channel_id);
                GC.KeepAlive(counterparty_node_id);
                GC.KeepAlive(funding_transaction);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(temporary_channel_id); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Call this upon creation of a batch funding transaction for the given channels.
+        * 
+        * Return values are identical to [`Self::funding_transaction_generated`], respective to
+        * each individual channel and transaction output.
+        * 
+        * Do NOT broadcast the funding transaction yourself. This batch funding transaction
+        * will only be broadcast when we have safely received and persisted the counterparty's
+        * signature for each channel.
+        * 
+        * If there is an error, all channels in the batch are to be considered closed.
+        */
+       public Result_NoneAPIErrorZ batch_funding_transaction_generated(TwoTuple_ChannelIdPublicKeyZ[] temporary_channels, byte[] funding_transaction) {
+               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));
+               GC.KeepAlive(this);
+               GC.KeepAlive(temporary_channels);
+               GC.KeepAlive(funding_transaction);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Atomically applies partial updates to the [`ChannelConfig`] of the given channels.
+        * 
+        * Once the updates are applied, each eligible channel (advertised with a known short channel
+        * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`],
+        * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated
+        * containing the new [`ChannelUpdate`] message which should be broadcast to the network.
+        * 
+        * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect
+        * `counterparty_node_id` is provided.
+        * 
+        * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value
+        * below [`MIN_CLTV_EXPIRY_DELTA`].
+        * 
+        * If an error is returned, none of the updates should be considered applied.
+        * 
+        * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
+        * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat
+        * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta
+        * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate
+        * [`ChannelUpdate`]: msgs::ChannelUpdate
+        * [`ChannelUnavailable`]: APIError::ChannelUnavailable
+        * [`APIMisuseError`]: APIError::APIMisuseError
+        */
+       public Result_NoneAPIErrorZ update_partial_channel_config(byte[] counterparty_node_id, ChannelId[] channel_ids, org.ldk.structs.ChannelConfigUpdate config_update) {
+               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);
+               GC.KeepAlive(this);
+               GC.KeepAlive(counterparty_node_id);
+               GC.KeepAlive(channel_ids);
+               GC.KeepAlive(config_update);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               foreach (ChannelId channel_ids_conv_11 in channel_ids) { if (this != null) { this.ptrs_to.AddLast(channel_ids_conv_11); }; };
+               if (this != null) { this.ptrs_to.AddLast(config_update); };
                return ret_hu_conv;
        }
 
@@ -524,14 +1432,15 @@ public class ChannelManager : CommonBase {
         * [`ChannelUnavailable`]: APIError::ChannelUnavailable
         * [`APIMisuseError`]: APIError::APIMisuseError
         */
-       public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, byte[][] channel_ids, org.ldk.structs.ChannelConfig config) {
-               long ret = bindings.ChannelManager_update_channel_config(this.ptr, InternalUtils.check_arr_len(counterparty_node_id, 33), channel_ids != null ? InternalUtils.mapArray(channel_ids, channel_ids_conv_8 => InternalUtils.check_arr_len(channel_ids_conv_8, 32)) : null, config == null ? 0 : config.ptr);
+       public Result_NoneAPIErrorZ update_channel_config(byte[] counterparty_node_id, ChannelId[] channel_ids, org.ldk.structs.ChannelConfig config) {
+               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);
                GC.KeepAlive(this);
                GC.KeepAlive(counterparty_node_id);
                GC.KeepAlive(channel_ids);
                GC.KeepAlive(config);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               foreach (ChannelId channel_ids_conv_11 in channel_ids) { if (this != null) { this.ptrs_to.AddLast(channel_ids_conv_11); }; };
                if (this != null) { this.ptrs_to.AddLast(config); };
                return ret_hu_conv;
        }
@@ -550,23 +1459,27 @@ public class ChannelManager : CommonBase {
         * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event.
         * 
         * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop
-        * you from forwarding more than you received.
+        * you from forwarding more than you received. See
+        * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount
+        * than expected.
         * 
         * Errors if the event was not handled in time, in which case the HTLC was automatically failed
         * backwards.
         * 
         * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
         * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
+        * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat
         */
-       public Result_NoneAPIErrorZ forward_intercepted_htlc(byte[] intercept_id, byte[] next_hop_channel_id, byte[] _next_node_id, long amt_to_forward_msat) {
-               long ret = bindings.ChannelManager_forward_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32), InternalUtils.check_arr_len(next_hop_channel_id, 32), InternalUtils.check_arr_len(_next_node_id, 33), amt_to_forward_msat);
+       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) {
+               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);
                GC.KeepAlive(this);
                GC.KeepAlive(intercept_id);
                GC.KeepAlive(next_hop_channel_id);
-               GC.KeepAlive(_next_node_id);
+               GC.KeepAlive(next_node_id);
                GC.KeepAlive(amt_to_forward_msat);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(next_hop_channel_id); };
                return ret_hu_conv;
        }
 
@@ -580,7 +1493,7 @@ public class ChannelManager : CommonBase {
         * [`HTLCIntercepted`]: events::Event::HTLCIntercepted
         */
        public Result_NoneAPIErrorZ fail_intercepted_htlc(byte[] intercept_id) {
-               long ret = bindings.ChannelManager_fail_intercepted_htlc(this.ptr, InternalUtils.check_arr_len(intercept_id, 32));
+               long ret = bindings.ChannelManager_fail_intercepted_htlc(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(intercept_id, 32)));
                GC.KeepAlive(this);
                GC.KeepAlive(intercept_id);
                if (ret >= 0 && ret <= 4096) { return null; }
@@ -604,14 +1517,23 @@ public class ChannelManager : CommonBase {
         * 
         * This currently includes:
         * Increasing or decreasing the on-chain feerate estimates for our outbound channels,
-        * Broadcasting `ChannelUpdate` messages if we've been disconnected from our peer for more
+        * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more
         * than a minute, informing the network that they should no longer attempt to route over
         * the channel.
-        * Expiring a channel's previous `ChannelConfig` if necessary to only allow forwarding HTLCs
-        * with the current `ChannelConfig`.
-        * 
-        * Note that this may cause reentrancy through `chain::Watch::update_channel` calls or feerate
+        * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs
+        * with the current [`ChannelConfig`].
+        * Removing peers which have disconnected but and no longer have any channels.
+        * Force-closing and removing channels which have not completed establishment in a timely manner.
+        * Forgetting about stale outbound payments, either those that have already been fulfilled
+        * or those awaiting an invoice that hasn't been delivered in the necessary amount of time.
+        * The latter is determined using the system clock in `std` and the highest seen block time
+        * minus two hours in `no-std`.
+        * 
+        * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate
         * estimate fetches.
+        * 
+        * [`ChannelUpdate`]: msgs::ChannelUpdate
+        * [`ChannelConfig`]: crate::util::config::ChannelConfig
         */
        public void timer_tick_occurred() {
                bindings.ChannelManager_timer_tick_occurred(this.ptr);
@@ -634,32 +1556,70 @@ public class ChannelManager : CommonBase {
         * startup during which time claims that were in-progress at shutdown may be replayed.
         */
        public void fail_htlc_backwards(byte[] payment_hash) {
-               bindings.ChannelManager_fail_htlc_backwards(this.ptr, InternalUtils.check_arr_len(payment_hash, 32));
+               bindings.ChannelManager_fail_htlc_backwards(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
                GC.KeepAlive(this);
                GC.KeepAlive(payment_hash);
        }
 
+       /**
+        * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the
+        * reason for the failure.
+        * 
+        * See [`FailureCode`] for valid failure codes.
+        */
+       public void fail_htlc_backwards_with_reason(byte[] payment_hash, org.ldk.structs.FailureCode failure_code) {
+               bindings.ChannelManager_fail_htlc_backwards_with_reason(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), failure_code.ptr);
+               GC.KeepAlive(this);
+               GC.KeepAlive(payment_hash);
+               GC.KeepAlive(failure_code);
+               if (this != null) { this.ptrs_to.AddLast(failure_code); };
+       }
+
        /**
         * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any
         * [`MessageSendEvent`]s needed to claim the payment.
         * 
-        * Note that calling this method does *not* guarantee that the payment has been claimed. You
-        * must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be
-        * provided to your [`EventHandler`] when [`process_pending_events`] is next called.
+        * This method is guaranteed to ensure the payment has been claimed but only if the current
+        * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race
+        * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment
+        * successful. It will generally be available in the next [`process_pending_events`] call.
         * 
         * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
         * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable`
         * event matches your expectation. If you fail to do so and call this method, you may provide
         * the sender \"proof-of-payment\" when they did not fulfill the full expected payment.
         * 
-        * [`Event::PaymentClaimable`]: crate::util::events::Event::PaymentClaimable
-        * [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed
+        * This function will fail the payment if it has custom TLVs with even type numbers, as we
+        * will assume they are unknown. If you intend to accept even custom TLVs, you should use
+        * [`claim_funds_with_known_custom_tlvs`].
+        * 
+        * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable
+        * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline
+        * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed
         * [`process_pending_events`]: EventsProvider::process_pending_events
         * [`create_inbound_payment`]: Self::create_inbound_payment
         * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
+        * [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs
         */
        public void claim_funds(byte[] payment_preimage) {
-               bindings.ChannelManager_claim_funds(this.ptr, InternalUtils.check_arr_len(payment_preimage, 32));
+               bindings.ChannelManager_claim_funds(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32)));
+               GC.KeepAlive(this);
+               GC.KeepAlive(payment_preimage);
+       }
+
+       /**
+        * This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with
+        * even type numbers.
+        * 
+        * # Note
+        * 
+        * You MUST check you've understood all even TLVs before using this to
+        * claim, otherwise you may unintentionally agree to some protocol you do not understand.
+        * 
+        * [`claim_funds`]: Self::claim_funds
+        */
+       public void claim_funds_with_known_custom_tlvs(byte[] payment_preimage) {
+               bindings.ChannelManager_claim_funds_with_known_custom_tlvs(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32)));
                GC.KeepAlive(this);
                GC.KeepAlive(payment_preimage);
        }
@@ -668,9 +1628,11 @@ public class ChannelManager : CommonBase {
         * Gets the node_id held by this ChannelManager
         */
        public byte[] get_our_node_id() {
-               byte[] ret = bindings.ChannelManager_get_our_node_id(this.ptr);
+               long ret = bindings.ChannelManager_get_our_node_id(this.ptr);
                GC.KeepAlive(this);
-               return ret;
+               if (ret >= 0 && ret <= 4096) { return null; }
+               byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
+               return ret_conv;
        }
 
        /**
@@ -691,14 +1653,15 @@ public class ChannelManager : CommonBase {
         * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
         * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
         */
-       public Result_NoneAPIErrorZ accept_inbound_channel(byte[] temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
-               long ret = bindings.ChannelManager_accept_inbound_channel(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
+       public Result_NoneAPIErrorZ accept_inbound_channel(org.ldk.structs.ChannelId temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
+               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()));
                GC.KeepAlive(this);
                GC.KeepAlive(temporary_channel_id);
                GC.KeepAlive(counterparty_node_id);
                GC.KeepAlive(user_channel_id);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(temporary_channel_id); };
                return ret_hu_conv;
        }
 
@@ -722,14 +1685,224 @@ public class ChannelManager : CommonBase {
         * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
         * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
         */
-       public Result_NoneAPIErrorZ accept_inbound_channel_from_trusted_peer_0conf(byte[] temporary_channel_id, byte[] counterparty_node_id, org.ldk.util.UInt128 user_channel_id) {
-               long ret = bindings.ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this.ptr, InternalUtils.check_arr_len(temporary_channel_id, 32), InternalUtils.check_arr_len(counterparty_node_id, 33), user_channel_id.getLEBytes());
+       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) {
+               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()));
                GC.KeepAlive(this);
                GC.KeepAlive(temporary_channel_id);
                GC.KeepAlive(counterparty_node_id);
                GC.KeepAlive(user_channel_id);
                if (ret >= 0 && ret <= 4096) { return null; }
                Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(temporary_channel_id); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the
+        * [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer will
+        * not have an expiration unless otherwise set on the builder.
+        * 
+        * # Privacy
+        * 
+        * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the offer.
+        * However, if one is not found, uses a one-hop [`BlindedPath`] with
+        * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case,
+        * the node must be announced, otherwise, there is no way to find a path to the introduction in
+        * order to send the [`InvoiceRequest`].
+        * 
+        * Also, uses a derived signing pubkey in the offer for recipient privacy.
+        * 
+        * # Limitations
+        * 
+        * Requires a direct connection to the introduction node in the responding [`InvoiceRequest`]'s
+        * reply path.
+        * 
+        * # Errors
+        * 
+        * Errors if the parameterized [`Router`] is unable to create a blinded path for the offer.
+        * 
+        * [`Offer`]: crate::offers::offer::Offer
+        * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+        */
+       public Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ create_offer_builder() {
+               long ret = bindings.ChannelManager_create_offer_builder(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ ret_hu_conv = Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the
+        * [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund.
+        * 
+        * # Payment
+        * 
+        * The provided `payment_id` is used to ensure that only one invoice is paid for the refund.
+        * See [Avoiding Duplicate Payments] for other requirements once the payment has been sent.
+        * 
+        * The builder will have the provided expiration set. Any changes to the expiration on the
+        * returned builder will not be honored by [`ChannelManager`]. For `no-std`, the highest seen
+        * block time minus two hours is used for the current time when determining if the refund has
+        * expired.
+        * 
+        * To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the
+        * invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail
+        * with an [`Event::InvoiceRequestFailed`].
+        * 
+        * If `max_total_routing_fee_msat` is not specified, The default from
+        * [`RouteParameters::from_payment_params_and_value`] is applied.
+        * 
+        * # Privacy
+        * 
+        * Uses [`MessageRouter::create_blinded_paths`] to construct a [`BlindedPath`] for the refund.
+        * However, if one is not found, uses a one-hop [`BlindedPath`] with
+        * [`ChannelManager::get_our_node_id`] as the introduction node instead. In the latter case,
+        * the node must be announced, otherwise, there is no way to find a path to the introduction in
+        * order to send the [`Bolt12Invoice`].
+        * 
+        * Also, uses a derived payer id in the refund for payer privacy.
+        * 
+        * # Limitations
+        * 
+        * Requires a direct connection to an introduction node in the responding
+        * [`Bolt12Invoice::payment_paths`].
+        * 
+        * # Errors
+        * 
+        * Errors if:
+        * - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
+        * - `amount_msats` is invalid, or
+        * - the parameterized [`Router`] is unable to create a blinded path for the refund.
+        * 
+        * [`Refund`]: crate::offers::refund::Refund
+        * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+        * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
+        * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
+        */
+       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) {
+               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);
+               GC.KeepAlive(this);
+               GC.KeepAlive(amount_msats);
+               GC.KeepAlive(absolute_expiry);
+               GC.KeepAlive(payment_id);
+               GC.KeepAlive(retry_strategy);
+               GC.KeepAlive(max_total_routing_fee_msat);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ ret_hu_conv = Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(retry_strategy); };
+               if (this != null) { this.ptrs_to.AddLast(max_total_routing_fee_msat); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and
+        * enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual
+        * [`Bolt12Invoice`] once it is received.
+        * 
+        * Uses [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is recognized by
+        * the [`ChannelManager`] when handling a [`Bolt12Invoice`] message in response to the request.
+        * The optional parameters are used in the builder, if `Some`:
+        * - `quantity` for [`InvoiceRequest::quantity`] which must be set if
+        * [`Offer::expects_quantity`] is `true`.
+        * - `amount_msats` if overpaying what is required for the given `quantity` is desired, and
+        * - `payer_note` for [`InvoiceRequest::payer_note`].
+        * 
+        * If `max_total_routing_fee_msat` is not specified, The default from
+        * [`RouteParameters::from_payment_params_and_value`] is applied.
+        * 
+        * # Payment
+        * 
+        * The provided `payment_id` is used to ensure that only one invoice is paid for the request
+        * when received. See [Avoiding Duplicate Payments] for other requirements once the payment has
+        * been sent.
+        * 
+        * To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the
+        * invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the
+        * payment will fail with an [`Event::InvoiceRequestFailed`].
+        * 
+        * # Privacy
+        * 
+        * Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`]
+        * as the introduction node and a derived payer id for payer privacy. As such, currently, the
+        * node must be announced. Otherwise, there is no way to find a path to the introduction node
+        * in order to send the [`Bolt12Invoice`].
+        * 
+        * # Limitations
+        * 
+        * Requires a direct connection to an introduction node in [`Offer::paths`] or to
+        * [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding
+        * [`Bolt12Invoice::payment_paths`].
+        * 
+        * # Errors
+        * 
+        * Errors if:
+        * - a duplicate `payment_id` is provided given the caveats in the aforementioned link,
+        * - the provided parameters are invalid for the offer,
+        * - the offer is for an unsupported chain, or
+        * - the parameterized [`Router`] is unable to create a blinded reply path for the invoice
+        * request.
+        * 
+        * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+        * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity
+        * [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note
+        * [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder
+        * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+        * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
+        * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments
+        */
+       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) {
+               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);
+               GC.KeepAlive(this);
+               GC.KeepAlive(offer);
+               GC.KeepAlive(quantity);
+               GC.KeepAlive(amount_msats);
+               GC.KeepAlive(payer_note);
+               GC.KeepAlive(payment_id);
+               GC.KeepAlive(retry_strategy);
+               GC.KeepAlive(max_total_routing_fee_msat);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(offer); };
+               if (this != null) { this.ptrs_to.AddLast(quantity); };
+               if (this != null) { this.ptrs_to.AddLast(amount_msats); };
+               if (this != null) { this.ptrs_to.AddLast(payer_note); };
+               if (this != null) { this.ptrs_to.AddLast(retry_strategy); };
+               if (this != null) { this.ptrs_to.AddLast(max_total_routing_fee_msat); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a [`Bolt12Invoice`] for a [`Refund`] and enqueues it to be sent via an onion
+        * message.
+        * 
+        * The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a
+        * [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding
+        * [`PaymentPreimage`]. It is returned purely for informational purposes.
+        * 
+        * # Limitations
+        * 
+        * Requires a direct connection to an introduction node in [`Refund::paths`] or to
+        * [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each
+        * node meeting the aforementioned criteria, but there's no guarantee that they will be
+        * received and no retries will be made.
+        * 
+        * # Errors
+        * 
+        * Errors if:
+        * - the refund is for an unsupported chain, or
+        * - the parameterized [`Router`] is unable to create a blinded payment path or reply path for
+        * the invoice.
+        * 
+        * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
+        */
+       public Result_Bolt12InvoiceBolt12SemanticErrorZ request_refund_payment(org.ldk.structs.Refund refund) {
+               long ret = bindings.ChannelManager_request_refund_payment(this.ptr, refund.ptr);
+               GC.KeepAlive(this);
+               GC.KeepAlive(refund);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               Result_Bolt12InvoiceBolt12SemanticErrorZ ret_hu_conv = Result_Bolt12InvoiceBolt12SemanticErrorZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(refund); };
                return ret_hu_conv;
        }
 
@@ -740,9 +1913,9 @@ public class ChannelManager : CommonBase {
         * This differs from [`create_inbound_payment_for_hash`] only in that it generates the
         * [`PaymentHash`] and [`PaymentPreimage`] for you.
         * 
-        * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which
-        * will have the [`PaymentClaimable::payment_preimage`] field filled in. That should then be
-        * passed directly to [`claim_funds`].
+        * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`] event, which
+        * will have the [`PaymentClaimable::purpose`] return `Some` for [`PaymentPurpose::preimage`]. That
+        * should then be passed directly to [`claim_funds`].
         * 
         * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements.
         * 
@@ -756,39 +1929,25 @@ public class ChannelManager : CommonBase {
         * 
         * Errors if `min_value_msat` is greater than total bitcoin supply.
         * 
+        * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
+        * on versions of LDK prior to 0.0.114.
+        * 
         * [`claim_funds`]: Self::claim_funds
         * [`PaymentClaimable`]: events::Event::PaymentClaimable
-        * [`PaymentClaimable::payment_preimage`]: events::Event::PaymentClaimable::payment_preimage
+        * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose
+        * [`PaymentPurpose::preimage`]: events::PaymentPurpose::preimage
         * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
         */
-       public Result_C2Tuple_PaymentHashPaymentSecretZNoneZ create_inbound_payment(org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
-               long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs);
-               GC.KeepAlive(this);
-               GC.KeepAlive(min_value_msat);
-               GC.KeepAlive(invoice_expiry_delta_secs);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               Result_C2Tuple_PaymentHashPaymentSecretZNoneZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZNoneZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Legacy version of [`create_inbound_payment`]. Use this method if you wish to share
-        * serialized state with LDK node(s) running 0.0.103 and earlier.
-        * 
-        * May panic if `invoice_expiry_delta_secs` is greater than one year.
-        * 
-        * # Note
-        * This method is deprecated and will be removed soon.
-        * 
-        * [`create_inbound_payment`]: Self::create_inbound_payment
-        */
-       public Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ create_inbound_payment_legacy(org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
-               long ret = bindings.ChannelManager_create_inbound_payment_legacy(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs);
+       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) {
+               long ret = bindings.ChannelManager_create_inbound_payment(this.ptr, min_value_msat.ptr, invoice_expiry_delta_secs, min_final_cltv_expiry_delta.ptr);
                GC.KeepAlive(this);
                GC.KeepAlive(min_value_msat);
                GC.KeepAlive(invoice_expiry_delta_secs);
+               GC.KeepAlive(min_final_cltv_expiry_delta);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ ret_hu_conv = Result_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ.constr_from_ptr(ret);
+               Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ret_hu_conv = Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(min_value_msat); };
+               if (this != null) { this.ptrs_to.AddLast(min_final_cltv_expiry_delta); };
                return ret_hu_conv;
        }
 
@@ -821,8 +1980,8 @@ public class ChannelManager : CommonBase {
         * If you need exact expiry semantics, you should enforce them upon receipt of
         * [`PaymentClaimable`].
         * 
-        * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry`
-        * set to at least [`MIN_FINAL_CLTV_EXPIRY`].
+        * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta`
+        * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`].
         * 
         * Note that a malicious eavesdropper can intuit whether an inbound payment was created by
         * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime.
@@ -834,39 +1993,23 @@ public class ChannelManager : CommonBase {
         * 
         * Errors if `min_value_msat` is greater than total bitcoin supply.
         * 
+        * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable
+        * on versions of LDK prior to 0.0.114.
+        * 
         * [`create_inbound_payment`]: Self::create_inbound_payment
         * [`PaymentClaimable`]: events::Event::PaymentClaimable
         */
-       public Result_PaymentSecretNoneZ create_inbound_payment_for_hash(byte[] payment_hash, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
-               long ret = bindings.ChannelManager_create_inbound_payment_for_hash(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), min_value_msat.ptr, invoice_expiry_delta_secs);
+       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) {
+               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);
                GC.KeepAlive(this);
                GC.KeepAlive(payment_hash);
                GC.KeepAlive(min_value_msat);
                GC.KeepAlive(invoice_expiry_delta_secs);
+               GC.KeepAlive(min_final_cltv_expiry);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_PaymentSecretNoneZ ret_hu_conv = Result_PaymentSecretNoneZ.constr_from_ptr(ret);
-               return ret_hu_conv;
-       }
-
-       /**
-        * Legacy version of [`create_inbound_payment_for_hash`]. Use this method if you wish to share
-        * serialized state with LDK node(s) running 0.0.103 and earlier.
-        * 
-        * May panic if `invoice_expiry_delta_secs` is greater than one year.
-        * 
-        * # Note
-        * This method is deprecated and will be removed soon.
-        * 
-        * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
-        */
-       public Result_PaymentSecretAPIErrorZ create_inbound_payment_for_hash_legacy(byte[] payment_hash, org.ldk.structs.Option_u64Z min_value_msat, int invoice_expiry_delta_secs) {
-               long ret = bindings.ChannelManager_create_inbound_payment_for_hash_legacy(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), min_value_msat.ptr, invoice_expiry_delta_secs);
-               GC.KeepAlive(this);
-               GC.KeepAlive(payment_hash);
-               GC.KeepAlive(min_value_msat);
-               GC.KeepAlive(invoice_expiry_delta_secs);
-               if (ret >= 0 && ret <= 4096) { return null; }
-               Result_PaymentSecretAPIErrorZ ret_hu_conv = Result_PaymentSecretAPIErrorZ.constr_from_ptr(ret);
+               Result_ThirtyTwoBytesNoneZ ret_hu_conv = Result_ThirtyTwoBytesNoneZ.constr_from_ptr(ret);
+               if (this != null) { this.ptrs_to.AddLast(min_value_msat); };
+               if (this != null) { this.ptrs_to.AddLast(min_final_cltv_expiry); };
                return ret_hu_conv;
        }
 
@@ -876,13 +2019,13 @@ public class ChannelManager : CommonBase {
         * 
         * [`create_inbound_payment`]: Self::create_inbound_payment
         */
-       public Result_PaymentPreimageAPIErrorZ get_payment_preimage(byte[] payment_hash, byte[] payment_secret) {
-               long ret = bindings.ChannelManager_get_payment_preimage(this.ptr, InternalUtils.check_arr_len(payment_hash, 32), InternalUtils.check_arr_len(payment_secret, 32));
+       public Result_ThirtyTwoBytesAPIErrorZ get_payment_preimage(byte[] payment_hash, byte[] payment_secret) {
+               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)));
                GC.KeepAlive(this);
                GC.KeepAlive(payment_hash);
                GC.KeepAlive(payment_secret);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_PaymentPreimageAPIErrorZ ret_hu_conv = Result_PaymentPreimageAPIErrorZ.constr_from_ptr(ret);
+               Result_ThirtyTwoBytesAPIErrorZ ret_hu_conv = Result_ThirtyTwoBytesAPIErrorZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
 
@@ -890,7 +2033,7 @@ public class ChannelManager : CommonBase {
         * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids
         * are used when constructing the phantom invoice's route hints.
         * 
-        * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
+        * [phantom node payments]: crate::sign::PhantomKeysManager
         */
        public long get_phantom_scid() {
                long ret = bindings.ChannelManager_get_phantom_scid(this.ptr);
@@ -901,7 +2044,7 @@ public class ChannelManager : CommonBase {
        /**
         * Gets route hints for use in receiving [phantom node payments].
         * 
-        * [phantom node payments]: crate::chain::keysinterface::PhantomKeysManager
+        * [phantom node payments]: crate::sign::PhantomKeysManager
         */
        public PhantomRouteHints get_phantom_route_hints() {
                long ret = bindings.ChannelManager_get_phantom_route_hints(this.ptr);
@@ -992,60 +2135,97 @@ public class ChannelManager : CommonBase {
        }
 
        /**
-        * Blocks until ChannelManager needs to be persisted or a timeout is reached. It returns a bool
-        * indicating whether persistence is necessary. Only one listener on
-        * [`await_persistable_update`], [`await_persistable_update_timeout`], or a future returned by
-        * [`get_persistable_update_future`] is guaranteed to be woken up.
+        * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or
+        * may have events that need processing.
         * 
-        * Note that this method is not available with the `no-std` feature.
+        * In order to check if this [`ChannelManager`] needs persisting, call
+        * [`Self::get_and_clear_needs_persistence`].
         * 
-        * [`await_persistable_update`]: Self::await_persistable_update
-        * [`await_persistable_update_timeout`]: Self::await_persistable_update_timeout
-        * [`get_persistable_update_future`]: Self::get_persistable_update_future
+        * Note that callbacks registered on the [`Future`] MUST NOT call back into this
+        * [`ChannelManager`] and should instead register actions to be taken later.
         */
-       public bool await_persistable_update_timeout(long max_wait) {
-               bool ret = bindings.ChannelManager_await_persistable_update_timeout(this.ptr, max_wait);
+       public Future get_event_or_persistence_needed_future() {
+               long ret = bindings.ChannelManager_get_event_or_persistence_needed_future(this.ptr);
                GC.KeepAlive(this);
-               GC.KeepAlive(max_wait);
-               return ret;
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
        }
 
        /**
-        * Blocks until ChannelManager needs to be persisted. Only one listener on
-        * [`await_persistable_update`], `await_persistable_update_timeout`, or a future returned by
-        * [`get_persistable_update_future`] is guaranteed to be woken up.
+        * Returns true if this [`ChannelManager`] needs to be persisted.
         * 
-        * [`await_persistable_update`]: Self::await_persistable_update
-        * [`get_persistable_update_future`]: Self::get_persistable_update_future
+        * See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that
+        * indicates this should be checked.
         */
-       public void await_persistable_update() {
-               bindings.ChannelManager_await_persistable_update(this.ptr);
+       public bool get_and_clear_needs_persistence() {
+               bool ret = bindings.ChannelManager_get_and_clear_needs_persistence(this.ptr);
                GC.KeepAlive(this);
+               return ret;
        }
 
        /**
-        * Gets a [`Future`] that completes when a persistable update is available. Note that
-        * callbacks registered on the [`Future`] MUST NOT call back into this [`ChannelManager`] and
-        * should instead register actions to be taken later.
+        * Gets the latest best block which was connected either via the [`chain::Listen`] or
+        * [`chain::Confirm`] interfaces.
         */
-       public Future get_persistable_update_future() {
-               long ret = bindings.ChannelManager_get_persistable_update_future(this.ptr);
+       public BestBlock current_best_block() {
+               long ret = bindings.ChannelManager_current_best_block(this.ptr);
                GC.KeepAlive(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               org.ldk.structs.Future ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Future(null, ret); }
+               org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
                return ret_hu_conv;
        }
 
        /**
-        * Gets the latest best block which was connected either via the [`chain::Listen`] or
-        * [`chain::Confirm`] interfaces.
+        * Fetches the set of [`NodeFeatures`] flags that are provided by or required by
+        * [`ChannelManager`].
         */
-       public BestBlock current_best_block() {
-               long ret = bindings.ChannelManager_current_best_block(this.ptr);
+       public NodeFeatures node_features() {
+               long ret = bindings.ChannelManager_node_features(this.ptr);
                GC.KeepAlive(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               org.ldk.structs.BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BestBlock(null, ret); }
+               org.ldk.structs.NodeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by
+        * [`ChannelManager`].
+        */
+       public ChannelFeatures channel_features() {
+               long ret = bindings.ChannelManager_channel_features(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by
+        * [`ChannelManager`].
+        */
+       public ChannelTypeFeatures channel_type_features() {
+               long ret = bindings.ChannelManager_channel_type_features(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.ChannelTypeFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTypeFeatures(null, ret); }
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
+       }
+
+       /**
+        * Fetches the set of [`InitFeatures`] flags that are provided by or required by
+        * [`ChannelManager`].
+        */
+       public InitFeatures init_features() {
+               long ret = bindings.ChannelManager_init_features(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               org.ldk.structs.InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InitFeatures(null, ret); }
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
                return ret_hu_conv;
        }
@@ -1064,26 +2244,41 @@ public class ChannelManager : CommonBase {
        }
 
        /**
-        * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
+        * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg.
+        * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is
         */
-       public byte[] write() {
-               byte[] ret = bindings.ChannelManager_write(this.ptr);
+       public OffersMessageHandler as_OffersMessageHandler() {
+               long ret = bindings.ChannelManager_as_OffersMessageHandler(this.ptr);
                GC.KeepAlive(this);
-               return ret;
+               if (ret >= 0 && ret <= 4096) { return null; }
+               OffersMessageHandler ret_hu_conv = new OffersMessageHandler(null, ret);
+               if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+               return ret_hu_conv;
        }
 
        /**
-        * Constructs a new Payer which calls the relevant methods on this_arg.
-        * This copies the `inner` pointer in this_arg and thus the returned Payer must be freed before this_arg is
+        * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg.
+        * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is
         */
-       public Payer as_Payer() {
-               long ret = bindings.ChannelManager_as_Payer(this.ptr);
+       public NodeIdLookUp as_NodeIdLookUp() {
+               long ret = bindings.ChannelManager_as_NodeIdLookUp(this.ptr);
                GC.KeepAlive(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Payer ret_hu_conv = new Payer(null, ret);
+               NodeIdLookUp ret_hu_conv = new NodeIdLookUp(null, ret);
                if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
                return ret_hu_conv;
        }
 
+       /**
+        * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read
+        */
+       public byte[] write() {
+               long ret = bindings.ChannelManager_write(this.ptr);
+               GC.KeepAlive(this);
+               if (ret >= 0 && ret <= 4096) { return null; }
+               byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
+               return ret_conv;
+       }
+
 }
 } } }