Rename APIError::RouteError to ::InvalidRoute
[rust-lightning] / lightning / src / util / events.rs
index 04a3b1004bd342f1d438b37c1f1035a7b1f3d346..18058bc03a8e10505ce0f966729cb56d66a7d147 100644 (file)
@@ -182,6 +182,12 @@ pub enum HTLCDestination {
                /// Short channel id we are requesting to forward an HTLC to.
                requested_forward_scid: u64,
        },
+       /// We couldn't forward to the outgoing scid. An example would be attempting to send a duplicate
+       /// intercept HTLC.
+       InvalidForward {
+               /// Short channel id we are requesting to forward an HTLC to.
+               requested_forward_scid: u64
+       },
        /// Failure scenario where an HTLC may have been forwarded to be intended for us,
        /// but is invalid for some reason, so we reject it.
        ///
@@ -200,12 +206,15 @@ impl_writeable_tlv_based_enum_upgradable!(HTLCDestination,
                (0, node_id, required),
                (2, channel_id, required),
        },
+       (1, InvalidForward) => {
+               (0, requested_forward_scid, required),
+       },
        (2, UnknownNextHop) => {
                (0, requested_forward_scid, required),
        },
        (4, FailedPayment) => {
                (0, payment_hash, required),
-       }
+       },
 );
 
 #[cfg(anchors)]
@@ -601,11 +610,25 @@ pub enum Event {
                /// now + 5*time_forwardable).
                time_forwardable: Duration,
        },
-       /// Used to indicate that we've intercepted an HTLC forward.
+       /// Used to indicate that we've intercepted an HTLC forward. This event will only be generated if
+       /// you've encoded an intercept scid in the receiver's invoice route hints using
+       /// [`ChannelManager::get_intercept_scid`] and have set [`UserConfig::accept_intercept_htlcs`].
+       ///
+       /// [`ChannelManager::forward_intercepted_htlc`] or
+       /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See
+       /// their docs for more information.
+       ///
+       /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
+       /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs
+       /// [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
+       /// [`ChannelManager::fail_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::fail_intercepted_htlc
        HTLCIntercepted {
                /// An id to help LDK identify which HTLC is being forwarded or failed.
                intercept_id: InterceptId,
-               /// The fake scid that was programmed as the next hop's scid.
+               /// The fake scid that was programmed as the next hop's scid, generated using
+               /// [`ChannelManager::get_intercept_scid`].
+               ///
+               /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
                requested_next_hop_scid: u64,
                /// The payment hash used for this HTLC.
                payment_hash: PaymentHash,