Compare commits

..

No commits in common. "158b059596500e94e08a3ecc79742b86f85ad540" and "35f13c7290b39513acf8a8b4b1b7ce9dbd8b6bb8" have entirely different histories.

10 changed files with 79 additions and 153 deletions

3
.gitmodules vendored
View file

@ -1,6 +1,3 @@
[submodule "haskoin-core"] [submodule "haskoin-core"]
path = haskoin-core path = haskoin-core
url = https://github.com/khazaddum/haskoin-core.git url = https://github.com/khazaddum/haskoin-core.git
[submodule "zcash-haskell"]
path = zcash-haskell
url = git@git.vergara.tech:Vergara_Tech/zcash-haskell.git

View file

@ -5,21 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.4.0]
### Added
- `zcash-haskell` library
### Changed
- Sending of transactions to support ZIP-317.
- Functions to check if Unified Address is valid.
### Removed
- Dependency on patched `haskoin-core` library
## [0.3.4] ## [0.3.4]
### Added ### Added

2
Setup.hs Normal file
View file

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

View file

@ -202,6 +202,6 @@ main = do
"Zenith" "Zenith"
def def
{ getBanner = { getBanner =
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0" " ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.3.3"
} }
(root nodeUser nodePwd) (root nodeUser nodePwd)

1
haskoin-core Submodule

@ -0,0 +1 @@
Subproject commit 23132427a25ebdedbcab4d4a931eaafa13de9011

View file

@ -1,5 +1,5 @@
name: zenith name: zenith
version: 0.4.0 version: 0.3.4
git: "https://git.vergara.tech/Vergara_Tech/zenith" git: "https://git.vergara.tech/Vergara_Tech/zenith"
license: BOSL license: BOSL
author: "Rene Vergara" author: "Rene Vergara"
@ -31,6 +31,7 @@ library:
- bytestring - bytestring
- http-conduit - http-conduit
- scientific - scientific
- haskoin-core
- vector - vector
- regex-base - regex-base
- regex-posix - regex-posix
@ -41,8 +42,6 @@ library:
- array - array
- base64-bytestring - base64-bytestring
- hexstring - hexstring
- blake2
- zcash-haskell
executables: executables:
zenith: zenith:

View file

@ -7,11 +7,9 @@ module Zenith where
import Control.Concurrent (threadDelay) import Control.Concurrent (threadDelay)
import Control.Monad import Control.Monad
import Crypto.Hash.BLAKE2.BLAKE2b
import Data.Aeson import Data.Aeson
import Data.Aeson.Types import Data.Aeson.Types
import qualified Data.Array as A import qualified Data.Array as A
import Data.Bits
import qualified Data.ByteString as B import qualified Data.ByteString as B
import qualified Data.ByteString.Base64 as B64 import qualified Data.ByteString.Base64 as B64
import qualified Data.ByteString.Char8 as C import qualified Data.ByteString.Char8 as C
@ -28,10 +26,7 @@ import qualified Data.Text.IO as TIO
import qualified Data.Vector as V import qualified Data.Vector as V
import Data.Word import Data.Word
import GHC.Generics import GHC.Generics
import ZcashHaskell.Orchard (isValidUnifiedAddress) import Haskoin.Address.Bech32
import ZcashHaskell.Sapling (isValidShieldedAddress)
{-import Haskoin.Address.Bech32-}
import Network.HTTP.Simple import Network.HTTP.Simple
import Network.HTTP.Types import Network.HTTP.Types
import Numeric import Numeric
@ -45,12 +40,14 @@ import Text.Regex.Base
import Text.Regex.Posix import Text.Regex.Posix
-- | A type to model Zcash RPC calls -- | A type to model Zcash RPC calls
data RpcCall = RpcCall data RpcCall =
{ jsonrpc :: T.Text RpcCall
, id :: T.Text { jsonrpc :: T.Text
, method :: T.Text , id :: T.Text
, params :: [Value] , method :: T.Text
} deriving (Show, Generic, ToJSON, FromJSON) , params :: [Value]
}
deriving (Show, Generic, ToJSON, FromJSON)
-- | Type for modelling the different address sources for Zcash 5.0.0 -- | Type for modelling the different address sources for Zcash 5.0.0
data AddressSource data AddressSource
@ -89,12 +86,14 @@ instance FromJSON ZcashPool where
"orchard" -> return Orchard "orchard" -> return Orchard
_ -> fail "Not a known Zcash pool" _ -> fail "Not a known Zcash pool"
data ZcashAddress = ZcashAddress data ZcashAddress =
{ source :: AddressSource ZcashAddress
, pool :: [ZcashPool] { source :: AddressSource
, account :: Maybe Integer , pool :: [ZcashPool]
, addy :: T.Text , account :: Maybe Integer
} deriving (Eq) , addy :: T.Text
}
deriving (Eq)
instance Show ZcashAddress where instance Show ZcashAddress where
show (ZcashAddress s p i a) = show (ZcashAddress s p i a) =
@ -102,11 +101,13 @@ instance Show ZcashAddress where
"..." ++ T.unpack (T.takeEnd 8 a) ++ " Pools: " ++ show p "..." ++ T.unpack (T.takeEnd 8 a) ++ " Pools: " ++ show p
-- | A type to model the response of the Zcash RPC -- | A type to model the response of the Zcash RPC
data RpcResponse r = RpcResponse data RpcResponse r =
{ err :: Maybe T.Text RpcResponse
, respId :: T.Text { err :: Maybe T.Text
, result :: r , respId :: T.Text
} deriving (Show, Generic, ToJSON) , result :: r
}
deriving (Show, Generic, ToJSON)
instance (FromJSON r) => FromJSON (RpcResponse r) where instance (FromJSON r) => FromJSON (RpcResponse r) where
parseJSON (Object obj) = do parseJSON (Object obj) = do
@ -130,12 +131,14 @@ instance FromJSON NodeVersion where
pure $ NodeVersion v pure $ NodeVersion v
-- | A type to model an address group -- | A type to model an address group
data AddressGroup = AddressGroup data AddressGroup =
{ agsource :: AddressSource AddressGroup
, agtransparent :: [ZcashAddress] { agsource :: AddressSource
, agsapling :: [ZcashAddress] , agtransparent :: [ZcashAddress]
, agunified :: [ZcashAddress] , agsapling :: [ZcashAddress]
} deriving (Show, Generic) , agunified :: [ZcashAddress]
}
deriving (Show, Generic)
instance FromJSON AddressGroup where instance FromJSON AddressGroup where
parseJSON = parseJSON =
@ -187,16 +190,18 @@ displayZec s
| otherwise = show (fromIntegral s / 100000000) ++ " ZEC " | otherwise = show (fromIntegral s / 100000000) ++ " ZEC "
-- | A type to model a Zcash transaction -- | A type to model a Zcash transaction
data ZcashTx = ZcashTx data ZcashTx =
{ ztxid :: T.Text ZcashTx
, zamount :: Double { ztxid :: T.Text
, zamountZat :: Integer , zamount :: Double
, zblockheight :: Integer , zamountZat :: Integer
, zblocktime :: Integer , zblockheight :: Integer
, zchange :: Bool , zblocktime :: Integer
, zconfirmations :: Integer , zchange :: Bool
, zmemo :: T.Text , zconfirmations :: Integer
} deriving (Show, Generic) , zmemo :: T.Text
}
deriving (Show, Generic)
instance FromJSON ZcashTx where instance FromJSON ZcashTx where
parseJSON = parseJSON =
@ -236,11 +241,13 @@ instance ToJSON ZcashTx where
] ]
-- | Type for the UA balance -- | Type for the UA balance
data UABalance = UABalance data UABalance =
{ uatransparent :: Integer UABalance
, uasapling :: Integer { uatransparent :: Integer
, uaorchard :: Integer , uasapling :: Integer
} deriving (Eq) , uaorchard :: Integer
}
deriving (Eq)
instance Show UABalance where instance Show UABalance where
show (UABalance t s o) = show (UABalance t s o) =
@ -268,11 +275,13 @@ instance FromJSON UABalance where
pure $ UABalance vT vS vO pure $ UABalance vT vS vO
-- | Type for Operation Result -- | Type for Operation Result
data OpResult = OpResult data OpResult =
{ opsuccess :: T.Text OpResult
, opmessage :: Maybe T.Text { opsuccess :: T.Text
, optxid :: Maybe T.Text , opmessage :: Maybe T.Text
} deriving (Show, Eq) , optxid :: Maybe T.Text
}
deriving (Show, Eq)
instance FromJSON OpResult where instance FromJSON OpResult where
parseJSON = parseJSON =
@ -324,8 +333,8 @@ getAddresses ag = agtransparent ag <> agsapling ag <> agunified ag
validateAddress :: T.Text -> Maybe ZcashPool validateAddress :: T.Text -> Maybe ZcashPool
validateAddress txt --(tReg || sReg && isJust chk) || (uReg && isJust chk) validateAddress txt --(tReg || sReg && isJust chk) || (uReg && isJust chk)
| tReg = Just Transparent | tReg = Just Transparent
| sReg && chkS = Just Sapling | sReg && isJust chk = Just Sapling
| uReg && chk = Just Orchard | uReg && isJust chk = Just Orchard
| otherwise = Nothing | otherwise = Nothing
where where
transparentRegex = "^t1[a-zA-Z0-9]{33}$" :: String transparentRegex = "^t1[a-zA-Z0-9]{33}$" :: String
@ -334,8 +343,7 @@ validateAddress txt --(tReg || sReg && isJust chk) || (uReg && isJust chk)
tReg = T.unpack txt =~ transparentRegex :: Bool tReg = T.unpack txt =~ transparentRegex :: Bool
sReg = T.unpack txt =~ shieldedRegex :: Bool sReg = T.unpack txt =~ shieldedRegex :: Bool
uReg = T.unpack txt =~ unifiedRegex :: Bool uReg = T.unpack txt =~ unifiedRegex :: Bool
chk = isValidUnifiedAddress $ E.encodeUtf8 txt chk = bech32mDecode txt
chkS = isValidShieldedAddress $ E.encodeUtf8 txt
-- | RPC methods -- | RPC methods
-- | List addresses -- | List addresses
@ -425,7 +433,7 @@ sendTx user pwd fromAddy toAddy amount memo = do
(V.fromList (V.fromList
[object ["address" .= toAddy, "amount" .= amount]]) [object ["address" .= toAddy, "amount" .= amount]])
, Data.Aeson.Number $ Scientific.scientific 1 1 , Data.Aeson.Number $ Scientific.scientific 1 1
, Data.Aeson.Null , Data.Aeson.Number $ Scientific.scientific 1 (-5)
, Data.Aeson.String privacyPolicy , Data.Aeson.String privacyPolicy
] ]
Just memo' -> Just memo' ->
@ -439,7 +447,7 @@ sendTx user pwd fromAddy toAddy amount memo = do
] ]
]) ])
, Data.Aeson.Number $ Scientific.scientific 1 1 , Data.Aeson.Number $ Scientific.scientific 1 1
, Data.Aeson.Null , Data.Aeson.Number $ Scientific.scientific 1 (-5)
, Data.Aeson.String privacyPolicy , Data.Aeson.String privacyPolicy
] ]
response <- makeZcashCall user pwd "z_sendmany" pd response <- makeZcashCall user pwd "z_sendmany" pd

View file

@ -17,7 +17,7 @@
# #
# resolver: ./custom-snapshot.yaml # resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-21.6 resolver: lts-20.8
# User packages to be built. # User packages to be built.
# Various formats can be used as shown in the example below. # Various formats can be used as shown in the example below.
@ -30,8 +30,7 @@ resolver: lts-21.6
# - wai # - wai
packages: packages:
- . - .
#- haskoin-core - haskoin-core
#- zcash-haskell
# Dependency packages to be pulled from upstream that are not in the resolver. # Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as # These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example: # forks / in-progress versions pinned to a git hash. For example:
@ -43,19 +42,8 @@ packages:
# #
# extra-deps: [] # extra-deps: []
extra-deps: extra-deps:
- git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
commit: fef3d3af35a09db718cddb8fc9166b2d2691a744
- git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
- git: https://github.com/reach-sh/haskell-hexstring.git - git: https://github.com/reach-sh/haskell-hexstring.git
commit: 085c16fb21b9f856a435a3faab980e7e0b319341 commit: 085c16fb21b9f856a435a3faab980e7e0b319341
- git: https://github.com/well-typed/borsh.git
commit: d2fcfa159e0a844b1ec5e8ed3e232d4b380fa831
- vector-0.13.0.0@sha256:fa5cac81a17a5af388716792e8b99c24b3b66770086756d0d8b23f8272a0244c,9112
- generically-0.1.1
- vector-algorithms-0.9.0.1
#- vector-0.12.3.1@sha256:abbfe8830e13549596e1295219d340eb01bd00e1c7124d0dd16586911a291c59,8218
#extra-lib-dirs: [/home/rav/Documents/programs/haskoin]
# #
# Override default flag values for local packages and extra-deps # Override default flag values for local packages and extra-deps
# flags: {} # flags: {}
@ -76,6 +64,7 @@ extra-deps:
# #
# Extra directories used by stack for building # Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir] # extra-include-dirs: [/path/to/dir]
#extra-lib-dirs: [/home/rav/Documents/programs/haskoin]
# #
# Allow a newer minor version of GHC than the snapshot specifies # Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor # compiler-check: newer-minor

View file

@ -4,28 +4,6 @@
# https://docs.haskellstack.org/en/stable/lock_files # https://docs.haskellstack.org/en/stable/lock_files
packages: packages:
- completed:
commit: fef3d3af35a09db718cddb8fc9166b2d2691a744
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
name: zcash-haskell
pantry-tree:
sha256: ec7782cf2646da17548d59af0ea98dcbaac1b6c2176258c696a7f508db6dbc21
size: 1126
version: 0.1.0
original:
commit: fef3d3af35a09db718cddb8fc9166b2d2691a744
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
- completed:
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
name: foreign-rust
pantry-tree:
sha256: be2f6fc0fab58a90fec657bdb6bd0ccf0810c7dccfe95c78b85e174fae227e42
size: 2315
version: 0.1.0
original:
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
- completed: - completed:
commit: 085c16fb21b9f856a435a3faab980e7e0b319341 commit: 085c16fb21b9f856a435a3faab980e7e0b319341
git: https://github.com/reach-sh/haskell-hexstring.git git: https://github.com/reach-sh/haskell-hexstring.git
@ -37,41 +15,9 @@ packages:
original: original:
commit: 085c16fb21b9f856a435a3faab980e7e0b319341 commit: 085c16fb21b9f856a435a3faab980e7e0b319341
git: https://github.com/reach-sh/haskell-hexstring.git git: https://github.com/reach-sh/haskell-hexstring.git
- completed:
commit: d2fcfa159e0a844b1ec5e8ed3e232d4b380fa831
git: https://github.com/well-typed/borsh.git
name: borsh
pantry-tree:
sha256: 8335925f495a5a653fcb74b6b8bb18cd0b6b7fe7099a1686108704e6ab82f47b
size: 2268
version: 0.3.0
original:
commit: d2fcfa159e0a844b1ec5e8ed3e232d4b380fa831
git: https://github.com/well-typed/borsh.git
- completed:
hackage: vector-0.13.0.0@sha256:fa5cac81a17a5af388716792e8b99c24b3b66770086756d0d8b23f8272a0244c,9112
pantry-tree:
sha256: d2461d28022c8c0a91da08b579b1bff478f617102d2f5ef596cc5b28d14b8b6a
size: 4092
original:
hackage: vector-0.13.0.0@sha256:fa5cac81a17a5af388716792e8b99c24b3b66770086756d0d8b23f8272a0244c,9112
- completed:
hackage: generically-0.1.1@sha256:aa00d9a77b7fb90c08f935699758ed9de55975021b1e979c6a4a4b5b49a940a9,1133
pantry-tree:
sha256: ec19e6d2aecfbe7a59e789526b9d7ab5c8ba853f017248d0203ee69a9769adb7
size: 233
original:
hackage: generically-0.1.1
- completed:
hackage: vector-algorithms-0.9.0.1@sha256:f3e5c6695529a94edf762117cafd91c989cb642ad3f8ca4014dbb13c8f6c2a20,3826
pantry-tree:
sha256: aef389e57ae6020e5da719bee40aaf6cccf1c4d1e7743a85d30c9d8c25d170a0
size: 1510
original:
hackage: vector-algorithms-0.9.0.1
snapshots: snapshots:
- completed: - completed:
sha256: 2e7d4a730d8eb5373b2d383fac84efcf7c81e3b7a5fce71b4c2e19a1768f25a6 sha256: bfafe5735ccb74527d754b1f9999ded72d7c3a6c3a88529449661431ccfbd6cc
size: 640239 size: 649327
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/6.yaml url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/8.yaml
original: lts-21.6 original: lts-20.8

View file

@ -1,11 +1,11 @@
cabal-version: 1.12 cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.35.1. -- This file has been generated from package.yaml by hpack version 0.35.0.
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: zenith name: zenith
version: 0.4.0 version: 0.3.4
synopsis: Haskell CLI for Zcash Full Node synopsis: Haskell CLI for Zcash Full Node
description: Please see the README on repo at <https://git.vergara.tech/Vergara_Tech/zenith#readme> description: Please see the README on repo at <https://git.vergara.tech/Vergara_Tech/zenith#readme>
author: Rene Vergara author: Rene Vergara
@ -36,8 +36,8 @@ library
, array , array
, base >=4.7 && <5 , base >=4.7 && <5
, base64-bytestring , base64-bytestring
, blake2
, bytestring , bytestring
, haskoin-core
, hexstring , hexstring
, http-conduit , http-conduit
, http-types , http-types
@ -48,7 +48,6 @@ library
, scientific , scientific
, text , text
, vector , vector
, zcash-haskell
default-language: Haskell2010 default-language: Haskell2010
executable zenith executable zenith