+ /// Included in a received commitment_signed message (implying we've revoke_and_ack'ed it), but
+ /// the remote side hasn't yet revoked their previous state, which we need them to do before we
+ /// accept this HTLC. Implies AwaitingRemoteRevoke.
+ /// We also have not yet included this HTLC in a commitment_signed message, and are waiting on
+ /// a remote revoke_and_ack on a previous state before we can do so.
+ AwaitingRemoteRevokeToAnnounce,
+ /// Included in a received commitment_signed message (implying we've revoke_and_ack'ed it), but
+ /// the remote side hasn't yet revoked their previous state, which we need them to do before we
+ /// accept this HTLC. Implies AwaitingRemoteRevoke.
+ /// We have included this HTLC in our latest commitment_signed and are now just waiting on a
+ /// revoke_and_ack.
+ AwaitingAnnouncedRemoteRevoke,
+ Committed,
+ /// Removed by us and a new commitment_signed was sent (if we were AwaitingRemoteRevoke when we
+ /// created it we would have put it in the holding cell instead). When they next revoke_and_ack
+ /// we'll drop it.
+ /// Note that we have to keep an eye on the HTLC until we've received a broadcastable
+ /// commitment transaction without it as otherwise we'll have to force-close the channel to
+ /// claim it before the timeout (obviously doesn't apply to revoked HTLCs that we can't claim
+ /// anyway). That said, ChannelMonitor does this for us (see
+ /// ChannelMonitor::would_broadcast_at_height) so we actually remove the HTLC from our own
+ /// local state before then, once we're sure that the next commitment_signed and
+ /// ChannelMonitor::provide_latest_local_commitment_tx_info will not include this HTLC.
+ LocalRemoved,
+}
+
+struct InboundHTLCOutput {
+ htlc_id: u64,
+ amount_msat: u64,
+ cltv_expiry: u32,
+ payment_hash: [u8; 32],
+ state: InboundHTLCState,
+ /// If we're in LocalRemoved, set to true if we fulfilled the HTLC, and can claim money
+ local_removed_fulfilled: bool,
+ /// state pre-Committed implies pending_forward_state, otherwise it must be None
+ pending_forward_state: Option<PendingHTLCStatus>,
+}
+
+#[derive(PartialEq)]
+enum OutboundHTLCState {
+ /// Added by us and included in a commitment_signed (if we were AwaitingRemoteRevoke when we
+ /// created it we would have put it in the holding cell instead). When they next revoke_and_ack
+ /// we will promote to Committed (note that they may not accept it until the next time we
+ /// revoke, but we dont really care about that:
+ /// * they've revoked, so worst case we can announce an old state and get our (option on)
+ /// money back (though we wont), and,
+ /// * we'll send them a revoke when they send a commitment_signed, and since only they're
+ /// allowed to remove it, the "can only be removed once committed on both sides" requirement
+ /// doesn't matter to us and its up to them to enforce it, worst-case they jump ahead but
+ /// we'll never get out of sync).