Compare commits
No commits in common. "268d17c09417d3a901e438e1d73167043867cce7" and "19afc808aca157623a07a154f443d0fce8109e98" have entirely different histories.
268d17c094
...
19afc808ac
9 changed files with 26 additions and 77 deletions
|
@ -7,14 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
## Added
|
||||||
|
|
||||||
- `Core` module
|
- `Core` module
|
||||||
- `CLI` module
|
- `CLI` module
|
||||||
- `DB` module
|
- `DB` module
|
||||||
- Command line arguments to switch to legacy version
|
- Command line arguments to switch to legacy version
|
||||||
- New configuration parameter for Zebra port
|
|
||||||
- New functions to call `getinfo` and `getblockchaininfo` RPC methods
|
|
||||||
|
|
||||||
## [0.4.1]
|
## [0.4.1]
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,6 @@ main = do
|
||||||
dbName <- require config "dbName"
|
dbName <- require config "dbName"
|
||||||
nodeUser <- require config "nodeUser"
|
nodeUser <- require config "nodeUser"
|
||||||
nodePwd <- require config "nodePwd"
|
nodePwd <- require config "nodePwd"
|
||||||
zebraPort <- require config "zebraPort"
|
|
||||||
if not (null args)
|
if not (null args)
|
||||||
then do
|
then do
|
||||||
case head args of
|
case head args of
|
||||||
|
@ -216,7 +215,7 @@ main = do
|
||||||
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0"
|
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0"
|
||||||
}
|
}
|
||||||
(root nodeUser nodePwd)
|
(root nodeUser nodePwd)
|
||||||
"cli" -> runZenithCLI zebraPort dbName
|
"cli" -> runZenithCLI dbName
|
||||||
_ -> printUsage
|
_ -> printUsage
|
||||||
else printUsage
|
else printUsage
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ library:
|
||||||
- text
|
- text
|
||||||
- bytestring
|
- bytestring
|
||||||
- http-conduit
|
- http-conduit
|
||||||
- http-client
|
|
||||||
- scientific
|
- scientific
|
||||||
- vector
|
- vector
|
||||||
- regex-base
|
- regex-base
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
|
||||||
|
|
||||||
module Zenith.CLI where
|
module Zenith.CLI where
|
||||||
|
|
||||||
|
@ -34,8 +33,6 @@ import Brick.Widgets.Core
|
||||||
)
|
)
|
||||||
import qualified Brick.Widgets.List as L
|
import qualified Brick.Widgets.List as L
|
||||||
import qualified Data.Vector as Vec
|
import qualified Data.Vector as Vec
|
||||||
import Network.HTTP.Simple
|
|
||||||
import ZcashHaskell.Types
|
|
||||||
import Zenith.Core
|
import Zenith.Core
|
||||||
|
|
||||||
data Name
|
data Name
|
||||||
|
@ -88,6 +85,15 @@ listDrawElement sel a =
|
||||||
else str s
|
else str s
|
||||||
in C.hCenter $ selStr $ show a
|
in C.hCenter $ selStr $ show a
|
||||||
|
|
||||||
|
initialState :: State
|
||||||
|
initialState =
|
||||||
|
State
|
||||||
|
"Main"
|
||||||
|
(L.list WList (Vec.fromList ["wall1"]) 1)
|
||||||
|
(L.list AList (Vec.fromList ["addr1", "addr2"]) 1)
|
||||||
|
(L.list TList (Vec.fromList ["tx1", "tx2", "tx3"]) 1)
|
||||||
|
"Start up Ok!"
|
||||||
|
|
||||||
customAttr :: A.AttrName
|
customAttr :: A.AttrName
|
||||||
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
||||||
|
|
||||||
|
@ -123,25 +129,10 @@ theApp =
|
||||||
, M.appAttrMap = const theMap
|
, M.appAttrMap = const theMap
|
||||||
}
|
}
|
||||||
|
|
||||||
runZenithCLI :: Int -> T.Text -> IO ()
|
runZenithCLI :: T.Text -> IO ()
|
||||||
runZenithCLI port dbName = do
|
runZenithCLI dbName = do
|
||||||
w <- checkZebra port
|
w <- checkWallets dbName
|
||||||
case (w :: Maybe ZebraGetInfo) of
|
if (null w)
|
||||||
Just zebra -> do
|
then void $ M.defaultMain theApp initialState
|
||||||
bc <- checkBlockChain port
|
else do
|
||||||
case (bc :: Maybe ZebraGetBlockChainInfo) of
|
print "No wallet found. Create one? Y/N"
|
||||||
Nothing -> print "Unable to determine blockchain status"
|
|
||||||
Just chainInfo -> do
|
|
||||||
void $
|
|
||||||
M.defaultMain theApp $
|
|
||||||
State
|
|
||||||
((show . zgb_net) chainInfo)
|
|
||||||
(L.list WList (Vec.fromList ["wall1"]) 1)
|
|
||||||
(L.list AList (Vec.fromList ["addr1", "addr2"]) 1)
|
|
||||||
(L.list TList (Vec.fromList ["tx1", "tx2", "tx3"]) 1)
|
|
||||||
("Start up Ok! Connected to Zebra " ++
|
|
||||||
(T.unpack . zgi_build) zebra ++ " on port " ++ show port ++ ".")
|
|
||||||
Nothing -> do
|
|
||||||
print $
|
|
||||||
"No Zebra node available on port " <>
|
|
||||||
show port <> ". Check your configuration"
|
|
||||||
|
|
|
@ -1,48 +1,12 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
|
||||||
|
|
||||||
-- Core wallet functionality for Zenith
|
|
||||||
module Zenith.Core where
|
module Zenith.Core where
|
||||||
|
|
||||||
import Data.Aeson
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Database.Persist
|
import Database.Persist
|
||||||
import Database.Persist.Sqlite
|
import Database.Persist.Sqlite
|
||||||
import Network.HTTP.Client
|
|
||||||
import ZcashHaskell.Types
|
|
||||||
import ZcashHaskell.Utils
|
|
||||||
import Zenith.DB
|
import Zenith.DB
|
||||||
|
|
||||||
-- * Database functions
|
checkWallets :: T.Text -> IO [Entity ZcashWallet]
|
||||||
-- | Returns the list of wallets available in the given database
|
|
||||||
checkWallets ::
|
|
||||||
T.Text -- ^ The database name to check
|
|
||||||
-> IO [Entity ZcashWallet]
|
|
||||||
checkWallets dbName = do
|
checkWallets dbName = do
|
||||||
runSqlite dbName $ do runMigration migrateAll
|
runSqlite dbName $ do runMigration migrateAll
|
||||||
runSqlite dbName $ selectList [ZcashWalletBirthdayHeight >. 0] []
|
wallets <- runSqlite dbName $ selectList [ZcashWalletBirthdayHeight >. 0] []
|
||||||
|
return wallets
|
||||||
-- * Zebra Node interaction
|
|
||||||
-- | Checks the status of the `zebrad` node
|
|
||||||
checkZebra ::
|
|
||||||
Int -- ^ Port where `zebrad` is available
|
|
||||||
-> IO (Maybe ZebraGetInfo)
|
|
||||||
checkZebra port = do
|
|
||||||
res <- makeZebraCall port "getinfo" []
|
|
||||||
let body = responseBody (res :: Response (RpcResponse ZebraGetInfo))
|
|
||||||
return $ result body
|
|
||||||
|
|
||||||
-- | Checks the status of the Zcash blockchain
|
|
||||||
checkBlockChain ::
|
|
||||||
Int -- ^ Port where `zebrad` is available
|
|
||||||
-> IO (Maybe ZebraGetBlockChainInfo)
|
|
||||||
checkBlockChain port = do
|
|
||||||
let f = makeZebraCall port
|
|
||||||
result <$> (responseBody <$> f "getblockchaininfo" [])
|
|
||||||
|
|
||||||
-- | Generic RPC call function
|
|
||||||
connectZebra ::
|
|
||||||
FromJSON a => Int -> T.Text -> [Data.Aeson.Value] -> IO (Maybe a)
|
|
||||||
connectZebra port m params = do
|
|
||||||
res <- makeZebraCall port m params
|
|
||||||
let body = responseBody res
|
|
||||||
return $ result body
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ packages:
|
||||||
# extra-deps: []
|
# extra-deps: []
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
- git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||||
commit: 09cee9a064219e4be89413ef86341aa18b62be68
|
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
||||||
- git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
- git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
||||||
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
||||||
- git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
|
- git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- completed:
|
- completed:
|
||||||
commit: 09cee9a064219e4be89413ef86341aa18b62be68
|
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
||||||
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||||
name: zcash-haskell
|
name: zcash-haskell
|
||||||
pantry-tree:
|
pantry-tree:
|
||||||
sha256: 6bf1902a377bf9399442de6f0b89219479fa908e70706918e81b88caa28dc0f5
|
sha256: 1bf709484bc488e51e18aa11001abdc06100ed7086b9bbd765d28c4a3d8e9113
|
||||||
size: 1367
|
size: 1366
|
||||||
version: 0.4.1
|
version: 0.4.1
|
||||||
original:
|
original:
|
||||||
commit: 09cee9a064219e4be89413ef86341aa18b62be68
|
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
||||||
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||||
- completed:
|
- completed:
|
||||||
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
||||||
|
|
|
@ -43,7 +43,6 @@ library
|
||||||
, base64-bytestring
|
, base64-bytestring
|
||||||
, brick
|
, brick
|
||||||
, bytestring
|
, bytestring
|
||||||
, http-client
|
|
||||||
, http-conduit
|
, http-conduit
|
||||||
, http-types
|
, http-types
|
||||||
, microlens
|
, microlens
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
nodeUser = "user"
|
nodeUser = "user"
|
||||||
nodePwd = "superSecret"
|
nodePwd = "superSecret"
|
||||||
dbName = "zenith.db"
|
dbName = "zenith.db"
|
||||||
zebraPort = 18232
|
|
||||||
|
|
Loading…
Reference in a new issue