Compare commits
No commits in common. "d118a839933d056491ae5e177a453f0441dd6ae9" and "c13d321da5784f9f93b5a289d88bc4b49137510f" have entirely different histories.
d118a83993
...
c13d321da5
2 changed files with 10 additions and 54 deletions
|
@ -26,12 +26,19 @@ import ZcashHaskell.Types
|
||||||
( TransparentAddress(..)
|
( TransparentAddress(..)
|
||||||
, TransparentType(..)
|
, TransparentType(..)
|
||||||
, ZcashNet(..)
|
, ZcashNet(..)
|
||||||
, getTransparentPrefix
|
|
||||||
)
|
)
|
||||||
|
|
||||||
encodeTransparent :: TransparentAddress -> T.Text
|
encodeTransparent :: TransparentAddress -> T.Text
|
||||||
encodeTransparent t =
|
encodeTransparent t =
|
||||||
encodeTransparent' (getTransparentPrefix (ta_net t) (ta_type t)) $ ta_bytes 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
|
||||||
where
|
where
|
||||||
encodeTransparent' :: (Word8, Word8) -> BS.ByteString -> T.Text
|
encodeTransparent' :: (Word8, Word8) -> BS.ByteString -> T.Text
|
||||||
encodeTransparent' (a, b) h =
|
encodeTransparent' (a, b) h =
|
||||||
|
|
|
@ -64,7 +64,7 @@ data ZcashNet
|
||||||
type AccountId = Int
|
type AccountId = Int
|
||||||
|
|
||||||
-- ** Constants
|
-- ** Constants
|
||||||
-- | Type for coin types on the different networks
|
-- | Types for coin types on the different networks
|
||||||
data CoinType
|
data CoinType
|
||||||
= MainNetCoin
|
= MainNetCoin
|
||||||
| TestNetCoin
|
| TestNetCoin
|
||||||
|
@ -77,57 +77,6 @@ getValue c =
|
||||||
TestNetCoin -> 1
|
TestNetCoin -> 1
|
||||||
RegTestNetCoin -> 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
|
-- * RPC
|
||||||
-- | A type to model Zcash RPC calls
|
-- | A type to model Zcash RPC calls
|
||||||
data RpcCall = RpcCall
|
data RpcCall = RpcCall
|
||||||
|
|
Loading…
Reference in a new issue