Compare commits
No commits in common. "7f1877a8cc862f2dba64ad95949ca48f8b333727" and "76178ca5d44ed889a79477b1b251a0fd7f244ec8" have entirely different histories.
7f1877a8cc
...
76178ca5d4
12 changed files with 339 additions and 1059 deletions
33
CHANGELOG.md
33
CHANGELOG.md
|
@ -5,7 +5,7 @@ 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.6.0.0-beta]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
@ -20,36 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Dialog to add new account
|
- Dialog to add new account
|
||||||
- Dialog to add new wallet
|
- Dialog to add new wallet
|
||||||
- Dialog to display transaction details and copy TX ID
|
- Dialog to display transaction details and copy TX ID
|
||||||
- Dialog to send a new transaction
|
|
||||||
- Dialog to display Tx ID after successful broadcast
|
|
||||||
- Unconfirmed balance display on TUI and GUI
|
|
||||||
- Tracking of unconfirmed notes
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- Upgraded to GHC 9.6.5
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Validation of input of amount for sending in TUI
|
|
||||||
|
|
||||||
### Removed
|
|
||||||
|
|
||||||
- Legacy interface to `zcashd`
|
|
||||||
|
|
||||||
## [0.5.3.1-beta]
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Docker image
|
|
||||||
|
|
||||||
## [0.5.3.0-beta]
|
## [0.5.3.0-beta]
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Address Book functionality. Allows users to store frequently used zcash addresses and
|
|
||||||
generate transactions using them.
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Improved formatting of sync progress
|
- Improved formatting of sync progress
|
||||||
|
@ -60,6 +34,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [0.5.2.0-beta]
|
## [0.5.2.0-beta]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Address Book functionality. Allows users to store frequently used zcash addresses and
|
||||||
|
generate transactions using them.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Update to `zcash-haskell-0.6.2.0` to increase performance of transaction creation
|
- Update to `zcash-haskell-0.6.2.0` to increase performance of transaction creation
|
||||||
|
|
19
app/Main.hs
19
app/Main.hs
|
@ -11,8 +11,7 @@ import Data.Sort
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.IO as TIO
|
import qualified Data.Text.IO as TIO
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
|
import System.Console.StructuredCLI
|
||||||
{-import System.Console.StructuredCLI-}
|
|
||||||
import System.Environment (getArgs)
|
import System.Environment (getArgs)
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import System.IO
|
import System.IO
|
||||||
|
@ -24,7 +23,7 @@ import Zenith.GUI (runZenithGUI)
|
||||||
import Zenith.Types (Config(..), ZcashAddress(..), ZcashPool(..), ZcashTx(..))
|
import Zenith.Types (Config(..), ZcashAddress(..), ZcashPool(..), ZcashTx(..))
|
||||||
import Zenith.Utils
|
import Zenith.Utils
|
||||||
import Zenith.Zcashd
|
import Zenith.Zcashd
|
||||||
{-
|
|
||||||
prompt :: String -> IO String
|
prompt :: String -> IO String
|
||||||
prompt text = do
|
prompt text = do
|
||||||
putStr text
|
putStr text
|
||||||
|
@ -198,15 +197,14 @@ processUri user pwd =
|
||||||
_ -> False
|
_ -> False
|
||||||
_ <- liftIO $ sendWithUri user pwd (addList !! (idx - 1)) u repTo
|
_ <- liftIO $ sendWithUri user pwd (addList !! (idx - 1)) u repTo
|
||||||
return NoAction
|
return NoAction
|
||||||
-}
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
config <- load [ "$(HOME)/Zenith/zenith.cfg" ]
|
config <- load [ "$(HOME)/Zenith/zenith.cfg" ]
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
dbFileName <- require config "dbFileName"
|
dbFileName <- require config "dbFileName"
|
||||||
{-nodeUser <- require config "nodeUser"-}
|
nodeUser <- require config "nodeUser"
|
||||||
{-nodePwd <- require config "nodePwd"-}
|
nodePwd <- require config "nodePwd"
|
||||||
zebraPort <- require config "zebraPort"
|
zebraPort <- require config "zebraPort"
|
||||||
zebraHost <- require config "zebraHost"
|
zebraHost <- require config "zebraHost"
|
||||||
dbFP <- getZenithPath
|
dbFP <- getZenithPath
|
||||||
|
@ -215,7 +213,7 @@ main = do
|
||||||
if not (null args)
|
if not (null args)
|
||||||
then do
|
then do
|
||||||
case head args of
|
case head args of
|
||||||
{-"legacy" -> do
|
"legacy" -> do
|
||||||
checkServer nodeUser nodePwd
|
checkServer nodeUser nodePwd
|
||||||
void $
|
void $
|
||||||
runCLI
|
runCLI
|
||||||
|
@ -224,10 +222,9 @@ main = do
|
||||||
{ 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.4.0"
|
||||||
}
|
}
|
||||||
(root nodeUser nodePwd) -}
|
(root nodeUser nodePwd)
|
||||||
|
|
||||||
"gui" -> runZenithGUI myConfig
|
|
||||||
"tui" -> runZenithTUI myConfig
|
"tui" -> runZenithTUI myConfig
|
||||||
|
"gui" -> runZenithGUI myConfig
|
||||||
"rescan" -> clearSync myConfig
|
"rescan" -> clearSync myConfig
|
||||||
_ -> printUsage
|
_ -> printUsage
|
||||||
else printUsage
|
else printUsage
|
||||||
|
@ -236,6 +233,6 @@ printUsage :: IO ()
|
||||||
printUsage = do
|
printUsage = do
|
||||||
putStrLn "zenith [command] [parameters]\n"
|
putStrLn "zenith [command] [parameters]\n"
|
||||||
putStrLn "Available commands:"
|
putStrLn "Available commands:"
|
||||||
{-putStrLn "legacy\tLegacy CLI for zcashd"-}
|
putStrLn "legacy\tLegacy CLI for zcashd"
|
||||||
putStrLn "tui\tTUI for zebrad"
|
putStrLn "tui\tTUI for zebrad"
|
||||||
putStrLn "rescan\tRescan the existing wallet(s)"
|
putStrLn "rescan\tRescan the existing wallet(s)"
|
||||||
|
|
|
@ -2,7 +2,7 @@ packages:
|
||||||
./*.cabal
|
./*.cabal
|
||||||
zcash-haskell/zcash-haskell.cabal
|
zcash-haskell/zcash-haskell.cabal
|
||||||
|
|
||||||
with-compiler: ghc-9.6.5
|
with-compiler: ghc-9.4.8
|
||||||
|
|
||||||
source-repository-package
|
source-repository-package
|
||||||
type: git
|
type: git
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
active-repositories: hackage.haskell.org:merge
|
active-repositories: hackage.haskell.org:merge
|
||||||
constraints: any.Cabal ==3.10.3.0,
|
constraints: any.Cabal ==3.8.1.0,
|
||||||
any.Cabal-syntax ==3.10.3.0,
|
any.Cabal-syntax ==3.8.1.0,
|
||||||
any.Clipboard ==2.3.2.0,
|
any.Clipboard ==2.3.2.0,
|
||||||
any.HUnit ==1.6.2.0,
|
any.HUnit ==1.6.2.0,
|
||||||
any.Hclip ==3.0.0.4,
|
any.Hclip ==3.0.0.4,
|
||||||
any.JuicyPixels ==3.3.9,
|
any.JuicyPixels ==3.3.8,
|
||||||
JuicyPixels -mmap,
|
JuicyPixels -mmap,
|
||||||
any.OneTuple ==0.4.2,
|
any.OneTuple ==0.4.1.1,
|
||||||
any.OpenGLRaw ==3.3.4.1,
|
any.OpenGLRaw ==3.3.4.1,
|
||||||
OpenGLRaw -osandroid +usegles2 +useglxgetprocaddress +usenativewindowslibraries,
|
OpenGLRaw -osandroid +usegles2 +useglxgetprocaddress +usenativewindowslibraries,
|
||||||
any.QuickCheck ==2.14.3,
|
any.QuickCheck ==2.14.3,
|
||||||
|
@ -18,32 +18,32 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.X11 ==1.10.3,
|
any.X11 ==1.10.3,
|
||||||
X11 -pedantic,
|
X11 -pedantic,
|
||||||
any.adjunctions ==4.4.2,
|
any.adjunctions ==4.4.2,
|
||||||
any.aeson ==2.2.3.0,
|
any.aeson ==2.2.1.0,
|
||||||
aeson +ordered-keymap,
|
aeson +ordered-keymap,
|
||||||
any.alex ==3.5.1.0,
|
any.alex ==3.5.1.0,
|
||||||
any.ansi-terminal ==1.1.1,
|
any.ansi-terminal ==1.1,
|
||||||
ansi-terminal -example,
|
ansi-terminal -example,
|
||||||
any.ansi-terminal-types ==1.1,
|
any.ansi-terminal-types ==1.1,
|
||||||
any.appar ==0.1.8,
|
any.appar ==0.1.8,
|
||||||
any.array ==0.5.6.0,
|
any.array ==0.5.4.0,
|
||||||
any.ascii-progress ==0.3.3.0,
|
any.ascii-progress ==0.3.3.0,
|
||||||
ascii-progress -examples,
|
ascii-progress -examples,
|
||||||
any.asn1-encoding ==0.9.6,
|
any.asn1-encoding ==0.9.6,
|
||||||
any.asn1-parse ==0.9.5,
|
any.asn1-parse ==0.9.5,
|
||||||
any.asn1-types ==0.3.4,
|
any.asn1-types ==0.3.4,
|
||||||
any.assoc ==1.1.1,
|
any.assoc ==1.1,
|
||||||
assoc -tagged,
|
assoc +tagged,
|
||||||
any.async ==2.2.5,
|
any.async ==2.2.5,
|
||||||
async -bench,
|
async -bench,
|
||||||
any.attoparsec ==0.14.4,
|
any.attoparsec ==0.14.4,
|
||||||
attoparsec -developer,
|
attoparsec -developer,
|
||||||
any.attoparsec-aeson ==2.2.2.0,
|
any.attoparsec-aeson ==2.2.0.1,
|
||||||
any.authenticate-oauth ==1.7,
|
any.authenticate-oauth ==1.7,
|
||||||
any.auto-update ==0.2.1,
|
any.auto-update ==0.1.6,
|
||||||
any.base ==4.18.2.1,
|
any.base ==4.17.2.1,
|
||||||
any.base-compat ==0.14.0,
|
any.base-compat ==0.13.1,
|
||||||
any.base-compat-batteries ==0.14.0,
|
any.base-compat-batteries ==0.13.1,
|
||||||
any.base-orphans ==0.9.2,
|
any.base-orphans ==0.9.1,
|
||||||
any.base16 ==1.0,
|
any.base16 ==1.0,
|
||||||
any.base16-bytestring ==1.0.2.0,
|
any.base16-bytestring ==1.0.2.0,
|
||||||
any.base58-bytestring ==0.1.0,
|
any.base58-bytestring ==0.1.0,
|
||||||
|
@ -53,14 +53,14 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
bifunctors +tagged,
|
bifunctors +tagged,
|
||||||
any.bimap ==0.5.0,
|
any.bimap ==0.5.0,
|
||||||
any.binary ==0.8.9.1,
|
any.binary ==0.8.9.1,
|
||||||
any.binary-orphans ==1.0.5,
|
any.binary-orphans ==1.0.4.1,
|
||||||
any.bitvec ==1.1.5.0,
|
any.bitvec ==1.1.5.0,
|
||||||
bitvec +simd,
|
bitvec +simd,
|
||||||
any.blaze-builder ==0.4.2.3,
|
any.blaze-builder ==0.4.2.3,
|
||||||
any.blaze-html ==0.9.2.0,
|
any.blaze-html ==0.9.2.0,
|
||||||
any.blaze-markup ==0.8.3.0,
|
any.blaze-markup ==0.8.3.0,
|
||||||
any.borsh ==0.3.0,
|
any.borsh ==0.3.0,
|
||||||
any.brick ==2.4,
|
any.brick ==2.3.1,
|
||||||
brick -demos,
|
brick -demos,
|
||||||
any.byteorder ==1.0.4,
|
any.byteorder ==1.0.4,
|
||||||
any.bytes ==0.17.3,
|
any.bytes ==0.17.3,
|
||||||
|
@ -70,20 +70,19 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.bytestring-to-vector ==0.3.0.1,
|
any.bytestring-to-vector ==0.3.0.1,
|
||||||
any.c2hs ==0.28.8,
|
any.c2hs ==0.28.8,
|
||||||
c2hs +base3 -regression,
|
c2hs +base3 -regression,
|
||||||
any.cabal-doctest ==1.0.10,
|
any.cabal-doctest ==1.0.9,
|
||||||
any.call-stack ==0.4.0,
|
any.call-stack ==0.4.0,
|
||||||
any.case-insensitive ==1.2.1.0,
|
any.case-insensitive ==1.2.1.0,
|
||||||
any.cborg ==0.2.10.0,
|
any.cborg ==0.2.10.0,
|
||||||
cborg +optimize-gmp,
|
cborg +optimize-gmp,
|
||||||
any.cereal ==0.5.8.3,
|
any.cereal ==0.5.8.3,
|
||||||
cereal -bytestring-builder,
|
cereal -bytestring-builder,
|
||||||
any.character-ps ==0.1,
|
|
||||||
any.clock ==0.8.4,
|
any.clock ==0.8.4,
|
||||||
clock -llvm,
|
clock -llvm,
|
||||||
any.colour ==2.3.6,
|
any.colour ==2.3.6,
|
||||||
any.comonad ==5.0.8,
|
any.comonad ==5.0.8,
|
||||||
comonad +containers +distributive +indexed-traversable,
|
comonad +containers +distributive +indexed-traversable,
|
||||||
any.concurrent-output ==1.10.21,
|
any.concurrent-output ==1.10.20,
|
||||||
any.conduit ==1.3.5,
|
any.conduit ==1.3.5,
|
||||||
any.conduit-extra ==1.3.6,
|
any.conduit-extra ==1.3.6,
|
||||||
any.config-ini ==0.2.7.0,
|
any.config-ini ==0.2.7.0,
|
||||||
|
@ -93,14 +92,14 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.containers ==0.6.7,
|
any.containers ==0.6.7,
|
||||||
any.contravariant ==1.5.5,
|
any.contravariant ==1.5.5,
|
||||||
contravariant +semigroups +statevar +tagged,
|
contravariant +semigroups +statevar +tagged,
|
||||||
any.cookie ==0.5.0,
|
any.cookie ==0.4.6,
|
||||||
any.crypto-api ==0.13.3,
|
any.crypto-api ==0.13.3,
|
||||||
crypto-api -all_cpolys,
|
crypto-api -all_cpolys,
|
||||||
any.crypto-pubkey-types ==0.4.3,
|
any.crypto-pubkey-types ==0.4.3,
|
||||||
any.crypton ==1.0.0,
|
any.crypton ==0.34,
|
||||||
crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes,
|
crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes,
|
||||||
any.crypton-connection ==0.4.1,
|
any.crypton-connection ==0.3.2,
|
||||||
any.crypton-x509 ==1.7.7,
|
any.crypton-x509 ==1.7.6,
|
||||||
any.crypton-x509-store ==1.6.9,
|
any.crypton-x509-store ==1.6.9,
|
||||||
any.crypton-x509-system ==1.6.7,
|
any.crypton-x509-system ==1.6.7,
|
||||||
any.crypton-x509-validation ==1.6.12,
|
any.crypton-x509-validation ==1.6.12,
|
||||||
|
@ -112,9 +111,9 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.data-default-instances-containers ==0.0.1,
|
any.data-default-instances-containers ==0.0.1,
|
||||||
any.data-default-instances-dlist ==0.0.1,
|
any.data-default-instances-dlist ==0.0.1,
|
||||||
any.data-default-instances-old-locale ==0.0.1,
|
any.data-default-instances-old-locale ==0.0.1,
|
||||||
any.data-fix ==0.3.4,
|
any.data-fix ==0.3.2,
|
||||||
any.deepseq ==1.4.8.1,
|
any.deepseq ==1.4.8.0,
|
||||||
any.directory ==1.3.8.4,
|
any.directory ==1.3.7.1,
|
||||||
any.distributive ==0.6.2.1,
|
any.distributive ==0.6.2.1,
|
||||||
distributive +semigroups +tagged,
|
distributive +semigroups +tagged,
|
||||||
any.dlist ==1.0,
|
any.dlist ==1.0,
|
||||||
|
@ -126,11 +125,13 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
entropy -donotgetentropy,
|
entropy -donotgetentropy,
|
||||||
any.envy ==2.1.3.0,
|
any.envy ==2.1.3.0,
|
||||||
any.esqueleto ==3.5.11.2,
|
any.esqueleto ==3.5.11.2,
|
||||||
any.exceptions ==0.10.7,
|
any.exceptions ==0.10.5,
|
||||||
any.extra ==1.7.16,
|
any.extra ==1.7.14,
|
||||||
any.fast-logger ==3.2.3,
|
any.fast-logger ==3.2.2,
|
||||||
any.filepath ==1.4.300.1,
|
any.filepath ==1.4.2.2,
|
||||||
any.fixed ==0.3,
|
any.fixed ==0.3,
|
||||||
|
any.foldable1-classes-compat ==0.1,
|
||||||
|
foldable1-classes-compat +tagged,
|
||||||
any.foreign-rust ==0.1.0,
|
any.foreign-rust ==0.1.0,
|
||||||
any.foreign-store ==0.2.1,
|
any.foreign-store ==0.2.1,
|
||||||
any.formatting ==7.2.0,
|
any.formatting ==7.2.0,
|
||||||
|
@ -140,29 +141,30 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
generic-deriving +base-4-9,
|
generic-deriving +base-4-9,
|
||||||
any.generically ==0.1.1,
|
any.generically ==0.1.1,
|
||||||
any.generics-sop ==0.5.1.4,
|
any.generics-sop ==0.5.1.4,
|
||||||
any.ghc ==9.6.5,
|
any.ghc ==9.4.8,
|
||||||
any.ghc-bignum ==1.3,
|
any.ghc-bignum ==1.3,
|
||||||
any.ghc-boot ==9.6.5,
|
any.ghc-boot ==9.4.8,
|
||||||
any.ghc-boot-th ==9.6.5,
|
any.ghc-boot-th ==9.4.8,
|
||||||
any.ghc-heap ==9.6.5,
|
any.ghc-heap ==9.4.8,
|
||||||
any.ghc-prim ==0.10.0,
|
any.ghc-prim ==0.9.1,
|
||||||
any.ghci ==9.6.5,
|
any.ghci ==9.4.8,
|
||||||
any.half ==0.3.1,
|
any.half ==0.3.1,
|
||||||
any.happy ==1.20.1.1,
|
any.happy ==1.20.1.1,
|
||||||
any.hashable ==1.4.7.0,
|
any.hashable ==1.4.4.0,
|
||||||
hashable -arch-native +integer-gmp -random-initial-seed,
|
hashable +integer-gmp -random-initial-seed,
|
||||||
|
any.haskeline ==0.8.2,
|
||||||
any.haskell-lexer ==1.1.1,
|
any.haskell-lexer ==1.1.1,
|
||||||
any.haskoin-core ==1.1.0,
|
any.haskoin-core ==1.1.0,
|
||||||
any.hexstring ==0.12.1.0,
|
any.hexstring ==0.12.1.0,
|
||||||
any.hourglass ==0.2.12,
|
any.hourglass ==0.2.12,
|
||||||
any.hpc ==0.6.2.0,
|
any.hpc ==0.6.1.0,
|
||||||
any.hsc2hs ==0.68.10,
|
any.hsc2hs ==0.68.10,
|
||||||
hsc2hs -in-ghc-tree,
|
hsc2hs -in-ghc-tree,
|
||||||
any.hspec ==2.11.9,
|
any.hspec ==2.11.7,
|
||||||
any.hspec-core ==2.11.9,
|
any.hspec-core ==2.11.7,
|
||||||
any.hspec-discover ==2.11.9,
|
any.hspec-discover ==2.11.7,
|
||||||
any.hspec-expectations ==0.8.4,
|
any.hspec-expectations ==0.8.4,
|
||||||
any.http-api-data ==0.6.1,
|
any.http-api-data ==0.6,
|
||||||
http-api-data -use-text-show,
|
http-api-data -use-text-show,
|
||||||
any.http-client ==0.7.17,
|
any.http-client ==0.7.17,
|
||||||
http-client +network-uri,
|
http-client +network-uri,
|
||||||
|
@ -170,18 +172,18 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.http-conduit ==2.3.8.3,
|
any.http-conduit ==2.3.8.3,
|
||||||
http-conduit +aeson,
|
http-conduit +aeson,
|
||||||
any.http-types ==0.12.4,
|
any.http-types ==0.12.4,
|
||||||
any.indexed-traversable ==0.1.4,
|
any.indexed-traversable ==0.1.3,
|
||||||
any.indexed-traversable-instances ==0.1.2,
|
any.indexed-traversable-instances ==0.1.1.2,
|
||||||
any.integer-conversion ==0.1.1,
|
any.integer-conversion ==0.1.0.1,
|
||||||
any.integer-gmp ==1.1,
|
any.integer-gmp ==1.1,
|
||||||
any.integer-logarithms ==1.0.3.1,
|
any.integer-logarithms ==1.0.3.1,
|
||||||
integer-logarithms -check-bounds +integer-gmp,
|
integer-logarithms -check-bounds +integer-gmp,
|
||||||
any.invariant ==0.6.3,
|
any.invariant ==0.6.3,
|
||||||
any.iproute ==1.7.12,
|
any.iproute ==1.7.12,
|
||||||
any.kan-extensions ==5.2.6,
|
any.kan-extensions ==5.2.5,
|
||||||
any.language-c ==0.9.3,
|
any.language-c ==0.9.3,
|
||||||
language-c -allwarnings +iecfpextension +usebytestrings,
|
language-c -allwarnings +iecfpextension +usebytestrings,
|
||||||
any.lens ==5.3.2,
|
any.lens ==5.2.3,
|
||||||
lens -benchmark-uniplate -dump-splices +inlining -j +test-hunit +test-properties +test-templates +trustworthy,
|
lens -benchmark-uniplate -dump-splices +inlining -j +test-hunit +test-properties +test-templates +trustworthy,
|
||||||
any.lens-aeson ==1.2.3,
|
any.lens-aeson ==1.2.3,
|
||||||
any.lift-type ==0.1.1.1,
|
any.lift-type ==0.1.1.1,
|
||||||
|
@ -194,7 +196,7 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
memory +support_bytestring +support_deepseq,
|
memory +support_bytestring +support_deepseq,
|
||||||
any.microlens ==0.4.13.1,
|
any.microlens ==0.4.13.1,
|
||||||
any.microlens-mtl ==0.2.0.3,
|
any.microlens-mtl ==0.2.0.3,
|
||||||
any.microlens-th ==0.4.3.15,
|
any.microlens-th ==0.4.3.14,
|
||||||
any.mime-types ==0.1.2.0,
|
any.mime-types ==0.1.2.0,
|
||||||
any.monad-control ==1.0.3.1,
|
any.monad-control ==1.0.3.1,
|
||||||
any.monad-logger ==0.3.40,
|
any.monad-logger ==0.3.40,
|
||||||
|
@ -204,16 +206,16 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.mono-traversable ==1.0.17.0,
|
any.mono-traversable ==1.0.17.0,
|
||||||
any.monomer ==1.6.0.1,
|
any.monomer ==1.6.0.1,
|
||||||
monomer -examples,
|
monomer -examples,
|
||||||
any.mtl ==2.3.1,
|
any.mtl ==2.2.2,
|
||||||
any.murmur3 ==1.0.5,
|
any.murmur3 ==1.0.5,
|
||||||
any.nanovg ==0.8.1.0,
|
any.nanovg ==0.8.1.0,
|
||||||
nanovg -examples -gl2 -gles3 -stb_truetype,
|
nanovg -examples -gl2 -gles3 -stb_truetype,
|
||||||
any.network ==3.2.1.0,
|
any.network ==3.1.4.0,
|
||||||
network -devel,
|
network -devel,
|
||||||
any.network-uri ==2.6.4.2,
|
any.network-uri ==2.6.4.2,
|
||||||
any.old-locale ==1.0.0.7,
|
any.old-locale ==1.0.0.7,
|
||||||
any.old-time ==1.1.0.4,
|
any.old-time ==1.1.0.4,
|
||||||
any.os-string ==2.0.6,
|
any.os-string ==2.0.2,
|
||||||
any.parallel ==3.2.2.0,
|
any.parallel ==3.2.2.0,
|
||||||
any.parsec ==3.1.16.1,
|
any.parsec ==3.1.16.1,
|
||||||
any.parser-combinators ==1.3.0,
|
any.parser-combinators ==1.3.0,
|
||||||
|
@ -226,7 +228,7 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.persistent-template ==2.12.0.0,
|
any.persistent-template ==2.12.0.0,
|
||||||
any.pretty ==1.1.3.6,
|
any.pretty ==1.1.3.6,
|
||||||
any.primitive ==0.9.0.0,
|
any.primitive ==0.9.0.0,
|
||||||
any.process ==1.6.19.0,
|
any.process ==1.6.18.0,
|
||||||
any.profunctors ==5.6.2,
|
any.profunctors ==5.6.2,
|
||||||
any.psqueues ==0.2.8.0,
|
any.psqueues ==0.2.8.0,
|
||||||
any.pureMD5 ==2.1.4,
|
any.pureMD5 ==2.1.4,
|
||||||
|
@ -236,7 +238,7 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.quickcheck-io ==0.2.0,
|
any.quickcheck-io ==0.2.0,
|
||||||
any.quickcheck-transformer ==0.3.1.2,
|
any.quickcheck-transformer ==0.3.1.2,
|
||||||
any.random ==1.2.1.2,
|
any.random ==1.2.1.2,
|
||||||
any.reflection ==2.1.8,
|
any.reflection ==2.1.7,
|
||||||
reflection -slow +template-haskell,
|
reflection -slow +template-haskell,
|
||||||
any.regex-base ==0.94.0.2,
|
any.regex-base ==0.94.0.2,
|
||||||
any.regex-compat ==0.95.2.1,
|
any.regex-compat ==0.95.2.1,
|
||||||
|
@ -247,14 +249,14 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.rts ==1.0.2,
|
any.rts ==1.0.2,
|
||||||
any.safe ==0.3.21,
|
any.safe ==0.3.21,
|
||||||
any.safe-exceptions ==0.1.7.4,
|
any.safe-exceptions ==0.1.7.4,
|
||||||
any.scientific ==0.3.8.0,
|
any.scientific ==0.3.7.0,
|
||||||
scientific -integer-simple,
|
scientific -bytestring-builder -integer-simple,
|
||||||
any.sdl2 ==2.5.5.0,
|
any.sdl2 ==2.5.5.0,
|
||||||
sdl2 -examples -no-linear -opengl-example +pkgconfig +recent-ish,
|
sdl2 -examples -no-linear -opengl-example +pkgconfig +recent-ish,
|
||||||
any.secp256k1-haskell ==1.2.0,
|
any.secp256k1-haskell ==1.2.0,
|
||||||
any.semialign ==1.3.1,
|
any.semialign ==1.3,
|
||||||
semialign +semigroupoids,
|
semialign +semigroupoids,
|
||||||
any.semigroupoids ==6.0.1,
|
any.semigroupoids ==6.0.0.1,
|
||||||
semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers,
|
semigroupoids +comonad +containers +contravariant +distributive +tagged +unordered-containers,
|
||||||
any.semigroups ==0.20,
|
any.semigroups ==0.20,
|
||||||
semigroups +binary +bytestring -bytestring-builder +containers +deepseq +hashable +tagged +template-haskell +text +transformers +unordered-containers,
|
semigroups +binary +bytestring -bytestring-builder +containers +deepseq +hashable +tagged +template-haskell +text +transformers +unordered-containers,
|
||||||
|
@ -271,53 +273,57 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
any.stm-chans ==3.0.0.9,
|
any.stm-chans ==3.0.0.9,
|
||||||
any.streaming-commons ==0.2.2.6,
|
any.streaming-commons ==0.2.2.6,
|
||||||
streaming-commons -use-bytestring-builder,
|
streaming-commons -use-bytestring-builder,
|
||||||
any.strict ==0.5.1,
|
any.strict ==0.5,
|
||||||
any.string-conversions ==0.4.0.1,
|
any.string-conversions ==0.4.0.1,
|
||||||
|
any.structured-cli ==2.7.0.1,
|
||||||
|
structured-cli -debug,
|
||||||
any.system-cxx-std-lib ==1.0,
|
any.system-cxx-std-lib ==1.0,
|
||||||
any.tagged ==0.8.8,
|
any.tagged ==0.8.8,
|
||||||
tagged +deepseq +transformers,
|
tagged +deepseq +transformers,
|
||||||
any.template-haskell ==2.20.0.0,
|
any.template-haskell ==2.19.0.0,
|
||||||
any.terminal-size ==0.3.4,
|
any.terminal-size ==0.3.4,
|
||||||
any.terminfo ==0.4.1.6,
|
any.terminfo ==0.4.1.5,
|
||||||
any.text ==2.0.2,
|
any.text ==2.0.2,
|
||||||
any.text-iso8601 ==0.1.1,
|
any.text-iso8601 ==0.1,
|
||||||
any.text-short ==0.1.6,
|
any.text-short ==0.1.5,
|
||||||
text-short -asserts,
|
text-short -asserts,
|
||||||
any.text-show ==3.10.5,
|
any.text-show ==3.10.4,
|
||||||
text-show +base-4-9 +integer-gmp +new-functor-classes +template-haskell-2-11,
|
text-show +base-4-9 +integer-gmp +new-functor-classes +template-haskell-2-11,
|
||||||
any.text-zipper ==0.13,
|
any.text-zipper ==0.13,
|
||||||
any.tf-random ==0.5,
|
any.tf-random ==0.5,
|
||||||
any.th-abstraction ==0.7.0.0,
|
any.th-abstraction ==0.6.0.0,
|
||||||
any.th-compat ==0.1.5,
|
any.th-compat ==0.1.5,
|
||||||
any.th-lift ==0.8.4,
|
any.th-lift ==0.8.4,
|
||||||
any.th-lift-instances ==0.1.20,
|
any.th-lift-instances ==0.1.20,
|
||||||
any.these ==1.2.1,
|
any.these ==1.2,
|
||||||
any.time ==1.12.2,
|
any.time ==1.12.2,
|
||||||
any.time-compat ==1.9.7,
|
any.time-compat ==1.9.6.1,
|
||||||
|
time-compat -old-locale,
|
||||||
any.time-locale-compat ==0.1.1.5,
|
any.time-locale-compat ==0.1.1.5,
|
||||||
time-locale-compat -old-locale,
|
time-locale-compat -old-locale,
|
||||||
any.tls ==2.1.0,
|
any.tls ==2.0.2,
|
||||||
tls -devel,
|
tls -devel,
|
||||||
any.transformers ==0.6.1.0,
|
any.transformers ==0.5.6.2,
|
||||||
any.transformers-base ==0.4.6,
|
any.transformers-base ==0.4.6,
|
||||||
transformers-base +orphaninstances,
|
transformers-base +orphaninstances,
|
||||||
any.transformers-compat ==0.7.2,
|
any.transformers-compat ==0.7.2,
|
||||||
transformers-compat -five +five-three -four +generic-deriving +mtl -three -two,
|
transformers-compat -five +five-three -four +generic-deriving +mtl -three -two,
|
||||||
any.typed-process ==0.2.11.1,
|
any.typed-process ==0.2.11.1,
|
||||||
any.unix ==2.8.4.0,
|
any.unix ==2.7.3,
|
||||||
any.unix-compat ==0.7.2,
|
any.unix-compat ==0.7.1,
|
||||||
any.unix-time ==0.4.15,
|
unix-compat -old-time,
|
||||||
|
any.unix-time ==0.4.12,
|
||||||
any.unliftio ==0.2.25.0,
|
any.unliftio ==0.2.25.0,
|
||||||
any.unliftio-core ==0.2.1.0,
|
any.unliftio-core ==0.2.1.0,
|
||||||
any.unordered-containers ==0.2.20,
|
any.unordered-containers ==0.2.20,
|
||||||
unordered-containers -debug,
|
unordered-containers -debug,
|
||||||
any.utf8-string ==1.0.2,
|
any.utf8-string ==1.0.2,
|
||||||
any.uuid-types ==1.0.6,
|
any.uuid-types ==1.0.5.1,
|
||||||
any.vault ==0.3.1.5,
|
any.vault ==0.3.1.5,
|
||||||
vault +useghc,
|
vault +useghc,
|
||||||
any.vector ==0.13.1.0,
|
any.vector ==0.13.1.0,
|
||||||
vector +boundschecks -internalchecks -unsafechecks -wall,
|
vector +boundschecks -internalchecks -unsafechecks -wall,
|
||||||
any.vector-algorithms ==0.9.0.2,
|
any.vector-algorithms ==0.9.0.1,
|
||||||
vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks,
|
vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks,
|
||||||
any.vector-stream ==0.1.0.1,
|
any.vector-stream ==0.1.0.1,
|
||||||
any.void ==0.7.3,
|
any.void ==0.7.3,
|
||||||
|
@ -327,10 +333,10 @@ constraints: any.Cabal ==3.10.3.0,
|
||||||
vty-crossplatform -demos,
|
vty-crossplatform -demos,
|
||||||
any.vty-unix ==0.2.0.0,
|
any.vty-unix ==0.2.0.0,
|
||||||
any.wide-word ==0.1.6.0,
|
any.wide-word ==0.1.6.0,
|
||||||
any.witherable ==0.5,
|
any.witherable ==0.4.2,
|
||||||
any.word-wrap ==0.5,
|
any.word-wrap ==0.5,
|
||||||
any.wreq ==0.5.4.3,
|
any.wreq ==0.5.4.3,
|
||||||
wreq -aws -developer +doctest -httpbin,
|
wreq -aws -developer +doctest -httpbin,
|
||||||
any.zlib ==0.7.1.0,
|
any.zlib ==0.6.3.0,
|
||||||
zlib -bundled-c-zlib +non-blocking-ffi +pkg-config
|
zlib -bundled-c-zlib +non-blocking-ffi +pkg-config
|
||||||
index-state: hackage.haskell.org 2024-07-10T18:40:26Z
|
index-state: hackage.haskell.org 2024-04-07T10:14:52Z
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
|
||||||
|
|
||||||
module Zenith.CLI where
|
module Zenith.CLI where
|
||||||
|
|
||||||
import qualified Brick.AttrMap as A
|
import qualified Brick.AttrMap as A
|
||||||
|
@ -10,10 +11,8 @@ import qualified Brick.BChan as BC
|
||||||
import qualified Brick.Focus as F
|
import qualified Brick.Focus as F
|
||||||
import Brick.Forms
|
import Brick.Forms
|
||||||
( Form(..)
|
( Form(..)
|
||||||
, FormFieldState
|
|
||||||
, (@@=)
|
, (@@=)
|
||||||
, allFieldsValid
|
, allFieldsValid
|
||||||
, editShowableField
|
|
||||||
, editShowableFieldWithValidate
|
, editShowableFieldWithValidate
|
||||||
, editTextField
|
, editTextField
|
||||||
, focusedFormInputAttr
|
, focusedFormInputAttr
|
||||||
|
@ -23,11 +22,13 @@ import Brick.Forms
|
||||||
, renderForm
|
, renderForm
|
||||||
, setFieldValid
|
, setFieldValid
|
||||||
, updateFormState
|
, updateFormState
|
||||||
|
, FormFieldState
|
||||||
|
, editShowableField
|
||||||
)
|
)
|
||||||
import qualified Brick.Main as M
|
import qualified Brick.Main as M
|
||||||
import qualified Brick.Types as BT
|
import qualified Brick.Types as BT
|
||||||
import Brick.Types (Widget)
|
import Brick.Types (Widget)
|
||||||
import Brick.Util (bg, fg, on, style)
|
import Brick.Util (bg, clamp, fg, on, style)
|
||||||
import qualified Brick.Widgets.Border as B
|
import qualified Brick.Widgets.Border as B
|
||||||
import Brick.Widgets.Border.Style (unicode, unicodeBold)
|
import Brick.Widgets.Border.Style (unicode, unicodeBold)
|
||||||
import qualified Brick.Widgets.Center as C
|
import qualified Brick.Widgets.Center as C
|
||||||
|
@ -42,8 +43,8 @@ import Brick.Widgets.Core
|
||||||
, joinBorders
|
, joinBorders
|
||||||
, padAll
|
, padAll
|
||||||
, padBottom
|
, padBottom
|
||||||
, padLeft
|
|
||||||
, padTop
|
, padTop
|
||||||
|
, padLeft
|
||||||
, setAvailableSize
|
, setAvailableSize
|
||||||
, str
|
, str
|
||||||
, strWrap
|
, strWrap
|
||||||
|
@ -53,8 +54,8 @@ import Brick.Widgets.Core
|
||||||
, txtWrapWith
|
, txtWrapWith
|
||||||
, updateAttrMap
|
, updateAttrMap
|
||||||
, vBox
|
, vBox
|
||||||
, vLimit
|
|
||||||
, viewport
|
, viewport
|
||||||
|
, vLimit
|
||||||
, withAttr
|
, withAttr
|
||||||
, withBorderStyle
|
, withBorderStyle
|
||||||
)
|
)
|
||||||
|
@ -88,33 +89,22 @@ import ZcashHaskell.Keys (generateWalletSeedPhrase, getWalletSeed)
|
||||||
import ZcashHaskell.Orchard (getSaplingFromUA, isValidUnifiedAddress)
|
import ZcashHaskell.Orchard (getSaplingFromUA, isValidUnifiedAddress)
|
||||||
import ZcashHaskell.Sapling (decodeSaplingAddress, isValidShieldedAddress)
|
import ZcashHaskell.Sapling (decodeSaplingAddress, isValidShieldedAddress)
|
||||||
import ZcashHaskell.Transparent
|
import ZcashHaskell.Transparent
|
||||||
( decodeTransparentAddress
|
( decodeExchangeAddress
|
||||||
|
, decodeTransparentAddress
|
||||||
, encodeTransparentReceiver
|
, encodeTransparentReceiver
|
||||||
)
|
)
|
||||||
import ZcashHaskell.Types
|
import ZcashHaskell.Types
|
||||||
import ZcashHaskell.Utils (getBlockTime, makeZebraCall)
|
import ZcashHaskell.Utils (getBlockTime, makeZebraCall)
|
||||||
import Zenith.Core
|
import Zenith.Core
|
||||||
import Zenith.DB
|
import Zenith.DB
|
||||||
import Zenith.Scanner (processTx, updateConfs)
|
import Zenith.Scanner (processTx)
|
||||||
import Zenith.Types
|
import Zenith.Types
|
||||||
( Config(..)
|
( Config(..)
|
||||||
, PhraseDB(..)
|
, PhraseDB(..)
|
||||||
, UnifiedAddressDB(..)
|
, UnifiedAddressDB(..)
|
||||||
, ZcashNetDB(..)
|
, ZcashNetDB(..)
|
||||||
)
|
)
|
||||||
<<<<<<< HEAD
|
|
||||||
import Zenith.Utils (displayTaz, displayZec, jsonNumber, showAddress, getZenithPath)
|
import Zenith.Utils (displayTaz, displayZec, jsonNumber, showAddress, getZenithPath)
|
||||||
=======
|
|
||||||
import Zenith.Utils
|
|
||||||
( displayTaz
|
|
||||||
, displayZec
|
|
||||||
, isRecipientValid
|
|
||||||
, jsonNumber
|
|
||||||
, parseAddress
|
|
||||||
, showAddress
|
|
||||||
, validBarValue
|
|
||||||
)
|
|
||||||
>>>>>>> milestone2
|
|
||||||
|
|
||||||
data Name
|
data Name
|
||||||
= WList
|
= WList
|
||||||
|
@ -207,9 +197,8 @@ data State = State
|
||||||
, _txForm :: !(Form SendInput () Name)
|
, _txForm :: !(Form SendInput () Name)
|
||||||
, _abAddresses :: !(L.List Name (Entity AddressBook))
|
, _abAddresses :: !(L.List Name (Entity AddressBook))
|
||||||
, _abForm :: !(Form AdrBookEntry () Name)
|
, _abForm :: !(Form AdrBookEntry () Name)
|
||||||
, _abCurAdrs :: !T.Text -- used for address book CRUD operations
|
, _abCurAdrs :: !T.Text -- used for address book CRUD operations
|
||||||
, _sentTx :: !(Maybe HexString)
|
, _sentTx :: !(Maybe HexString)
|
||||||
, _unconfBalance :: !Integer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''State
|
makeLenses ''State
|
||||||
|
@ -227,11 +216,10 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
show (st ^. network) <>
|
show (st ^. network) <>
|
||||||
" - " <>
|
" - " <>
|
||||||
(T.unpack
|
(T.unpack
|
||||||
(maybe
|
(maybe
|
||||||
"(None)"
|
"(None)"
|
||||||
(\(_, w) -> zcashWalletName $ entityVal w)
|
(\(_, w) -> zcashWalletName $ entityVal w)
|
||||||
(L.listSelectedElement (st ^. wallets)))) ++
|
(L.listSelectedElement (st ^. wallets)))) ++ " "))
|
||||||
" "))
|
|
||||||
(C.hCenter
|
(C.hCenter
|
||||||
(str
|
(str
|
||||||
("Account: " ++
|
("Account: " ++
|
||||||
|
@ -246,16 +234,9 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
if st ^. network == MainNet
|
if st ^. network == MainNet
|
||||||
then displayZec (st ^. balance)
|
then displayZec (st ^. balance)
|
||||||
else displayTaz (st ^. balance))) <=>
|
else displayTaz (st ^. balance))) <=>
|
||||||
C.hCenter
|
listAddressBox " Addresses " (st ^. addresses) <+>
|
||||||
(str
|
|
||||||
("Unconf: " ++
|
|
||||||
if st ^. network == MainNet
|
|
||||||
then displayZec (st ^. unconfBalance)
|
|
||||||
else displayTaz (st ^. unconfBalance))) <=>
|
|
||||||
listAddressBox "Addresses" (st ^. addresses) <+>
|
|
||||||
B.vBorder <+>
|
B.vBorder <+>
|
||||||
(C.hCenter
|
(C.hCenter (str ("Last block seen: " ++ show (st ^. syncBlock) ++ "\n")) <=>
|
||||||
(str ("Last block seen: " ++ show (st ^. syncBlock) ++ "\n")) <=>
|
|
||||||
listTxBox " Transactions " (st ^. network) (st ^. transactions))) <=>
|
listTxBox " Transactions " (st ^. network) (st ^. transactions))) <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(hBox
|
(hBox
|
||||||
|
@ -332,8 +313,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
vBox ([str "Actions", B.hBorder] <> actionList))
|
vBox ([str "Actions", B.hBorder] <> actionList))
|
||||||
else emptyWidget
|
else emptyWidget
|
||||||
where
|
where
|
||||||
keyList =
|
keyList = map (C.hCenter . str) ["?", "Esc", "w", "a", "v", "s", "b", "q"]
|
||||||
map (C.hCenter . str) ["?", "Esc", "w", "a", "v", "s", "b", "q"]
|
|
||||||
actionList =
|
actionList =
|
||||||
map
|
map
|
||||||
(hLimit 40 . str)
|
(hLimit 40 . str)
|
||||||
|
@ -394,55 +374,50 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
-- Address Book List
|
-- Address Book List
|
||||||
AdrBook ->
|
AdrBook ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just $ str " Address Book ") Nothing 60)
|
(D.dialog (Just $ str " Address Book ") Nothing 60)
|
||||||
(withAttr abDefAttr $
|
(withAttr abDefAttr $
|
||||||
setAvailableSize (50, 20) $
|
setAvailableSize (50,20) $
|
||||||
viewport ABViewport BT.Vertical $
|
viewport ABViewport BT.Vertical $
|
||||||
vLimit 20 $
|
vLimit 20 $
|
||||||
hLimit 50 $
|
hLimit 50 $
|
||||||
vBox
|
vBox [vLimit 16 $
|
||||||
[ vLimit 16 $
|
hLimit 50 $
|
||||||
hLimit 50 $
|
vBox $ [ L.renderList listDrawAB True (s ^. abAddresses) ],
|
||||||
vBox $ [L.renderList listDrawAB True (s ^. abAddresses)]
|
padTop Max $
|
||||||
, padTop Max $
|
vLimit 4 $
|
||||||
vLimit 4 $
|
hLimit 50 $
|
||||||
hLimit 50 $
|
withAttr abMBarAttr $
|
||||||
withAttr abMBarAttr $
|
vBox $ [C.hCenter $
|
||||||
vBox $
|
(capCommand "N" "ew Address" <+>
|
||||||
[ C.hCenter $
|
capCommand "E" "dit Address" <+>
|
||||||
(capCommand "N" "ew Address" <+>
|
capCommand3 "" "C" "opy Address"),
|
||||||
capCommand "E" "dit Address" <+>
|
C.hCenter $
|
||||||
capCommand3 "" "C" "opy Address")
|
(capCommand "D" "elete Address" <+>
|
||||||
, C.hCenter $
|
capCommand "S" "end Zcash" <+>
|
||||||
(capCommand "D" "elete Address" <+>
|
capCommand3 "E" "x" "it")]])
|
||||||
capCommand "S" "end Zcash" <+> capCommand3 "E" "x" "it")
|
|
||||||
]
|
|
||||||
])
|
|
||||||
-- Address Book new entry form
|
-- Address Book new entry form
|
||||||
AdrBookForm ->
|
AdrBookForm ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just $ str " New Address Book Entry ") Nothing 50)
|
(D.dialog (Just $ str " New Address Book Entry ") Nothing 50)
|
||||||
(renderForm (st ^. abForm) <=>
|
(renderForm (st ^. abForm) <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(hBox [capCommand "↲" " Save", capCommand3 "" "<Esc>" " Cancel"]))
|
(hBox [capCommand "↲" " Save", capCommand3 "" "<Esc>" " Cancel"]))
|
||||||
-- Address Book edit/update entry form
|
-- Address Book edit/update entry form
|
||||||
AdrBookUpdForm ->
|
AdrBookUpdForm ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just $ str " Edit Address Book Entry ") Nothing 50)
|
(D.dialog (Just $ str " Edit Address Book Entry ") Nothing 50)
|
||||||
(renderForm (st ^. abForm) <=>
|
(renderForm (st ^. abForm) <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(hBox [capCommand "↲" " Save", capCommand3 "" "<Esc>" " Cancel"]))
|
(hBox [capCommand "↲" " Save", capCommand3 "" "<Esc>" " Cancel"]))
|
||||||
-- Address Book edit/update entry form
|
-- Address Book edit/update entry form
|
||||||
AdrBookDelForm ->
|
AdrBookDelForm ->
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just $ str " Delete Address Book Entry ") Nothing 50)
|
(D.dialog (Just $ str " Delete Address Book Entry ") Nothing 50)
|
||||||
(renderForm (st ^. abForm) <=>
|
(renderForm (st ^. abForm) <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(hBox
|
(hBox [capCommand "C" "onfirm delete", capCommand3 "" "<Esc>" " Cancel"]))
|
||||||
[ capCommand "C" "onfirm delete"
|
|
||||||
, capCommand3 "" "<Esc>" " Cancel"
|
|
||||||
]))
|
|
||||||
--
|
--
|
||||||
|
|
||||||
splashDialog :: State -> Widget Name
|
splashDialog :: State -> Widget Name
|
||||||
splashDialog st =
|
splashDialog st =
|
||||||
if st ^. splashBox
|
if st ^. splashBox
|
||||||
|
@ -454,14 +429,16 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
(str
|
(str
|
||||||
" _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=>
|
" _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=>
|
||||||
C.hCenter
|
C.hCenter
|
||||||
(withAttr titleAttr (str "Zcash Wallet v0.6.0.0-beta")) <=>
|
(withAttr titleAttr (str "Zcash Wallet v0.5.3.0-beta")) <=>
|
||||||
C.hCenter (withAttr blinkAttr $ str "Press any key..."))
|
C.hCenter (withAttr blinkAttr $ str "Press any key..."))
|
||||||
else emptyWidget
|
else emptyWidget
|
||||||
|
|
||||||
capCommand3 :: String -> String -> String -> Widget Name
|
capCommand3 :: String -> String -> String -> Widget Name
|
||||||
capCommand3 l h e = hBox [str l, withAttr titleAttr (str h), str e]
|
capCommand3 l h e = hBox [str l, withAttr titleAttr (str h), str e]
|
||||||
|
|
||||||
capCommand2 :: String -> String -> String -> Widget Name
|
capCommand2 :: String -> String -> String -> Widget Name
|
||||||
capCommand2 l h e =
|
capCommand2 l h e = hBox [str l, withAttr titleAttr (str h), str e, str " | "]
|
||||||
hBox [str l, withAttr titleAttr (str h), str e, str " | "]
|
|
||||||
capCommand :: String -> String -> Widget Name
|
capCommand :: String -> String -> Widget Name
|
||||||
capCommand k comm = hBox [withAttr titleAttr (str k), str comm, str " | "]
|
capCommand k comm = hBox [withAttr titleAttr (str k), str comm, str " | "]
|
||||||
xCommand :: Widget Name
|
xCommand :: Widget Name
|
||||||
|
@ -586,20 +563,19 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
(WrapSettings False True NoFill FillAfterFirst)
|
(WrapSettings False True NoFill FillAfterFirst)
|
||||||
(st ^. msg)))
|
(st ^. msg)))
|
||||||
AdrBookEntryDisplay -> do
|
AdrBookEntryDisplay -> do
|
||||||
case L.listSelectedElement $ st ^. abAddresses of
|
case L.listSelectedElement $ st ^. abAddresses of
|
||||||
Just (_, a) -> do
|
Just (_, a) -> do
|
||||||
let abentry =
|
let abentry = T.pack $
|
||||||
T.pack $
|
" Descr: " ++
|
||||||
" Descr: " ++
|
T.unpack (addressBookAbdescrip (entityVal a)) ++
|
||||||
T.unpack (addressBookAbdescrip (entityVal a)) ++
|
"\n Address: " ++
|
||||||
"\n Address: " ++
|
T.unpack (addressBookAbaddress (entityVal a))
|
||||||
T.unpack (addressBookAbaddress (entityVal a))
|
|
||||||
withBorderStyle unicodeBold $
|
withBorderStyle unicodeBold $
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just $ txt " Address Book Entry ") Nothing 60)
|
(D.dialog (Just $ txt " Address Book Entry ") Nothing 60)
|
||||||
(padAll 1 $
|
(padAll 1 $
|
||||||
txtWrapWith (WrapSettings False True NoFill FillAfterFirst) $
|
txtWrapWith (WrapSettings False True NoFill FillAfterFirst) $
|
||||||
abentry)
|
abentry)
|
||||||
_ -> emptyWidget
|
_ -> emptyWidget
|
||||||
BlankDisplay -> emptyWidget
|
BlankDisplay -> emptyWidget
|
||||||
|
|
||||||
|
@ -621,12 +597,12 @@ mkSendForm bal =
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
isAmountValid :: Integer -> Float -> Bool
|
isAmountValid :: Integer -> Float -> Bool
|
||||||
isAmountValid b i = (fromIntegral b / 100000000.0) >= i
|
isAmountValid b i = (fromIntegral b * 100000000.0) >= i && i > 0
|
||||||
label s w =
|
label s w =
|
||||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||||
|
|
||||||
mkNewABForm :: AdrBookEntry -> Form AdrBookEntry e Name
|
mkNewABForm :: AdrBookEntry -> Form AdrBookEntry e Name
|
||||||
mkNewABForm =
|
mkNewABForm =
|
||||||
newForm
|
newForm
|
||||||
[ label "Descrip: " @@= editTextField descrip DescripField (Just 1)
|
[ label "Descrip: " @@= editTextField descrip DescripField (Just 1)
|
||||||
, label "Address: " @@= editTextField address AddressField (Just 1)
|
, label "Address: " @@= editTextField address AddressField (Just 1)
|
||||||
|
@ -635,6 +611,19 @@ mkNewABForm =
|
||||||
label s w =
|
label s w =
|
||||||
padBottom (Pad 1) $ vLimit 1 (hLimit 10 $ str s <+> fill ' ') <+> w
|
padBottom (Pad 1) $ vLimit 1 (hLimit 10 $ str s <+> fill ' ') <+> w
|
||||||
|
|
||||||
|
isRecipientValid :: T.Text -> Bool
|
||||||
|
isRecipientValid a =
|
||||||
|
case isValidUnifiedAddress (E.encodeUtf8 a) of
|
||||||
|
Just _a1 -> True
|
||||||
|
Nothing ->
|
||||||
|
isValidShieldedAddress (E.encodeUtf8 a) ||
|
||||||
|
(case decodeTransparentAddress (E.encodeUtf8 a) of
|
||||||
|
Just _a3 -> True
|
||||||
|
Nothing ->
|
||||||
|
case decodeExchangeAddress a of
|
||||||
|
Just _a4 -> True
|
||||||
|
Nothing -> False)
|
||||||
|
|
||||||
listDrawElement :: (Show a) => Bool -> a -> Widget Name
|
listDrawElement :: (Show a) => Bool -> a -> Widget Name
|
||||||
listDrawElement sel a =
|
listDrawElement sel a =
|
||||||
let selStr s =
|
let selStr s =
|
||||||
|
@ -695,9 +684,9 @@ listDrawAB :: Bool -> Entity AddressBook -> Widget Name
|
||||||
listDrawAB sel ab =
|
listDrawAB sel ab =
|
||||||
let selStr s =
|
let selStr s =
|
||||||
if sel
|
if sel
|
||||||
then withAttr abSelAttr (txt $ " " <> s)
|
then withAttr abSelAttr (txt $ " " <> s )
|
||||||
else txt $ " " <> s
|
else txt $ " " <> s
|
||||||
in selStr $ addressBookAbdescrip (entityVal ab)
|
in selStr $ addressBookAbdescrip (entityVal ab)
|
||||||
|
|
||||||
customAttr :: A.AttrName
|
customAttr :: A.AttrName
|
||||||
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
||||||
|
@ -726,32 +715,26 @@ abSelAttr = A.attrName "abselected"
|
||||||
abMBarAttr :: A.AttrName
|
abMBarAttr :: A.AttrName
|
||||||
abMBarAttr = A.attrName "menubar"
|
abMBarAttr = A.attrName "menubar"
|
||||||
|
|
||||||
|
validBarValue :: Float -> Float
|
||||||
|
validBarValue = clamp 0 1
|
||||||
|
|
||||||
scanZebra :: T.Text -> T.Text -> Int -> Int -> BC.BChan Tick -> IO ()
|
scanZebra :: T.Text -> T.Text -> Int -> Int -> BC.BChan Tick -> IO ()
|
||||||
scanZebra dbP zHost zPort b eChan = do
|
scanZebra dbP zHost zPort b eChan = do
|
||||||
_ <- liftIO $ initDb dbP
|
_ <- liftIO $ initDb dbP
|
||||||
bStatus <- liftIO $ checkBlockChain zHost zPort
|
bStatus <- liftIO $ checkBlockChain zHost zPort
|
||||||
pool <- runNoLoggingT $ initPool dbP
|
pool <- runNoLoggingT $ initPool dbP
|
||||||
dbBlock <- runNoLoggingT $ getMaxBlock pool
|
dbBlock <- runNoLoggingT $ getMaxBlock pool
|
||||||
confUp <- try $ updateConfs zHost zPort pool :: IO (Either IOError ())
|
let sb = max dbBlock b
|
||||||
case confUp of
|
if sb > zgb_blocks bStatus || sb < 1
|
||||||
Left _e0 ->
|
then liftIO $ BC.writeBChan eChan $ TickMsg "Invalid starting block for scan"
|
||||||
liftIO $
|
else do
|
||||||
BC.writeBChan eChan $ TickMsg "Failed to update unconfirmed transactions"
|
let bList = [(sb + 1) .. (zgb_blocks bStatus)]
|
||||||
Right _ -> do
|
if not (null bList)
|
||||||
let sb = max dbBlock b
|
|
||||||
if sb > zgb_blocks bStatus || sb < 1
|
|
||||||
then do
|
then do
|
||||||
liftIO $
|
let step =
|
||||||
BC.writeBChan eChan $ TickMsg "Invalid starting block for scan"
|
(1.0 :: Float) / fromIntegral (zgb_blocks bStatus - (sb + 1))
|
||||||
else do
|
mapM_ (processBlock pool step) bList
|
||||||
let bList = [(sb + 1) .. (zgb_blocks bStatus)]
|
else liftIO $ BC.writeBChan eChan $ TickVal 1.0
|
||||||
if not (null bList)
|
|
||||||
then do
|
|
||||||
let step =
|
|
||||||
(1.0 :: Float) /
|
|
||||||
fromIntegral (zgb_blocks bStatus - (sb + 1))
|
|
||||||
mapM_ (processBlock pool step) bList
|
|
||||||
else liftIO $ BC.writeBChan eChan $ TickVal 1.0
|
|
||||||
where
|
where
|
||||||
processBlock :: ConnectionPool -> Float -> Int -> IO ()
|
processBlock :: ConnectionPool -> Float -> Int -> IO ()
|
||||||
processBlock pool step bl = do
|
processBlock pool step bl = do
|
||||||
|
@ -1089,21 +1072,19 @@ appEvent (BT.VtyEvent e) = do
|
||||||
BT.modify $ set msg "Invalid inputs"
|
BT.modify $ set msg "Invalid inputs"
|
||||||
BT.modify $ set displayBox MsgDisplay
|
BT.modify $ set displayBox MsgDisplay
|
||||||
BT.modify $ set dialogBox Blank
|
BT.modify $ set dialogBox Blank
|
||||||
ev ->
|
ev -> BT.zoom txForm $ do
|
||||||
BT.zoom txForm $ do
|
handleFormEvent (BT.VtyEvent ev)
|
||||||
handleFormEvent (BT.VtyEvent ev)
|
fs <- BT.gets formState
|
||||||
fs <- BT.gets formState
|
BT.modify $
|
||||||
BT.modify $
|
setFieldValid
|
||||||
setFieldValid
|
(isRecipientValid (fs ^. sendTo))
|
||||||
(isRecipientValid (fs ^. sendTo))
|
RecField
|
||||||
RecField
|
|
||||||
AdrBook -> do
|
AdrBook -> do
|
||||||
case e of
|
case e of
|
||||||
V.EvKey (V.KChar 'x') [] ->
|
V.EvKey (V.KChar 'x') [] ->
|
||||||
BT.modify $ set dialogBox Blank
|
BT.modify $ set dialogBox Blank
|
||||||
V.EvKey (V.KChar 'c') []
|
V.EvKey (V.KChar 'c') [] -> do
|
||||||
-- Copy Address to Clipboard
|
-- Copy Address to Clipboard
|
||||||
-> do
|
|
||||||
case L.listSelectedElement $ s ^. abAddresses of
|
case L.listSelectedElement $ s ^. abAddresses of
|
||||||
Just (_, a) -> do
|
Just (_, a) -> do
|
||||||
liftIO $
|
liftIO $
|
||||||
|
@ -1111,72 +1092,53 @@ appEvent (BT.VtyEvent e) = do
|
||||||
T.unpack $ addressBookAbaddress (entityVal a)
|
T.unpack $ addressBookAbaddress (entityVal a)
|
||||||
BT.modify $
|
BT.modify $
|
||||||
set msg $
|
set msg $
|
||||||
"Address copied to Clipboard from >>\n" ++
|
"Address copied to Clipboard from >>\n" ++
|
||||||
T.unpack (addressBookAbdescrip (entityVal a))
|
T.unpack (addressBookAbdescrip (entityVal a))
|
||||||
BT.modify $ set displayBox MsgDisplay
|
BT.modify $ set displayBox MsgDisplay
|
||||||
_ -> do
|
_ -> do
|
||||||
BT.modify $
|
BT.modify $ set msg "Error while copying the address!!"
|
||||||
set msg "Error while copying the address!!"
|
BT.modify $ set displayBox MsgDisplay
|
||||||
BT.modify $ set displayBox MsgDisplay
|
|
||||||
-- Send Zcash transaction
|
-- Send Zcash transaction
|
||||||
V.EvKey (V.KChar 's') [] -> do
|
V.EvKey (V.KChar 's') [] -> do
|
||||||
case L.listSelectedElement $ s ^. abAddresses of
|
case L.listSelectedElement $ s ^. abAddresses of
|
||||||
Just (_, a) -> do
|
Just (_, a) -> do
|
||||||
BT.modify $
|
BT.modify $
|
||||||
set txForm $
|
set txForm $
|
||||||
mkSendForm
|
mkSendForm (s ^. balance) (SendInput (addressBookAbaddress (entityVal a)) 0.0 "")
|
||||||
(s ^. balance)
|
BT.modify $ set dialogBox SendTx
|
||||||
(SendInput
|
|
||||||
(addressBookAbaddress (entityVal a))
|
|
||||||
0.0
|
|
||||||
"")
|
|
||||||
BT.modify $ set dialogBox SendTx
|
|
||||||
_ -> do
|
_ -> do
|
||||||
BT.modify $
|
BT.modify $ set msg "No receiver address available!!"
|
||||||
set msg "No receiver address available!!"
|
BT.modify $ set displayBox MsgDisplay
|
||||||
BT.modify $ set displayBox MsgDisplay
|
|
||||||
-- Edit an entry in Address Book
|
-- Edit an entry in Address Book
|
||||||
V.EvKey (V.KChar 'e') [] -> do
|
V.EvKey (V.KChar 'e') [] -> do
|
||||||
case L.listSelectedElement $ s ^. abAddresses of
|
case L.listSelectedElement $ s ^. abAddresses of
|
||||||
Just (_, a) -> do
|
Just (_, a) -> do
|
||||||
BT.modify $
|
BT.modify $ set abCurAdrs (addressBookAbaddress (entityVal a))
|
||||||
set
|
BT.modify $
|
||||||
abCurAdrs
|
set abForm $
|
||||||
(addressBookAbaddress (entityVal a))
|
mkNewABForm (AdrBookEntry (addressBookAbdescrip (entityVal a)) (addressBookAbaddress (entityVal a)))
|
||||||
BT.modify $
|
BT.modify $ set dialogBox AdrBookUpdForm
|
||||||
set abForm $
|
|
||||||
mkNewABForm
|
|
||||||
(AdrBookEntry
|
|
||||||
(addressBookAbdescrip (entityVal a))
|
|
||||||
(addressBookAbaddress (entityVal a)))
|
|
||||||
BT.modify $ set dialogBox AdrBookUpdForm
|
|
||||||
_ -> do
|
_ -> do
|
||||||
BT.modify $ set dialogBox Blank
|
BT.modify $ set dialogBox Blank
|
||||||
-- Delete an entry from Address Book
|
-- Delete an entry from Address Book
|
||||||
V.EvKey (V.KChar 'd') [] -> do
|
V.EvKey (V.KChar 'd') [] -> do
|
||||||
case L.listSelectedElement $ s ^. abAddresses of
|
case L.listSelectedElement $ s ^. abAddresses of
|
||||||
Just (_, a) -> do
|
Just (_, a) -> do
|
||||||
BT.modify $
|
BT.modify $ set abCurAdrs (addressBookAbaddress (entityVal a))
|
||||||
set
|
BT.modify $
|
||||||
abCurAdrs
|
set abForm $
|
||||||
(addressBookAbaddress (entityVal a))
|
mkNewABForm (AdrBookEntry (addressBookAbdescrip (entityVal a)) (addressBookAbaddress (entityVal a)))
|
||||||
BT.modify $
|
BT.modify $ set dialogBox AdrBookDelForm
|
||||||
set abForm $
|
|
||||||
mkNewABForm
|
|
||||||
(AdrBookEntry
|
|
||||||
(addressBookAbdescrip (entityVal a))
|
|
||||||
(addressBookAbaddress (entityVal a)))
|
|
||||||
BT.modify $ set dialogBox AdrBookDelForm
|
|
||||||
_ -> do
|
_ -> do
|
||||||
BT.modify $ set dialogBox Blank
|
BT.modify $ set dialogBox Blank
|
||||||
-- Create a new entry in Address Book
|
-- Create a new entry in Address Book
|
||||||
V.EvKey (V.KChar 'n') [] -> do
|
V.EvKey (V.KChar 'n') [] -> do
|
||||||
BT.modify $
|
BT.modify $ set abForm $ mkNewABForm (AdrBookEntry "" "")
|
||||||
set abForm $ mkNewABForm (AdrBookEntry "" "")
|
BT.modify $ set dialogBox AdrBookForm
|
||||||
BT.modify $ set dialogBox AdrBookForm
|
|
||||||
-- Show AddressBook entry data
|
-- Show AddressBook entry data
|
||||||
V.EvKey V.KEnter [] -> do
|
V.EvKey V.KEnter [] -> do
|
||||||
BT.modify $ set displayBox AdrBookEntryDisplay
|
BT.modify $ set displayBox AdrBookEntryDisplay
|
||||||
|
|
||||||
-- Process any other event
|
-- Process any other event
|
||||||
ev -> BT.zoom abAddresses $ L.handleListEvent ev
|
ev -> BT.zoom abAddresses $ L.handleListEvent ev
|
||||||
-- Process new address book entry
|
-- Process new address book entry
|
||||||
|
@ -1184,101 +1146,75 @@ appEvent (BT.VtyEvent e) = do
|
||||||
case e of
|
case e of
|
||||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
||||||
V.EvKey V.KEnter [] -> do
|
V.EvKey V.KEnter [] -> do
|
||||||
pool <- liftIO $ runNoLoggingT $ initPool $ s ^. dbPath
|
pool <- liftIO $ runNoLoggingT $ initPool $ s ^. dbPath
|
||||||
fs <- BT.zoom abForm $ BT.gets formState
|
fs <- BT.zoom abForm $ BT.gets formState
|
||||||
let idescr = T.unpack $ T.strip (fs ^. descrip)
|
let idescr = T.unpack $ T.strip (fs ^. descrip)
|
||||||
let iabadr = fs ^. address
|
let iabadr = fs ^. address
|
||||||
if not (null idescr) && isRecipientValid iabadr
|
if not (null idescr) && isRecipientValid iabadr
|
||||||
then do
|
then do
|
||||||
res <-
|
res <- liftIO $ saveAdrsInAdrBook pool $ AddressBook (ZcashNetDB (s ^. network)) (fs ^. descrip) (fs ^.address)
|
||||||
liftIO $
|
case res of
|
||||||
saveAdrsInAdrBook pool $
|
Nothing -> do
|
||||||
AddressBook
|
BT.modify $ set msg ("AddressBook Entry already exists: " ++ T.unpack (fs ^.address))
|
||||||
(ZcashNetDB (s ^. network))
|
BT.modify $ set displayBox MsgDisplay
|
||||||
(fs ^. descrip)
|
Just _ -> do
|
||||||
(fs ^. address)
|
BT.modify $ set msg ("New AddressBook entry created!!\n" ++ T.unpack (fs ^.address))
|
||||||
case res of
|
BT.modify $ set displayBox MsgDisplay
|
||||||
Nothing -> do
|
|
||||||
BT.modify $
|
|
||||||
set
|
|
||||||
msg
|
|
||||||
("AddressBook Entry already exists: " ++
|
|
||||||
T.unpack (fs ^. address))
|
|
||||||
BT.modify $ set displayBox MsgDisplay
|
|
||||||
Just _ -> do
|
|
||||||
BT.modify $
|
|
||||||
set
|
|
||||||
msg
|
|
||||||
("New AddressBook entry created!!\n" ++
|
|
||||||
T.unpack (fs ^. address))
|
|
||||||
BT.modify $ set displayBox MsgDisplay
|
|
||||||
-- case end
|
-- case end
|
||||||
s' <- liftIO $ refreshAddressBook s
|
s' <- liftIO $ refreshAddressBook s
|
||||||
BT.put s'
|
BT.put s'
|
||||||
BT.modify $ set dialogBox AdrBook
|
BT.modify $ set dialogBox AdrBook
|
||||||
else do
|
else do
|
||||||
BT.modify $ set msg "Invalid or missing data!!: "
|
BT.modify $ set msg "Invalid or missing data!!: "
|
||||||
BT.modify $ set displayBox MsgDisplay
|
BT.modify $ set displayBox MsgDisplay
|
||||||
BT.modify $ set dialogBox AdrBookForm
|
BT.modify $ set dialogBox AdrBookForm
|
||||||
ev ->
|
ev -> BT.zoom abForm $ do
|
||||||
BT.zoom abForm $ do
|
handleFormEvent (BT.VtyEvent ev)
|
||||||
handleFormEvent (BT.VtyEvent ev)
|
fs <- BT.gets formState
|
||||||
fs <- BT.gets formState
|
BT.modify $
|
||||||
BT.modify $
|
setFieldValid
|
||||||
setFieldValid
|
(isRecipientValid (fs ^. address))
|
||||||
(isRecipientValid (fs ^. address))
|
AddressField
|
||||||
AddressField
|
|
||||||
AdrBookUpdForm -> do
|
AdrBookUpdForm -> do
|
||||||
case e of
|
case e of
|
||||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
||||||
V.EvKey V.KEnter [] -> do
|
V.EvKey V.KEnter [] -> do
|
||||||
pool <- liftIO $ runNoLoggingT $ initPool $ s ^. dbPath
|
pool <- liftIO $ runNoLoggingT $ initPool $ s ^. dbPath
|
||||||
fs <- BT.zoom abForm $ BT.gets formState
|
fs <- BT.zoom abForm $ BT.gets formState
|
||||||
let idescr = T.unpack $ T.strip (fs ^. descrip)
|
let idescr = T.unpack $ T.strip (fs ^. descrip)
|
||||||
let iabadr = fs ^. address
|
let iabadr = fs ^. address
|
||||||
if not (null idescr) && isRecipientValid iabadr
|
if not (null idescr) && isRecipientValid iabadr
|
||||||
then do
|
then do
|
||||||
res <-
|
res <- liftIO $ updateAdrsInAdrBook pool (fs ^. descrip) (fs ^.address) (s ^. abCurAdrs)
|
||||||
liftIO $
|
BT.modify $ set msg ("AddressBook entry modified!!\n" ++ T.unpack (fs ^.address))
|
||||||
updateAdrsInAdrBook
|
BT.modify $ set displayBox MsgDisplay
|
||||||
pool
|
|
||||||
(fs ^. descrip)
|
|
||||||
(fs ^. address)
|
|
||||||
(s ^. abCurAdrs)
|
|
||||||
BT.modify $
|
|
||||||
set
|
|
||||||
msg
|
|
||||||
("AddressBook entry modified!!\n" ++
|
|
||||||
T.unpack (fs ^. address))
|
|
||||||
BT.modify $ set displayBox MsgDisplay
|
|
||||||
-- case end
|
-- case end
|
||||||
s' <- liftIO $ refreshAddressBook s
|
s' <- liftIO $ refreshAddressBook s
|
||||||
BT.put s'
|
BT.put s'
|
||||||
BT.modify $ set dialogBox AdrBook
|
BT.modify $ set dialogBox AdrBook
|
||||||
else do
|
else do
|
||||||
BT.modify $ set msg "Invalid or missing data!!: "
|
BT.modify $ set msg "Invalid or missing data!!: "
|
||||||
BT.modify $ set displayBox MsgDisplay
|
BT.modify $ set displayBox MsgDisplay
|
||||||
BT.modify $ set dialogBox AdrBookForm
|
BT.modify $ set dialogBox AdrBookForm
|
||||||
ev ->
|
ev -> BT.zoom abForm $ do
|
||||||
BT.zoom abForm $ do
|
handleFormEvent (BT.VtyEvent ev)
|
||||||
handleFormEvent (BT.VtyEvent ev)
|
fs <- BT.gets formState
|
||||||
fs <- BT.gets formState
|
BT.modify $
|
||||||
BT.modify $
|
setFieldValid
|
||||||
setFieldValid
|
(isRecipientValid (fs ^. address))
|
||||||
(isRecipientValid (fs ^. address))
|
AddressField
|
||||||
AddressField
|
|
||||||
-- Process delete AddresBook entry
|
-- Process delete AddresBook entry
|
||||||
AdrBookDelForm -> do
|
AdrBookDelForm -> do
|
||||||
case e of
|
case e of
|
||||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox AdrBook
|
||||||
V.EvKey (V.KChar 'c') [] -> do
|
V.EvKey (V.KChar 'c') [] -> do
|
||||||
pool <- liftIO $ runNoLoggingT $ initPool $ s ^. dbPath
|
pool <- liftIO $ runNoLoggingT $ initPool $ s ^. dbPath
|
||||||
fs <- BT.zoom abForm $ BT.gets formState
|
fs <- BT.zoom abForm $ BT.gets formState
|
||||||
res <- liftIO $ deleteAdrsFromAB pool (fs ^. address)
|
res <- liftIO $ deleteAdrsFromAB pool (fs ^.address)
|
||||||
s' <- liftIO $ refreshAddressBook s
|
s' <- liftIO $ refreshAddressBook s
|
||||||
BT.put s'
|
BT.put s'
|
||||||
BT.modify $ set dialogBox AdrBook
|
BT.modify $ set dialogBox AdrBook
|
||||||
ev -> BT.modify $ set dialogBox AdrBookDelForm
|
ev -> BT.modify $ set dialogBox AdrBookDelForm
|
||||||
-- Process any other event
|
-- Process any other event
|
||||||
Blank -> do
|
Blank -> do
|
||||||
case e of
|
case e of
|
||||||
|
@ -1385,15 +1321,13 @@ runZenithTUI config = do
|
||||||
if not (null walList)
|
if not (null walList)
|
||||||
then zcashWalletLastSync $ entityVal $ head walList
|
then zcashWalletLastSync $ entityVal $ head walList
|
||||||
else 0
|
else 0
|
||||||
|
|
||||||
abookList <- getAdrBook pool $ zgb_net chainInfo
|
abookList <- getAdrBook pool $ zgb_net chainInfo
|
||||||
|
|
||||||
bal <-
|
bal <-
|
||||||
if not (null accList)
|
if not (null accList)
|
||||||
then getBalance pool $ entityKey $ head accList
|
then getBalance pool $ entityKey $ head accList
|
||||||
else return 0
|
else return 0
|
||||||
uBal <-
|
|
||||||
if not (null accList)
|
|
||||||
then getUnconfirmedBalance pool $ entityKey $ head accList
|
|
||||||
else return 0
|
|
||||||
eventChan <- BC.newBChan 10
|
eventChan <- BC.newBChan 10
|
||||||
_ <-
|
_ <-
|
||||||
forkIO $
|
forkIO $
|
||||||
|
@ -1434,7 +1368,6 @@ runZenithTUI config = do
|
||||||
(mkNewABForm (AdrBookEntry "" ""))
|
(mkNewABForm (AdrBookEntry "" ""))
|
||||||
""
|
""
|
||||||
Nothing
|
Nothing
|
||||||
uBal
|
|
||||||
Left e -> do
|
Left e -> do
|
||||||
print $
|
print $
|
||||||
"No Zebra node available on port " <>
|
"No Zebra node available on port " <>
|
||||||
|
@ -1463,10 +1396,6 @@ refreshWallet s = do
|
||||||
if not (null aL)
|
if not (null aL)
|
||||||
then getBalance pool $ entityKey $ head aL
|
then getBalance pool $ entityKey $ head aL
|
||||||
else return 0
|
else return 0
|
||||||
uBal <-
|
|
||||||
if not (null aL)
|
|
||||||
then getUnconfirmedBalance pool $ entityKey $ head aL
|
|
||||||
else return 0
|
|
||||||
txL <-
|
txL <-
|
||||||
if not (null addrL)
|
if not (null addrL)
|
||||||
then getUserTx pool $ entityKey $ head addrL
|
then getUserTx pool $ entityKey $ head addrL
|
||||||
|
@ -1477,8 +1406,6 @@ refreshWallet s = do
|
||||||
let txL' = L.listReplace (Vec.fromList txL) (Just 0) (s ^. transactions)
|
let txL' = L.listReplace (Vec.fromList txL) (Just 0) (s ^. transactions)
|
||||||
return $
|
return $
|
||||||
s & wallets .~ wL & accounts .~ aL' & syncBlock .~ bl & balance .~ bal &
|
s & wallets .~ wL & accounts .~ aL' & syncBlock .~ bl & balance .~ bal &
|
||||||
unconfBalance .~
|
|
||||||
uBal &
|
|
||||||
addresses .~
|
addresses .~
|
||||||
addrL' &
|
addrL' &
|
||||||
transactions .~
|
transactions .~
|
||||||
|
@ -1524,7 +1451,8 @@ addNewAccount n s = do
|
||||||
Right zA' -> do
|
Right zA' -> do
|
||||||
r <- saveAccount pool zA'
|
r <- saveAccount pool zA'
|
||||||
case r of
|
case r of
|
||||||
Nothing -> return $ s & msg .~ "Account already exists: " ++ T.unpack n
|
Nothing ->
|
||||||
|
return $ s & msg .~ "Account already exists: " ++ T.unpack n
|
||||||
Just x -> do
|
Just x -> do
|
||||||
aL <- runNoLoggingT $ getAccounts pool (entityKey selWallet)
|
aL <- runNoLoggingT $ getAccounts pool (entityKey selWallet)
|
||||||
let nL =
|
let nL =
|
||||||
|
@ -1547,7 +1475,6 @@ refreshAccount s = do
|
||||||
Just (_k, w) -> return w
|
Just (_k, w) -> return w
|
||||||
aL <- runNoLoggingT $ getAddresses pool $ entityKey selAccount
|
aL <- runNoLoggingT $ getAddresses pool $ entityKey selAccount
|
||||||
bal <- getBalance pool $ entityKey selAccount
|
bal <- getBalance pool $ entityKey selAccount
|
||||||
uBal <- getUnconfirmedBalance pool $ entityKey selAccount
|
|
||||||
let aL' = L.listReplace (Vec.fromList aL) (Just 0) (s ^. addresses)
|
let aL' = L.listReplace (Vec.fromList aL) (Just 0) (s ^. addresses)
|
||||||
selAddress <-
|
selAddress <-
|
||||||
do case L.listSelectedElement aL' of
|
do case L.listSelectedElement aL' of
|
||||||
|
@ -1558,17 +1485,13 @@ refreshAccount s = do
|
||||||
case selAddress of
|
case selAddress of
|
||||||
Nothing ->
|
Nothing ->
|
||||||
return $
|
return $
|
||||||
s & balance .~ bal & unconfBalance .~ uBal & addresses .~ aL' & msg .~
|
s & balance .~ bal & addresses .~ aL' & msg .~ "Switched to account: " ++
|
||||||
"Switched to account: " ++
|
|
||||||
T.unpack (zcashAccountName $ entityVal selAccount)
|
T.unpack (zcashAccountName $ entityVal selAccount)
|
||||||
Just (_i, a) -> do
|
Just (_i, a) -> do
|
||||||
tList <- getUserTx pool $ entityKey a
|
tList <- getUserTx pool $ entityKey a
|
||||||
let tL' = L.listReplace (Vec.fromList tList) (Just 0) (s ^. transactions)
|
let tL' = L.listReplace (Vec.fromList tList) (Just 0) (s ^. transactions)
|
||||||
return $
|
return $
|
||||||
s & balance .~ bal & unconfBalance .~ uBal & addresses .~ aL' &
|
s & balance .~ bal & addresses .~ aL' & transactions .~ tL' & msg .~
|
||||||
transactions .~
|
|
||||||
tL' &
|
|
||||||
msg .~
|
|
||||||
"Switched to account: " ++
|
"Switched to account: " ++
|
||||||
T.unpack (zcashAccountName $ entityVal selAccount)
|
T.unpack (zcashAccountName $ entityVal selAccount)
|
||||||
|
|
||||||
|
@ -1596,11 +1519,10 @@ refreshAddressBook s = do
|
||||||
do case L.listSelectedElement $ s ^. abAddresses of
|
do case L.listSelectedElement $ s ^. abAddresses of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
let fAdd =
|
let fAdd =
|
||||||
L.listSelectedElement $
|
L.listSelectedElement $ L.listMoveToBeginning $ s ^. abAddresses
|
||||||
L.listMoveToBeginning $ s ^. abAddresses
|
|
||||||
return fAdd
|
return fAdd
|
||||||
Just a2 -> return $ Just a2
|
Just a2 -> return $ Just a2
|
||||||
abookList <- getAdrBook pool (s ^. network)
|
abookList <- getAdrBook pool (s ^. network)
|
||||||
let tL' = L.listReplace (Vec.fromList abookList) (Just 0) (s ^. abAddresses)
|
let tL' = L.listReplace (Vec.fromList abookList) (Just 0) (s ^. abAddresses)
|
||||||
return $ s & abAddresses .~ tL'
|
return $ s & abAddresses .~ tL'
|
||||||
|
|
||||||
|
@ -1625,7 +1547,8 @@ addNewAddress n scope s = do
|
||||||
Right uA' -> do
|
Right uA' -> do
|
||||||
nAddr <- saveAddress pool uA'
|
nAddr <- saveAddress pool uA'
|
||||||
case nAddr of
|
case nAddr of
|
||||||
Nothing -> return $ s & msg .~ "Address already exists: " ++ T.unpack n
|
Nothing ->
|
||||||
|
return $ s & msg .~ "Address already exists: " ++ T.unpack n
|
||||||
Just x -> do
|
Just x -> do
|
||||||
addrL <- runNoLoggingT $ getAddresses pool (entityKey selAccount)
|
addrL <- runNoLoggingT $ getAddresses pool (entityKey selAccount)
|
||||||
let nL =
|
let nL =
|
||||||
|
@ -1651,7 +1574,6 @@ sendTransaction ::
|
||||||
-> IO ()
|
-> IO ()
|
||||||
sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do
|
sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do
|
||||||
BC.writeBChan chan $ TickMsg "Preparing transaction..."
|
BC.writeBChan chan $ TickMsg "Preparing transaction..."
|
||||||
<<<<<<< HEAD
|
|
||||||
zenithPath <- getZenithPath
|
zenithPath <- getZenithPath
|
||||||
let zenithLogPath = ( zenithPath ++ "zenith.log" )
|
let zenithLogPath = ( zenithPath ++ "zenith.log" )
|
||||||
outUA <- parseAddress ua
|
outUA <- parseAddress ua
|
||||||
|
@ -1687,24 +1609,3 @@ sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do
|
||||||
return $
|
return $
|
||||||
UnifiedAddress znet Nothing Nothing (Just $ ta_receiver a3)
|
UnifiedAddress znet Nothing Nothing (Just $ ta_receiver a3)
|
||||||
Nothing -> throwIO $ userError "Incorrect address"
|
Nothing -> throwIO $ userError "Incorrect address"
|
||||||
=======
|
|
||||||
case parseAddress ua znet of
|
|
||||||
Nothing -> BC.writeBChan chan $ TickMsg "Incorrect address"
|
|
||||||
Just outUA -> do
|
|
||||||
res <-
|
|
||||||
runFileLoggingT "zenith.log" $
|
|
||||||
prepareTx pool zHost zPort znet accId bl amt outUA memo
|
|
||||||
BC.writeBChan chan $ TickMsg "Transaction ready, sending to Zebra..."
|
|
||||||
case res of
|
|
||||||
Left e -> BC.writeBChan chan $ TickMsg $ show e
|
|
||||||
Right rawTx -> do
|
|
||||||
resp <-
|
|
||||||
makeZebraCall
|
|
||||||
zHost
|
|
||||||
zPort
|
|
||||||
"sendrawtransaction"
|
|
||||||
[Data.Aeson.String $ toText rawTx]
|
|
||||||
case resp of
|
|
||||||
Left e1 -> BC.writeBChan chan $ TickMsg $ "Zebra error: " ++ show e1
|
|
||||||
Right txId -> BC.writeBChan chan $ TickTx txId
|
|
||||||
>>>>>>> milestone2
|
|
||||||
|
|
187
src/Zenith/DB.hs
187
src/Zenith/DB.hs
|
@ -32,6 +32,7 @@ import qualified Data.Text as T
|
||||||
import qualified Data.Text.Encoding as TE
|
import qualified Data.Text.Encoding as TE
|
||||||
import Data.Word
|
import Data.Word
|
||||||
import Database.Esqueleto.Experimental
|
import Database.Esqueleto.Experimental
|
||||||
|
import qualified Database.Persist as P
|
||||||
import qualified Database.Persist.Sqlite as PS
|
import qualified Database.Persist.Sqlite as PS
|
||||||
import Database.Persist.TH
|
import Database.Persist.TH
|
||||||
import Haskoin.Transaction.Common
|
import Haskoin.Transaction.Common
|
||||||
|
@ -42,6 +43,7 @@ import Haskoin.Transaction.Common
|
||||||
)
|
)
|
||||||
import qualified Lens.Micro as ML ((&), (.~), (^.))
|
import qualified Lens.Micro as ML ((&), (.~), (^.))
|
||||||
import ZcashHaskell.Orchard (isValidUnifiedAddress)
|
import ZcashHaskell.Orchard (isValidUnifiedAddress)
|
||||||
|
import ZcashHaskell.Sapling (decodeSaplingOutputEsk)
|
||||||
import ZcashHaskell.Types
|
import ZcashHaskell.Types
|
||||||
( DecodedNote(..)
|
( DecodedNote(..)
|
||||||
, OrchardAction(..)
|
, OrchardAction(..)
|
||||||
|
@ -245,6 +247,12 @@ share
|
||||||
position Int
|
position Int
|
||||||
UniqueSSPos tx position
|
UniqueSSPos tx position
|
||||||
deriving Show Eq
|
deriving Show Eq
|
||||||
|
AddressBook
|
||||||
|
network ZcashNetDB
|
||||||
|
abdescrip T.Text
|
||||||
|
abaddress T.Text
|
||||||
|
UniqueABA abaddress
|
||||||
|
deriving Show Eq
|
||||||
QrCode
|
QrCode
|
||||||
address WalletAddressId OnDeleteCascade OnUpdateCascade
|
address WalletAddressId OnDeleteCascade OnUpdateCascade
|
||||||
version ZcashPool
|
version ZcashPool
|
||||||
|
@ -254,12 +262,6 @@ share
|
||||||
name T.Text
|
name T.Text
|
||||||
UniqueQr address version
|
UniqueQr address version
|
||||||
deriving Show Eq
|
deriving Show Eq
|
||||||
AddressBook
|
|
||||||
network ZcashNetDB
|
|
||||||
abdescrip T.Text
|
|
||||||
abaddress T.Text
|
|
||||||
UniqueABA abaddress
|
|
||||||
deriving Show Eq
|
|
||||||
|]
|
|]
|
||||||
|
|
||||||
-- * Database functions
|
-- * Database functions
|
||||||
|
@ -1396,35 +1398,6 @@ getBalance pool za = do
|
||||||
let oBal = sum oAmts
|
let oBal = sum oAmts
|
||||||
return . fromIntegral $ tBal + sBal + oBal
|
return . fromIntegral $ tBal + sBal + oBal
|
||||||
|
|
||||||
getTransparentBalance :: ConnectionPool -> ZcashAccountId -> IO Integer
|
|
||||||
getTransparentBalance pool za = do
|
|
||||||
trNotes <- getWalletUnspentTrNotes pool za
|
|
||||||
let tAmts = map (walletTrNoteValue . entityVal) trNotes
|
|
||||||
return . fromIntegral $ sum tAmts
|
|
||||||
|
|
||||||
getShieldedBalance :: ConnectionPool -> ZcashAccountId -> IO Integer
|
|
||||||
getShieldedBalance pool za = do
|
|
||||||
sapNotes <- getWalletUnspentSapNotes pool za
|
|
||||||
let sAmts = map (walletSapNoteValue . entityVal) sapNotes
|
|
||||||
let sBal = sum sAmts
|
|
||||||
orchNotes <- getWalletUnspentOrchNotes pool za
|
|
||||||
let oAmts = map (walletOrchNoteValue . entityVal) orchNotes
|
|
||||||
let oBal = sum oAmts
|
|
||||||
return . fromIntegral $ sBal + oBal
|
|
||||||
|
|
||||||
getUnconfirmedBalance :: ConnectionPool -> ZcashAccountId -> IO Integer
|
|
||||||
getUnconfirmedBalance pool za = do
|
|
||||||
trNotes <- getWalletUnspentUnconfirmedTrNotes pool za
|
|
||||||
let tAmts = map (walletTrNoteValue . entityVal) trNotes
|
|
||||||
let tBal = sum tAmts
|
|
||||||
sapNotes <- getWalletUnspentUnconfirmedSapNotes pool za
|
|
||||||
let sAmts = map (walletSapNoteValue . entityVal) sapNotes
|
|
||||||
let sBal = sum sAmts
|
|
||||||
orchNotes <- getWalletUnspentUnconfirmedOrchNotes pool za
|
|
||||||
let oAmts = map (walletOrchNoteValue . entityVal) orchNotes
|
|
||||||
let oBal = sum oAmts
|
|
||||||
return . fromIntegral $ tBal + sBal + oBal
|
|
||||||
|
|
||||||
clearWalletTransactions :: ConnectionPool -> IO ()
|
clearWalletTransactions :: ConnectionPool -> IO ()
|
||||||
clearWalletTransactions pool = do
|
clearWalletTransactions pool = do
|
||||||
runNoLoggingT $
|
runNoLoggingT $
|
||||||
|
@ -1462,42 +1435,10 @@ getWalletUnspentTrNotes pool za = do
|
||||||
PS.retryOnBusy $
|
PS.retryOnBusy $
|
||||||
flip PS.runSqlPool pool $ do
|
flip PS.runSqlPool pool $ do
|
||||||
select $ do
|
select $ do
|
||||||
(txs :& tNotes) <-
|
n <- from $ table @WalletTrNote
|
||||||
from $ table @WalletTransaction `innerJoin` table @WalletTrNote `on`
|
where_ (n ^. WalletTrNoteAccId ==. val za)
|
||||||
(\(txs :& tNotes) ->
|
where_ (n ^. WalletTrNoteSpent ==. val False)
|
||||||
txs ^. WalletTransactionId ==. tNotes ^. WalletTrNoteTx)
|
pure n
|
||||||
where_ (tNotes ^. WalletTrNoteAccId ==. val za)
|
|
||||||
where_ (tNotes ^. WalletTrNoteSpent ==. val False)
|
|
||||||
where_
|
|
||||||
((tNotes ^. WalletTrNoteChange ==. val True &&. txs ^.
|
|
||||||
WalletTransactionConf >=.
|
|
||||||
val 3) ||.
|
|
||||||
(tNotes ^. WalletTrNoteChange ==. val False &&. txs ^.
|
|
||||||
WalletTransactionConf >=.
|
|
||||||
val 10))
|
|
||||||
pure tNotes
|
|
||||||
|
|
||||||
getWalletUnspentUnconfirmedTrNotes ::
|
|
||||||
ConnectionPool -> ZcashAccountId -> IO [Entity WalletTrNote]
|
|
||||||
getWalletUnspentUnconfirmedTrNotes pool za = do
|
|
||||||
runNoLoggingT $
|
|
||||||
PS.retryOnBusy $
|
|
||||||
flip PS.runSqlPool pool $ do
|
|
||||||
select $ do
|
|
||||||
(txs :& tNotes) <-
|
|
||||||
from $ table @WalletTransaction `innerJoin` table @WalletTrNote `on`
|
|
||||||
(\(txs :& tNotes) ->
|
|
||||||
txs ^. WalletTransactionId ==. tNotes ^. WalletTrNoteTx)
|
|
||||||
where_ (tNotes ^. WalletTrNoteAccId ==. val za)
|
|
||||||
where_ (tNotes ^. WalletTrNoteSpent ==. val False)
|
|
||||||
where_
|
|
||||||
((tNotes ^. WalletTrNoteChange ==. val True &&. txs ^.
|
|
||||||
WalletTransactionConf <.
|
|
||||||
val 3) ||.
|
|
||||||
(tNotes ^. WalletTrNoteChange ==. val False &&. txs ^.
|
|
||||||
WalletTransactionConf <.
|
|
||||||
val 10))
|
|
||||||
pure tNotes
|
|
||||||
|
|
||||||
getWalletUnspentSapNotes ::
|
getWalletUnspentSapNotes ::
|
||||||
ConnectionPool -> ZcashAccountId -> IO [Entity WalletSapNote]
|
ConnectionPool -> ZcashAccountId -> IO [Entity WalletSapNote]
|
||||||
|
@ -1506,42 +1447,10 @@ getWalletUnspentSapNotes pool za = do
|
||||||
PS.retryOnBusy $
|
PS.retryOnBusy $
|
||||||
flip PS.runSqlPool pool $ do
|
flip PS.runSqlPool pool $ do
|
||||||
select $ do
|
select $ do
|
||||||
(txs :& sNotes) <-
|
n1 <- from $ table @WalletSapNote
|
||||||
from $ table @WalletTransaction `innerJoin` table @WalletSapNote `on`
|
where_ (n1 ^. WalletSapNoteAccId ==. val za)
|
||||||
(\(txs :& sNotes) ->
|
where_ (n1 ^. WalletSapNoteSpent ==. val False)
|
||||||
txs ^. WalletTransactionId ==. sNotes ^. WalletSapNoteTx)
|
pure n1
|
||||||
where_ (sNotes ^. WalletSapNoteAccId ==. val za)
|
|
||||||
where_ (sNotes ^. WalletSapNoteSpent ==. val False)
|
|
||||||
where_
|
|
||||||
((sNotes ^. WalletSapNoteChange ==. val True &&. txs ^.
|
|
||||||
WalletTransactionConf >=.
|
|
||||||
val 3) ||.
|
|
||||||
(sNotes ^. WalletSapNoteChange ==. val False &&. txs ^.
|
|
||||||
WalletTransactionConf >=.
|
|
||||||
val 10))
|
|
||||||
pure sNotes
|
|
||||||
|
|
||||||
getWalletUnspentUnconfirmedSapNotes ::
|
|
||||||
ConnectionPool -> ZcashAccountId -> IO [Entity WalletSapNote]
|
|
||||||
getWalletUnspentUnconfirmedSapNotes pool za = do
|
|
||||||
runNoLoggingT $
|
|
||||||
PS.retryOnBusy $
|
|
||||||
flip PS.runSqlPool pool $ do
|
|
||||||
select $ do
|
|
||||||
(txs :& sNotes) <-
|
|
||||||
from $ table @WalletTransaction `innerJoin` table @WalletSapNote `on`
|
|
||||||
(\(txs :& sNotes) ->
|
|
||||||
txs ^. WalletTransactionId ==. sNotes ^. WalletSapNoteTx)
|
|
||||||
where_ (sNotes ^. WalletSapNoteAccId ==. val za)
|
|
||||||
where_ (sNotes ^. WalletSapNoteSpent ==. val False)
|
|
||||||
where_
|
|
||||||
((sNotes ^. WalletSapNoteChange ==. val True &&. txs ^.
|
|
||||||
WalletTransactionConf <.
|
|
||||||
val 3) ||.
|
|
||||||
(sNotes ^. WalletSapNoteChange ==. val False &&. txs ^.
|
|
||||||
WalletTransactionConf <.
|
|
||||||
val 10))
|
|
||||||
pure sNotes
|
|
||||||
|
|
||||||
getWalletUnspentOrchNotes ::
|
getWalletUnspentOrchNotes ::
|
||||||
ConnectionPool -> ZcashAccountId -> IO [Entity WalletOrchNote]
|
ConnectionPool -> ZcashAccountId -> IO [Entity WalletOrchNote]
|
||||||
|
@ -1550,42 +1459,10 @@ getWalletUnspentOrchNotes pool za = do
|
||||||
PS.retryOnBusy $
|
PS.retryOnBusy $
|
||||||
flip PS.runSqlPool pool $ do
|
flip PS.runSqlPool pool $ do
|
||||||
select $ do
|
select $ do
|
||||||
(txs :& oNotes) <-
|
n2 <- from $ table @WalletOrchNote
|
||||||
from $ table @WalletTransaction `innerJoin` table @WalletOrchNote `on`
|
where_ (n2 ^. WalletOrchNoteAccId ==. val za)
|
||||||
(\(txs :& oNotes) ->
|
where_ (n2 ^. WalletOrchNoteSpent ==. val False)
|
||||||
txs ^. WalletTransactionId ==. oNotes ^. WalletOrchNoteTx)
|
pure n2
|
||||||
where_ (oNotes ^. WalletOrchNoteAccId ==. val za)
|
|
||||||
where_ (oNotes ^. WalletOrchNoteSpent ==. val False)
|
|
||||||
where_
|
|
||||||
((oNotes ^. WalletOrchNoteChange ==. val True &&. txs ^.
|
|
||||||
WalletTransactionConf >=.
|
|
||||||
val 3) ||.
|
|
||||||
(oNotes ^. WalletOrchNoteChange ==. val False &&. txs ^.
|
|
||||||
WalletTransactionConf >=.
|
|
||||||
val 10))
|
|
||||||
pure oNotes
|
|
||||||
|
|
||||||
getWalletUnspentUnconfirmedOrchNotes ::
|
|
||||||
ConnectionPool -> ZcashAccountId -> IO [Entity WalletOrchNote]
|
|
||||||
getWalletUnspentUnconfirmedOrchNotes pool za = do
|
|
||||||
runNoLoggingT $
|
|
||||||
PS.retryOnBusy $
|
|
||||||
flip PS.runSqlPool pool $ do
|
|
||||||
select $ do
|
|
||||||
(txs :& oNotes) <-
|
|
||||||
from $ table @WalletTransaction `innerJoin` table @WalletOrchNote `on`
|
|
||||||
(\(txs :& oNotes) ->
|
|
||||||
txs ^. WalletTransactionId ==. oNotes ^. WalletOrchNoteTx)
|
|
||||||
where_ (oNotes ^. WalletOrchNoteAccId ==. val za)
|
|
||||||
where_ (oNotes ^. WalletOrchNoteSpent ==. val False)
|
|
||||||
where_
|
|
||||||
((oNotes ^. WalletOrchNoteChange ==. val True &&. txs ^.
|
|
||||||
WalletTransactionConf <.
|
|
||||||
val 3) ||.
|
|
||||||
(oNotes ^. WalletOrchNoteChange ==. val False &&. txs ^.
|
|
||||||
WalletTransactionConf <.
|
|
||||||
val 10))
|
|
||||||
pure oNotes
|
|
||||||
|
|
||||||
selectUnspentNotes ::
|
selectUnspentNotes ::
|
||||||
ConnectionPool
|
ConnectionPool
|
||||||
|
@ -1646,27 +1523,6 @@ getWalletTxId pool wId = do
|
||||||
where_ (wtx ^. WalletTransactionId ==. val wId)
|
where_ (wtx ^. WalletTransactionId ==. val wId)
|
||||||
pure $ wtx ^. WalletTransactionTxId
|
pure $ wtx ^. WalletTransactionTxId
|
||||||
|
|
||||||
getUnconfirmedBlocks :: ConnectionPool -> IO [Int]
|
|
||||||
getUnconfirmedBlocks pool = do
|
|
||||||
r <-
|
|
||||||
runNoLoggingT $
|
|
||||||
PS.retryOnBusy $
|
|
||||||
flip PS.runSqlPool pool $ do
|
|
||||||
select $ do
|
|
||||||
wtx <- from $ table @WalletTransaction
|
|
||||||
where_ (wtx ^. WalletTransactionConf <=. val 10)
|
|
||||||
pure $ wtx ^. WalletTransactionBlock
|
|
||||||
return $ map (\(Value i) -> i) r
|
|
||||||
|
|
||||||
saveConfs :: ConnectionPool -> Int -> Int -> IO ()
|
|
||||||
saveConfs pool b c = do
|
|
||||||
runNoLoggingT $
|
|
||||||
PS.retryOnBusy $
|
|
||||||
flip PS.runSqlPool pool $ do
|
|
||||||
update $ \t -> do
|
|
||||||
set t [WalletTransactionConf =. val c]
|
|
||||||
where_ $ t ^. WalletTransactionBlock ==. val b
|
|
||||||
|
|
||||||
-- | Helper function to extract a Unified Address from the database
|
-- | Helper function to extract a Unified Address from the database
|
||||||
readUnifiedAddressDB :: WalletAddress -> Maybe UnifiedAddress
|
readUnifiedAddressDB :: WalletAddress -> Maybe UnifiedAddress
|
||||||
readUnifiedAddressDB =
|
readUnifiedAddressDB =
|
||||||
|
@ -1712,6 +1568,7 @@ updateAdrsInAdrBook pool d a ia = do
|
||||||
-- adrbook <- from $ table @AddressBook
|
-- adrbook <- from $ table @AddressBook
|
||||||
-- where_ ((adrbook ^. AddressBookAbaddress) ==. val a)
|
-- where_ ((adrbook ^. AddressBookAbaddress) ==. val a)
|
||||||
-- return adrbook
|
-- return adrbook
|
||||||
|
|
||||||
-- | delete an existing address from AddressBook
|
-- | delete an existing address from AddressBook
|
||||||
deleteAdrsFromAB :: ConnectionPool -> T.Text -> IO ()
|
deleteAdrsFromAB :: ConnectionPool -> T.Text -> IO ()
|
||||||
deleteAdrsFromAB pool ia = do
|
deleteAdrsFromAB pool ia = do
|
||||||
|
@ -1720,7 +1577,7 @@ deleteAdrsFromAB pool ia = do
|
||||||
flip PS.runSqlPool pool $ do
|
flip PS.runSqlPool pool $ do
|
||||||
delete $ do
|
delete $ do
|
||||||
ab <- from $ table @AddressBook
|
ab <- from $ table @AddressBook
|
||||||
where_ (ab ^. AddressBookAbaddress ==. val ia)
|
where_ (ab ^. AddressBookAbaddress ==. val ia)
|
||||||
|
|
||||||
rmdups :: Ord a => [a] -> [a]
|
rmdups :: Ord a => [a] -> [a]
|
||||||
rmdups = map head . group . sort
|
rmdups = map head . group . sort
|
||||||
|
|
|
@ -7,11 +7,8 @@ import Codec.Picture
|
||||||
import Codec.Picture.Types (pixelFold, promoteImage)
|
import Codec.Picture.Types (pixelFold, promoteImage)
|
||||||
import Codec.QRCode
|
import Codec.QRCode
|
||||||
import Codec.QRCode.JuicyPixels
|
import Codec.QRCode.JuicyPixels
|
||||||
import Control.Concurrent (threadDelay)
|
|
||||||
import Control.Exception (throwIO, try)
|
import Control.Exception (throwIO, try)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.Logger (runNoLoggingT)
|
||||||
import Control.Monad.Logger (runFileLoggingT, runNoLoggingT)
|
|
||||||
import Data.Aeson
|
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import qualified Data.ByteString.Lazy as LBS
|
import qualified Data.ByteString.Lazy as LBS
|
||||||
import Data.HexString (toText)
|
import Data.HexString (toText)
|
||||||
|
@ -26,15 +23,13 @@ import Lens.Micro.TH
|
||||||
import Monomer
|
import Monomer
|
||||||
import qualified Monomer.Lens as L
|
import qualified Monomer.Lens as L
|
||||||
import System.Hclip
|
import System.Hclip
|
||||||
import Text.Printf
|
|
||||||
import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..), wrapText)
|
import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..), wrapText)
|
||||||
import TextShow hiding (toText)
|
import TextShow hiding (toText)
|
||||||
import ZcashHaskell.Keys (generateWalletSeedPhrase)
|
import ZcashHaskell.Keys (generateWalletSeedPhrase)
|
||||||
import ZcashHaskell.Orchard (getSaplingFromUA, isValidUnifiedAddress)
|
import ZcashHaskell.Orchard (getSaplingFromUA, isValidUnifiedAddress)
|
||||||
import ZcashHaskell.Transparent (encodeTransparentReceiver)
|
import ZcashHaskell.Transparent (encodeTransparentReceiver)
|
||||||
import ZcashHaskell.Types
|
import ZcashHaskell.Types
|
||||||
( BlockResponse(..)
|
( Phrase(..)
|
||||||
, Phrase(..)
|
|
||||||
, Scope(..)
|
, Scope(..)
|
||||||
, ToBytes(..)
|
, ToBytes(..)
|
||||||
, UnifiedAddress(..)
|
, UnifiedAddress(..)
|
||||||
|
@ -42,20 +37,11 @@ import ZcashHaskell.Types
|
||||||
, ZebraGetBlockChainInfo(..)
|
, ZebraGetBlockChainInfo(..)
|
||||||
, ZebraGetInfo(..)
|
, ZebraGetInfo(..)
|
||||||
)
|
)
|
||||||
import ZcashHaskell.Utils (getBlockTime, makeZebraCall)
|
|
||||||
import Zenith.Core
|
import Zenith.Core
|
||||||
import Zenith.DB
|
import Zenith.DB
|
||||||
import Zenith.GUI.Theme
|
import Zenith.GUI.Theme
|
||||||
import Zenith.Scanner (processTx, updateConfs)
|
|
||||||
import Zenith.Types hiding (ZcashAddress(..))
|
import Zenith.Types hiding (ZcashAddress(..))
|
||||||
import Zenith.Utils
|
import Zenith.Utils (displayAmount, showAddress)
|
||||||
( displayAmount
|
|
||||||
, isRecipientValid
|
|
||||||
, jsonNumber
|
|
||||||
, parseAddress
|
|
||||||
, showAddress
|
|
||||||
, validBarValue
|
|
||||||
)
|
|
||||||
|
|
||||||
data AppEvent
|
data AppEvent
|
||||||
= AppInit
|
= AppInit
|
||||||
|
@ -75,7 +61,6 @@ data AppEvent
|
||||||
| SwitchAddr !Int
|
| SwitchAddr !Int
|
||||||
| SwitchAcc !Int
|
| SwitchAcc !Int
|
||||||
| SwitchWal !Int
|
| SwitchWal !Int
|
||||||
| UpdateBalance !(Integer, Integer)
|
|
||||||
| CopyAddr !(Maybe (Entity WalletAddress))
|
| CopyAddr !(Maybe (Entity WalletAddress))
|
||||||
| LoadTxs ![Entity UserTx]
|
| LoadTxs ![Entity UserTx]
|
||||||
| LoadAddrs ![Entity WalletAddress]
|
| LoadAddrs ![Entity WalletAddress]
|
||||||
|
@ -86,20 +71,11 @@ data AppEvent
|
||||||
| SaveAccount !(Maybe (Entity ZcashWallet))
|
| SaveAccount !(Maybe (Entity ZcashWallet))
|
||||||
| SaveWallet
|
| SaveWallet
|
||||||
| CloseSeed
|
| CloseSeed
|
||||||
| CloseTxId
|
|
||||||
| ShowSeed
|
| ShowSeed
|
||||||
| CopySeed !T.Text
|
| CopySeed !T.Text
|
||||||
| CopyTx !T.Text
|
| CopyTx !T.Text
|
||||||
| CloseTx
|
| CloseTx
|
||||||
| ShowTx !Int
|
| ShowTx !Int
|
||||||
| TickUp
|
|
||||||
| SyncVal !Float
|
|
||||||
| SendTx
|
|
||||||
| ShowSend
|
|
||||||
| CancelSend
|
|
||||||
| CheckRecipient !T.Text
|
|
||||||
| CheckAmount !Float
|
|
||||||
| ShowTxId !T.Text
|
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
data AppModel = AppModel
|
data AppModel = AppModel
|
||||||
|
@ -132,15 +108,6 @@ data AppModel = AppModel
|
||||||
, _showSeed :: !Bool
|
, _showSeed :: !Bool
|
||||||
, _modalMsg :: !(Maybe T.Text)
|
, _modalMsg :: !(Maybe T.Text)
|
||||||
, _showTx :: !(Maybe Int)
|
, _showTx :: !(Maybe Int)
|
||||||
, _timer :: !Int
|
|
||||||
, _barValue :: !Float
|
|
||||||
, _openSend :: !Bool
|
|
||||||
, _sendRecipient :: !T.Text
|
|
||||||
, _sendAmount :: !Float
|
|
||||||
, _sendMemo :: !T.Text
|
|
||||||
, _recipientValid :: !Bool
|
|
||||||
, _amountValid :: !Bool
|
|
||||||
, _showId :: !(Maybe T.Text)
|
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
makeLenses ''AppModel
|
makeLenses ''AppModel
|
||||||
|
@ -178,8 +145,6 @@ buildUI wenv model = widgetTree
|
||||||
, confirmOverlay `nodeVisible` isJust (model ^. confirmTitle)
|
, confirmOverlay `nodeVisible` isJust (model ^. confirmTitle)
|
||||||
, seedOverlay `nodeVisible` model ^. showSeed
|
, seedOverlay `nodeVisible` model ^. showSeed
|
||||||
, txOverlay `nodeVisible` isJust (model ^. showTx)
|
, txOverlay `nodeVisible` isJust (model ^. showTx)
|
||||||
, sendTxOverlay `nodeVisible` model ^. openSend
|
|
||||||
, txIdOverlay `nodeVisible` isJust (model ^. showId)
|
|
||||||
, msgOverlay `nodeVisible` isJust (model ^. msg)
|
, msgOverlay `nodeVisible` isJust (model ^. msg)
|
||||||
, modalOverlay `nodeVisible` isJust (model ^. modalMsg)
|
, modalOverlay `nodeVisible` isJust (model ^. modalMsg)
|
||||||
]
|
]
|
||||||
|
@ -310,12 +275,7 @@ buildUI wenv model = widgetTree
|
||||||
mainPane =
|
mainPane =
|
||||||
box_ [alignMiddle] $
|
box_ [alignMiddle] $
|
||||||
hstack
|
hstack
|
||||||
[ addressBox
|
[addressBox, txBox `nodeVisible` not (null $ model ^. transactions)]
|
||||||
, vstack
|
|
||||||
[ mainButton "Send" ShowSend `styleBasic` [textFont "Bold"]
|
|
||||||
, txBox `nodeVisible` not (null $ model ^. transactions)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
balanceBox =
|
balanceBox =
|
||||||
hstack
|
hstack
|
||||||
[ filler
|
[ filler
|
||||||
|
@ -323,24 +283,19 @@ buildUI wenv model = widgetTree
|
||||||
box_
|
box_
|
||||||
[alignMiddle]
|
[alignMiddle]
|
||||||
(vstack
|
(vstack
|
||||||
[ hstack
|
[ animFadeIn
|
||||||
[ filler
|
(label (displayAmount (model ^. network) $ model ^. balance) `styleBasic`
|
||||||
, animFadeIn
|
[textSize 20])
|
||||||
(label
|
|
||||||
(displayAmount (model ^. network) $ model ^. balance) `styleBasic`
|
|
||||||
[textSize 20])
|
|
||||||
, filler
|
|
||||||
]
|
|
||||||
, hstack
|
, hstack
|
||||||
[ filler
|
[ filler
|
||||||
, remixIcon remixHourglassFill `styleBasic` [textSize 8]
|
, remixIcon remixHourglassFill `styleBasic` [textSize 8]
|
||||||
, label
|
, label
|
||||||
(maybe "0" (displayAmount (model ^. network)) $
|
(maybe "0" (displayAmount (model ^. network)) $
|
||||||
model ^. unconfBalance) `styleBasic`
|
model ^. unconfBalance) `styleBasic`
|
||||||
[textSize 8]
|
[textSize 8] `nodeVisible`
|
||||||
|
isJust (model ^. unconfBalance)
|
||||||
, filler
|
, filler
|
||||||
] `nodeVisible`
|
]
|
||||||
isJust (model ^. unconfBalance)
|
|
||||||
]) `styleBasic`
|
]) `styleBasic`
|
||||||
[bgColor white, radius 5, border 1 btnColor]
|
[bgColor white, radius 5, border 1 btnColor]
|
||||||
, filler
|
, filler
|
||||||
|
@ -501,8 +456,6 @@ buildUI wenv model = widgetTree
|
||||||
("Last block sync: " <>
|
("Last block sync: " <>
|
||||||
maybe "N/A" (showt . zcashWalletLastSync . entityVal) currentWallet) `styleBasic`
|
maybe "N/A" (showt . zcashWalletLastSync . entityVal) currentWallet) `styleBasic`
|
||||||
[padding 3, textSize 8]
|
[padding 3, textSize 8]
|
||||||
, spacer
|
|
||||||
, label (showt $ model ^. timer) `styleBasic` [padding 3, textSize 8]
|
|
||||||
, filler
|
, filler
|
||||||
, image_ "./assets/1F993.png" [fitHeight] `styleBasic`
|
, image_ "./assets/1F993.png" [fitHeight] `styleBasic`
|
||||||
[height 24, width 24] `nodeVisible`
|
[height 24, width 24] `nodeVisible`
|
||||||
|
@ -536,73 +489,6 @@ buildUI wenv model = widgetTree
|
||||||
, cancelCaption $ model ^. confirmCancel
|
, cancelCaption $ model ^. confirmCancel
|
||||||
]
|
]
|
||||||
(hstack [label "Name:", filler, textField_ mainInput [maxLength 25]])
|
(hstack [label "Name:", filler, textField_ mainInput [maxLength 25]])
|
||||||
sendTxOverlay =
|
|
||||||
box
|
|
||||||
(vstack
|
|
||||||
[ filler
|
|
||||||
, hstack
|
|
||||||
[ filler
|
|
||||||
, box_
|
|
||||||
[]
|
|
||||||
(vstack
|
|
||||||
[ box_
|
|
||||||
[alignMiddle]
|
|
||||||
(label "Send Zcash" `styleBasic`
|
|
||||||
[textFont "Bold", textSize 12])
|
|
||||||
, separatorLine `styleBasic` [fgColor btnColor]
|
|
||||||
, spacer
|
|
||||||
, hstack
|
|
||||||
[ label "To:" `styleBasic` [width 50]
|
|
||||||
, spacer
|
|
||||||
, textField_ sendRecipient [onChange CheckRecipient] `styleBasic`
|
|
||||||
[ width 150
|
|
||||||
, styleIf
|
|
||||||
(not $ model ^. recipientValid)
|
|
||||||
(textColor red)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
, hstack
|
|
||||||
[ label "Amount:" `styleBasic` [width 50]
|
|
||||||
, spacer
|
|
||||||
, numericField_
|
|
||||||
sendAmount
|
|
||||||
[ decimals 8
|
|
||||||
, minValue 0.0
|
|
||||||
, maxValue
|
|
||||||
(fromIntegral (model ^. balance) / 100000000.0)
|
|
||||||
, validInput amountValid
|
|
||||||
, onChange CheckAmount
|
|
||||||
] `styleBasic`
|
|
||||||
[ width 150
|
|
||||||
, styleIf
|
|
||||||
(not $ model ^. amountValid)
|
|
||||||
(textColor red)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
, hstack
|
|
||||||
[ label "Memo:" `styleBasic` [width 50]
|
|
||||||
, spacer
|
|
||||||
, textArea sendMemo `styleBasic`
|
|
||||||
[width 150, height 40]
|
|
||||||
]
|
|
||||||
, spacer
|
|
||||||
, box_
|
|
||||||
[alignMiddle]
|
|
||||||
(hstack
|
|
||||||
[ spacer
|
|
||||||
, button "Cancel" CancelSend
|
|
||||||
, spacer
|
|
||||||
, mainButton "Send" SendTx `nodeEnabled`
|
|
||||||
(model ^. amountValid && model ^. recipientValid)
|
|
||||||
, spacer
|
|
||||||
])
|
|
||||||
]) `styleBasic`
|
|
||||||
[radius 4, border 2 btnColor, bgColor white, padding 4]
|
|
||||||
, filler
|
|
||||||
]
|
|
||||||
, filler
|
|
||||||
]) `styleBasic`
|
|
||||||
[bgColor (white & L.a .~ 0.5)]
|
|
||||||
seedOverlay =
|
seedOverlay =
|
||||||
alert CloseSeed $
|
alert CloseSeed $
|
||||||
vstack
|
vstack
|
||||||
|
@ -716,31 +602,6 @@ buildUI wenv model = widgetTree
|
||||||
]) `styleBasic`
|
]) `styleBasic`
|
||||||
[padding 2, bgColor white, width 280, borderB 1 gray]
|
[padding 2, bgColor white, width 280, borderB 1 gray]
|
||||||
]
|
]
|
||||||
txIdOverlay =
|
|
||||||
case model ^. showId of
|
|
||||||
Nothing -> alert CloseTxId $ label "N/A"
|
|
||||||
Just t ->
|
|
||||||
alert CloseTxId $
|
|
||||||
box_
|
|
||||||
[alignLeft]
|
|
||||||
(vstack
|
|
||||||
[ box_ [alignMiddle] $
|
|
||||||
label "Transaction Sent!" `styleBasic` [textFont "Bold"]
|
|
||||||
, spacer
|
|
||||||
, hstack
|
|
||||||
[ label "Tx ID " `styleBasic` [width 60, textFont "Bold"]
|
|
||||||
, separatorLine `styleBasic` [fgColor btnColor]
|
|
||||||
, spacer
|
|
||||||
, label_ (txtWrap t) [multiline]
|
|
||||||
, spacer
|
|
||||||
, box_
|
|
||||||
[onClick $ CopyTx t]
|
|
||||||
(remixIcon remixFileCopyFill `styleBasic`
|
|
||||||
[textColor white]) `styleBasic`
|
|
||||||
[cursorHand, bgColor btnColor, radius 2, padding 2]
|
|
||||||
]
|
|
||||||
]) `styleBasic`
|
|
||||||
[padding 2, bgColor white, width 280, borderB 1 gray, borderT 1 gray]
|
|
||||||
|
|
||||||
generateQRCodes :: Config -> IO ()
|
generateQRCodes :: Config -> IO ()
|
||||||
generateQRCodes config = do
|
generateQRCodes config = do
|
||||||
|
@ -818,14 +679,10 @@ handleEvent ::
|
||||||
-> [AppEventResponse AppModel AppEvent]
|
-> [AppEventResponse AppModel AppEvent]
|
||||||
handleEvent wenv node model evt =
|
handleEvent wenv node model evt =
|
||||||
case evt of
|
case evt of
|
||||||
AppInit ->
|
AppInit -> [Event NewWallet | isNothing currentWallet]
|
||||||
[Event NewWallet | isNothing currentWallet] <> [Producer timeTicker]
|
|
||||||
ShowMsg t -> [Model $ model & msg ?~ t & menuPopup .~ False]
|
ShowMsg t -> [Model $ model & msg ?~ t & menuPopup .~ False]
|
||||||
ShowError t ->
|
ShowError t ->
|
||||||
[ Model $
|
[Model $ model & msg ?~ t & menuPopup .~ False & inError .~ True]
|
||||||
model & msg ?~ t & menuPopup .~ False & inError .~ True & modalMsg .~
|
|
||||||
Nothing
|
|
||||||
]
|
|
||||||
ShowModal t -> [Model $ model & modalMsg ?~ t]
|
ShowModal t -> [Model $ model & modalMsg ?~ t]
|
||||||
WalletClicked -> [Model $ model & walPopup .~ True]
|
WalletClicked -> [Model $ model & walPopup .~ True]
|
||||||
AccountClicked -> [Model $ model & accPopup .~ True]
|
AccountClicked -> [Model $ model & accPopup .~ True]
|
||||||
|
@ -863,32 +720,6 @@ handleEvent wenv node model evt =
|
||||||
]
|
]
|
||||||
ConfirmCancel -> [Model $ model & confirmTitle .~ Nothing & mainInput .~ ""]
|
ConfirmCancel -> [Model $ model & confirmTitle .~ Nothing & mainInput .~ ""]
|
||||||
ShowSeed -> [Model $ model & showSeed .~ True & menuPopup .~ False]
|
ShowSeed -> [Model $ model & showSeed .~ True & menuPopup .~ False]
|
||||||
ShowSend -> [Model $ model & openSend .~ True]
|
|
||||||
SendTx ->
|
|
||||||
case currentAccount of
|
|
||||||
Nothing -> [Event $ ShowError "No account available", Event CancelSend]
|
|
||||||
Just acc ->
|
|
||||||
case currentWallet of
|
|
||||||
Nothing ->
|
|
||||||
[Event $ ShowError "No wallet available", Event CancelSend]
|
|
||||||
Just wal ->
|
|
||||||
[ Producer $
|
|
||||||
sendTransaction
|
|
||||||
(model ^. configuration)
|
|
||||||
(model ^. network)
|
|
||||||
(entityKey acc)
|
|
||||||
(zcashWalletLastSync $ entityVal wal)
|
|
||||||
(model ^. sendAmount)
|
|
||||||
(model ^. sendRecipient)
|
|
||||||
(model ^. sendMemo)
|
|
||||||
, Event CancelSend
|
|
||||||
]
|
|
||||||
CancelSend ->
|
|
||||||
[ Model $
|
|
||||||
model & openSend .~ False & sendRecipient .~ "" & sendAmount .~ 0.0 &
|
|
||||||
sendMemo .~
|
|
||||||
""
|
|
||||||
]
|
|
||||||
SaveAddress acc ->
|
SaveAddress acc ->
|
||||||
if T.length (model ^. mainInput) > 1
|
if T.length (model ^. mainInput) > 1
|
||||||
then [ Task $ addNewAddress (model ^. mainInput) External acc
|
then [ Task $ addNewAddress (model ^. mainInput) External acc
|
||||||
|
@ -931,15 +762,6 @@ handleEvent wenv node model evt =
|
||||||
case selectAccount i of
|
case selectAccount i of
|
||||||
Nothing -> return []
|
Nothing -> return []
|
||||||
Just acc -> runNoLoggingT $ getAddresses dbPool $ entityKey acc
|
Just acc -> runNoLoggingT $ getAddresses dbPool $ entityKey acc
|
||||||
, Task $
|
|
||||||
UpdateBalance <$> do
|
|
||||||
dbPool <- runNoLoggingT $ initPool $ c_dbPath $ model ^. configuration
|
|
||||||
case selectAccount i of
|
|
||||||
Nothing -> return (0, 0)
|
|
||||||
Just acc -> do
|
|
||||||
b <- getBalance dbPool $ entityKey acc
|
|
||||||
u <- getUnconfirmedBalance dbPool $ entityKey acc
|
|
||||||
return (b, u)
|
|
||||||
, Event $ SetPool Orchard
|
, Event $ SetPool Orchard
|
||||||
]
|
]
|
||||||
SwitchWal i ->
|
SwitchWal i ->
|
||||||
|
@ -951,13 +773,6 @@ handleEvent wenv node model evt =
|
||||||
Nothing -> return []
|
Nothing -> return []
|
||||||
Just wal -> runNoLoggingT $ getAccounts dbPool $ entityKey wal
|
Just wal -> runNoLoggingT $ getAccounts dbPool $ entityKey wal
|
||||||
]
|
]
|
||||||
UpdateBalance (b, u) ->
|
|
||||||
[ Model $
|
|
||||||
model & balance .~ b & unconfBalance .~
|
|
||||||
(if u == 0
|
|
||||||
then Nothing
|
|
||||||
else Just u)
|
|
||||||
]
|
|
||||||
CopyAddr a ->
|
CopyAddr a ->
|
||||||
[ setClipboardData ClipboardEmpty
|
[ setClipboardData ClipboardEmpty
|
||||||
, setClipboardData $
|
, setClipboardData $
|
||||||
|
@ -1002,55 +817,12 @@ handleEvent wenv node model evt =
|
||||||
else [Event $ NewAccount currentWallet]
|
else [Event $ NewAccount currentWallet]
|
||||||
LoadWallets a ->
|
LoadWallets a ->
|
||||||
if not (null a)
|
if not (null a)
|
||||||
then [ Model $ model & wallets .~ a
|
then [Model $ model & wallets .~ a, Event $ SwitchWal 0]
|
||||||
, Event $ SwitchWal $ model ^. selWallet
|
|
||||||
]
|
|
||||||
else [Event NewWallet]
|
else [Event NewWallet]
|
||||||
CloseMsg -> [Model $ model & msg .~ Nothing & inError .~ False]
|
CloseMsg -> [Model $ model & msg .~ Nothing & inError .~ False]
|
||||||
CloseSeed -> [Model $ model & showSeed .~ False]
|
CloseSeed -> [Model $ model & showSeed .~ False]
|
||||||
CloseTx -> [Model $ model & showTx .~ Nothing]
|
CloseTx -> [Model $ model & showTx .~ Nothing]
|
||||||
CloseTxId -> [Model $ model & showId .~ Nothing]
|
|
||||||
ShowTx i -> [Model $ model & showTx ?~ i]
|
ShowTx i -> [Model $ model & showTx ?~ i]
|
||||||
TickUp ->
|
|
||||||
if (model ^. timer) < 90
|
|
||||||
then [Model $ model & timer .~ (1 + model ^. timer)]
|
|
||||||
else if (model ^. barValue) == 1.0
|
|
||||||
then [ Model $ model & timer .~ 0 & barValue .~ 0.0
|
|
||||||
, Producer $
|
|
||||||
scanZebra
|
|
||||||
(c_dbPath $ model ^. configuration)
|
|
||||||
(c_zebraHost $ model ^. configuration)
|
|
||||||
(c_zebraPort $ model ^. configuration)
|
|
||||||
]
|
|
||||||
else [Model $ model & timer .~ 0]
|
|
||||||
SyncVal i ->
|
|
||||||
if (i + model ^. barValue) >= 0.999
|
|
||||||
then [ Model $ model & barValue .~ 1.0 & modalMsg .~ Nothing
|
|
||||||
, Task $ do
|
|
||||||
case currentWallet of
|
|
||||||
Nothing -> return $ ShowError "No wallet available"
|
|
||||||
Just cW -> do
|
|
||||||
syncWallet (model ^. configuration) cW
|
|
||||||
return $ SwitchAddr (model ^. selAddr)
|
|
||||||
, Task $ do
|
|
||||||
pool <-
|
|
||||||
runNoLoggingT $ initPool $ c_dbPath $ model ^. configuration
|
|
||||||
wL <- getWallets pool (model ^. network)
|
|
||||||
return $ LoadWallets wL
|
|
||||||
]
|
|
||||||
else [ Model $
|
|
||||||
model & barValue .~ validBarValue (i + model ^. barValue) &
|
|
||||||
modalMsg ?~
|
|
||||||
("Wallet Sync: " <>
|
|
||||||
T.pack (printf "%.2f%%" (model ^. barValue * 100)))
|
|
||||||
]
|
|
||||||
CheckRecipient a -> [Model $ model & recipientValid .~ isRecipientValid a]
|
|
||||||
CheckAmount i ->
|
|
||||||
[ Model $
|
|
||||||
model & amountValid .~
|
|
||||||
(i < (fromIntegral (model ^. balance) / 100000000.0))
|
|
||||||
]
|
|
||||||
ShowTxId tx -> [Model $ model & showId ?~ tx & modalMsg .~ Nothing]
|
|
||||||
where
|
where
|
||||||
currentWallet =
|
currentWallet =
|
||||||
if null (model ^. wallets)
|
if null (model ^. wallets)
|
||||||
|
@ -1139,104 +911,6 @@ handleEvent wenv node model evt =
|
||||||
wL <- getWallets pool (model ^. network)
|
wL <- getWallets pool (model ^. network)
|
||||||
return $ LoadWallets wL
|
return $ LoadWallets wL
|
||||||
|
|
||||||
scanZebra :: T.Text -> T.Text -> Int -> (AppEvent -> IO ()) -> IO ()
|
|
||||||
scanZebra dbPath zHost zPort sendMsg = do
|
|
||||||
_ <- liftIO $ initDb dbPath
|
|
||||||
bStatus <- liftIO $ checkBlockChain zHost zPort
|
|
||||||
pool <- runNoLoggingT $ initPool dbPath
|
|
||||||
b <- liftIO $ getMinBirthdayHeight pool
|
|
||||||
dbBlock <- runNoLoggingT $ getMaxBlock pool
|
|
||||||
let sb = max dbBlock b
|
|
||||||
confUp <- try $ updateConfs zHost zPort pool :: IO (Either IOError ())
|
|
||||||
case confUp of
|
|
||||||
Left _e0 -> sendMsg (ShowError "Failed to update unconfirmed transactions")
|
|
||||||
Right _ -> do
|
|
||||||
if sb > zgb_blocks bStatus || sb < 1
|
|
||||||
then sendMsg (ShowError "Invalid starting block for scan")
|
|
||||||
else do
|
|
||||||
let bList = [(sb + 1) .. (zgb_blocks bStatus)]
|
|
||||||
if not (null bList)
|
|
||||||
then do
|
|
||||||
let step = (1.0 :: Float) / fromIntegral (length bList)
|
|
||||||
mapM_ (processBlock pool step) bList
|
|
||||||
else sendMsg (SyncVal 1.0)
|
|
||||||
where
|
|
||||||
processBlock :: ConnectionPool -> Float -> Int -> IO ()
|
|
||||||
processBlock pool step bl = do
|
|
||||||
r <-
|
|
||||||
liftIO $
|
|
||||||
makeZebraCall
|
|
||||||
zHost
|
|
||||||
zPort
|
|
||||||
"getblock"
|
|
||||||
[Data.Aeson.String $ showt bl, jsonNumber 1]
|
|
||||||
case r of
|
|
||||||
Left e1 -> sendMsg (ShowError $ showt e1)
|
|
||||||
Right blk -> do
|
|
||||||
r2 <-
|
|
||||||
liftIO $
|
|
||||||
makeZebraCall
|
|
||||||
zHost
|
|
||||||
zPort
|
|
||||||
"getblock"
|
|
||||||
[Data.Aeson.String $ showt bl, jsonNumber 0]
|
|
||||||
case r2 of
|
|
||||||
Left e2 -> sendMsg (ShowError $ showt e2)
|
|
||||||
Right hb -> do
|
|
||||||
let blockTime = getBlockTime hb
|
|
||||||
mapM_ (runNoLoggingT . processTx zHost zPort blockTime pool) $
|
|
||||||
bl_txs $ addTime blk blockTime
|
|
||||||
sendMsg (SyncVal step)
|
|
||||||
addTime :: BlockResponse -> Int -> BlockResponse
|
|
||||||
addTime bl t =
|
|
||||||
BlockResponse
|
|
||||||
(bl_confirmations bl)
|
|
||||||
(bl_height bl)
|
|
||||||
(fromIntegral t)
|
|
||||||
(bl_txs bl)
|
|
||||||
|
|
||||||
sendTransaction ::
|
|
||||||
Config
|
|
||||||
-> ZcashNet
|
|
||||||
-> ZcashAccountId
|
|
||||||
-> Int
|
|
||||||
-> Float
|
|
||||||
-> T.Text
|
|
||||||
-> T.Text
|
|
||||||
-> (AppEvent -> IO ())
|
|
||||||
-> IO ()
|
|
||||||
sendTransaction config znet accId bl amt ua memo sendMsg = do
|
|
||||||
sendMsg $ ShowModal "Preparing transaction..."
|
|
||||||
case parseAddress ua znet of
|
|
||||||
Nothing -> sendMsg $ ShowError "Incorrect address"
|
|
||||||
Just outUA -> do
|
|
||||||
let dbPath = c_dbPath config
|
|
||||||
let zHost = c_zebraHost config
|
|
||||||
let zPort = c_zebraPort config
|
|
||||||
pool <- runNoLoggingT $ initPool dbPath
|
|
||||||
res <-
|
|
||||||
runFileLoggingT "zenith.log" $
|
|
||||||
prepareTx pool zHost zPort znet accId bl amt outUA memo
|
|
||||||
case res of
|
|
||||||
Left e -> sendMsg $ ShowError $ T.pack $ show e
|
|
||||||
Right rawTx -> do
|
|
||||||
sendMsg $ ShowModal "Transaction ready, sending to Zebra..."
|
|
||||||
resp <-
|
|
||||||
makeZebraCall
|
|
||||||
zHost
|
|
||||||
zPort
|
|
||||||
"sendrawtransaction"
|
|
||||||
[Data.Aeson.String $ toText rawTx]
|
|
||||||
case resp of
|
|
||||||
Left e1 -> sendMsg $ ShowError $ "Zebra error: " <> showt e1
|
|
||||||
Right txId -> sendMsg $ ShowTxId txId
|
|
||||||
|
|
||||||
timeTicker :: (AppEvent -> IO ()) -> IO ()
|
|
||||||
timeTicker sendMsg = do
|
|
||||||
sendMsg TickUp
|
|
||||||
threadDelay $ 1000 * 1000
|
|
||||||
timeTicker sendMsg
|
|
||||||
|
|
||||||
txtWrap :: T.Text -> T.Text
|
txtWrap :: T.Text -> T.Text
|
||||||
txtWrap = wrapText (WrapSettings False True NoFill FillAfterFirst) 32
|
txtWrap = wrapText (WrapSettings False True NoFill FillAfterFirst) 32
|
||||||
|
|
||||||
|
@ -1274,14 +948,6 @@ runZenithGUI config = do
|
||||||
if not (null addrList)
|
if not (null addrList)
|
||||||
then getQrCode pool Orchard $ entityKey $ head addrList
|
then getQrCode pool Orchard $ entityKey $ head addrList
|
||||||
else return Nothing
|
else return Nothing
|
||||||
bal <-
|
|
||||||
if not (null accList)
|
|
||||||
then getBalance pool $ entityKey $ head accList
|
|
||||||
else return 0
|
|
||||||
unconfBal <-
|
|
||||||
if not (null accList)
|
|
||||||
then getUnconfirmedBalance pool $ entityKey $ head accList
|
|
||||||
else return 0
|
|
||||||
let model =
|
let model =
|
||||||
AppModel
|
AppModel
|
||||||
config
|
config
|
||||||
|
@ -1296,10 +962,8 @@ runZenithGUI config = do
|
||||||
0
|
0
|
||||||
Nothing
|
Nothing
|
||||||
True
|
True
|
||||||
bal
|
314259000
|
||||||
(if unconfBal == 0
|
(Just 300000)
|
||||||
then Nothing
|
|
||||||
else Just unconfBal)
|
|
||||||
Orchard
|
Orchard
|
||||||
qr
|
qr
|
||||||
False
|
False
|
||||||
|
@ -1318,15 +982,6 @@ runZenithGUI config = do
|
||||||
False
|
False
|
||||||
Nothing
|
Nothing
|
||||||
Nothing
|
Nothing
|
||||||
0
|
|
||||||
1.0
|
|
||||||
False
|
|
||||||
""
|
|
||||||
0.0
|
|
||||||
""
|
|
||||||
False
|
|
||||||
False
|
|
||||||
Nothing
|
|
||||||
startApp model handleEvent buildUI params
|
startApp model handleEvent buildUI params
|
||||||
Left e -> do
|
Left e -> do
|
||||||
initDb dbFilePath
|
initDb dbFilePath
|
||||||
|
@ -1363,15 +1018,6 @@ runZenithGUI config = do
|
||||||
False
|
False
|
||||||
Nothing
|
Nothing
|
||||||
Nothing
|
Nothing
|
||||||
0
|
|
||||||
1.0
|
|
||||||
False
|
|
||||||
""
|
|
||||||
0.0
|
|
||||||
""
|
|
||||||
False
|
|
||||||
False
|
|
||||||
Nothing
|
|
||||||
startApp model handleEvent buildUI params
|
startApp model handleEvent buildUI params
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
|
|
|
@ -64,12 +64,6 @@ zenithTheme =
|
||||||
L.active .
|
L.active .
|
||||||
L.btnMainStyle . L.text ?~
|
L.btnMainStyle . L.text ?~
|
||||||
hiliteTextStyle &
|
hiliteTextStyle &
|
||||||
L.disabled .
|
|
||||||
L.btnMainStyle . L.text ?~
|
|
||||||
hiliteTextStyle &
|
|
||||||
L.disabled .
|
|
||||||
L.btnMainStyle . L.bgColor ?~
|
|
||||||
gray07c &
|
|
||||||
L.basic .
|
L.basic .
|
||||||
L.textFieldStyle . L.text ?~
|
L.textFieldStyle . L.text ?~
|
||||||
baseTextStyle &
|
baseTextStyle &
|
||||||
|
@ -84,36 +78,6 @@ zenithTheme =
|
||||||
baseTextStyle &
|
baseTextStyle &
|
||||||
L.focusHover .
|
L.focusHover .
|
||||||
L.textFieldStyle . L.text ?~
|
L.textFieldStyle . L.text ?~
|
||||||
baseTextStyle &
|
|
||||||
L.basic .
|
|
||||||
L.numericFieldStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.hover .
|
|
||||||
L.numericFieldStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.focus .
|
|
||||||
L.numericFieldStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.active .
|
|
||||||
L.numericFieldStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.focusHover .
|
|
||||||
L.numericFieldStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.basic .
|
|
||||||
L.textAreaStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.hover .
|
|
||||||
L.textAreaStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.focus .
|
|
||||||
L.textAreaStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.active .
|
|
||||||
L.textAreaStyle . L.text ?~
|
|
||||||
baseTextStyle &
|
|
||||||
L.focusHover .
|
|
||||||
L.textAreaStyle . L.text ?~
|
|
||||||
baseTextStyle
|
baseTextStyle
|
||||||
|
|
||||||
zenithThemeColors :: BaseThemeColors
|
zenithThemeColors :: BaseThemeColors
|
||||||
|
|
|
@ -33,13 +33,7 @@ import ZcashHaskell.Types
|
||||||
)
|
)
|
||||||
import ZcashHaskell.Utils (getBlockTime, makeZebraCall, readZebraTransaction)
|
import ZcashHaskell.Utils (getBlockTime, makeZebraCall, readZebraTransaction)
|
||||||
import Zenith.Core (checkBlockChain)
|
import Zenith.Core (checkBlockChain)
|
||||||
import Zenith.DB
|
import Zenith.DB (getMaxBlock, initDb, saveTransaction)
|
||||||
( getMaxBlock
|
|
||||||
, getUnconfirmedBlocks
|
|
||||||
, initDb
|
|
||||||
, saveConfs
|
|
||||||
, saveTransaction
|
|
||||||
)
|
|
||||||
import Zenith.Utils (jsonNumber)
|
import Zenith.Utils (jsonNumber)
|
||||||
|
|
||||||
-- | Function to scan the Zcash blockchain through the Zebra node and populate the Zenith database
|
-- | Function to scan the Zcash blockchain through the Zebra node and populate the Zenith database
|
||||||
|
@ -161,26 +155,3 @@ processTx host port bt pool t = do
|
||||||
(fromRawSBundle $ zt_sBundle rzt)
|
(fromRawSBundle $ zt_sBundle rzt)
|
||||||
(fromRawOBundle $ zt_oBundle rzt)
|
(fromRawOBundle $ zt_oBundle rzt)
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
-- | Function to update unconfirmed transactions
|
|
||||||
updateConfs ::
|
|
||||||
T.Text -- ^ Host name for `zebrad`
|
|
||||||
-> Int -- ^ Port for `zebrad`
|
|
||||||
-> ConnectionPool
|
|
||||||
-> IO ()
|
|
||||||
updateConfs host port pool = do
|
|
||||||
targetBlocks <- getUnconfirmedBlocks pool
|
|
||||||
mapM_ updateTx targetBlocks
|
|
||||||
where
|
|
||||||
updateTx :: Int -> IO ()
|
|
||||||
updateTx b = do
|
|
||||||
r <-
|
|
||||||
makeZebraCall
|
|
||||||
host
|
|
||||||
port
|
|
||||||
"getblock"
|
|
||||||
[Data.Aeson.String $ T.pack $ show b, jsonNumber 1]
|
|
||||||
case r of
|
|
||||||
Left e -> throwIO $ userError e
|
|
||||||
Right blk -> do
|
|
||||||
saveConfs pool b $ fromInteger $ bl_confirmations blk
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ module Zenith.Utils where
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.Functor (void)
|
import Data.Functor (void)
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Ord (clamp)
|
|
||||||
import Data.Scientific (Scientific(..), scientific)
|
import Data.Scientific (Scientific(..), scientific)
|
||||||
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
|
||||||
|
@ -13,17 +12,8 @@ import System.Process (createProcess_, shell)
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import Text.Regex.Posix
|
import Text.Regex.Posix
|
||||||
import ZcashHaskell.Orchard (encodeUnifiedAddress, isValidUnifiedAddress)
|
import ZcashHaskell.Orchard (encodeUnifiedAddress, isValidUnifiedAddress)
|
||||||
import ZcashHaskell.Sapling (decodeSaplingAddress, isValidShieldedAddress)
|
import ZcashHaskell.Sapling (isValidShieldedAddress)
|
||||||
import ZcashHaskell.Transparent
|
import ZcashHaskell.Types (ZcashNet(..))
|
||||||
( decodeExchangeAddress
|
|
||||||
, decodeTransparentAddress
|
|
||||||
)
|
|
||||||
import ZcashHaskell.Types
|
|
||||||
( SaplingAddress(..)
|
|
||||||
, TransparentAddress(..)
|
|
||||||
, UnifiedAddress(..)
|
|
||||||
, ZcashNet(..)
|
|
||||||
)
|
|
||||||
import Zenith.Types
|
import Zenith.Types
|
||||||
( AddressGroup(..)
|
( AddressGroup(..)
|
||||||
, UnifiedAddressDB(..)
|
, UnifiedAddressDB(..)
|
||||||
|
@ -97,34 +87,3 @@ getZenithPath = do
|
||||||
d <- getHomeDirectory
|
d <- getHomeDirectory
|
||||||
let homeDirectory = d
|
let homeDirectory = d
|
||||||
return (homeDirectory ++ "/Zenith/")
|
return (homeDirectory ++ "/Zenith/")
|
||||||
|
|
||||||
-- | Bound a value to the 0..1 range, used for progress reporting on UIs
|
|
||||||
validBarValue :: Float -> Float
|
|
||||||
validBarValue = clamp (0, 1)
|
|
||||||
|
|
||||||
isRecipientValid :: T.Text -> Bool
|
|
||||||
isRecipientValid a =
|
|
||||||
case isValidUnifiedAddress (E.encodeUtf8 a) of
|
|
||||||
Just _a1 -> True
|
|
||||||
Nothing ->
|
|
||||||
isValidShieldedAddress (E.encodeUtf8 a) ||
|
|
||||||
(case decodeTransparentAddress (E.encodeUtf8 a) of
|
|
||||||
Just _a3 -> True
|
|
||||||
Nothing ->
|
|
||||||
case decodeExchangeAddress a of
|
|
||||||
Just _a4 -> True
|
|
||||||
Nothing -> False)
|
|
||||||
|
|
||||||
parseAddress :: T.Text -> ZcashNet -> Maybe UnifiedAddress
|
|
||||||
parseAddress a znet =
|
|
||||||
case isValidUnifiedAddress (E.encodeUtf8 a) of
|
|
||||||
Just a1 -> Just a1
|
|
||||||
Nothing ->
|
|
||||||
case decodeSaplingAddress (E.encodeUtf8 a) of
|
|
||||||
Just a2 ->
|
|
||||||
Just $ UnifiedAddress znet Nothing (Just $ sa_receiver a2) Nothing
|
|
||||||
Nothing ->
|
|
||||||
case decodeTransparentAddress (E.encodeUtf8 a) of
|
|
||||||
Just a3 ->
|
|
||||||
Just $ UnifiedAddress znet Nothing Nothing (Just $ ta_receiver a3)
|
|
||||||
Nothing -> Nothing
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e8074419cfb54559a4c09731ad2448d5930869a2
|
Subproject commit 90c8a7c3028bd6836dea5655221277a25d457653
|
|
@ -1,6 +1,6 @@
|
||||||
cabal-version: 3.0
|
cabal-version: 3.0
|
||||||
name: zenith
|
name: zenith
|
||||||
version: 0.6.0.0-beta
|
version: 0.5.3.0-beta
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Rene Vergara
|
author: Rene Vergara
|
||||||
|
@ -53,7 +53,7 @@ library
|
||||||
, exceptions
|
, exceptions
|
||||||
, monad-logger
|
, monad-logger
|
||||||
, vty-crossplatform
|
, vty-crossplatform
|
||||||
, secp256k1-haskell >= 1
|
, secp256k1-haskell
|
||||||
, pureMD5
|
, pureMD5
|
||||||
, ghc >=9.4.8
|
, ghc >=9.4.8
|
||||||
, haskoin-core
|
, haskoin-core
|
||||||
|
@ -101,7 +101,7 @@ executable zenith
|
||||||
, configurator
|
, configurator
|
||||||
, data-default
|
, data-default
|
||||||
, sort
|
, sort
|
||||||
--, structured-cli
|
, structured-cli
|
||||||
, text
|
, text
|
||||||
, time
|
, time
|
||||||
, zenith
|
, zenith
|
||||||
|
|
Loading…
Reference in a new issue