{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}

module Haskoin.Data (
    Network (..),
) where

import Control.DeepSeq
import Data.Binary (Binary (..))
import Data.ByteString (ByteString)
import Data.Bytes.Get
import Data.Bytes.Put
import Data.Bytes.Serial
import Data.List
import Data.Serialize (Serialize (..))
import Data.String
import Data.Text (Text)
import Data.Word (Word32, Word64, Word8)
import GHC.Generics (Generic)
import Haskoin.Block.Common
import Text.Read

-- | Network definition.
data Network = Network
    { -- | lowercase alphanumeric and dashes
      Network -> String
getNetworkName :: !String
    , -- | prefix for 'Base58' P2PKH addresses
      Network -> Word8
getAddrPrefix :: !Word8
    , -- | prefix for 'Base58' P2SH addresses
      Network -> Word8
getScriptPrefix :: !Word8
    , -- | prefix for WIF private key
      Network -> Word8
getSecretPrefix :: !Word8
    , -- | prefix for extended public key
      Network -> Word32
getExtPubKeyPrefix :: !Word32
    , -- | prefix for extended private key
      Network -> Word32
getExtSecretPrefix :: !Word32
    , -- | network magic
      Network -> Word32
getNetworkMagic :: !Word32
    , -- | genesis block header
      Network -> BlockHeader
getGenesisHeader :: !BlockHeader
    , -- | maximum block size in bytes
      Network -> Int
getMaxBlockSize :: !Int
    , -- | maximum amount of satoshi
      Network -> Word64
getMaxSatoshi :: !Word64
    , -- | user agent string
      Network -> ByteString
getHaskoinUserAgent :: !ByteString
    , -- | default port for P2P connections
      Network -> Int
getDefaultPort :: !Int
    , -- | allow min difficulty blocks (testnet)
      Network -> Bool
getAllowMinDifficultyBlocks :: !Bool
    , -- | do not retarget difficulty (regtest)
      Network -> Bool
getPowNoRetargetting :: !Bool
    , -- | proof-of-work target higest possible value
      Network -> Integer
getPowLimit :: !Integer
    , -- | block at which BIP34 activates
      Network -> (Word32, BlockHash)
getBip34Block :: !(BlockHeight, BlockHash)
    , -- | block at which BIP65 activates
      Network -> Word32
getBip65Height :: !BlockHeight
    , -- | block at which BIP66 activates
      Network -> Word32
getBip66Height :: !BlockHeight
    , -- | time between difficulty retargets
      Network -> Word32
getTargetTimespan :: !Word32
    , -- | time between blocks
      Network -> Word32
getTargetSpacing :: !Word32
    , -- | checkpoints
      Network -> [(Word32, BlockHash)]
getCheckpoints :: ![(BlockHeight, BlockHash)]
    , -- | BIP44 derivation path root
      Network -> Word32
getBip44Coin :: !Word32
    , -- | peer-to-peer network seeds
      Network -> [String]
getSeeds :: ![String]
    , -- | fork id for replay protection
      Network -> Maybe Word32
getSigHashForkId :: !(Maybe Word32)
    , -- | EDA start block height
      Network -> Maybe Word32
getEdaBlockHeight :: !(Maybe Word32)
    , -- | DAA start block height
      Network -> Maybe Word32
getDaaBlockHeight :: !(Maybe Word32)
    , -- | asert3-2d algorithm activation time
      -- TODO: Replace with block height after fork
      Network -> Maybe Word32
getAsertActivationTime :: !(Maybe Word32)
    , -- | asert3-2d algorithm halflife (not used for non-BCH networks)
      Network -> Integer
getAsertHalfLife :: !Integer
    , -- | segregated witness active
      Network -> Bool
getSegWit :: !Bool
    , -- | 'CashAddr' prefix (for Bitcoin Cash)
      Network -> Maybe Text
getCashAddrPrefix :: !(Maybe Text)
    , -- | 'Bech32' prefix (for SegWit network)
      Network -> Maybe Text
getBech32Prefix :: !(Maybe Text)
    , -- | Replace-By-Fee (BIP-125)
      Network -> Bool
getReplaceByFee :: !Bool
    , -- | Subsidy halving interval
      Network -> Word32
getHalvingInterval :: !Word32
    }
    deriving (Network -> Network -> Bool
(Network -> Network -> Bool)
-> (Network -> Network -> Bool) -> Eq Network
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Network -> Network -> Bool
$c/= :: Network -> Network -> Bool
== :: Network -> Network -> Bool
$c== :: Network -> Network -> Bool
Eq, Int -> Network -> ShowS
[Network] -> ShowS
Network -> String
(Int -> Network -> ShowS)
-> (Network -> String) -> ([Network] -> ShowS) -> Show Network
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Network] -> ShowS
$cshowList :: [Network] -> ShowS
show :: Network -> String
$cshow :: Network -> String
showsPrec :: Int -> Network -> ShowS
$cshowsPrec :: Int -> Network -> ShowS
Show, ReadPrec [Network]
ReadPrec Network
Int -> ReadS Network
ReadS [Network]
(Int -> ReadS Network)
-> ReadS [Network]
-> ReadPrec Network
-> ReadPrec [Network]
-> Read Network
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Network]
$creadListPrec :: ReadPrec [Network]
readPrec :: ReadPrec Network
$creadPrec :: ReadPrec Network
readList :: ReadS [Network]
$creadList :: ReadS [Network]
readsPrec :: Int -> ReadS Network
$creadsPrec :: Int -> ReadS Network
Read, (forall x. Network -> Rep Network x)
-> (forall x. Rep Network x -> Network) -> Generic Network
forall x. Rep Network x -> Network
forall x. Network -> Rep Network x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Network x -> Network
$cfrom :: forall x. Network -> Rep Network x
Generic, Network -> ()
(Network -> ()) -> NFData Network
forall a. (a -> ()) -> NFData a
rnf :: Network -> ()
$crnf :: Network -> ()
NFData)