diff --git a/app/Main.hs b/app/Main.hs index fc62d88..6b5ca16 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -199,14 +199,16 @@ processUri user pwd = main :: IO () main = do - config <- load ["/home/zenith/zenith.cfg"] + config <- load [ "$(HOME)/Zenith/zenith.cfg" ] args <- getArgs - dbFilePath <- require config "dbFilePath" + --dbFilePath <- require config "dbFilePath" nodeUser <- require config "nodeUser" nodePwd <- require config "nodePwd" zebraPort <- require config "zebraPort" zebraHost <- require config "zebraHost" - let myConfig = Config dbFilePath zebraHost zebraPort + dbFP <- getZenithPath + let dbFilePath = dbFP ++ "zenith.db" + let myConfig = Config (T.pack dbFilePath) zebraHost zebraPort if not (null args) then do case head args of @@ -224,7 +226,7 @@ main = do "rescan" -> clearSync myConfig _ -> printUsage else printUsage - + printUsage :: IO () printUsage = do putStrLn "zenith [command] [parameters]\n" diff --git a/cabal.project b/cabal.project index 217198a..d245ac1 100644 --- a/cabal.project +++ b/cabal.project @@ -2,7 +2,7 @@ packages: ./*.cabal zcash-haskell/zcash-haskell.cabal -with-compiler: ghc-9.4.8 +with-compiler: ghc-9.6.5 source-repository-package type: git diff --git a/cabal.project.freeze b/cabal.project.freeze index 3b9c8d2..76e4598 100644 --- a/cabal.project.freeze +++ b/cabal.project.freeze @@ -113,7 +113,7 @@ constraints: any.Cabal ==3.8.1.0, any.foreign-rust ==0.1.0, any.generically ==0.1.1, any.generics-sop ==0.5.1.4, - any.ghc ==9.4.8, + any.ghc ==9.6.5, any.ghc-bignum ==1.3, any.ghc-boot ==9.4.8, any.ghc-boot-th ==9.4.8, diff --git a/docker_files/Dockerfile b/docker_files/Dockerfile deleted file mode 100644 index 27f33a1..0000000 --- a/docker_files/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM ubuntu:22.04 -MAINTAINER Rene V. Vergara A. - -RUN apt update - -RUN apt -y install libxss-dev -RUN apt -y install libxrandr-dev -RUN apt -y install libsecp256k1-dev -RUN apt -y install xclip - -RUN mkdir /home/zenith -RUN useradd -ms /bin/bash zenusr - -COPY bash_rc_adm /root/.bashrc -COPY bash_rc_usr /home/zenusr/.bashrc -COPY zenith /usr/local/bin -COPY librustzcash_wrapper.so /usr/local/lib -COPY sapling-spend.params /usr/local/lib -COPY sapling-output.params /usr/local/lib - -CMD ["/bin/bash"] diff --git a/docker_files/bash_rc_adm b/docker_files/bash_rc_adm deleted file mode 100644 index 3313436..0000000 --- a/docker_files/bash_rc_adm +++ /dev/null @@ -1,100 +0,0 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - -# If not running interactively, don't do anything -[ -z "$PS1" ] && return - -# don't put duplicate lines in the history. See bash(1) for more options -# ... or force ignoredups and ignorespace -HISTCONTROL=ignoredups:ignorespace - -# append to the history file, don't overwrite it -shopt -s histappend - -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - -# set a fancy prompt (non-color, unless we know we "want" color) -case "$TERM" in - xterm-color) color_prompt=yes;; -esac - -# uncomment for a colored prompt, if the terminal has the capability; turned -# off by default to not distract the user: the focus in a terminal window -# should be on the output of commands, not on the prompt -#force_color_prompt=yes - -if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes - else - color_prompt= - fi -fi - -if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' -else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' -fi -unset color_prompt force_color_prompt - -# If this is an xterm set the title to user@host:dir -case "$TERM" in -xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) - ;; -esac - -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Alias definitions. -# You may want to put all your additions into a separate file like -# ~/.bash_aliases, instead of adding them here directly. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. - -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi - -# enable programmable completion features (you don't need to enable -# this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). -#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then -# . /etc/bash_completion -#fi -export LD_LIBRARY_PATH=/usr/local/lib \ No newline at end of file diff --git a/docker_files/bash_rc_usr b/docker_files/bash_rc_usr deleted file mode 100644 index 5538262..0000000 --- a/docker_files/bash_rc_usr +++ /dev/null @@ -1,118 +0,0 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - -# don't put duplicate lines or lines starting with space in the history. -# See bash(1) for more options -HISTCONTROL=ignoreboth - -# append to the history file, don't overwrite it -shopt -s histappend - -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# If set, the pattern "**" used in a pathname expansion context will -# match all files and zero or more directories and subdirectories. -#shopt -s globstar - -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - -# set a fancy prompt (non-color, unless we know we "want" color) -case "$TERM" in - xterm-color|*-256color) color_prompt=yes;; -esac - -# uncomment for a colored prompt, if the terminal has the capability; turned -# off by default to not distract the user: the focus in a terminal window -# should be on the output of commands, not on the prompt -#force_color_prompt=yes - -if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes - else - color_prompt= - fi -fi - -if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' -else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' -fi -unset color_prompt force_color_prompt - -# If this is an xterm set the title to user@host:dir -case "$TERM" in -xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) - ;; -esac - -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# colored GCC warnings and errors -#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Add an "alert" alias for long running commands. Use like so: -# sleep 10; alert -alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' - -# Alias definitions. -# You may want to put all your additions into a separate file like -# ~/.bash_aliases, instead of adding them here directly. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. - -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi - -# enable programmable completion features (you don't need to enable -# this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). -if ! shopt -oq posix; then - if [ -f /usr/share/bash-completion/bash_completion ]; then - . /usr/share/bash-completion/bash_completion - elif [ -f /etc/bash_completion ]; then - . /etc/bash_completion - fi -fi -export LD_LIBRARY_PATH=/usr/local/lib \ No newline at end of file diff --git a/docker_files/runzenith b/docker_files/runzenith deleted file mode 100755 index 9227228..0000000 --- a/docker_files/runzenith +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -ZFOLDER=~/Zenith -IMAGE_NAME=zenith-docker:0.5.3.0 - -# Check if data folder exists -if [ ! -d "$ZFOLDER" ]; then - echo "Error starting Zenith image" - echo "Zenith configurtion and data folder ($ZFOLDER) does not exists." - echo "Aborting process..." - exit -fi - -# Check if the image exists locally -if [[ "$(docker images -q $IMAGE_NAME 2> /dev/null)" == "" ]]; then - echo "Error starting Zenith image" - echo "Image $IMAGE_NAME not found locally." - echo "Aborting process..." - exit -fi - -docker run -it --mount src=$ZFOLDER,target=/home/zenith,type=bind --net=host $IMAGE_NAME - -# End - diff --git a/installer/zenith-0.5.0.3-binary.tar.gz b/installer/zenith-0.5.0.3-binary.tar.gz new file mode 100644 index 0000000..4a562b7 Binary files /dev/null and b/installer/zenith-0.5.0.3-binary.tar.gz differ diff --git a/installer/zenith-0.5.0.3-binary/README.txt b/installer/zenith-0.5.0.3-binary/README.txt new file mode 100644 index 0000000..51ed7ab --- /dev/null +++ b/installer/zenith-0.5.0.3-binary/README.txt @@ -0,0 +1,12 @@ + +Para instalar solo el ejecutable + +1.- Instalar el programa compilado utilizando el siguiente commando + +sudo zeninstall + +2.- Crear los elementos basicos y la configuracion default + +zenconfig + + diff --git a/docker_files/zenith b/installer/zenith-0.5.0.3-binary/bin/zenith similarity index 81% rename from docker_files/zenith rename to installer/zenith-0.5.0.3-binary/bin/zenith index 93d5e1a..2258ca5 100755 Binary files a/docker_files/zenith and b/installer/zenith-0.5.0.3-binary/bin/zenith differ diff --git a/docker_files/zenith.cfg b/installer/zenith-0.5.0.3-binary/cfg/zenith.cfg similarity index 68% rename from docker_files/zenith.cfg rename to installer/zenith-0.5.0.3-binary/cfg/zenith.cfg index df25661..58e2bc4 100644 --- a/docker_files/zenith.cfg +++ b/installer/zenith-0.5.0.3-binary/cfg/zenith.cfg @@ -1,5 +1,5 @@ nodeUser = "user" nodePwd = "superSecret" -dbFilePath = "/home/zenith/zenith.db" +dbFileName = "zenith.db" zebraHost = "127.0.0.1" zebraPort = 18232 diff --git a/docker_files/librustzcash_wrapper.so b/installer/zenith-0.5.0.3-binary/lib/librustzcash_wrapper.so similarity index 100% rename from docker_files/librustzcash_wrapper.so rename to installer/zenith-0.5.0.3-binary/lib/librustzcash_wrapper.so diff --git a/docker_files/sapling-output.params b/installer/zenith-0.5.0.3-binary/lib/sapling-output.params similarity index 100% rename from docker_files/sapling-output.params rename to installer/zenith-0.5.0.3-binary/lib/sapling-output.params diff --git a/docker_files/sapling-spend.params b/installer/zenith-0.5.0.3-binary/lib/sapling-spend.params similarity index 100% rename from docker_files/sapling-spend.params rename to installer/zenith-0.5.0.3-binary/lib/sapling-spend.params diff --git a/installer/zenith-0.5.0.3-binary/zenconfig b/installer/zenith-0.5.0.3-binary/zenconfig new file mode 100755 index 0000000..7ef9086 --- /dev/null +++ b/installer/zenith-0.5.0.3-binary/zenconfig @@ -0,0 +1,29 @@ +#!/bin/bash +echo +echo Zenith Full Node Wallet Config +echo +if [ -d $HOME/Zenith ]; then + echo "Configuration files found, please backup your Zenith folder or" + echo "remove it before trying to configure Zenith again." + echo + exit +else + if [ -f /usr/local/bin/zenith ] && [ -f /usr/local/bin/librustzcash_wrapper.so ]; then + echo "Creating Zenith folder ...." + mkdir -p $HOME/Zenith + echo "Copying default configuration ...." + cp ./cfg/zenith.cfg $HOME/Zenith/ + echo "Configuring library path ...." + if [ ! grep -q "LD_LIBRARY_PATH" "$HOME/.bashrc" ]; then + echo 'export LD_LIBRARY_PATH=/usr/local/lib' | tee -a $HOME/.bashrc + echo "Loading configuration ...." + source $HOME/.bashrc + else + echo "Library path configured ...." + fi + echo "Zenith is ready!!" + else + echo "Please, install Zenith first!!!" + fi + echo +fi diff --git a/installer/zenith-0.5.0.3-binary/zeninstall b/installer/zenith-0.5.0.3-binary/zeninstall new file mode 100755 index 0000000..c333bc1 --- /dev/null +++ b/installer/zenith-0.5.0.3-binary/zeninstall @@ -0,0 +1,28 @@ +#!/bin/bash +echo +echo "Zenith Full Node Wallet Installer (Version 0.5.3.0)" +echo +if [ "$UID" != "0" ]; then + echo "Please run the installer using 'sudo'!!!" + echo + exit +else + echo "Starting zenith installation ...." + echo + echo "Installing dependencies ...." + apt update + apt -y install libxss-dev + apt -y install libxrandr-dev + apt -y install libsecp256k1-dev + apt -y install xclip + apt -y clean + echo + echo "Installing zenith ...." + cp ./bin/zenith /usr/local/bin + cp ./lib/librustzcash_wrapper.so /usr/local/lib + cp ./lib/sapling-spend.params /usr/local/lib + cp ./lib/sapling-output.params /usr/local/lib + echo + echo "Zenith installed !!!" + echo +fi diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index 776642b..fbb9575 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -104,7 +104,7 @@ import Zenith.Types , UnifiedAddressDB(..) , ZcashNetDB(..) ) -import Zenith.Utils (displayTaz, displayZec, jsonNumber, showAddress) +import Zenith.Utils (displayTaz, displayZec, jsonNumber, showAddress, getZenithPath) data Name = WList @@ -1574,9 +1574,11 @@ sendTransaction :: -> IO () sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do BC.writeBChan chan $ TickMsg "Preparing transaction..." + zenithPath <- getZenithPath + let zenithLogPath = ( zenithPath ++ "zenith.log" ) outUA <- parseAddress ua res <- - runFileLoggingT "/home/zenith/zenith.log" $ + runFileLoggingT zenithLogPath $ prepareTx pool zHost zPort znet accId bl amt outUA memo BC.writeBChan chan $ TickMsg "Transaction ready, sending to Zebra..." case res of diff --git a/src/Zenith/Utils.hs b/src/Zenith/Utils.hs index 0f73fc9..0d43a7c 100644 --- a/src/Zenith/Utils.hs +++ b/src/Zenith/Utils.hs @@ -9,6 +9,7 @@ import Data.Scientific (Scientific(..), scientific) import qualified Data.Text as T import qualified Data.Text.Encoding as E import System.Process (createProcess_, shell) +import System.Directory import Text.Regex.Posix import ZcashHaskell.Orchard (encodeUnifiedAddress, isValidUnifiedAddress) import ZcashHaskell.Sapling (isValidShieldedAddress) @@ -72,3 +73,10 @@ copyAddress a = void $ createProcess_ "toClipboard" $ shell $ "echo " ++ T.unpack (addy a) ++ " | xclip -r -selection clipboard" + +-- | Get current user and build zenith path +getZenithPath :: IO String +getZenithPath = do + d <- getHomeDirectory + let homeDirectory = d + return (homeDirectory ++ "/Zenith/") diff --git a/zenith.cabal b/zenith.cabal index c7dedb1..f1796e3 100644 --- a/zenith.cabal +++ b/zenith.cabal @@ -52,7 +52,7 @@ library , vty-crossplatform , secp256k1-haskell , pureMD5 - , ghc + , ghc >=9.6.5 , haskoin-core , hexstring , http-client @@ -77,7 +77,8 @@ library , vty , word-wrap , zcash-haskell - --pkgconfig-depends: rustzcash_wrapper + , directory +--pkgconfig-depends: rustzcash_wrapper default-language: Haskell2010 executable zenith