Add constants to library
This commit is contained in:
parent
815b4f16b4
commit
d118a83993
2 changed files with 54 additions and 10 deletions
|
@ -26,19 +26,12 @@ import ZcashHaskell.Types
|
|||
( TransparentAddress(..)
|
||||
, TransparentType(..)
|
||||
, ZcashNet(..)
|
||||
, getTransparentPrefix
|
||||
)
|
||||
|
||||
encodeTransparent :: TransparentAddress -> T.Text
|
||||
encodeTransparent t =
|
||||
case ta_type t of
|
||||
P2SH ->
|
||||
case ta_net t of
|
||||
MainNet -> encodeTransparent' (0x1c, 0xbd) $ ta_bytes t
|
||||
_ -> encodeTransparent' (0x1c, 0xba) $ ta_bytes t
|
||||
P2PKH ->
|
||||
case ta_net t of
|
||||
MainNet -> encodeTransparent' (0x1c, 0xb8) $ ta_bytes t
|
||||
_ -> encodeTransparent' (0x1d, 0x25) $ ta_bytes t
|
||||
encodeTransparent' (getTransparentPrefix (ta_net t) (ta_type t)) $ ta_bytes t
|
||||
where
|
||||
encodeTransparent' :: (Word8, Word8) -> BS.ByteString -> T.Text
|
||||
encodeTransparent' (a, b) h =
|
||||
|
|
|
@ -64,7 +64,7 @@ data ZcashNet
|
|||
type AccountId = Int
|
||||
|
||||
-- ** Constants
|
||||
-- | Types for coin types on the different networks
|
||||
-- | Type for coin types on the different networks
|
||||
data CoinType
|
||||
= MainNetCoin
|
||||
| TestNetCoin
|
||||
|
@ -77,6 +77,57 @@ getValue c =
|
|||
TestNetCoin -> 1
|
||||
RegTestNetCoin -> 1
|
||||
|
||||
-- | Type for Sapling Human-readable part
|
||||
data SaplingHrp
|
||||
= SapExtSpendingKey
|
||||
| SapExtFullViewingKey
|
||||
| SapPaymentAddress
|
||||
| SapTestExtSpendingKey
|
||||
| SapTestExtFullViewingKey
|
||||
| SapTestPaymentAddress
|
||||
|
||||
getSaplingHrp :: SaplingHrp -> String
|
||||
getSaplingHrp s =
|
||||
case s of
|
||||
SapExtSpendingKey -> "secret-extended-key-main"
|
||||
SapExtFullViewingKey -> "zxviews"
|
||||
SapPaymentAddress -> "zs"
|
||||
SapTestExtSpendingKey -> "secret-extended-key-test"
|
||||
SapTestExtFullViewingKey -> "zxviewtestsapling"
|
||||
SapTestPaymentAddress -> "ztestsapling"
|
||||
|
||||
-- | Type for Unified Human-readable part
|
||||
data UnifiedHrp
|
||||
= UniPaymentAddress
|
||||
| UniFullViewingKey
|
||||
| UniIncomingViewingKey
|
||||
| UniTestPaymentAddress
|
||||
| UniTestFullViewingKey
|
||||
| UniTestIncomingViewingKey
|
||||
|
||||
getUnifiedHrp :: UnifiedHrp -> String
|
||||
getUnifiedHrp s =
|
||||
case s of
|
||||
UniPaymentAddress -> "u"
|
||||
UniFullViewingKey -> "uview"
|
||||
UniIncomingViewingKey -> "uivk"
|
||||
UniTestPaymentAddress -> "utest"
|
||||
UniTestFullViewingKey -> "uviewtest"
|
||||
UniTestIncomingViewingKey -> "uivktest"
|
||||
|
||||
-- | Function to get the Base58 prefix for encoding a 'TransparentAddress'
|
||||
getTransparentPrefix :: ZcashNet -> TransparentType -> (Word8, Word8)
|
||||
getTransparentPrefix n t =
|
||||
case t of
|
||||
P2SH ->
|
||||
case n of
|
||||
MainNet -> (0x1c, 0xbd)
|
||||
_ -> (0x1c, 0xba)
|
||||
P2PKH ->
|
||||
case n of
|
||||
MainNet -> (0x1c, 0xb8)
|
||||
_ -> (0x1d, 0x25)
|
||||
|
||||
-- * RPC
|
||||
-- | A type to model Zcash RPC calls
|
||||
data RpcCall = RpcCall
|
||||
|
|
Loading…
Reference in a new issue