packages feed

lnd-client-0.1.0.1: src/LndClient/Data/PendingChannel.hs

module LndClient.Data.PendingChannel
  ( PendingChannel (..),
  )
where

import LndClient.Data.ChannelPoint
import LndClient.Import
import qualified Proto.Lnrpc.Ln0 as LnGRPC
import qualified Proto.Lnrpc.Ln0_Fields as LnGRPC

data PendingChannel = PendingChannel
  { remoteNodePub :: NodePubKey,
    channelPoint :: ChannelPoint,
    capacity :: MSat,
    localBalance :: MSat,
    remoteBalance :: MSat,
    localChanReserveSat :: MSat,
    remoteChanReserveSat :: MSat,
    initiator :: LnInitiator
  }
  deriving stock (Eq, Show, Generic)

instance Out PendingChannel

instance
  FromGrpc
    PendingChannel
    LnGRPC.PendingChannelsResponse'PendingChannel
  where
  fromGrpc x =
    PendingChannel
      <$> fromGrpc
        (x ^. LnGRPC.remoteNodePub)
      <*> channelPointParser
        (x ^. LnGRPC.channelPoint)
      <*> fromGrpcSat (x ^. LnGRPC.capacity)
      <*> fromGrpcSat (x ^. LnGRPC.localBalance)
      <*> fromGrpcSat (x ^. LnGRPC.remoteBalance)
      <*> fromGrpcSat (x ^. LnGRPC.localChanReserveSat)
      <*> fromGrpcSat (x ^. LnGRPC.remoteChanReserveSat)
      <*> fromGrpc (x ^. LnGRPC.initiator)