Move the public channel state API into a new module
[rust-lightning] / lightning / src / ln / channelmanager.rs
index 6ae78ec9ced4c45a7189237b2ca91640c97ddd68..1c883755f5a6a5ee77b3ef188925bb2bd18aebb7 100644 (file)
@@ -21,7 +21,7 @@ use bitcoin::blockdata::block::Header;
 use bitcoin::blockdata::transaction::Transaction;
 use bitcoin::blockdata::constants::ChainHash;
 use bitcoin::key::constants::SECRET_KEY_SIZE;
-use bitcoin::network::constants::Network;
+use bitcoin::network::Network;
 
 use bitcoin::hashes::Hash;
 use bitcoin::hashes::sha256::Hash as Sha256;
@@ -32,6 +32,7 @@ use bitcoin::secp256k1::Secp256k1;
 use bitcoin::{secp256k1, Sequence};
 
 use crate::blinded_path::{BlindedPath, NodeIdLookUp};
+use crate::blinded_path::message::ForwardNode;
 use crate::blinded_path::payment::{Bolt12OfferContext, Bolt12RefundContext, PaymentConstraints, PaymentContext, ReceiveTlvs};
 use crate::chain;
 use crate::chain::{Confirm, ChannelMonitorUpdateStatus, Watch, BestBlock};
@@ -45,7 +46,8 @@ use crate::events::{Event, EventHandler, EventsProvider, MessageSendEvent, Messa
 use crate::ln::inbound_payment;
 use crate::ln::types::{ChannelId, PaymentHash, PaymentPreimage, PaymentSecret};
 use crate::ln::channel::{self, Channel, ChannelPhase, ChannelContext, ChannelError, ChannelUpdateStatus, ShutdownResult, UnfundedChannelContext, UpdateFulfillCommitFetch, OutboundV1Channel, InboundV1Channel, WithChannelContext};
-pub use crate::ln::channel::{InboundHTLCDetails, InboundHTLCStateDetails, OutboundHTLCDetails, OutboundHTLCStateDetails};
+pub use crate::ln::channel_state::{ChannelCounterparty, ChannelDetails, ChannelShutdownState, CounterpartyForwardingInfo};
+pub use crate::ln::channel_state::{InboundHTLCDetails, InboundHTLCStateDetails, OutboundHTLCDetails, OutboundHTLCStateDetails};
 use crate::ln::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
 #[cfg(any(feature = "_test_utils", test))]
 use crate::ln::features::Bolt11InvoiceFeatures;
@@ -68,7 +70,7 @@ use crate::offers::refund::{Refund, RefundBuilder};
 use crate::onion_message::messenger::{new_pending_onion_message, Destination, MessageRouter, PendingOnionMessage, Responder, ResponseInstruction};
 use crate::onion_message::offers::{OffersMessage, OffersMessageHandler};
 use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
-use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
+use crate::sign::ecdsa::EcdsaChannelSigner;
 use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
 use crate::util::wakers::{Future, Notifier};
 use crate::util::scid_utils::fake_scid;
@@ -680,6 +682,7 @@ struct ClaimingPayment {
        receiver_node_id: PublicKey,
        htlcs: Vec<events::ClaimedHTLC>,
        sender_intended_value: Option<u64>,
+       onion_fields: Option<RecipientOnionFields>,
 }
 impl_writeable_tlv_based!(ClaimingPayment, {
        (0, amount_msat, required),
@@ -687,6 +690,7 @@ impl_writeable_tlv_based!(ClaimingPayment, {
        (4, receiver_node_id, required),
        (5, htlcs, optional_vec),
        (7, sender_intended_value, option),
+       (9, onion_fields, option),
 });
 
 struct ClaimablePayment {
@@ -1061,8 +1065,8 @@ pub trait AChannelManager {
        type NodeSigner: NodeSigner + ?Sized;
        /// A type that may be dereferenced to [`Self::NodeSigner`].
        type NS: Deref<Target = Self::NodeSigner>;
-       /// A type implementing [`WriteableEcdsaChannelSigner`].
-       type Signer: WriteableEcdsaChannelSigner + Sized;
+       /// A type implementing [`EcdsaChannelSigner`].
+       type Signer: EcdsaChannelSigner + Sized;
        /// A type implementing [`SignerProvider`] for [`Self::Signer`].
        type SignerProvider: SignerProvider<EcdsaSigner= Self::Signer> + ?Sized;
        /// A type that may be dereferenced to [`Self::SignerProvider`].
@@ -1167,7 +1171,7 @@ where
 ///
 /// ```
 /// use bitcoin::BlockHash;
-/// use bitcoin::network::constants::Network;
+/// use bitcoin::network::Network;
 /// use lightning::chain::BestBlock;
 /// # use lightning::chain::channelmonitor::ChannelMonitor;
 /// use lightning::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs};
@@ -2283,338 +2287,6 @@ const MAX_UNFUNDED_CHANNEL_PEERS: usize = 50;
 /// many peers we reject new (inbound) connections.
 const MAX_NO_CHANNEL_PEERS: usize = 250;
 
-/// Information needed for constructing an invoice route hint for this channel.
-#[derive(Clone, Debug, PartialEq)]
-pub struct CounterpartyForwardingInfo {
-       /// Base routing fee in millisatoshis.
-       pub fee_base_msat: u32,
-       /// Amount in millionths of a satoshi the channel will charge per transferred satoshi.
-       pub fee_proportional_millionths: u32,
-       /// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart,
-       /// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s
-       /// `cltv_expiry_delta` for more details.
-       pub cltv_expiry_delta: u16,
-}
-
-/// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
-/// to better separate parameters.
-#[derive(Clone, Debug, PartialEq)]
-pub struct ChannelCounterparty {
-       /// The node_id of our counterparty
-       pub node_id: PublicKey,
-       /// The Features the channel counterparty provided upon last connection.
-       /// Useful for routing as it is the most up-to-date copy of the counterparty's features and
-       /// many routing-relevant features are present in the init context.
-       pub features: InitFeatures,
-       /// The value, in satoshis, that must always be held in the channel for our counterparty. This
-       /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by
-       /// claiming at least this value on chain.
-       ///
-       /// This value is not included in [`inbound_capacity_msat`] as it can never be spent.
-       ///
-       /// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat
-       pub unspendable_punishment_reserve: u64,
-       /// Information on the fees and requirements that the counterparty requires when forwarding
-       /// payments to us through this channel.
-       pub forwarding_info: Option<CounterpartyForwardingInfo>,
-       /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field
-       /// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message
-       /// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107.
-       pub outbound_htlc_minimum_msat: Option<u64>,
-       /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel.
-       pub outbound_htlc_maximum_msat: Option<u64>,
-}
-
-/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`]
-#[derive(Clone, Debug, PartialEq)]
-pub struct ChannelDetails {
-       /// The channel's ID (prior to funding transaction generation, this is a random 32 bytes,
-       /// thereafter this is the txid of the funding transaction xor the funding transaction output).
-       /// Note that this means this value is *not* persistent - it can change once during the
-       /// lifetime of the channel.
-       pub channel_id: ChannelId,
-       /// Parameters which apply to our counterparty. See individual fields for more information.
-       pub counterparty: ChannelCounterparty,
-       /// The Channel's funding transaction output, if we've negotiated the funding transaction with
-       /// our counterparty already.
-       pub funding_txo: Option<OutPoint>,
-       /// The features which this channel operates with. See individual features for more info.
-       ///
-       /// `None` until negotiation completes and the channel type is finalized.
-       pub channel_type: Option<ChannelTypeFeatures>,
-       /// The position of the funding transaction in the chain. None if the funding transaction has
-       /// not yet been confirmed and the channel fully opened.
-       ///
-       /// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
-       /// payments instead of this. See [`get_inbound_payment_scid`].
-       ///
-       /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
-       /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
-       ///
-       /// [`inbound_scid_alias`]: Self::inbound_scid_alias
-       /// [`outbound_scid_alias`]: Self::outbound_scid_alias
-       /// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
-       /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
-       /// [`confirmations_required`]: Self::confirmations_required
-       pub short_channel_id: Option<u64>,
-       /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
-       /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
-       /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
-       /// `Some(0)`).
-       ///
-       /// This will be `None` as long as the channel is not available for routing outbound payments.
-       ///
-       /// [`short_channel_id`]: Self::short_channel_id
-       /// [`confirmations_required`]: Self::confirmations_required
-       pub outbound_scid_alias: Option<u64>,
-       /// An optional [`short_channel_id`] alias for this channel, randomly generated by our
-       /// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
-       /// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
-       /// when they see a payment to be routed to us.
-       ///
-       /// Our counterparty may choose to rotate this value at any time, though will always recognize
-       /// previous values for inbound payment forwarding.
-       ///
-       /// [`short_channel_id`]: Self::short_channel_id
-       pub inbound_scid_alias: Option<u64>,
-       /// The value, in satoshis, of this channel as appears in the funding output
-       pub channel_value_satoshis: u64,
-       /// The value, in satoshis, that must always be held in the channel for us. This value ensures
-       /// that if we broadcast a revoked state, our counterparty can punish us by claiming at least
-       /// this value on chain.
-       ///
-       /// This value is not included in [`outbound_capacity_msat`] as it can never be spent.
-       ///
-       /// This value will be `None` for outbound channels until the counterparty accepts the channel.
-       ///
-       /// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat
-       pub unspendable_punishment_reserve: Option<u64>,
-       /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound
-       /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if
-       /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise
-       /// `user_channel_id` will be randomized for an inbound channel.  This may be zero for objects
-       /// serialized with LDK versions prior to 0.0.113.
-       ///
-       /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
-       /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
-       /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
-       pub user_channel_id: u128,
-       /// The currently negotiated fee rate denominated in satoshi per 1000 weight units,
-       /// which is applied to commitment and HTLC transactions.
-       ///
-       /// This value will be `None` for objects serialized with LDK versions prior to 0.0.115.
-       pub feerate_sat_per_1000_weight: Option<u32>,
-       /// Our total balance.  This is the amount we would get if we close the channel.
-       /// This value is not exact. Due to various in-flight changes and feerate changes, exactly this
-       /// amount is not likely to be recoverable on close.
-       ///
-       /// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose
-       /// balance is not available for inclusion in new outbound HTLCs). This further does not include
-       /// any pending outgoing HTLCs which are awaiting some other resolution to be sent.
-       /// This does not consider any on-chain fees.
-       ///
-       /// See also [`ChannelDetails::outbound_capacity_msat`]
-       pub balance_msat: u64,
-       /// The available outbound capacity for sending HTLCs to the remote peer. This does not include
-       /// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
-       /// available for inclusion in new outbound HTLCs). This further does not include any pending
-       /// outgoing HTLCs which are awaiting some other resolution to be sent.
-       ///
-       /// See also [`ChannelDetails::balance_msat`]
-       ///
-       /// This value is not exact. Due to various in-flight changes, feerate changes, and our
-       /// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we
-       /// should be able to spend nearly this amount.
-       pub outbound_capacity_msat: u64,
-       /// The available outbound capacity for sending a single HTLC to the remote peer. This is
-       /// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by
-       /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us
-       /// to use a limit as close as possible to the HTLC limit we can currently send.
-       ///
-       /// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`],
-       /// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`].
-       pub next_outbound_htlc_limit_msat: u64,
-       /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of
-       /// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than
-       /// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a
-       /// route which is valid.
-       pub next_outbound_htlc_minimum_msat: u64,
-       /// The available inbound capacity for the remote peer to send HTLCs to us. This does not
-       /// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not
-       /// available for inclusion in new inbound HTLCs).
-       /// Note that there are some corner cases not fully handled here, so the actual available
-       /// inbound capacity may be slightly higher than this.
-       ///
-       /// This value is not exact. Due to various in-flight changes, feerate changes, and our
-       /// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable.
-       /// However, our counterparty should be able to spend nearly this amount.
-       pub inbound_capacity_msat: u64,
-       /// The number of required confirmations on the funding transaction before the funding will be
-       /// considered "locked". This number is selected by the channel fundee (i.e. us if
-       /// [`is_outbound`] is *not* set), and can be selected for inbound channels with
-       /// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with
-       /// [`ChannelHandshakeLimits::max_minimum_depth`].
-       ///
-       /// This value will be `None` for outbound channels until the counterparty accepts the channel.
-       ///
-       /// [`is_outbound`]: ChannelDetails::is_outbound
-       /// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth
-       /// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth
-       pub confirmations_required: Option<u32>,
-       /// The current number of confirmations on the funding transaction.
-       ///
-       /// This value will be `None` for objects serialized with LDK versions prior to 0.0.113.
-       pub confirmations: Option<u32>,
-       /// The number of blocks (after our commitment transaction confirms) that we will need to wait
-       /// until we can claim our funds after we force-close the channel. During this time our
-       /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty
-       /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any
-       /// time to claim our non-HTLC-encumbered funds.
-       ///
-       /// This value will be `None` for outbound channels until the counterparty accepts the channel.
-       pub force_close_spend_delay: Option<u16>,
-       /// True if the channel was initiated (and thus funded) by us.
-       pub is_outbound: bool,
-       /// True if the channel is confirmed, channel_ready messages have been exchanged, and the
-       /// channel is not currently being shut down. `channel_ready` message exchange implies the
-       /// required confirmation count has been reached (and we were connected to the peer at some
-       /// point after the funding transaction received enough confirmations). The required
-       /// confirmation count is provided in [`confirmations_required`].
-       ///
-       /// [`confirmations_required`]: ChannelDetails::confirmations_required
-       pub is_channel_ready: bool,
-       /// The stage of the channel's shutdown.
-       /// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116.
-       pub channel_shutdown_state: Option<ChannelShutdownState>,
-       /// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b)
-       /// the peer is connected, and (c) the channel is not currently negotiating a shutdown.
-       ///
-       /// This is a strict superset of `is_channel_ready`.
-       pub is_usable: bool,
-       /// True if this channel is (or will be) publicly-announced.
-       pub is_public: bool,
-       /// The smallest value HTLC (in msat) we will accept, for this channel. This field
-       /// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107
-       pub inbound_htlc_minimum_msat: Option<u64>,
-       /// The largest value HTLC (in msat) we currently will accept, for this channel.
-       pub inbound_htlc_maximum_msat: Option<u64>,
-       /// Set of configurable parameters that affect channel operation.
-       ///
-       /// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109.
-       pub config: Option<ChannelConfig>,
-       /// Pending inbound HTLCs.
-       ///
-       /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
-       pub pending_inbound_htlcs: Vec<InboundHTLCDetails>,
-       /// Pending outbound HTLCs.
-       ///
-       /// This field is empty for objects serialized with LDK versions prior to 0.0.122.
-       pub pending_outbound_htlcs: Vec<OutboundHTLCDetails>,
-}
-
-impl ChannelDetails {
-       /// Gets the current SCID which should be used to identify this channel for inbound payments.
-       /// This should be used for providing invoice hints or in any other context where our
-       /// counterparty will forward a payment to us.
-       ///
-       /// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the
-       /// [`ChannelDetails::short_channel_id`]. See those for more information.
-       pub fn get_inbound_payment_scid(&self) -> Option<u64> {
-               self.inbound_scid_alias.or(self.short_channel_id)
-       }
-
-       /// Gets the current SCID which should be used to identify this channel for outbound payments.
-       /// This should be used in [`Route`]s to describe the first hop or in other contexts where
-       /// we're sending or forwarding a payment outbound over this channel.
-       ///
-       /// This is either the [`ChannelDetails::short_channel_id`], if set, or the
-       /// [`ChannelDetails::outbound_scid_alias`]. See those for more information.
-       pub fn get_outbound_payment_scid(&self) -> Option<u64> {
-               self.short_channel_id.or(self.outbound_scid_alias)
-       }
-
-       fn from_channel_context<SP: Deref, F: Deref>(
-               context: &ChannelContext<SP>, best_block_height: u32, latest_features: InitFeatures,
-               fee_estimator: &LowerBoundedFeeEstimator<F>
-       ) -> Self
-       where
-               SP::Target: SignerProvider,
-               F::Target: FeeEstimator
-       {
-               let balance = context.get_available_balances(fee_estimator);
-               let (to_remote_reserve_satoshis, to_self_reserve_satoshis) =
-                       context.get_holder_counterparty_selected_channel_reserve_satoshis();
-               ChannelDetails {
-                       channel_id: context.channel_id(),
-                       counterparty: ChannelCounterparty {
-                               node_id: context.get_counterparty_node_id(),
-                               features: latest_features,
-                               unspendable_punishment_reserve: to_remote_reserve_satoshis,
-                               forwarding_info: context.counterparty_forwarding_info(),
-                               // Ensures that we have actually received the `htlc_minimum_msat` value
-                               // from the counterparty through the `OpenChannel` or `AcceptChannel`
-                               // message (as they are always the first message from the counterparty).
-                               // Else `Channel::get_counterparty_htlc_minimum_msat` could return the
-                               // default `0` value set by `Channel::new_outbound`.
-                               outbound_htlc_minimum_msat: if context.have_received_message() {
-                                       Some(context.get_counterparty_htlc_minimum_msat()) } else { None },
-                               outbound_htlc_maximum_msat: context.get_counterparty_htlc_maximum_msat(),
-                       },
-                       funding_txo: context.get_funding_txo(),
-                       // Note that accept_channel (or open_channel) is always the first message, so
-                       // `have_received_message` indicates that type negotiation has completed.
-                       channel_type: if context.have_received_message() { Some(context.get_channel_type().clone()) } else { None },
-                       short_channel_id: context.get_short_channel_id(),
-                       outbound_scid_alias: if context.is_usable() { Some(context.outbound_scid_alias()) } else { None },
-                       inbound_scid_alias: context.latest_inbound_scid_alias(),
-                       channel_value_satoshis: context.get_value_satoshis(),
-                       feerate_sat_per_1000_weight: Some(context.get_feerate_sat_per_1000_weight()),
-                       unspendable_punishment_reserve: to_self_reserve_satoshis,
-                       balance_msat: balance.balance_msat,
-                       inbound_capacity_msat: balance.inbound_capacity_msat,
-                       outbound_capacity_msat: balance.outbound_capacity_msat,
-                       next_outbound_htlc_limit_msat: balance.next_outbound_htlc_limit_msat,
-                       next_outbound_htlc_minimum_msat: balance.next_outbound_htlc_minimum_msat,
-                       user_channel_id: context.get_user_id(),
-                       confirmations_required: context.minimum_depth(),
-                       confirmations: Some(context.get_funding_tx_confirmations(best_block_height)),
-                       force_close_spend_delay: context.get_counterparty_selected_contest_delay(),
-                       is_outbound: context.is_outbound(),
-                       is_channel_ready: context.is_usable(),
-                       is_usable: context.is_live(),
-                       is_public: context.should_announce(),
-                       inbound_htlc_minimum_msat: Some(context.get_holder_htlc_minimum_msat()),
-                       inbound_htlc_maximum_msat: context.get_holder_htlc_maximum_msat(),
-                       config: Some(context.config()),
-                       channel_shutdown_state: Some(context.shutdown_state()),
-                       pending_inbound_htlcs: context.get_pending_inbound_htlc_details(),
-                       pending_outbound_htlcs: context.get_pending_outbound_htlc_details(),
-               }
-       }
-}
-
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-/// Further information on the details of the channel shutdown.
-/// Upon channels being forced closed (i.e. commitment transaction confirmation detected
-/// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or
-/// the channel will be removed shortly.
-/// Also note, that in normal operation, peers could disconnect at any of these states
-/// and require peer re-connection before making progress onto other states
-pub enum ChannelShutdownState {
-       /// Channel has not sent or received a shutdown message.
-       NotShuttingDown,
-       /// Local node has sent a shutdown message for this channel.
-       ShutdownInitiated,
-       /// Shutdown message exchanges have concluded and the channels are in the midst of
-       /// resolving all existing open HTLCs before closing can continue.
-       ResolvingHTLCs,
-       /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates.
-       NegotiatingClosingFee,
-       /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about
-       /// to drop the channel.
-       ShutdownComplete,
-}
-
 /// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
 /// These include payments that have yet to find a successful path, or have unresolved HTLCs.
 #[derive(Debug, PartialEq)]
@@ -2690,7 +2362,7 @@ macro_rules! handle_error {
                                        let counterparty_node_id = shutdown_res.counterparty_node_id;
                                        let channel_id = shutdown_res.channel_id;
                                        let logger = WithContext::from(
-                                               &$self.logger, Some(counterparty_node_id), Some(channel_id),
+                                               &$self.logger, Some(counterparty_node_id), Some(channel_id), None
                                        );
                                        log_error!(logger, "Force-closing channel: {}", err.err);
 
@@ -2761,7 +2433,7 @@ macro_rules! convert_chan_phase_err {
                                (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), *$channel_id))
                        },
                        ChannelError::Close(msg) => {
-                               let logger = WithChannelContext::from(&$self.logger, &$channel.context);
+                               let logger = WithChannelContext::from(&$self.logger, &$channel.context, None);
                                log_error!(logger, "Closing channel {} due to close-required error: {}", $channel_id, msg);
                                update_maps_on_chan_removal!($self, $channel.context);
                                let reason = ClosureReason::ProcessingError { err: msg.clone() };
@@ -2896,7 +2568,7 @@ macro_rules! emit_channel_ready_event {
 
 macro_rules! handle_monitor_update_completion {
        ($self: ident, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr) => { {
-               let logger = WithChannelContext::from(&$self.logger, &$chan.context);
+               let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
                let mut updates = $chan.monitor_updating_restored(&&logger,
                        &$self.node_signer, $self.chain_hash, &$self.default_configuration,
                        $self.best_block.read().unwrap().height);
@@ -2995,7 +2667,7 @@ macro_rules! handle_monitor_update_completion {
 macro_rules! handle_new_monitor_update {
        ($self: ident, $update_res: expr, $chan: expr, _internal, $completed: expr) => { {
                debug_assert!($self.background_events_processed_since_startup.load(Ordering::Acquire));
-               let logger = WithChannelContext::from(&$self.logger, &$chan.context);
+               let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
                match $update_res {
                        ChannelMonitorUpdateStatus::UnrecoverableError => {
                                let err_str = "ChannelMonitor[Update] persistence failed unrecoverably. This indicates we cannot continue normal operation and must shut down.";
@@ -3576,7 +3248,7 @@ where
                }
 
                let logger = WithContext::from(
-                       &self.logger, Some(shutdown_res.counterparty_node_id), Some(shutdown_res.channel_id),
+                       &self.logger, Some(shutdown_res.counterparty_node_id), Some(shutdown_res.channel_id), None
                );
 
                log_debug!(logger, "Finishing closure of channel due to {} with {} HTLCs to fail",
@@ -3652,7 +3324,7 @@ where
                        } else {
                                ClosureReason::HolderForceClosed
                        };
-                       let logger = WithContext::from(&self.logger, Some(*peer_node_id), Some(*channel_id));
+                       let logger = WithContext::from(&self.logger, Some(*peer_node_id), Some(*channel_id), None);
                        if let hash_map::Entry::Occupied(chan_phase_entry) = peer_state.channel_by_id.entry(channel_id.clone()) {
                                log_error!(logger, "Force-closing channel {}", channel_id);
                                let mut chan_phase = remove_channel_phase!(self, chan_phase_entry);
@@ -3886,7 +3558,7 @@ where
                }
 
                log_info!(
-                       WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id)),
+                       WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id), Some(msg.payment_hash)),
                        "Failed to accept/forward incoming HTLC: {}", err_msg
                );
                // If `msg.blinding_point` is set, we must always fail with malformed.
@@ -3948,7 +3620,7 @@ where
                macro_rules! return_err {
                        ($msg: expr, $err_code: expr, $data: expr) => {
                                {
-                                       let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id));
+                                       let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id), Some(msg.payment_hash));
                                        log_info!(logger, "Failed to accept/forward incoming HTLC: {}", $msg);
                                        if msg.blinding_point.is_some() {
                                                return PendingHTLCStatus::Fail(HTLCFailureMsg::Malformed(
@@ -4017,7 +3689,7 @@ where
                if chan.context.get_short_channel_id().is_none() {
                        return Err(LightningError{err: "Channel not yet established".to_owned(), action: msgs::ErrorAction::IgnoreError});
                }
-               let logger = WithChannelContext::from(&self.logger, &chan.context);
+               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                log_trace!(logger, "Attempting to generate broadcast channel update for channel {}", &chan.context.channel_id());
                self.get_channel_update_for_unicast(chan)
        }
@@ -4034,7 +3706,7 @@ where
        /// [`channel_update`]: msgs::ChannelUpdate
        /// [`internal_closing_signed`]: Self::internal_closing_signed
        fn get_channel_update_for_unicast(&self, chan: &Channel<SP>) -> Result<msgs::ChannelUpdate, LightningError> {
-               let logger = WithChannelContext::from(&self.logger, &chan.context);
+               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                log_trace!(logger, "Attempting to generate channel update for channel {}", chan.context.channel_id());
                let short_channel_id = match chan.context.get_short_channel_id().or(chan.context.latest_inbound_scid_alias()) {
                        None => return Err(LightningError{err: "Channel not yet established".to_owned(), action: msgs::ErrorAction::IgnoreError}),
@@ -4045,7 +3717,7 @@ where
        }
 
        fn get_channel_update_for_onion(&self, short_channel_id: u64, chan: &Channel<SP>) -> Result<msgs::ChannelUpdate, LightningError> {
-               let logger = WithChannelContext::from(&self.logger, &chan.context);
+               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                log_trace!(logger, "Generating channel update for channel {}", chan.context.channel_id());
                let were_node_one = self.our_network_pubkey.serialize()[..] < chan.context.get_counterparty_node_id().serialize()[..];
 
@@ -4084,8 +3756,8 @@ where
        pub(crate) fn test_send_payment_along_path(&self, path: &Path, payment_hash: &PaymentHash, recipient_onion: RecipientOnionFields, total_value: u64, cur_height: u32, payment_id: PaymentId, keysend_preimage: &Option<PaymentPreimage>, session_priv_bytes: [u8; 32]) -> Result<(), APIError> {
                let _lck = self.total_consistency_lock.read().unwrap();
                self.send_payment_along_path(SendAlongPathArgs {
-                       path, payment_hash, recipient_onion, total_value, cur_height, payment_id, keysend_preimage,
-                       session_priv_bytes
+                       path, payment_hash, recipient_onion: &recipient_onion, total_value,
+                       cur_height, payment_id, keysend_preimage, session_priv_bytes
                })
        }
 
@@ -4103,7 +3775,7 @@ where
                        &self.secp_ctx, &path, &session_priv, total_value, recipient_onion, cur_height,
                        payment_hash, keysend_preimage, prng_seed
                ).map_err(|e| {
-                       let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None);
+                       let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None, Some(*payment_hash));
                        log_error!(logger, "Failed to build an onion for path for payment hash {}", payment_hash);
                        e
                })?;
@@ -4111,14 +3783,14 @@ where
                let err: Result<(), _> = loop {
                        let (counterparty_node_id, id) = match self.short_to_chan_info.read().unwrap().get(&path.hops.first().unwrap().short_channel_id) {
                                None => {
-                                       let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None);
+                                       let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None, Some(*payment_hash));
                                        log_error!(logger, "Failed to find first-hop for payment hash {}", payment_hash);
                                        return Err(APIError::ChannelUnavailable{err: "No channel available with first hop!".to_owned()})
                                },
                                Some((cp_id, chan_id)) => (cp_id.clone(), chan_id.clone()),
                        };
 
-                       let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(id));
+                       let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(id), Some(*payment_hash));
                        log_trace!(logger,
                                "Attempting to send payment with payment hash {} along path with next hop {}",
                                payment_hash, path.hops.first().unwrap().short_channel_id);
@@ -4135,7 +3807,7 @@ where
                                                        return Err(APIError::ChannelUnavailable{err: "Peer for first hop currently disconnected".to_owned()});
                                                }
                                                let funding_txo = chan.context.get_funding_txo().unwrap();
-                                               let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                               let logger = WithChannelContext::from(&self.logger, &chan.context, Some(*payment_hash));
                                                let send_res = chan.send_htlc_and_commit(htlc_msat, payment_hash.clone(),
                                                        htlc_cltv, HTLCSource::OutboundRoute {
                                                                path: path.clone(),
@@ -4520,7 +4192,7 @@ where
                                        },
                                }
 
-                               let logger = WithChannelContext::from(&self.logger, &chan.context);
+                               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                let funding_res = chan.get_funding_created(funding_transaction, funding_txo, is_batch_funding, &&logger);
                                match funding_res {
                                        Ok(funding_msg) => (chan, funding_msg),
@@ -4632,7 +4304,7 @@ where
                let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
                let mut result = Ok(());
 
-               if !funding_transaction.is_coin_base() {
+               if !funding_transaction.is_coinbase() {
                        for inp in funding_transaction.input.iter() {
                                if inp.witness.is_empty() {
                                        result = result.and(Err(APIError::APIMisuseError {
@@ -4688,9 +4360,9 @@ where
                                is_batch_funding,
                                |chan, tx| {
                                        let mut output_index = None;
-                                       let expected_spk = chan.context.get_funding_redeemscript().to_v0_p2wsh();
+                                       let expected_spk = chan.context.get_funding_redeemscript().to_p2wsh();
                                        for (idx, outp) in tx.output.iter().enumerate() {
-                                               if outp.script_pubkey == expected_spk && outp.value == chan.context.get_value_satoshis() {
+                                               if outp.script_pubkey == expected_spk && outp.value.to_sat() == chan.context.get_value_satoshis() {
                                                        if output_index.is_some() {
                                                                return Err("Multiple outputs matched the expected script and value");
                                                        }
@@ -4909,7 +4581,7 @@ where
                                None => {
                                        let error = format!("Channel with id {} not found for the passed counterparty node_id {}",
                                                next_hop_channel_id, next_node_id);
-                                       let logger = WithContext::from(&self.logger, Some(next_node_id), Some(*next_hop_channel_id));
+                                       let logger = WithContext::from(&self.logger, Some(next_node_id), Some(*next_hop_channel_id), None);
                                        log_error!(logger, "{} when attempting to forward intercepted HTLC", error);
                                        return Err(APIError::ChannelUnavailable {
                                                err: error
@@ -5042,7 +4714,7 @@ where
 
                                // Process the HTLC on the incoming channel.
                                match self.do_funded_channel_callback(incoming_scid, |chan: &mut Channel<SP>| {
-                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                       let logger = WithChannelContext::from(&self.logger, &chan.context, Some(update_add_htlc.payment_hash));
                                        chan.can_accept_incoming_htlc(
                                                update_add_htlc, &self.fee_estimator, &logger,
                                        )
@@ -5155,7 +4827,7 @@ where
                                                                        }) => {
                                                                                macro_rules! failure_handler {
                                                                                        ($msg: expr, $err_code: expr, $err_data: expr, $phantom_ss: expr, $next_hop_unknown: expr) => {
-                                                                                               let logger = WithContext::from(&self.logger, forwarding_counterparty, Some(prev_channel_id));
+                                                                                               let logger = WithContext::from(&self.logger, forwarding_counterparty, Some(prev_channel_id), Some(payment_hash));
                                                                                                log_info!(logger, "Failed to accept/forward incoming HTLC: {}", $msg);
 
                                                                                                let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
@@ -5266,7 +4938,7 @@ where
                                        let mut peer_state_lock = peer_state_mutex_opt.unwrap().lock().unwrap();
                                        let peer_state = &mut *peer_state_lock;
                                        if let Some(ChannelPhase::Funded(ref mut chan)) = peer_state.channel_by_id.get_mut(&forward_chan_id) {
-                                               let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                for forward_info in pending_forwards.drain(..) {
                                                        let queue_fail_htlc_res = match forward_info {
                                                                HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
@@ -5278,6 +4950,7 @@ where
                                                                                }, skimmed_fee_msat, ..
                                                                        },
                                                                }) => {
+                                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, Some(payment_hash));
                                                                        log_trace!(logger, "Adding HTLC from short id {} with payment_hash {} to channel with short id {} after delay", prev_short_channel_id, &payment_hash, short_chan_id);
                                                                        let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
                                                                                short_channel_id: prev_short_channel_id,
@@ -5710,7 +5383,7 @@ where
        fn update_channel_fee(&self, chan_id: &ChannelId, chan: &mut Channel<SP>, new_feerate: u32) -> NotifyOption {
                if !chan.context.is_outbound() { return NotifyOption::SkipPersistNoEvents; }
 
-               let logger = WithChannelContext::from(&self.logger, &chan.context);
+               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
 
                // If the feerate has decreased by less than half, don't bother
                if new_feerate <= chan.context.get_feerate_sat_per_1000_weight() && new_feerate * 2 > chan.context.get_feerate_sat_per_1000_weight() {
@@ -5803,7 +5476,7 @@ where
                        | {
                                context.maybe_expire_prev_config();
                                if unfunded_context.should_expire_unfunded_channel() {
-                                       let logger = WithChannelContext::from(&self.logger, context);
+                                       let logger = WithChannelContext::from(&self.logger, context, None);
                                        log_error!(logger,
                                                "Force-closing pending channel with ID {} for not establishing in a timely manner", chan_id);
                                        update_maps_on_chan_removal!(self, &context);
@@ -5890,7 +5563,7 @@ where
                                                                chan.context.maybe_expire_prev_config();
 
                                                                if chan.should_disconnect_peer_awaiting_response() {
-                                                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                                        log_debug!(logger, "Disconnecting peer {} due to not making any progress on channel {}",
                                                                                        counterparty_node_id, chan_id);
                                                                        pending_msg_events.push(MessageSendEvent::HandleError {
@@ -5929,7 +5602,7 @@ where
 
                                        for (chan_id, req) in peer_state.inbound_channel_request_by_id.iter_mut() {
                                                if { req.ticks_remaining -= 1 ; req.ticks_remaining } <= 0 {
-                                                       let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(*chan_id));
+                                                       let logger = WithContext::from(&self.logger, Some(counterparty_node_id), Some(*chan_id), None);
                                                        log_error!(logger, "Force-closing unaccepted inbound channel {} for not accepting in a timely manner", &chan_id);
                                                        peer_state.pending_msg_events.push(
                                                                events::MessageSendEvent::HandleError {
@@ -6215,7 +5888,7 @@ where
                                ref phantom_shared_secret, outpoint: _, ref blinded_failure, ref channel_id, ..
                        }) => {
                                log_trace!(
-                                       WithContext::from(&self.logger, None, Some(*channel_id)),
+                                       WithContext::from(&self.logger, None, Some(*channel_id), Some(*payment_hash)),
                                        "Failing {}HTLC with payment_hash {} backwards from us: {:?}",
                                        if blinded_failure.is_some() { "blinded " } else { "" }, &payment_hash, onion_error
                                );
@@ -6323,19 +5996,27 @@ where
                                        }
                                }
 
-                               let htlcs = payment.htlcs.iter().map(events::ClaimedHTLC::from).collect();
-                               let sender_intended_value = payment.htlcs.first().map(|htlc| htlc.total_msat);
-                               let dup_purpose = claimable_payments.pending_claiming_payments.insert(payment_hash,
-                                       ClaimingPayment { amount_msat: payment.htlcs.iter().map(|source| source.value).sum(),
-                                       payment_purpose: payment.purpose, receiver_node_id, htlcs, sender_intended_value
-                               });
-                               if dup_purpose.is_some() {
-                                       debug_assert!(false, "Shouldn't get a duplicate pending claim event ever");
-                                       log_error!(self.logger, "Got a duplicate pending claimable event on payment hash {}! Please report this bug",
-                                               &payment_hash);
-                               }
+                               let claiming_payment = claimable_payments.pending_claiming_payments
+                                       .entry(payment_hash)
+                                       .and_modify(|_| {
+                                               debug_assert!(false, "Shouldn't get a duplicate pending claim event ever");
+                                               log_error!(self.logger, "Got a duplicate pending claimable event on payment hash {}! Please report this bug",
+                                                       &payment_hash);
+                                       })
+                                       .or_insert_with(|| {
+                                               let htlcs = payment.htlcs.iter().map(events::ClaimedHTLC::from).collect();
+                                               let sender_intended_value = payment.htlcs.first().map(|htlc| htlc.total_msat);
+                                               ClaimingPayment {
+                                                       amount_msat: payment.htlcs.iter().map(|source| source.value).sum(),
+                                                       payment_purpose: payment.purpose,
+                                                       receiver_node_id,
+                                                       htlcs,
+                                                       sender_intended_value,
+                                                       onion_fields: payment.onion_fields,
+                                               }
+                                       });
 
-                               if let Some(RecipientOnionFields { ref custom_tlvs, .. }) = payment.onion_fields {
+                               if let Some(RecipientOnionFields { ref custom_tlvs, .. }) = claiming_payment.onion_fields {
                                        if !custom_tlvs_known && custom_tlvs.iter().any(|(typ, _)| typ % 2 == 0) {
                                                log_info!(self.logger, "Rejecting payment with payment hash {} as we cannot accept payment with unknown even TLVs: {}",
                                                        &payment_hash, log_iter!(custom_tlvs.iter().map(|(typ, _)| typ).filter(|typ| *typ % 2 == 0)));
@@ -6409,7 +6090,7 @@ where
                                        if let msgs::ErrorAction::IgnoreError = err.err.action {
                                                // We got a temporary failure updating monitor, but will claim the
                                                // HTLC when the monitor updating is restored (or on chain).
-                                               let logger = WithContext::from(&self.logger, None, Some(prev_hop_chan_id));
+                                               let logger = WithContext::from(&self.logger, None, Some(prev_hop_chan_id), Some(payment_hash));
                                                log_error!(logger, "Temporary failure claiming HTLC, treating as success: {}", err.err.err);
                                        } else { errs.push((pk, err)); }
                                }
@@ -6468,7 +6149,7 @@ where
                                if let hash_map::Entry::Occupied(mut chan_phase_entry) = peer_state.channel_by_id.entry(chan_id) {
                                        if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
                                                let counterparty_node_id = chan.context.get_counterparty_node_id();
-                                               let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                let fulfill_res = chan.get_update_fulfill_htlc_and_commit(prev_hop.htlc_id, payment_preimage, &&logger);
 
                                                match fulfill_res {
@@ -6561,7 +6242,7 @@ where
                                // with a preimage we *must* somehow manage to propagate it to the upstream
                                // channel, or we must have an ability to receive the same event and try
                                // again on restart.
-                               log_error!(WithContext::from(&self.logger, None, Some(prev_hop.channel_id)),
+                               log_error!(WithContext::from(&self.logger, None, Some(prev_hop.channel_id), None),
                                        "Critical error: failed to update channel monitor with preimage {:?}: {:?}",
                                        payment_preimage, update_res);
                        }
@@ -6742,6 +6423,7 @@ where
                                                receiver_node_id,
                                                htlcs,
                                                sender_intended_value: sender_intended_total_msat,
+                                               onion_fields,
                                        }) = payment {
                                                self.pending_events.lock().unwrap().push_back((events::Event::PaymentClaimed {
                                                        payment_hash,
@@ -6750,6 +6432,7 @@ where
                                                        receiver_node_id: Some(receiver_node_id),
                                                        htlcs,
                                                        sender_intended_total_msat,
+                                                       onion_fields,
                                                }, None));
                                        }
                                },
@@ -6784,7 +6467,7 @@ where
                funding_broadcastable: Option<Transaction>,
                channel_ready: Option<msgs::ChannelReady>, announcement_sigs: Option<msgs::AnnouncementSignatures>)
        -> (Option<(u64, OutPoint, ChannelId, u128, Vec<(PendingHTLCInfo, u64)>)>, Option<(u64, Vec<msgs::UpdateAddHTLC>)>) {
-               let logger = WithChannelContext::from(&self.logger, &channel.context);
+               let logger = WithChannelContext::from(&self.logger, &channel.context, None);
                log_trace!(logger, "Handling channel resumption for channel {} with {} RAA, {} commitment update, {} pending forwards, {} pending update_add_htlcs, {}broadcasting funding, {} channel ready, {} announcement",
                        &channel.context.channel_id(),
                        if raa.is_some() { "an" } else { "no" },
@@ -6895,7 +6578,7 @@ where
                                pending.retain(|upd| upd.update_id > highest_applied_update_id);
                                pending.len()
                        } else { 0 };
-               let logger = WithChannelContext::from(&self.logger, &channel.context);
+               let logger = WithChannelContext::from(&self.logger, &channel.context, None);
                log_trace!(logger, "ChannelMonitor updated to {}. Current highest is {}. {} pending in-flight updates.",
                        highest_applied_update_id, channel.context.get_latest_monitor_update_id(),
                        remaining_in_flight);
@@ -6949,7 +6632,7 @@ where
 
        fn do_accept_inbound_channel(&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey, accept_0conf: bool, user_channel_id: u128) -> Result<(), APIError> {
 
-               let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id));
+               let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id), None);
                let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
 
                let peers_without_funded_channels =
@@ -7249,7 +6932,7 @@ where
                                        match phase.get_mut() {
                                                ChannelPhase::UnfundedOutboundV1(chan) => {
                                                        try_chan_phase_entry!(self, chan.accept_channel(&msg, &self.default_configuration.channel_handshake_limits, &peer_state.latest_features), phase);
-                                                       (chan.context.get_value_satoshis(), chan.context.get_funding_redeemscript().to_v0_p2wsh(), chan.context.get_user_id())
+                                                       (chan.context.get_value_satoshis(), chan.context.get_funding_redeemscript().to_p2wsh(), chan.context.get_user_id())
                                                },
                                                _ => {
                                                        return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got an unexpected accept_channel message from peer with counterparty_node_id {}", counterparty_node_id), msg.common_fields.temporary_channel_id));
@@ -7285,7 +6968,7 @@ where
                let (mut chan, funding_msg_opt, monitor) =
                        match peer_state.channel_by_id.remove(&msg.temporary_channel_id) {
                                Some(ChannelPhase::UnfundedInboundV1(inbound_chan)) => {
-                                       let logger = WithChannelContext::from(&self.logger, &inbound_chan.context);
+                                       let logger = WithChannelContext::from(&self.logger, &inbound_chan.context, None);
                                        match inbound_chan.funding_created(msg, best_block, &self.signer_provider, &&logger) {
                                                Ok(res) => res,
                                                Err((inbound_chan, err)) => {
@@ -7357,7 +7040,7 @@ where
                                                        }
                                                        Ok(())
                                                } else {
-                                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                        log_error!(logger, "Persisting initial ChannelMonitor failed, implying the funding outpoint was duplicated");
                                                        fail_chan!("Duplicate funding outpoint");
                                                }
@@ -7385,7 +7068,8 @@ where
                                        let logger = WithContext::from(
                                                &self.logger,
                                                Some(chan.context.get_counterparty_node_id()),
-                                               Some(chan.context.channel_id())
+                                               Some(chan.context.channel_id()),
+                                               None
                                        );
                                        let res =
                                                chan.funding_signed(&msg, best_block, &self.signer_provider, &&logger);
@@ -7441,7 +7125,7 @@ where
                match peer_state.channel_by_id.entry(msg.channel_id) {
                        hash_map::Entry::Occupied(mut chan_phase_entry) => {
                                if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
-                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                        let announcement_sigs_opt = try_chan_phase_entry!(self, chan.channel_ready(&msg, &self.node_signer,
                                                self.chain_hash, &self.default_configuration, &self.best_block.read().unwrap(), &&logger), chan_phase_entry);
                                        if let Some(announcement_sigs) = announcement_sigs_opt {
@@ -7499,7 +7183,7 @@ where
                                match phase {
                                        ChannelPhase::Funded(chan) => {
                                                if !chan.received_shutdown() {
-                                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                        log_info!(logger, "Received a shutdown message from our counterparty for channel {}{}.",
                                                                msg.channel_id,
                                                                if chan.sent_shutdown() { " after we initiated shutdown" } else { "" });
@@ -7527,7 +7211,7 @@ where
                                        },
                                        ChannelPhase::UnfundedInboundV1(_) | ChannelPhase::UnfundedOutboundV1(_) => {
                                                let context = phase.context_mut();
-                                               let logger = WithChannelContext::from(&self.logger, context);
+                                               let logger = WithChannelContext::from(&self.logger, context, None);
                                                log_error!(logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
                                                let mut chan = remove_channel_phase!(self, chan_phase_entry);
                                                finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
@@ -7596,7 +7280,7 @@ where
                };
                if let Some(broadcast_tx) = tx {
                        let channel_id = chan_option.as_ref().map(|channel| channel.context().channel_id());
-                       log_info!(WithContext::from(&self.logger, Some(*counterparty_node_id), channel_id), "Broadcasting {}", log_tx!(broadcast_tx));
+                       log_info!(WithContext::from(&self.logger, Some(*counterparty_node_id), channel_id, None), "Broadcasting {}", log_tx!(broadcast_tx));
                        self.tx_broadcaster.broadcast_transactions(&[&broadcast_tx]);
                }
                if let Some(ChannelPhase::Funded(chan)) = chan_option {
@@ -7647,7 +7331,7 @@ where
                                                        ),
                                                Err(e) => PendingHTLCStatus::Fail(e)
                                        };
-                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                       let logger = WithChannelContext::from(&self.logger, &chan.context, Some(msg.payment_hash));
                                        // If the update_add is completely bogus, the call will Err and we will close,
                                        // but if we've sent a shutdown and they haven't acknowledged it yet, we just
                                        // want to reject the new HTLC and fail it backwards instead of forwarding.
@@ -7713,7 +7397,7 @@ where
                                        if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
                                                let res = try_chan_phase_entry!(self, chan.update_fulfill_htlc(&msg), chan_phase_entry);
                                                if let HTLCSource::PreviousHopData(prev_hop) = &res.0 {
-                                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                        log_trace!(logger,
                                                                "Holding the next revoke_and_ack from {} until the preimage is durably persisted in the inbound edge's ChannelMonitor",
                                                                msg.channel_id);
@@ -7812,7 +7496,7 @@ where
                match peer_state.channel_by_id.entry(msg.channel_id) {
                        hash_map::Entry::Occupied(mut chan_phase_entry) => {
                                if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
-                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                        let funding_txo = chan.context.get_funding_txo();
                                        let monitor_update_opt = try_chan_phase_entry!(self, chan.commitment_signed(&msg, &&logger), chan_phase_entry);
                                        if let Some(monitor_update) = monitor_update_opt {
@@ -7890,7 +7574,7 @@ where
                                                                                        prev_short_channel_id, prev_funding_outpoint, prev_channel_id, prev_htlc_id, prev_user_channel_id, forward_info });
                                                                        },
                                                                        hash_map::Entry::Occupied(_) => {
-                                                                               let logger = WithContext::from(&self.logger, None, Some(prev_channel_id));
+                                                                               let logger = WithContext::from(&self.logger, None, Some(prev_channel_id), Some(forward_info.payment_hash));
                                                                                log_info!(logger, "Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}", scid);
                                                                                let htlc_source = HTLCSource::PreviousHopData(HTLCPreviousHopData {
                                                                                        short_channel_id: prev_short_channel_id,
@@ -8000,7 +7684,7 @@ where
                        match peer_state.channel_by_id.entry(msg.channel_id) {
                                hash_map::Entry::Occupied(mut chan_phase_entry) => {
                                        if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
-                                               let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                let funding_txo_opt = chan.context.get_funding_txo();
                                                let mon_update_blocked = if let Some(funding_txo) = funding_txo_opt {
                                                        self.raa_monitor_updates_held(
@@ -8040,7 +7724,7 @@ where
                match peer_state.channel_by_id.entry(msg.channel_id) {
                        hash_map::Entry::Occupied(mut chan_phase_entry) => {
                                if let ChannelPhase::Funded(chan) = chan_phase_entry.get_mut() {
-                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                        try_chan_phase_entry!(self, chan.update_fee(&self.fee_estimator, &msg, &&logger), chan_phase_entry);
                                } else {
                                        return try_chan_phase_entry!(self, Err(ChannelError::Close(
@@ -8120,7 +7804,7 @@ where
                                        if were_node_one == msg_from_node_one {
                                                return Ok(NotifyOption::SkipPersistNoEvents);
                                        } else {
-                                               let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                               let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                log_debug!(logger, "Received channel_update {:?} for channel {}.", msg, chan_id);
                                                let did_change = try_chan_phase_entry!(self, chan.channel_update(&msg), chan_phase_entry);
                                                // If nothing changed after applying their update, we don't need to bother
@@ -8151,7 +7835,7 @@ where
                                                msg.channel_id
                                        )
                                })?;
-                       let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id));
+                       let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(msg.channel_id), None);
                        let mut peer_state_lock = peer_state_mutex.lock().unwrap();
                        let peer_state = &mut *peer_state_lock;
                        match peer_state.channel_by_id.entry(msg.channel_id) {
@@ -8249,7 +7933,7 @@ where
                        for monitor_event in monitor_events.drain(..) {
                                match monitor_event {
                                        MonitorEvent::HTLCEvent(htlc_update) => {
-                                               let logger = WithContext::from(&self.logger, counterparty_node_id, Some(channel_id));
+                                               let logger = WithContext::from(&self.logger, counterparty_node_id, Some(channel_id), Some(htlc_update.payment_hash));
                                                if let Some(preimage) = htlc_update.payment_preimage {
                                                        log_trace!(logger, "Claiming HTLC with preimage {} from our monitor", preimage);
                                                        self.claim_funds_internal(htlc_update.source, preimage,
@@ -8349,7 +8033,7 @@ where
                                                let counterparty_node_id = chan.context.get_counterparty_node_id();
                                                let funding_txo = chan.context.get_funding_txo();
                                                let (monitor_opt, holding_cell_failed_htlcs) =
-                                                       chan.maybe_free_holding_cell_htlcs(&self.fee_estimator, &&WithChannelContext::from(&self.logger, &chan.context));
+                                                       chan.maybe_free_holding_cell_htlcs(&self.fee_estimator, &&WithChannelContext::from(&self.logger, &chan.context, None));
                                                if !holding_cell_failed_htlcs.is_empty() {
                                                        failed_htlcs.push((holding_cell_failed_htlcs, *channel_id, counterparty_node_id));
                                                }
@@ -8456,7 +8140,7 @@ where
                                peer_state.channel_by_id.retain(|channel_id, phase| {
                                        match phase {
                                                ChannelPhase::Funded(chan) => {
-                                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                        match chan.maybe_propose_closing_signed(&self.fee_estimator, &&logger) {
                                                                Ok((msg_opt, tx_opt, shutdown_result_opt)) => {
                                                                        if let Some(msg) = msg_opt {
@@ -8561,8 +8245,6 @@ macro_rules! create_offer_builder { ($self: ident, $builder: ty) => {
        ///
        /// Errors if the parameterized [`Router`] is unable to create a blinded path for the offer.
        ///
-       /// This is not exported to bindings users as builder patterns don't map outside of move semantics.
-       ///
        /// [`Offer`]: crate::offers::offer::Offer
        /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
        pub fn create_offer_builder(&$self) -> Result<$builder, Bolt12SemanticError> {
@@ -8625,8 +8307,6 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
        /// - `amount_msats` is invalid, or
        /// - the parameterized [`Router`] is unable to create a blinded path for the refund.
        ///
-       /// This is not exported to bindings users as builder patterns don't map outside of move semantics.
-       ///
        /// [`Refund`]: crate::offers::refund::Refund
        /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
        /// [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths
@@ -8998,8 +8678,16 @@ where
 
                let peers = self.per_peer_state.read().unwrap()
                        .iter()
-                       .filter(|(_, peer)| peer.lock().unwrap().latest_features.supports_onion_messages())
-                       .map(|(node_id, _)| *node_id)
+                       .map(|(node_id, peer_state)| (node_id, peer_state.lock().unwrap()))
+                       .filter(|(_, peer)| peer.latest_features.supports_onion_messages())
+                       .map(|(node_id, peer)| ForwardNode {
+                               node_id: *node_id,
+                               short_channel_id: peer.channel_by_id
+                                       .iter()
+                                       .filter(|(_, channel)| channel.context().is_usable())
+                                       .min_by_key(|(_, channel)| channel.context().channel_creation_height)
+                                       .and_then(|(_, channel)| channel.context().get_short_channel_id()),
+                       })
                        .collect::<Vec<_>>();
 
                self.router
@@ -9138,7 +8826,7 @@ where
                mut completed_blocker: Option<RAAMonitorUpdateBlockingAction>) {
 
                let logger = WithContext::from(
-                       &self.logger, Some(counterparty_node_id), Some(channel_id),
+                       &self.logger, Some(counterparty_node_id), Some(channel_id), None
                );
                loop {
                        let per_peer_state = self.per_peer_state.read().unwrap();
@@ -9348,7 +9036,7 @@ where
                        *best_block = BestBlock::new(header.prev_blockhash, new_height)
                }
 
-               self.do_chain_event(Some(new_height), |channel| channel.best_block_updated(new_height, header.time, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context)));
+               self.do_chain_event(Some(new_height), |channel| channel.best_block_updated(new_height, header.time, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context, None)));
        }
 }
 
@@ -9374,13 +9062,13 @@ where
                let _persistence_guard =
                        PersistenceNotifierGuard::optionally_notify_skipping_background_events(
                                self, || -> NotifyOption { NotifyOption::DoPersist });
-               self.do_chain_event(Some(height), |channel| channel.transactions_confirmed(&block_hash, height, txdata, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context))
+               self.do_chain_event(Some(height), |channel| channel.transactions_confirmed(&block_hash, height, txdata, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context, None))
                        .map(|(a, b)| (a, Vec::new(), b)));
 
                let last_best_block_height = self.best_block.read().unwrap().height;
                if height < last_best_block_height {
                        let timestamp = self.highest_seen_timestamp.load(Ordering::Acquire);
-                       self.do_chain_event(Some(last_best_block_height), |channel| channel.best_block_updated(last_best_block_height, timestamp as u32, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context)));
+                       self.do_chain_event(Some(last_best_block_height), |channel| channel.best_block_updated(last_best_block_height, timestamp as u32, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context, None)));
                }
        }
 
@@ -9397,7 +9085,7 @@ where
                                self, || -> NotifyOption { NotifyOption::DoPersist });
                *self.best_block.write().unwrap() = BestBlock::new(block_hash, height);
 
-               self.do_chain_event(Some(height), |channel| channel.best_block_updated(height, header.time, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context)));
+               self.do_chain_event(Some(height), |channel| channel.best_block_updated(height, header.time, self.chain_hash, &self.node_signer, &self.default_configuration, &&WithChannelContext::from(&self.logger, &channel.context, None)));
 
                macro_rules! max_time {
                        ($timestamp: expr) => {
@@ -9446,7 +9134,7 @@ where
                self.do_chain_event(None, |channel| {
                        if let Some(funding_txo) = channel.context.get_funding_txo() {
                                if funding_txo.txid == *txid {
-                                       channel.funding_transaction_unconfirmed(&&WithChannelContext::from(&self.logger, &channel.context)).map(|()| (None, Vec::new(), None))
+                                       channel.funding_transaction_unconfirmed(&&WithChannelContext::from(&self.logger, &channel.context, None)).map(|()| (None, Vec::new(), None))
                                } else { Ok((None, Vec::new(), None)) }
                        } else { Ok((None, Vec::new(), None)) }
                });
@@ -9497,7 +9185,7 @@ where
                                                                        timed_out_htlcs.push((source, payment_hash, HTLCFailReason::reason(failure_code, data),
                                                                                HTLCDestination::NextHopChannel { node_id: Some(channel.context.get_counterparty_node_id()), channel_id: channel.context.channel_id() }));
                                                                }
-                                                               let logger = WithChannelContext::from(&self.logger, &channel.context);
+                                                               let logger = WithChannelContext::from(&self.logger, &channel.context, None);
                                                                if let Some(channel_ready) = channel_ready_opt {
                                                                        send_channel_ready!(self, pending_msg_events, channel, channel_ready);
                                                                        if channel.context.is_usable() {
@@ -9622,7 +9310,7 @@ where
                                                        HTLCFailReason::from_failure_code(0x2000 | 2),
                                                        HTLCDestination::InvalidForward { requested_forward_scid }));
                                        let logger = WithContext::from(
-                                               &self.logger, None, Some(htlc.prev_channel_id)
+                                               &self.logger, None, Some(htlc.prev_channel_id), Some(htlc.forward_info.payment_hash)
                                        );
                                        log_trace!(logger, "Timing out intercepted HTLC with requested forward scid {}", requested_forward_scid);
                                        false
@@ -9938,7 +9626,7 @@ where
                let mut per_peer_state = self.per_peer_state.write().unwrap();
                let remove_peer = {
                        log_debug!(
-                               WithContext::from(&self.logger, Some(*counterparty_node_id), None),
+                               WithContext::from(&self.logger, Some(*counterparty_node_id), None, None),
                                "Marking channels with {} disconnected and generating channel_updates.",
                                log_pubkey!(counterparty_node_id)
                        );
@@ -9949,18 +9637,21 @@ where
                                peer_state.channel_by_id.retain(|_, phase| {
                                        let context = match phase {
                                                ChannelPhase::Funded(chan) => {
-                                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                        if chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok() {
                                                                // We only retain funded channels that are not shutdown.
                                                                return true;
                                                        }
                                                        &mut chan.context
                                                },
-                                               // We retain UnfundedOutboundV1 channel for some time in case
-                                               // peer unexpectedly disconnects, and intends to reconnect again.
-                                               ChannelPhase::UnfundedOutboundV1(_) => {
-                                                       return true;
-                                               },
+                                               // If we get disconnected and haven't yet committed to a funding
+                                               // transaction, we can replay the `open_channel` on reconnection, so don't
+                                               // bother dropping the channel here. However, if we already committed to
+                                               // the funding transaction we don't yet support replaying the funding
+                                               // handshake (and bailing if the peer rejects it), so we force-close in
+                                               // that case.
+                                               ChannelPhase::UnfundedOutboundV1(chan) if chan.is_resumable() => return true,
+                                               ChannelPhase::UnfundedOutboundV1(chan) => &mut chan.context,
                                                // Unfunded inbound channels will always be removed.
                                                ChannelPhase::UnfundedInboundV1(chan) => {
                                                        &mut chan.context
@@ -10051,7 +9742,7 @@ where
        }
 
        fn peer_connected(&self, counterparty_node_id: &PublicKey, init_msg: &msgs::Init, inbound: bool) -> Result<(), ()> {
-               let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), None);
+               let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), None, None);
                if !init_msg.features.supports_static_remote_key() {
                        log_debug!(logger, "Peer {} does not support static remote key, disconnecting", log_pubkey!(counterparty_node_id));
                        return Err(());
@@ -10116,7 +9807,7 @@ where
                                for (_, phase) in peer_state.channel_by_id.iter_mut() {
                                        match phase {
                                                ChannelPhase::Funded(chan) => {
-                                                       let logger = WithChannelContext::from(&self.logger, &chan.context);
+                                                       let logger = WithChannelContext::from(&self.logger, &chan.context, None);
                                                        pending_msg_events.push(events::MessageSendEvent::SendChannelReestablish {
                                                                node_id: chan.context.get_counterparty_node_id(),
                                                                msg: chan.get_channel_reestablish(&&logger),
@@ -11517,7 +11208,7 @@ where
                        let mut channel: Channel<SP> = Channel::read(reader, (
                                &args.entropy_source, &args.signer_provider, best_block_height, &provided_channel_type_features(&args.default_config)
                        ))?;
-                       let logger = WithChannelContext::from(&args.logger, &channel.context);
+                       let logger = WithChannelContext::from(&args.logger, &channel.context, None);
                        let funding_txo = channel.context.get_funding_txo().ok_or(DecodeError::InvalidValue)?;
                        funding_txo_to_channel_id.insert(funding_txo, channel.context.channel_id());
                        funding_txo_set.insert(funding_txo.clone());
@@ -11576,6 +11267,7 @@ where
                                                        // claim update ChannelMonitor updates were persisted prior to persising
                                                        // the ChannelMonitor update for the forward leg, so attempting to fail the
                                                        // backwards leg of the HTLC will simply be rejected.
+                                                       let logger = WithChannelContext::from(&args.logger, &channel.context, Some(*payment_hash));
                                                        log_info!(logger,
                                                                "Failing HTLC with hash {} as it is missing in the ChannelMonitor for channel {} but was present in the (stale) ChannelManager",
                                                                &channel.context.channel_id(), &payment_hash);
@@ -11630,7 +11322,7 @@ where
 
                for (funding_txo, monitor) in args.channel_monitors.iter() {
                        if !funding_txo_set.contains(funding_txo) {
-                               let logger = WithChannelMonitor::from(&args.logger, monitor);
+                               let logger = WithChannelMonitor::from(&args.logger, monitor, None);
                                let channel_id = monitor.channel_id();
                                log_info!(logger, "Queueing monitor update to ensure missing channel {} is force closed",
                                        &channel_id);
@@ -11853,7 +11545,7 @@ where
                        let peer_state = &mut *peer_state_lock;
                        for phase in peer_state.channel_by_id.values() {
                                if let ChannelPhase::Funded(chan) = phase {
-                                       let logger = WithChannelContext::from(&args.logger, &chan.context);
+                                       let logger = WithChannelContext::from(&args.logger, &chan.context, None);
 
                                        // Channels that were persisted have to be funded, otherwise they should have been
                                        // discarded.
@@ -11892,7 +11584,7 @@ where
                if let Some(in_flight_upds) = in_flight_monitor_updates {
                        for ((counterparty_id, funding_txo), mut chan_in_flight_updates) in in_flight_upds {
                                let channel_id = funding_txo_to_channel_id.get(&funding_txo).copied();
-                               let logger = WithContext::from(&args.logger, Some(counterparty_id), channel_id);
+                               let logger = WithContext::from(&args.logger, Some(counterparty_id), channel_id, None);
                                if let Some(monitor) = args.channel_monitors.get(&funding_txo) {
                                        // Now that we've removed all the in-flight monitor updates for channels that are
                                        // still open, we need to replay any monitor updates that are for closed channels,
@@ -11937,8 +11629,8 @@ where
                        for (_, monitor) in args.channel_monitors.iter() {
                                let counterparty_opt = outpoint_to_peer.get(&monitor.get_funding_txo().0);
                                if counterparty_opt.is_none() {
-                                       let logger = WithChannelMonitor::from(&args.logger, monitor);
                                        for (htlc_source, (htlc, _)) in monitor.get_pending_or_resolved_outbound_htlcs() {
+                                               let logger = WithChannelMonitor::from(&args.logger, monitor, Some(htlc.payment_hash));
                                                if let HTLCSource::OutboundRoute { payment_id, session_priv, path, .. } = htlc_source {
                                                        if path.hops.is_empty() {
                                                                log_error!(logger, "Got an empty path for a pending payment");
@@ -11979,6 +11671,7 @@ where
                                                }
                                        }
                                        for (htlc_source, (htlc, preimage_opt)) in monitor.get_all_current_outbound_htlcs() {
+                                               let logger = WithChannelMonitor::from(&args.logger, monitor, Some(htlc.payment_hash));
                                                match htlc_source {
                                                        HTLCSource::PreviousHopData(prev_hop_data) => {
                                                                let pending_forward_matches_htlc = |info: &PendingAddHTLCInfo| {
@@ -12176,7 +11869,7 @@ where
                        let peer_state = &mut *peer_state_lock;
                        for (chan_id, phase) in peer_state.channel_by_id.iter_mut() {
                                if let ChannelPhase::Funded(chan) = phase {
-                                       let logger = WithChannelContext::from(&args.logger, &chan.context);
+                                       let logger = WithChannelContext::from(&args.logger, &chan.context, None);
                                        if chan.context.outbound_scid_alias() == 0 {
                                                let mut outbound_scid_alias;
                                                loop {
@@ -12246,7 +11939,7 @@ where
                                                        let mut peer_state_lock = peer_state_mutex.lock().unwrap();
                                                        let peer_state = &mut *peer_state_lock;
                                                        if let Some(ChannelPhase::Funded(channel)) = peer_state.channel_by_id.get_mut(&previous_channel_id) {
-                                                               let logger = WithChannelContext::from(&args.logger, &channel.context);
+                                                               let logger = WithChannelContext::from(&args.logger, &channel.context, Some(payment_hash));
                                                                channel.claim_htlc_while_disconnected_dropping_mon_update(claimable_htlc.prev_hop.htlc_id, payment_preimage, &&logger);
                                                        }
                                                }
@@ -12261,6 +11954,7 @@ where
                                                amount_msat: claimable_amt_msat,
                                                htlcs: payment.htlcs.iter().map(events::ClaimedHTLC::from).collect(),
                                                sender_intended_total_msat: payment.htlcs.first().map(|htlc| htlc.total_msat),
+                                               onion_fields: payment.onion_fields,
                                        }, None));
                                }
                        }
@@ -12269,7 +11963,7 @@ where
                for (node_id, monitor_update_blocked_actions) in monitor_update_blocked_actions_per_peer.unwrap() {
                        if let Some(peer_state) = per_peer_state.get(&node_id) {
                                for (channel_id, actions) in monitor_update_blocked_actions.iter() {
-                                       let logger = WithContext::from(&args.logger, Some(node_id), Some(*channel_id));
+                                       let logger = WithContext::from(&args.logger, Some(node_id), Some(*channel_id), None);
                                        for action in actions.iter() {
                                                if let MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
                                                        downstream_counterparty_and_funding_outpoint:
@@ -12297,7 +11991,7 @@ where
                                }
                                peer_state.lock().unwrap().monitor_update_blocked_actions = monitor_update_blocked_actions;
                        } else {
-                               log_error!(WithContext::from(&args.logger, Some(node_id), None), "Got blocked actions without a per-peer-state for {}", node_id);
+                               log_error!(WithContext::from(&args.logger, Some(node_id), None, None), "Got blocked actions without a per-peer-state for {}", node_id);
                                return Err(DecodeError::InvalidValue);
                        }
                }
@@ -13799,10 +13493,12 @@ pub mod bench {
        use crate::util::test_utils;
        use crate::util::config::{UserConfig, MaxDustHTLCExposure};
 
+       use bitcoin::amount::Amount;
        use bitcoin::blockdata::locktime::absolute::LockTime;
        use bitcoin::hashes::Hash;
        use bitcoin::hashes::sha256::Hash as Sha256;
        use bitcoin::{Transaction, TxOut};
+       use bitcoin::transaction::Version;
 
        use crate::sync::{Arc, Mutex, RwLock};
 
@@ -13879,8 +13575,8 @@ pub mod bench {
 
                let tx;
                if let Event::FundingGenerationReady { temporary_channel_id, output_script, .. } = get_event!(node_a_holder, Event::FundingGenerationReady) {
-                       tx = Transaction { version: 2, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
-                               value: 8_000_000, script_pubkey: output_script,
+                       tx = Transaction { version: Version::TWO, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
+                               value: Amount::from_sat(8_000_000), script_pubkey: output_script,
                        }]};
                        node_a.funding_transaction_generated(&temporary_channel_id, &node_b.get_our_node_id(), tx.clone()).unwrap();
                } else { panic!(); }