RPC Server #103
1 changed files with 42 additions and 18 deletions
|
@ -16,6 +16,7 @@ import qualified Data.ByteString.Base64 as B64
|
||||||
import qualified Data.ByteString.Char8 as C
|
import qualified Data.ByteString.Char8 as C
|
||||||
import Data.Char (toLower)
|
import Data.Char (toLower)
|
||||||
import Data.HexString
|
import Data.HexString
|
||||||
|
import Data.Int (Int64)
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Encoding as E
|
import qualified Data.Text.Encoding as E
|
||||||
|
@ -103,6 +104,32 @@ data Config = Config
|
||||||
, c_zenithPort :: !Int
|
, c_zenithPort :: !Int
|
||||||
} deriving (Eq, Prelude.Show)
|
} deriving (Eq, Prelude.Show)
|
||||||
|
|
||||||
|
data ZcashPool
|
||||||
|
= Transparent
|
||||||
|
| Sprout
|
||||||
|
| Sapling
|
||||||
|
| Orchard
|
||||||
|
deriving (Show, Read, Eq)
|
||||||
|
|
||||||
|
derivePersistField "ZcashPool"
|
||||||
|
|
||||||
|
instance ToJSON ZcashPool where
|
||||||
|
toJSON zp =
|
||||||
|
case zp of
|
||||||
|
Transparent -> Data.Aeson.String "p2pkh"
|
||||||
|
Sprout -> Data.Aeson.String "sprout"
|
||||||
|
Sapling -> Data.Aeson.String "sapling"
|
||||||
|
Orchard -> Data.Aeson.String "orchard"
|
||||||
|
|
||||||
|
instance FromJSON ZcashPool where
|
||||||
|
parseJSON =
|
||||||
|
withText "ZcashPool" $ \case
|
||||||
|
"p2pkh" -> return Transparent
|
||||||
|
"sprout" -> return Sprout
|
||||||
|
"sapling" -> return Sapling
|
||||||
|
"orchard" -> return Orchard
|
||||||
|
_ -> fail "Not a known Zcash pool"
|
||||||
|
|
||||||
-- ** API types
|
-- ** API types
|
||||||
data ZcashWalletAPI = ZcashWalletAPI
|
data ZcashWalletAPI = ZcashWalletAPI
|
||||||
{ zw_index :: !Int
|
{ zw_index :: !Int
|
||||||
|
@ -133,6 +160,21 @@ data ZcashAddressAPI = ZcashAddressAPI
|
||||||
|
|
||||||
$(deriveJSON defaultOptions {fieldLabelModifier = drop 3} ''ZcashAddressAPI)
|
$(deriveJSON defaultOptions {fieldLabelModifier = drop 3} ''ZcashAddressAPI)
|
||||||
|
|
||||||
|
data ZcashNoteAPI = ZcashNoteAPI
|
||||||
|
{ zn_txid :: !HexString
|
||||||
|
, zn_pool :: !ZcashPool
|
||||||
|
, zn_amount :: !Float
|
||||||
|
, zn_amountZats :: !Int64
|
||||||
|
, zn_memo :: !T.Text
|
||||||
|
, zn_confirmed :: !Bool
|
||||||
|
, zn_blockheight :: !Int64
|
||||||
|
, zn_blocktime :: !Int64
|
||||||
|
, zn_outindex :: !Int
|
||||||
|
, zn_change :: !Bool
|
||||||
|
} deriving (Eq, Prelude.Show)
|
||||||
|
|
||||||
|
$(deriveJSON defaultOptions {fieldLabelModifier = drop 3} ''ZcashNoteAPI)
|
||||||
|
|
||||||
-- ** `zebrad`
|
-- ** `zebrad`
|
||||||
-- | Type for modeling the tree state response
|
-- | Type for modeling the tree state response
|
||||||
data ZebraTreeInfo = ZebraTreeInfo
|
data ZebraTreeInfo = ZebraTreeInfo
|
||||||
|
@ -177,24 +219,6 @@ instance FromJSON AddressSource where
|
||||||
"mnemonic_seed" -> return MnemonicSeed
|
"mnemonic_seed" -> return MnemonicSeed
|
||||||
_ -> fail "Not a known address source"
|
_ -> fail "Not a known address source"
|
||||||
|
|
||||||
data ZcashPool
|
|
||||||
= Transparent
|
|
||||||
| Sprout
|
|
||||||
| Sapling
|
|
||||||
| Orchard
|
|
||||||
deriving (Show, Read, Eq, Generic, ToJSON)
|
|
||||||
|
|
||||||
derivePersistField "ZcashPool"
|
|
||||||
|
|
||||||
instance FromJSON ZcashPool where
|
|
||||||
parseJSON =
|
|
||||||
withText "ZcashPool" $ \case
|
|
||||||
"p2pkh" -> return Transparent
|
|
||||||
"sprout" -> return Sprout
|
|
||||||
"sapling" -> return Sapling
|
|
||||||
"orchard" -> return Orchard
|
|
||||||
_ -> fail "Not a known Zcash pool"
|
|
||||||
|
|
||||||
data ZcashAddress = ZcashAddress
|
data ZcashAddress = ZcashAddress
|
||||||
{ source :: AddressSource
|
{ source :: AddressSource
|
||||||
, pool :: [ZcashPool]
|
, pool :: [ZcashPool]
|
||||||
|
|
Loading…
Reference in a new issue