Compare commits
No commits in common. "0a1f35eefcc868eee9acfb4ca9bdad0192ac9df3" and "9e62a54e591f75898305241c46ac56ab11f77a5e" have entirely different histories.
0a1f35eefc
...
9e62a54e59
5 changed files with 7 additions and 98 deletions
|
@ -9,11 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- RPC methods:
|
- RPC method `shieldnotes`
|
||||||
- `shieldnotes`
|
- RPC method `deshieldfunds`
|
||||||
- `deshieldfunds`
|
|
||||||
- `getfullvk`
|
|
||||||
- `getincomingvk`
|
|
||||||
|
|
||||||
## [0.7.2.0-beta]
|
## [0.7.2.0-beta]
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,6 @@ data ZenithMethod
|
||||||
| ShieldNotes
|
| ShieldNotes
|
||||||
| DeshieldFunds
|
| DeshieldFunds
|
||||||
| GetFVK
|
| GetFVK
|
||||||
| GetIVK
|
|
||||||
| UnknownMethod
|
| UnknownMethod
|
||||||
deriving (Eq, Prelude.Show)
|
deriving (Eq, Prelude.Show)
|
||||||
|
|
||||||
|
@ -148,7 +147,6 @@ instance ToJSON ZenithMethod where
|
||||||
toJSON ShieldNotes = Data.Aeson.String "shieldnotes"
|
toJSON ShieldNotes = Data.Aeson.String "shieldnotes"
|
||||||
toJSON DeshieldFunds = Data.Aeson.String "deshieldfunds"
|
toJSON DeshieldFunds = Data.Aeson.String "deshieldfunds"
|
||||||
toJSON GetFVK = Data.Aeson.String "getfullvk"
|
toJSON GetFVK = Data.Aeson.String "getfullvk"
|
||||||
toJSON GetIVK = Data.Aeson.String "getincomingvk"
|
|
||||||
toJSON UnknownMethod = Data.Aeson.Null
|
toJSON UnknownMethod = Data.Aeson.Null
|
||||||
|
|
||||||
instance FromJSON ZenithMethod where
|
instance FromJSON ZenithMethod where
|
||||||
|
@ -168,7 +166,6 @@ instance FromJSON ZenithMethod where
|
||||||
"shieldnotes" -> pure ShieldNotes
|
"shieldnotes" -> pure ShieldNotes
|
||||||
"deshieldfunds" -> pure DeshieldFunds
|
"deshieldfunds" -> pure DeshieldFunds
|
||||||
"getfullvk" -> pure GetFVK
|
"getfullvk" -> pure GetFVK
|
||||||
"getincomingvk" -> pure GetIVK
|
|
||||||
_ -> pure UnknownMethod
|
_ -> pure UnknownMethod
|
||||||
|
|
||||||
data ZenithParams
|
data ZenithParams
|
||||||
|
@ -551,16 +548,6 @@ instance FromJSON RpcCall where
|
||||||
pure $ RpcCall v i GetFVK (ViewingKeyParams x)
|
pure $ RpcCall v i GetFVK (ViewingKeyParams x)
|
||||||
else pure $ RpcCall v i GetFVK BadParams
|
else pure $ RpcCall v i GetFVK BadParams
|
||||||
_anyOther -> pure $ RpcCall v i GetFVK BadParams
|
_anyOther -> pure $ RpcCall v i GetFVK BadParams
|
||||||
GetIVK -> do
|
|
||||||
p <- obj .: "params"
|
|
||||||
case p of
|
|
||||||
Array a ->
|
|
||||||
if V.length a == 1
|
|
||||||
then do
|
|
||||||
x <- parseJSON $ a V.! 0
|
|
||||||
pure $ RpcCall v i GetIVK (ViewingKeyParams x)
|
|
||||||
else pure $ RpcCall v i GetIVK BadParams
|
|
||||||
_anyOther -> pure $ RpcCall v i GetIVK BadParams
|
|
||||||
|
|
||||||
type ZenithRPC
|
type ZenithRPC
|
||||||
= "status" :> Get '[ JSON] Value :<|> BasicAuth "zenith-realm" Bool :> ReqBody
|
= "status" :> Get '[ JSON] Value :<|> BasicAuth "zenith-realm" Bool :> ReqBody
|
||||||
|
@ -1102,34 +1089,6 @@ zenithServer state = getinfo :<|> handleRPC
|
||||||
ErrorResponse (callId req) (-32006) "Account does not exist."
|
ErrorResponse (callId req) (-32006) "Account does not exist."
|
||||||
_anyOtherParams ->
|
_anyOtherParams ->
|
||||||
return $ ErrorResponse (callId req) (-32602) "Invalid params"
|
return $ ErrorResponse (callId req) (-32602) "Invalid params"
|
||||||
GetIVK -> do
|
|
||||||
case parameters req of
|
|
||||||
ViewingKeyParams aid -> do
|
|
||||||
let dbPath = w_dbPath state
|
|
||||||
let net = w_network state
|
|
||||||
pool <- liftIO $ runNoLoggingT $ initPool dbPath
|
|
||||||
acc <- liftIO $ getAccountById pool $ toSqlKey $ fromIntegral aid
|
|
||||||
case acc of
|
|
||||||
Just acc' -> do
|
|
||||||
ivk <-
|
|
||||||
liftIO $
|
|
||||||
try
|
|
||||||
(deriveUivk
|
|
||||||
net
|
|
||||||
(getOrchSK $ zcashAccountOrchSpendKey $ entityVal acc')
|
|
||||||
(getSapSK $ zcashAccountSapSpendKey $ entityVal acc')
|
|
||||||
(getTranSK $ zcashAccountTPrivateKey $ entityVal acc')) :: Handler
|
|
||||||
(Either SomeException T.Text)
|
|
||||||
case ivk of
|
|
||||||
Left _ ->
|
|
||||||
return $
|
|
||||||
ErrorResponse (callId req) (-32010) "Internal Error"
|
|
||||||
Right ivk' -> return $ ViewingKeyResponse (callId req) ivk'
|
|
||||||
Nothing ->
|
|
||||||
return $
|
|
||||||
ErrorResponse (callId req) (-32006) "Account does not exist."
|
|
||||||
_anyOtherParams ->
|
|
||||||
return $ ErrorResponse (callId req) (-32602) "Invalid params"
|
|
||||||
|
|
||||||
authenticate :: Config -> BasicAuthCheck Bool
|
authenticate :: Config -> BasicAuthCheck Bool
|
||||||
authenticate config = BasicAuthCheck check
|
authenticate config = BasicAuthCheck check
|
||||||
|
|
|
@ -774,55 +774,6 @@ main = do
|
||||||
Left e -> assertFailure e
|
Left e -> assertFailure e
|
||||||
Right (ViewingKeyResponse i c) -> c `shouldNotBe` ""
|
Right (ViewingKeyResponse i c) -> c `shouldNotBe` ""
|
||||||
Right x -> assertFailure $ show x
|
Right x -> assertFailure $ show x
|
||||||
describe "Incoming" $ do
|
|
||||||
it "bad credentials" $ do
|
|
||||||
res <-
|
|
||||||
makeZenithCall
|
|
||||||
"127.0.0.1"
|
|
||||||
nodePort
|
|
||||||
"baduser"
|
|
||||||
"idontknow"
|
|
||||||
GetIVK
|
|
||||||
BlankParams
|
|
||||||
res `shouldBe` Left "Invalid credentials"
|
|
||||||
describe "correct credentials" $ do
|
|
||||||
it "no parameters" $ do
|
|
||||||
res <-
|
|
||||||
makeZenithCall
|
|
||||||
"127.0.0.1"
|
|
||||||
nodePort
|
|
||||||
nodeUser
|
|
||||||
nodePwd
|
|
||||||
GetIVK
|
|
||||||
BlankParams
|
|
||||||
case res of
|
|
||||||
Left e -> assertFailure e
|
|
||||||
Right (ErrorResponse i c m) -> c `shouldBe` (-32602)
|
|
||||||
it "invalid account" $ do
|
|
||||||
res <-
|
|
||||||
makeZenithCall
|
|
||||||
"127.0.0.1"
|
|
||||||
nodePort
|
|
||||||
nodeUser
|
|
||||||
nodePwd
|
|
||||||
GetIVK
|
|
||||||
(ViewingKeyParams 27)
|
|
||||||
case res of
|
|
||||||
Left e -> assertFailure e
|
|
||||||
Right (ErrorResponse i c m) -> c `shouldBe` (-32006)
|
|
||||||
it "valid account" $ do
|
|
||||||
res <-
|
|
||||||
makeZenithCall
|
|
||||||
"127.0.0.1"
|
|
||||||
nodePort
|
|
||||||
nodeUser
|
|
||||||
nodePwd
|
|
||||||
GetIVK
|
|
||||||
(ViewingKeyParams 1)
|
|
||||||
case res of
|
|
||||||
Left e -> assertFailure e
|
|
||||||
Right (ViewingKeyResponse i c) -> c `shouldNotBe` ""
|
|
||||||
Right x -> assertFailure $ show x
|
|
||||||
|
|
||||||
startAPI :: Config -> IO ()
|
startAPI :: Config -> IO ()
|
||||||
startAPI config = do
|
startAPI config = do
|
||||||
|
|
|
@ -833,13 +833,15 @@
|
||||||
"name": "getincomingvk",
|
"name": "getincomingvk",
|
||||||
"summary": "Get the incoming viewing key for the given account.",
|
"summary": "Get the incoming viewing key for the given account.",
|
||||||
"description": "Derives the incoming viewing key for the given account per ZIP-316.",
|
"description": "Derives the incoming viewing key for the given account per ZIP-316.",
|
||||||
"tags": [],
|
"tags": [
|
||||||
|
{ "$ref": "#/components/tags/draft"}
|
||||||
|
],
|
||||||
"params": [
|
"params": [
|
||||||
{ "$ref": "#/components/contentDescriptors/AccountId"}
|
{ "$ref": "#/components/contentDescriptors/AccountId"}
|
||||||
],
|
],
|
||||||
"paramStructure": "by-position",
|
"paramStructure": "by-position",
|
||||||
"result": {
|
"result": {
|
||||||
"name": "Incoming viewing key",
|
"name": "Full viewing key",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ViewingKey"
|
"$ref": "#/components/schemas/ViewingKey"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
name: zenith
|
name: zenith
|
||||||
version: 0.8.0.0-beta
|
version: 0.7.2.0-beta
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Rene Vergara
|
author: Rene Vergara
|
||||||
|
|
Loading…
Add table
Reference in a new issue