diff --git a/.gitignore b/.gitignore index a845a7619f..c08baa7ccb 100644 --- a/.gitignore +++ b/.gitignore @@ -113,9 +113,13 @@ contrib/debian/substvars src/rpcmisc~.cpp src/komodo-cli +src/pirate-cli src/komodod +src/pirated src/komodo-tx +src/pirate-tx src/komodo-test +src/pirate-test src/wallet-utility src/komodo-cli.exe src/komodod.exe diff --git a/README.md b/README.md index 0ed523f6cd..c07d4ecece 100644 --- a/README.md +++ b/README.md @@ -44,33 +44,48 @@ sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool libncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libqrencode-dev libdb++-dev ntp ntpdate nano software-properties-common curl libevent-dev libcurl4-gnutls-dev cmake clang libsodium-dev -y ``` -### Build Komodo +### Build Pirate -This software is based on zcash and considered experimental and is continously undergoing heavy development. +This software is based on zcash and considered experimental and is continuously undergoing heavy development. -The dev branch is considered the bleeding edge codebase while the master-branch is considered tested (unit tests, runtime tests, functionality). At no point of time do the Komodo Platform developers take any responsbility for any damage out of the usage of this software. -Komodo builds for all operating systems out of the same codebase. Follow the OS specific instructions from below. +The dev branch is considered the bleeding edge codebase while the master-branch is considered tested (unit tests, runtime tests, functionality). At no point of time do the Pirate developers take any responsibility for any damage out of the usage of this software. +Pirate builds for all operating systems out of the same codebase. Follow the OS specific instructions from below. #### Linux ```shell git clone https://github.com/PirateNetwork/pirate --branch master cd pirate +# This step is not required for when using the Qt GUI ./zcutil/fetch-params.sh + # -j8 = using 8 threads for the compilation - replace 8 with number of threads you want to use; -j$(nproc) for all threads available + +#For CLI binaries ./zcutil/build.sh -j8 -# This can take some time. + +#For qt GUI binaries +./zcutil/build-qt-linux.sh -j8. ``` #### OSX Ensure you have [brew](https://brew.sh) and the command line tools installed (comes automatically with XCode) and run: ```shell -brew update && brew install gcc@6 +brew update +brew upgrade +brew tap discoteq/discoteq; brew install flock +brew install autoconf autogen automake gcc@8 binutilsprotobuf coreutils wget python3 git clone https://github.com/PirateNetwork/pirate --branch master cd pirate +# This step is not required for when using the Qt GUI ./zcutil/fetch-params.sh + # -j8 = using 8 threads for the compilation - replace 8 with number of threads you want to use; -j$(nproc) for all threads available + +#For CLI binaries ./zcutil/build-mac.sh -j8 -#This can take some time. + +#For qt GUI binaries +./zcutil/build-qt-mac.sh -j8 ``` #### Windows @@ -88,19 +103,38 @@ sudo update-alternatives --config x86_64-w64-mingw32-g++ git clone https://github.com/PirateNetwork/pirate --branch master cd pirate +# This step is not required for when using the Qt GUI ./zcutil/fetch-params.sh + # -j8 = using 8 threads for the compilation - replace 8 with number of threads you want to use; -j$(nproc) for all threads available + +#For CLI binaries ./zcutil/build-win.sh -j8 -#This can take some time. + +#For qt GUI binaries +./zcutil/build-qt-win.sh -j8 ``` -**pirate is experimental and a work-in-progress.** Use at your own risk. +**Pirate is experimental and a work-in-progress.** Use at your own risk. + +To run the Pirate GUI wallet: + +**Linux** +`pirate-qt-linux` + +**OSX** +`pirate-qt-mac` + +**Windows** +`pirate-qt-win.exe` + To run the daemon for PirateChain: -`komodod -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1` -both komodod and komodo-cl are located in the src directory after successfully building +`pirated` +both pirated and pirate-cli are located in the src directory after successfully building To reset the PirateChain blockchain change into the *~/.komodo/PIRATE* data directory and delete the corresponding files by running `rm -rf blocks chainstate debug.log komodostate db.log` and restart daemon +To initiate a bootstrap download on the GUI wallet add bootstrap=1 to the PIRATE.conf file. **Pirate is based on Komodo which is unfinished and highly experimental.** Use at your own risk. diff --git a/configure.ac b/configure.ac index a2f6a1bcbe..300c471b73 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) define(_CLIENT_VERSION_MINOR, 1) -define(_CLIENT_VERSION_REVISION, 0) +define(_CLIENT_VERSION_REVISION, 1) define(_CLIENT_VERSION_BUILD, 50) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) @@ -15,10 +15,10 @@ AC_CONFIG_HEADERS([src/config/bitcoin-config.h]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([build-aux/m4]) -BITCOIN_DAEMON_NAME=komodod +BITCOIN_DAEMON_NAME=pirated BITCOIN_GUI_NAME=pirate-qt -BITCOIN_CLI_NAME=komodo-cli -BITCOIN_TX_NAME=komodo-tx +BITCOIN_CLI_NAME=pirate-cli +BITCOIN_TX_NAME=pirate-tx dnl Unless the user specified ARFLAGS, force it to be cr AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to if not set]) @@ -244,7 +244,7 @@ CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS" AC_ARG_WITH([utils], [AS_HELP_STRING([--with-utils], - [build komodo-cli komodo-tx wallet-utility (default=yes)])], + [build pirate-cli pirate-tx wallet-utility (default=yes)])], [build_bitcoin_utils=$withval], [build_bitcoin_utils=yes]) @@ -845,7 +845,7 @@ AC_MSG_CHECKING([whether to build bitcoind]) AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes]) AC_MSG_RESULT($build_bitcoind) -AC_MSG_CHECKING([whether to build utils (komodo-cli komodo-tx wallet-utility)]) +AC_MSG_CHECKING([whether to build utils (pirate-cli pirate-tx wallet-utility)]) AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes]) AC_MSG_RESULT($build_bitcoin_utils) diff --git a/depends/packages/libarchive.mk b/depends/packages/libarchive.mk new file mode 100644 index 0000000000..d6a2873769 --- /dev/null +++ b/depends/packages/libarchive.mk @@ -0,0 +1,49 @@ +package=libarchive +$(package)_version=3.4.1 +$(package)_download_path=https://github.com/libarchive/libarchive/releases/download/v$($(package)_version) +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_download_file=$(package)-$($(package)_version).tar.gz +$(package)_config_opts=--with-sysroot=$(host_prefix)/lib +$(package)_config_opts_linux=--disable-bsdtar --disable-bsdcpio --disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-unknown-linux-gnu +$(package)_config_opts_mingw32=--disable-bsdtar --disable-bsdcpio --disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-w64-mingw32 +$(package)_config_opts_darwin=--disable-bsdtar --disable-bsdcpio --disable-shared --enable-static --prefix=$(host_prefix) +$(package)_sha256_hash=fcf87f3ad8db2e4f74f32526dee62dd1fb9894782b0a503a89c9d7a70a235191 +$(package)_cflags_darwin=-mmacosx-version-min=10.9 +$(package)_conf_tool=./configure + +$(package)_dependencies=zlib + +ifeq ($(build_os),darwin) +define $(package)_set_vars + $(package)_build_env=MACOSX_DEPLOYMENT_TARGET="10.9" +endef +endif + +ifeq ($(build_os),linux) +define $(package)_set_vars + $(package)_config_env=LD_LIBRARY_PATH="$(host_prefix)/lib" PKG_CONFIG_LIBDIR="$(host_prefix)/lib/pkgconfig" CPPFLAGS="-I$(host_prefix)/include" LDFLAGS="-L$(host_prefix)/lib" +endef +endif + + +define $(package)_config_cmds + echo '=== config for $(package):' && \ + echo '$($(package)_config_env) $($(package)_conf_tool) $($(package)_config_opts)' && \ + echo '=== ' && \ + $($(package)_config_env) $($(package)_conf_tool) $($(package)_config_opts) +endef + +ifeq ($(build_os),darwin) +define $(package)_build_cmds + $(MAKE) CPPFLAGS="-I$(host_prefix)/include -fPIC" CFLAGS='-mmacosx-version-min=10.9' +endef +else +define $(package)_build_cmds + $(MAKE) CPPFLAGS="-I$(host_prefix)/include -fPIC" +endef +endif + +define $(package)_stage_cmds + echo 'Staging dir: $($(package)_staging_dir)$(host_prefix)/' && \ + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/libcurl.mk b/depends/packages/libcurl.mk index fd82dc4e0b..d1a3ec1036 100644 --- a/depends/packages/libcurl.mk +++ b/depends/packages/libcurl.mk @@ -1,9 +1,9 @@ package=libcurl -$(package)_version=7.67.0 +$(package)_version=7.74.0 $(package)_dependencies=openssl $(package)_download_path=https://curl.haxx.se/download $(package)_file_name=curl-$($(package)_version).tar.gz -$(package)_sha256_hash=52af3361cf806330b88b4fe6f483b6844209d47ae196ac46da4de59bb361ab02 +$(package)_sha256_hash=e56b3921eeb7a2951959c02db0912b5fcd5fdba5aca071da819e1accf338bbd7 $(package)_config_opts_linux=--disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-unknown-linux-gnu $(package)_config_opts_mingw32=--enable-mingw --disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-w64-mingw32 $(package)_config_opts_darwin=--disable-shared --enable-static --prefix=$(host_prefix) @@ -27,7 +27,7 @@ define $(package)_config_cmds echo '=== config for $(package):' && \ echo '$($(package)_config_env) $($(package)_conf_tool) $($(package)_config_opts)' && \ echo '=== ' && \ - $($(package)_config_env) $($(package)_conf_tool) $($(package)_config_opts) + $($(package)_config_env) $($(package)_conf_tool) $($(package)_config_opts) endef ifeq ($(build_os),darwin) diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 495dac25af..a7afee33b5 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -8,7 +8,7 @@ else endif qt_native_packages = native_protobuf -qt_packages = qrencode protobuf zlib +qt_packages = qrencode protobuf qt_linux_packages:=qt expat libxcb xcb_proto libXau xproto freetype fontconfig qt_android_packages=qt @@ -56,7 +56,7 @@ native_packages := native_ccache wallet_packages=bdb ifeq ($(host_os),linux) - packages := boost openssl libevent zeromq $(zcash_packages) googletest libcurl #googlemock + packages := boost openssl libevent zeromq $(zcash_packages) zlib libarchive googletest libcurl #googlemock else - packages := boost openssl libevent zeromq $(zcash_packages) libcurl googletest #googlemock + packages := boost openssl libevent zeromq $(zcash_packages) zlib libarchive libcurl googletest #googlemock endif diff --git a/makeReleaseMac.sh b/makeReleaseMac.sh index 1f34cfbca4..50c97ac28f 100755 --- a/makeReleaseMac.sh +++ b/makeReleaseMac.sh @@ -1,6 +1,6 @@ #!/bin/sh -PACKAGE_DIR="PirateWallet.app" +PACKAGE_DIR="PirateOcean.app" mkdir ${PACKAGE_DIR} mkdir ${PACKAGE_DIR}/Contents mkdir ${PACKAGE_DIR}/Contents/MacOS @@ -13,8 +13,6 @@ for binary in "${binaries[@]}"; do # do the work in the destination directory cp ${binary} ${PACKAGE_DIR}/Contents/MacOS/ - cp zcutil/res/mac-init.sh ${PACKAGE_DIR}/Contents/MacOS/ - cp zcutil/res/start.sh ${PACKAGE_DIR}/Contents/MacOS/ cp zcutil/res/Info.plist ${PACKAGE_DIR}/Contents/ cp zcutil/res/PkgInfo ${PACKAGE_DIR}/Contents/ cp src/qt/res/icons/pirate.icns ${PACKAGE_DIR}/Contents/Resources/logo.icns @@ -73,4 +71,4 @@ do done -create-dmg --volname "PirateWallet-v3.0.0" --volicon "zcutil/res/logo.icns" --window-pos 200 120 --icon "PirateWallet.app" 200 190 --app-drop-link 600 185 --hide-extension "PirateWallet.app" --window-size 800 400 --hdiutil-quiet --background zcutil/res/dmgbg.png PirateWallet-v3.0.0.dmg PirateWallet.app +create-dmg --volname "pirate-qt-mac" --volicon "zcutil/res/logo.icns" --window-pos 200 120 --icon "PirateOcean.app" 200 190 --app-drop-link 600 185 --hide-extension "PirateOcean.app" --window-size 800 400 --hdiutil-quiet --background zcutil/res/dmgbg.png pirate-qt-mac.dmg PirateOcean.app diff --git a/src/Makefile.am b/src/Makefile.am index 7d0f181bd8..a60e28faaa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,13 +33,13 @@ BITCOIN_INCLUDES += -I$(srcdir)/snark/libsnark BITCOIN_INCLUDES += -I$(srcdir)/univalue/include if TARGET_WINDOWS -LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl +LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl -larchive endif if TARGET_DARWIN -LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl +LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl -larchive endif if TARGET_LINUX -LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl +LIBBITCOIN_SERVER=libbitcoin_server.a -lcurl -larchive endif LIBBITCOIN_WALLET=libbitcoin_wallet.a @@ -122,11 +122,11 @@ noinst_PROGRAMS = TESTS = #if BUILD_BITCOIND - bin_PROGRAMS += komodod + bin_PROGRAMS += pirated #endif if BUILD_BITCOIN_UTILS - bin_PROGRAMS += komodo-cli komodo-tx + bin_PROGRAMS += pirate-cli pirate-tx endif if ENABLE_WALLET bin_PROGRAMS += wallet-utility @@ -212,6 +212,7 @@ BITCOIN_CORE_H = \ netbase.h \ notaries_staked.h \ noui.h \ + params.h \ paymentdisclosure.h \ paymentdisclosuredb.h \ policy/fees.h \ @@ -344,6 +345,7 @@ libbitcoin_server_a_SOURCES = \ notaries_staked.cpp \ noui.cpp \ notarisationdb.cpp \ + params.cpp \ paymentdisclosure.cpp \ paymentdisclosuredb.cpp \ policy/fees.cpp \ @@ -564,16 +566,16 @@ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h # # bitcoind binary # -komodod_SOURCES = bitcoind.cpp -komodod_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -komodod_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -komodod_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +pirated_SOURCES = bitcoind.cpp +pirated_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) +pirated_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +pirated_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) if TARGET_WINDOWS -komodod_SOURCES += bitcoind-res.rc +pirated_SOURCES += bitcoind-res.rc endif -komodod_LDADD = \ +pirated_LDADD = \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_COMMON) \ $(LIBUNIVALUE) \ @@ -591,10 +593,10 @@ komodod_LDADD = \ $(LIBCRYPTOCONDITIONS) if ENABLE_WALLET -komodod_LDADD += $(LIBBITCOIN_WALLET) +pirated_LDADD += $(LIBBITCOIN_WALLET) endif -komodod_LDADD += \ +pirated_LDADD += \ $(BOOST_LIBS) \ $(BDB_LIBS) \ $(SSL_LIBS) \ @@ -611,31 +613,31 @@ komodod_LDADD += \ $(LIBCRYPTOCONDITIONS) # if TARGET_DARWIN -# komodod_LDADD += libcc.dylib $(LIBSECP256K1) +# pirated_LDADD += libcc.dylib $(LIBSECP256K1) # endif # if TARGET_WINDOWS -# komodod_LDADD += libcc.dll $(LIBSECP256K1) +# pirated_LDADD += libcc.dll $(LIBSECP256K1) # endif # if TARGET_LINUX -# komodod_LDADD += libcc.so $(LIBSECP256K1) +# pirated_LDADD += libcc.so $(LIBSECP256K1) # endif if ENABLE_PROTON -komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) +pirated_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) endif # [+] Decker: use static linking for libstdc++.6.dylib, libgomp.1.dylib, libgcc_s.1.dylib if TARGET_DARWIN -komodod_LDFLAGS += -static-libgcc +pirated_LDFLAGS += -static-libgcc endif # bitcoin-cli binary # -komodo_cli_SOURCES = bitcoin-cli.cpp -komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) -komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -komodo_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +pirate_cli_SOURCES = bitcoin-cli.cpp +pirate_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) +pirate_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +pirate_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) if TARGET_DARWIN -komodo_cli_LDFLAGS += -static-libgcc +pirate_cli_LDFLAGS += -static-libgcc endif # wallet-utility binary # @@ -647,10 +649,10 @@ wallet_utility_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) endif if TARGET_WINDOWS -komodo_cli_SOURCES += bitcoin-cli-res.rc +pirate_cli_SOURCES += bitcoin-cli-res.rc endif -komodo_cli_LDADD = \ +pirate_cli_LDADD = \ $(LIBBITCOIN_CLI) \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ @@ -683,17 +685,17 @@ wallet_utility_LDADD = \ endif # zcash-tx binary # -komodo_tx_SOURCES = komodo-tx.cpp -komodo_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -komodo_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -komodo_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +pirate_tx_SOURCES = komodo-tx.cpp +pirate_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) +pirate_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +pirate_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) if TARGET_WINDOWS -komodo_tx_SOURCES += bitcoin-tx-res.rc +pirate_tx_SOURCES += bitcoin-tx-res.rc endif # FIXME: Is libzcash needed for zcash_tx? -komodo_tx_LDADD = \ +pirate_tx_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_UTIL) \ @@ -706,7 +708,7 @@ komodo_tx_LDADD = \ $(LIBZCASH_LIBS) \ $(LIBCRYPTOCONDITIONS) -komodo_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) +pirate_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) # # zcash protocol primitives # @@ -815,6 +817,6 @@ include Makefile.ktest.include #include Makefile.gtest.include endif -#if ENABLE_QT +if ENABLE_QT include Makefile.qt.include -#endif +endif diff --git a/src/Makefile.ktest.include b/src/Makefile.ktest.include index bfbccc196a..961c71a494 100644 --- a/src/Makefile.ktest.include +++ b/src/Makefile.ktest.include @@ -1,8 +1,8 @@ -TESTS += komodo-test -bin_PROGRAMS += komodo-test +TESTS += pirate-test +bin_PROGRAMS += pirate-test # tool for generating our public parameters -komodo_test_SOURCES = \ +pirate_test_SOURCES = \ test-komodo/main.cpp \ test-komodo/testutils.cpp \ test-komodo/test_cryptoconditions.cpp \ @@ -16,8 +16,8 @@ komodo_test_SOURCES = \ test-komodo/test_addrman.cpp \ test-komodo/test_netbase_tests.cpp -komodo_test_CPPFLAGS = $(komodod_CPPFLAGS) +pirate_test_CPPFLAGS = $(pirated_CPPFLAGS) -komodo_test_LDADD = -lgtest $(komodod_LDADD) +pirate_test_LDADD = -lgtest $(pirated_LDADD) -komodo_test_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static +pirate_test_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 544972586a..d92655d6c2 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -96,7 +96,7 @@ static int AppInitRPC(int argc, char* argv[]) // ParseParameters(argc, argv); std:string name; - name = GetArg("-ac_name",""); + name = GetArg("-ac_name","PIRATE"); if ( !name.empty() ) strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); diff --git a/src/init.cpp b/src/init.cpp index 2edd8f39ff..b6ded2fda6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -35,6 +35,7 @@ #include "httprpc.h" #include "key.h" #include "notarisationdb.h" +#include "params.h" #ifdef ENABLE_MINING #include "key_io.h" @@ -401,6 +402,7 @@ std::string HelpMessage(HelpMessageMode mode) // strUsage += HelpMessageOpt("-prune=", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. " // "Warning: Reverting this setting requires re-downloading the entire blockchain. " // "(default: 0 = disable pruning blocks, >%u = target size in MiB to use for block files)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); + strUsage += HelpMessageOpt("-bootstrap", _("Download and install bootstrap on startup")); strUsage += HelpMessageOpt("-reindex", _("Rebuild block chain index from current blk000??.dat files on startup")); #if !defined(WIN32) strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)")); @@ -847,7 +849,7 @@ bool InitSanityCheck(void) static void ZC_LoadParams( - const CChainParams& chainparams + const CChainParams& chainparams, bool verified ) { struct timeval tv_start, tv_end; @@ -876,6 +878,19 @@ static void ZC_LoadParams( return; } + if (!verified) { + if (!checkParams()) { + uiInterface.ThreadSafeMessageBox(strprintf( + _("Network parameters checksums failed:\n" + "%s\n" + "Please restart the wallet to re-download."), + ZC_GetParamsDir()), + "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return; + } + } + LogPrintf("Loading verifying key from %s\n", vk_path.string().c_str()); gettimeofday(&tv_start, 0); @@ -1439,8 +1454,27 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if ( KOMODO_NSPV_FULLNODE ) { // Initialize Zcash circuit parameters - ZC_LoadParams(chainparams); + uiInterface.InitMessage(_("Verifying Params...")); + initalizeMapParam(); + bool paramsVerified = checkParams(); + if(!paramsVerified) { + downloadFiles("Network Params"); + } + if (fRequestShutdown) + { + LogPrintf("Shutdown requested. Exiting.\n"); + return false; + } + + ZC_LoadParams(chainparams, paramsVerified); } + + if (fRequestShutdown) + { + LogPrintf("Shutdown requested. Exiting.\n"); + return false; + } + /* Start the RPC server already. It will be started in "warmup" mode * and not really process calls already (but it will signify connections * that the server is there and will be ready later). Warmup mode will @@ -1633,6 +1667,48 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fReindex = GetBoolArg("-reindex", false); + bool useBootstrap = false; + bool newInstall = GetBoolArg("-bootstrapinstall", false); + if (!boost::filesystem::exists(GetDataDir() / "blocks") || !boost::filesystem::exists(GetDataDir() / "chainstate")) + newInstall = true; + + if (newInstall) { + bool fBoot = uiInterface.ThreadSafeMessageBox( + "\n\n" + _("New install detected.\n\nPress OK to download the blockchain bootstrap."), + "", CClientUIInterface::ICON_INFORMATION | CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL | CClientUIInterface::BTN_OK | CClientUIInterface::BTN_CANCEL); + if (fBoot) { + useBootstrap = true; + } + } + + if (GetBoolArg("-bootstrap", false) && !useBootstrap) { + bool fBoot = uiInterface.ThreadSafeMessageBox( + "\n\n" + _("Bootstrap option detected.\n\nPress OK to download the blockchain bootstrap."), + "", CClientUIInterface::ICON_INFORMATION | CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL | CClientUIInterface::BTN_OK | CClientUIInterface::BTN_CANCEL); + if (fBoot) { + useBootstrap = true; + } + } + + if (useBootstrap) { + fReindex = false; + //wipe transactions from wallet to create a clean slate + OverrideSetArg("-zappwallettxes","2"); + boost::filesystem::remove_all(GetDataDir() / "blocks"); + boost::filesystem::remove_all(GetDataDir() / "chainstate"); + boost::filesystem::remove_all(GetDataDir() / "notarisations"); + boost::filesystem::remove(GetDataDir() / "komodostate"); + boost::filesystem::remove(GetDataDir() / "signedmasks"); + boost::filesystem::remove(GetDataDir() / "komodostate.ind"); + getBootstrap(); + } + + if (fRequestShutdown) + { + LogPrintf("Shutdown requested. Exiting.\n"); + return false; + } + boost::filesystem::create_directories(GetDataDir() / "blocks"); // block tree db settings @@ -1879,10 +1955,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) InitWarning(msg); } else if (nLoadWalletRet == DB_TOO_NEW) - strErrors << _("Error loading wallet.dat: Wallet requires newer version of Komodo") << "\n"; + strErrors << _("Error loading wallet.dat: Wallet requires newer version of Pirate") << "\n"; else if (nLoadWalletRet == DB_NEED_REWRITE) { - strErrors << _("Wallet needed to be rewritten: restart Zcash to complete") << "\n"; + strErrors << _("Wallet needed to be rewritten: restart Pirate to complete") << "\n"; LogPrintf("%s", strErrors.str()); return InitError(strErrors.str()); } @@ -1904,7 +1980,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) pwalletMain = new CWallet(strWalletFile); DBErrors nZapWalletRet = pwalletMain->ZapWalletTx(vWtx); if (nZapWalletRet != DB_LOAD_OK) { - uiInterface.InitMessage(_("Error loading wallet.zero: Wallet corrupted")); + uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted")); return false; } @@ -1918,24 +1994,24 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (nLoadWalletRet != DB_LOAD_OK) { if (nLoadWalletRet == DB_CORRUPT) - strErrors << _("Error loading wallet.zero: Wallet corrupted") << "\n"; + strErrors << _("Error loading wallet.dat: Wallet corrupted") << "\n"; else if (nLoadWalletRet == DB_NONCRITICAL_ERROR) { - string msg(_("Warning: error reading wallet.zero! All keys read correctly, but transaction data" + string msg(_("Warning: error reading wallet.dat! All keys read correctly, but transaction data" " or address book entries might be missing or incorrect.")); InitWarning(msg); } else if (nLoadWalletRet == DB_TOO_NEW) - strErrors << _("Error loading wallet.zero: Wallet requires newer version of Bitcoin Core") << "\n"; + strErrors << _("Error loading wallet.dat: Wallet requires newer version of Pirate") << "\n"; else if (nLoadWalletRet == DB_NEED_REWRITE) { - strErrors << _("Wallet needed to be rewritten: restart Zero to complete") << "\n"; + strErrors << _("Wallet needed to be rewritten: restart Pirate to complete") << "\n"; LogPrintf("%s", strErrors.str()); return InitError(strErrors.str()); } else - strErrors << _("Error loading wallet.zero") << "\n"; + strErrors << _("Error loading wallet.dat") << "\n"; } } @@ -2005,6 +2081,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (fFirstRun) { + useBootstrap = false; // Create new keyUser and set as default key CPubKey newDefaultKey; if (pwalletMain->GetKeyFromPool(newDefaultKey)) { @@ -2022,7 +2099,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) RegisterValidationInterface(pwalletMain); CBlockIndex *pindexRescan = chainActive.Tip(); - if (clearWitnessCaches || GetBoolArg("-rescan", false) || !fInitializeArcTx) + if (clearWitnessCaches || GetBoolArg("-rescan", false) || !fInitializeArcTx || useBootstrap) { pwalletMain->ClearNoteWitnessCache(); pindexRescan = chainActive.Genesis(); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 586e9fa67f..79c60ebcf7 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1431,6 +1431,7 @@ void komodo_configfile(char *symbol,uint16_t rpcport) fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nrpcworkqueue=256\nrpcallowip=127.0.0.1\nrpcbind=127.0.0.1\n",crc,password,rpcport); fclose(fp); printf("Created (%s)\n",fname); + SoftSetArg("-bootstrapinstall", std::string("1")); } else printf("Couldnt create (%s)\n",fname); #endif } @@ -1750,12 +1751,6 @@ void komodo_args(char *argv0) SoftSetArg("-ac_private", std::string("1")); SoftSetArg("-ac_halving", std::string("77777")); - SoftSetArg("-consolidation", std::string("1")); - SoftSetArg("-deletetx", std::string("1")); - SoftSetArg("-deleteinterval", std::string("1")); - SoftSetArg("-keeptxnum", std::string("10")); - SoftSetArg("-keeptxfornblocks", std::string("100")); - SoftSetArg("-addnode", std::string("zero.kolo.supernet.org")); vector PIRATEnodes = { "136.243.58.134","209.250.227.29","195.201.230.227","159.89.45.197","67.207.94.69","178.63.77.56","94.45.155.6","195.93.180.221","51.83.3.42","45.76.232.40","139.99.208.174" }; mapMultiArgs["-addnode"] = PIRATEnodes; diff --git a/src/params.cpp b/src/params.cpp new file mode 100644 index 0000000000..f61f48e11c --- /dev/null +++ b/src/params.cpp @@ -0,0 +1,440 @@ + +#include "params.h" +#include "ui_interface.h" + +std::map mapParams; + +void sha256_hash_string (unsigned char hash[SHA256_DIGEST_LENGTH], char outputBuffer[65]) +{ + int i = 0; + + for(i = 0; i < SHA256_DIGEST_LENGTH; i++) + { + sprintf(outputBuffer + (i * 2), "%02x", hash[i]); + } + + outputBuffer[64] = 0; +} + +int sha256_file(const char *path, char outputBuffer[65]) +{ + errno = 0; + FILE *file = fopen(path, "rb"); + if (!file) { + return -534; + } + + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX sha256; + SHA256_Init(&sha256); + const int bufSize = 32768; + unsigned char *buffer = (unsigned char *)malloc(bufSize); + int bytesRead = 0; + if(!buffer) return ENOMEM; + while((bytesRead = fread(buffer, 1, bufSize, file))) + { + SHA256_Update(&sha256, buffer, bytesRead); + } + SHA256_Final(hash, &sha256); + + sha256_hash_string(hash, outputBuffer); + fclose(file); + free(buffer); + return 0; +} + + +bool checkParams() { + bool allVerified = true; + for (std::map::iterator it = mapParams.begin(); it != mapParams.end(); ++it) { + std::string uiMessage = "Verifying " + it->second.name + "...."; + uiInterface.InitMessage(_(uiMessage.c_str())); + const char *path = it->second.path.string().c_str(); + char calc_hash[65]; + sha256_file(path ,calc_hash); + if (calc_hash == it->second.hash) { + it->second.verified = true; + } else { + allVerified = false; + } + } + return allVerified; +} + + +static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) +{ + size_t written = fwrite(ptr, size, nmemb, (FILE *)stream); + return written; +} + + + +static int xferinfo(void *p, + curl_off_t dltotal, curl_off_t dlnow, + curl_off_t ultotal, curl_off_t ulnow) +{ + struct CurlProgress *myp = (struct CurlProgress *)p; + CURL *curl = myp->curl; + TIMETYPE curtime = 0; + + char *url = NULL; + curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url); + + std::map::iterator mi = mapParams.find(url); + if (mi != mapParams.end()) { + mi->second.dlnow = dlnow; + mi->second.dltotal = dltotal; + } + + return 0; +} + +void initalizeMapParamBootstrap() { + mapParams.clear(); + + ParamFile bootFile; + bootFile.name = "bootstrap"; + bootFile.URL = "http://bootstrap.dexstats.info/ARRR-bootstrap.tar.gz"; + bootFile.verified = false; + bootFile.path = GetDataDir() / "ARRR-bootstrap.tar.gz"; + bootFile.dlnow = 0; + bootFile.dltotal = 0; + mapParams[bootFile.URL] = bootFile; + +} + + +void initalizeMapParam() { + + mapParams.clear(); + + ParamFile pkFile; + pkFile.name = "sprout-proving.key"; + pkFile.URL = PK_URL; + pkFile.hash = PK_SHA256; + pkFile.verified = false; + pkFile.path = ZC_GetParamsDir() / "sprout-proving.key"; + pkFile.dlnow = 0; + pkFile.dltotal = 0; + mapParams[pkFile.URL] = pkFile; + + ParamFile vkFile; + vkFile.name = "sprout-verifying.key"; + vkFile.URL = VK_URL; + vkFile.hash = VK_SHA256; + vkFile.verified = false; + vkFile.path = ZC_GetParamsDir() / "sprout-verifying.key"; + vkFile.dlnow = 0; + vkFile.dltotal = 0; + mapParams[vkFile.URL] = vkFile; + + ParamFile spendFile; + spendFile.name = "sapling-spend.params"; + spendFile.URL = SAPLING_SPEND_URL; + spendFile.hash = SAPLING_SPEND_SHA256; + spendFile.verified = false; + spendFile.path = ZC_GetParamsDir() / "sapling-spend.params"; + spendFile.dlnow = 0; + spendFile.dltotal = 0; + mapParams[spendFile.URL] = spendFile; + + ParamFile outputFile; + outputFile.name = "sapling-output.params"; + outputFile.URL = SAPLING_OUTPUT_URL; + outputFile.hash = SAPLING_OUTPUT_SHA256; + outputFile.verified = false; + outputFile.path = ZC_GetParamsDir() / "sapling-output.params"; + outputFile.dlnow = 0; + outputFile.dltotal = 0; + mapParams[outputFile.URL] = outputFile; + + ParamFile groth16File; + groth16File.name = "sprout-groth16.params"; + groth16File.URL = SPROUT_GROTH16_URL; + groth16File.hash = SPROUT_GROTH16_SHA256; + groth16File.verified = false; + groth16File.path = ZC_GetParamsDir() / "sprout-groth16.params"; + groth16File.dlnow = 0; + groth16File.dltotal = 0; + mapParams[groth16File.URL] = groth16File; + +} + +bool downloadFiles(std::string title) +{ + + bool downloadComplete = true; + curl_global_init(CURL_GLOBAL_ALL); + CURLM *multi_handle; + multi_handle = curl_multi_init(); + int still_running = 0; /* keep number of running handles */ + + if (!exists(ZC_GetParamsDir())) { + create_directory(ZC_GetParamsDir()); + } + + for (std::map::iterator it = mapParams.begin(); it != mapParams.end(); ++it) { + + if (!it->second.verified) { + /* init the curl session */ + it->second.curl = curl_easy_init(); + if(it->second.curl) { + it->second.prog.lastruntime = 0; + it->second.prog.curl = it->second.curl; + } + + //open file for writing + const char *path = it->second.path.string().c_str(); + it->second.file = fopen(path, "wb"); + if (!it->second.file) { + return false; + } + + curl_easy_setopt(it->second.curl, CURLOPT_URL, it->second.URL.c_str()); + curl_easy_setopt(it->second.curl, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(it->second.curl, CURLOPT_SSL_VERIFYHOST, 0L); + curl_easy_setopt(it->second.curl, CURLOPT_VERBOSE, 0L); + curl_easy_setopt(it->second.curl, CURLOPT_XFERINFOFUNCTION, xferinfo); + curl_easy_setopt(it->second.curl, CURLOPT_XFERINFODATA, &it->second.prog); + curl_easy_setopt(it->second.curl, CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt(it->second.curl, CURLOPT_WRITEFUNCTION, write_data); + curl_easy_setopt(it->second.curl, CURLOPT_WRITEDATA, it->second.file); + curl_multi_add_handle(multi_handle, it->second.curl); + } + } + + + curl_multi_perform(multi_handle, &still_running); + + std::string uiMessage; + uiMessage = "Downloading " + title + "......0.00%"; + uiInterface.InitMessage(_(uiMessage.c_str())); + int64_t nNow = GetTime(); + + while(still_running) { + boost::this_thread::interruption_point(); + + if (ShutdownRequested()) { + downloadComplete = false; + break; + } + + if (GetTime() >= nNow + 1) { + nNow = GetTime(); + int64_t dltotal = 0; + int64_t dlnow = 0; + for (std::map::iterator it = mapParams.begin(); it != mapParams.end(); ++it) { + if (!it->second.verified) { + dltotal += it->second.dltotal; + dlnow += it->second.dlnow; + } + } + double pert = 0.00; + if (dltotal > 0) { + pert = (dlnow / (double)dltotal) * 100; + } + uiMessage = "Downloading " + title + "......" + std::to_string(pert).substr(0,10) + "%"; + uiInterface.InitMessage(_(uiMessage.c_str())); + } + + + struct timeval timeout; + int rc; /* select() return code */ + CURLMcode mc; /* curl_multi_fdset() return code */ + + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + int maxfd = -1; + + long curl_timeo = -1; + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + /* set a suitable timeout to play around with */ + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + curl_multi_timeout(multi_handle, &curl_timeo); + if(curl_timeo >= 0) { + timeout.tv_sec = curl_timeo / 1000; + if(timeout.tv_sec > 1) + timeout.tv_sec = 1; + else + timeout.tv_usec = (curl_timeo % 1000) * 1000; + } + + /* get file descriptors from the transfers */ + mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); + + if(mc != CURLM_OK) { + fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); + downloadComplete = false; + break; + } + + /* On success the value of maxfd is guaranteed to be >= -1. We call + select(maxfd + 1, ...); specially in case of (maxfd == -1) there are + no fds ready yet so we call select(0, ...) --or Sleep() on Windows-- + to sleep 100ms, which is the minimum suggested value in the + curl_multi_fdset() doc. */ + + if(maxfd == -1) { +#ifdef _WIN32 + Sleep(100); + rc = 0; +#else + /* Portable sleep for platforms other than Windows. */ + struct timeval wait = { 0, 100 * 1000 }; /* 100ms */ + rc = select(0, NULL, NULL, NULL, &wait); +#endif + } + else { + /* Note that on some platforms 'timeout' may be modified by select(). + If you need access to the original value save a copy beforehand. */ + rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout); + } + + switch(rc) { + case -1: + downloadComplete = false; + break; + case 0: + default: + /* timeout or readable/writable sockets */ + curl_multi_perform(multi_handle, &still_running); + break; + } + } + + + for (std::map::iterator it = mapParams.begin(); it != mapParams.end(); ++it) { + if (!it->second.verified) { + fclose(it->second.file); + curl_easy_cleanup(it->second.curl); + } + } + + curl_multi_cleanup(multi_handle); + curl_global_cleanup(); + + return downloadComplete; +} + + +void getBootstrap() { + initalizeMapParamBootstrap(); + bool dlsuccess = downloadFiles("Bootstrap"); + + for (std::map::iterator it = mapParams.begin(); it != mapParams.end(); ++it) { + const char *path = it->second.path.string().c_str(); + if (dlsuccess) { + extract(path); + } + if (boost::filesystem::exists(it->second.path.string())) { + boost::filesystem::remove(it->second.path.string()); + } + } +} + + +bool extract(const char *filename) { + + bool extractComplete = true; + struct archive *a; + struct archive *ext; + struct archive_entry *entry; + int r; + + int flags = ARCHIVE_EXTRACT_TIME; + flags |= ARCHIVE_EXTRACT_PERM; + flags |= ARCHIVE_EXTRACT_ACL; + flags |= ARCHIVE_EXTRACT_FFLAGS; + + a = archive_read_new(); + ext = archive_write_disk_new(); + archive_write_disk_set_options(ext, flags); + archive_write_disk_set_standard_lookup(ext); + + if (archive_read_support_format_tar(a) != ARCHIVE_OK) + extractComplete = false; + + if (archive_read_support_filter_gzip(a) != ARCHIVE_OK) + extractComplete = false; + + if (filename != NULL && strcmp(filename, "-") == 0) + filename = NULL; + + r = archive_read_open_filename(a, filename, 10240); + if (r != ARCHIVE_OK) { + LogPrintf("archive_read_open_filename() %s %d\n",archive_error_string(a), r); + extractComplete = false; + } + + if (extractComplete) { + for (;;) { + r = archive_read_next_header(a, &entry); + if (r == ARCHIVE_EOF) { + break; + } + if (r != ARCHIVE_OK) { + LogPrintf("archive_read_next_header() %s %d\n",archive_error_string(a), r); + extractComplete = false; + } + + const char* currentFile = archive_entry_pathname(entry); + std::string path = GetDataDir().string() + "/" + currentFile; + std::string uiMessage = "Extracting Bootstrap file "; + uiMessage.append(currentFile); + uiInterface.InitMessage(_(uiMessage.c_str())); + archive_entry_set_pathname(entry, path.c_str()); + r = archive_write_header(ext, entry); + if (r != ARCHIVE_OK) { + LogPrintf("archive_write_header() %s %d\n",archive_error_string(ext), r); + extractComplete = false; + } else { + copy_data(a, ext); + r = archive_write_finish_entry(ext); + if (r != ARCHIVE_OK) { + LogPrintf("archive_write_finish_entry() %s %d\n",archive_error_string(ext), r); + extractComplete = false; + } + } + } + } + + archive_read_close(a); + archive_read_free(a); + + archive_write_close(ext); + archive_write_free(ext); + + return extractComplete; +} + + +static int copy_data(struct archive *ar, struct archive *aw) { + int r; + const void *buff; + size_t size; + int64_t offset; + + for (;;) { + r = archive_read_data_block(ar, &buff, &size, &offset); + + if (r == ARCHIVE_EOF) + return (ARCHIVE_OK); + + if (r != ARCHIVE_OK) + return (r); + + r = archive_write_data_block(aw, buff, size, offset); + if (r != ARCHIVE_OK) { + LogPrintf("archive_write_data_block() %s\n",archive_error_string(aw)); + return (r); + } + } +} diff --git a/src/params.h b/src/params.h new file mode 100644 index 0000000000..1d50f85661 --- /dev/null +++ b/src/params.h @@ -0,0 +1,83 @@ +#ifndef BITCOIN_PARAMS_H +#define BITCOIN_PARAMS_H + + +#include "init.h" +#include "util.h" + +#include +#include +#include +#include +#include +#include + +/* somewhat unix-specific */ +#include +#include + +/* curl stuff */ +#include + +#include +#include + +#include +#include + +#define TIME_IN_US 1 +#define TIMETYPE curl_off_t +#define TIMEOPT CURLINFO_TOTAL_TIME_T +#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000 + +static const std::string PK_SHA256 = "8bc20a7f013b2b58970cddd2e7ea028975c88ae7ceb9259a5344a16bc2c0eef7"; +static const std::string VK_SHA256 = "4bd498dae0aacfd8e98dc306338d017d9c08dd0918ead18172bd0aec2fc5df82"; +static const std::string SAPLING_SPEND_SHA256 = "8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13"; +static const std::string SAPLING_OUTPUT_SHA256 = "2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4"; +static const std::string SPROUT_GROTH16_SHA256 = "b685d700c60328498fbde589c8c7c484c722b788b265b72af448a5bf0ee55b50"; + +static const std::string PK_URL = "https://download.z.cash/downloads/sprout-proving.key"; +static const std::string VK_URL = "https://download.z.cash/downloads/sprout-verifying.key"; +static const std::string SAPLING_SPEND_URL = "https://download.z.cash/downloads/sapling-spend.params"; +static const std::string SAPLING_OUTPUT_URL = "https://download.z.cash/downloads/sapling-output.params"; +static const std::string SPROUT_GROTH16_URL = "https://download.z.cash/downloads/sprout-groth16.params"; + + + + + +struct CurlProgress { + TIMETYPE lastruntime; /* type depends on version, see above */ + CURL *curl; +}; + + +struct ParamFile { + std::string name; + std::string URL; + std::string hash; + bool verified; + boost::filesystem::path path; + FILE *file; + int64_t dlnow; + int64_t dltotal; + CURL *curl; + CurlProgress prog; +}; + + + +extern std::map mapParams; + +extern bool checkParams(); +extern void initalizeMapParamBootstrap(); +extern void initalizeMapParam(); +static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream); +extern bool downloadFiles(std::string title); +extern void getBootstrap(); +static bool extract(const char *filename); +static int copy_data(struct archive *ar, struct archive *aw); + +static int verbose = 0; + +#endif // BITCOIN_PARAMS_H diff --git a/src/pirate-cli b/src/pirate-cli deleted file mode 100644 index b30e4e0eee..0000000000 --- a/src/pirate-cli +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# Copyright (c) 2019 PirateChain - no rights reserved - -# set working directory to the location of this script -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR - -NAME=PIRATE - -CLI=${KOMODOCLI:-./komodo-cli} -$CLI -ac_name=$NAME "$@" diff --git a/src/pirated b/src/pirated deleted file mode 100644 index fd7a8eaeb9..0000000000 --- a/src/pirated +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# Copyright (c) 2019 PirateChain - no rights reserved - -# set working directory to the location of this script -DIR="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )" -cd $DIR - -NAME=PIRATE - -# Chain parameters - -SUPPLY=0 -REWARD=25600000000 -HALVING=77777 -PRIVATE=1 -SEEDNODE=136.243.102.225 - -# Full speed ahead -KMD=${KOMODOD:-./komodod} -$KMD -ac_name=$NAME \ - -ac_supply=$SUPPLY \ - -ac_reward=$REWARD \ - -ac_halving=$HALVING \ - -ac_private=$PRIVATE \ - -addnode=$SEEDNODE "$@" diff --git a/src/pirated.bat b/src/pirated.bat deleted file mode 100644 index 0d021a826d..0000000000 --- a/src/pirated.bat +++ /dev/null @@ -1,10 +0,0 @@ -@call :GET_CURRENT_DIR -@cd %THIS_DIR% -komodod.exe -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=178.63.77.56 %1 %2 %3 %4 %5 %6 %7 %8 %9 -@goto :EOF - -:GET_CURRENT_DIR -@pushd %~dp0 -@set THIS_DIR=%CD% -@popd -@goto :EOF diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 5d70e9f161..20c62b0549 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -50,7 +50,7 @@ static const int MAX_URI_LENGTH = 255; #define QAPP_ORG_NAME "Pirate Chain" #define QAPP_ORG_DOMAIN "pirate.black" -#define QAPP_APP_NAME_DEFAULT "Pirate Wallet" -#define QAPP_APP_NAME_TESTNET "Pirate Wallet Testnet" +#define QAPP_APP_NAME_DEFAULT "Pirate Ocean" +#define QAPP_APP_NAME_TESTNET "Pirate Ocean Testnet" #endif // KOMODO_QT_GUICONSTANTS_H diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 6f974d252a..284f1df70d 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -9,6 +9,7 @@ #include "timedata.h" #include "main.h" #include "wallet/wallet.h" +#include "wallet/rpcpiratewallet.h" #include "key_io.h" #include @@ -29,139 +30,152 @@ bool TransactionRecord::showTransaction(const CWalletTx &wtx) /* * Decompose CWallet transaction to model transaction records. */ -QList TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx) +QList TransactionRecord::decomposeTransaction(const RpcArcTransaction &arcTx) { QList parts; - int64_t nTime = wtx.GetTxTime(); - CAmount nCredit = wtx.GetCredit(ISMINE_ALL); - CAmount nDebit = wtx.GetDebit(ISMINE_ALL); - CAmount nNet = nCredit - nDebit; - uint256 hash = wtx.GetHash(); - std::map mapValue = wtx.mapValue; - - if (nNet > 0 || wtx.IsCoinBase()) - { - // - // Credit - // - for(unsigned int i = 0; i < wtx.vout.size(); i++) - { - const CTxOut& txout = wtx.vout[i]; - isminetype mine = wallet->IsMine(txout); - if(mine) - { - TransactionRecord sub(hash, nTime); - CTxDestination address; - sub.idx = i; // vout index - sub.credit = txout.nValue; - sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; - if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address)) - { - // Received by Komodo Address - sub.type = TransactionRecord::RecvWithAddress; - sub.address = EncodeDestination(address); - } - else - { - // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction - sub.type = TransactionRecord::RecvFromOther; - sub.address = mapValue["from"]; - } - if (wtx.IsCoinBase()) - { - // Generated - sub.type = TransactionRecord::Generated; - } - - parts.append(sub); + QList partsChange; + + if (arcTx.spentFrom.size() > 0) { + + for (int i = 0; i < arcTx.vTSend.size(); i++) { + auto tx = TransactionRecord(); + tx.archiveType = arcTx.archiveType; + tx.hash = arcTx.txid; + tx.time = arcTx.nTime; + tx.address = arcTx.vTSend[i].encodedAddress; + tx.debit = arcTx.vTSend[i].amount; + tx.idx = arcTx.vTSend[i].vout; + + bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vTSend[i].encodedAddress) != arcTx.spentFrom.end(); + if (change) { + tx.type = TransactionRecord::SendToSelf; + partsChange.append(tx); + } else { + tx.type = TransactionRecord::SendToAddress; + parts.append(tx); } } - } - else - { - bool involvesWatchAddress = false; - isminetype fAllFromMe = ISMINE_SPENDABLE; - for (const CTxIn& txin : wtx.vin) - { - isminetype mine = wallet->IsMine(txin); - if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; - if(fAllFromMe > mine) fAllFromMe = mine; + + + CAmount sproutValueReceived = 0; + for (int i = 0; i < arcTx.vZcReceived.size(); i++) { + sproutValueReceived += arcTx.vZcReceived[i].amount; + auto tx = TransactionRecord(); + tx.archiveType = arcTx.archiveType; + tx.hash = arcTx.txid; + tx.time = arcTx.nTime; + tx.address = arcTx.vZcReceived[i].encodedAddress; + tx.credit = -arcTx.vZcReceived[i].amount; + tx.idx = arcTx.vZcReceived[i].jsOutIndex; + + bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZcReceived[i].encodedAddress) != arcTx.spentFrom.end(); + if (change) { + tx.type = TransactionRecord::SendToSelf; + partsChange.append(tx); + } else { + tx.type = TransactionRecord::SendToAddress; + parts.append(tx); + } } - isminetype fAllToMe = ISMINE_SPENDABLE; - for (const CTxOut& txout : wtx.vout) - { - isminetype mine = wallet->IsMine(txout); - if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; - if(fAllToMe > mine) fAllToMe = mine; + if (arcTx.sproutValue - arcTx.sproutValueSpent - sproutValueReceived != 0) { + auto tx = TransactionRecord(); + tx.archiveType = arcTx.archiveType; + tx.hash = arcTx.txid; + tx.time = arcTx.nTime; + tx.address = "Private Sprout Address"; + tx.credit = -arcTx.sproutValue - arcTx.sproutValueSpent; + tx.type = TransactionRecord::SendToAddress; + parts.append(tx); } - if (fAllFromMe && fAllToMe) - { - // Payment to self - CAmount nChange = wtx.GetChange(); + for (int i = 0; i < arcTx.vZsSend.size(); i++) { + auto tx = TransactionRecord(); + tx.archiveType = arcTx.archiveType; + tx.hash = arcTx.txid; + tx.time = arcTx.nTime; + tx.address = arcTx.vZsSend[i].encodedAddress; + tx.credit = -arcTx.vZsSend[i].amount; + tx.idx = arcTx.vZsSend[i].shieldedOutputIndex; - parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "", - -(nDebit - nChange), nCredit - nChange)); - parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to TransactionRecord as constructor argument + bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZsSend[i].encodedAddress) != arcTx.spentFrom.end(); + if (change) { + tx.type = TransactionRecord::SendToSelf; + partsChange.append(tx); + } else { + tx.type = TransactionRecord::SendToAddress; + parts.append(tx); + } } - else if (fAllFromMe) - { - // - // Debit - // - CAmount nTxFee = nDebit - wtx.GetValueOut(); + } - for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++) - { - const CTxOut& txout = wtx.vout[nOut]; - TransactionRecord sub(hash, nTime); - sub.idx = nOut; - sub.involvesWatchAddress = involvesWatchAddress; - - if(wallet->IsMine(txout)) - { - // Ignore parts sent to self, as this is usually the change - // from a transaction sent back to our own address. - continue; - } - - CTxDestination address; - if (ExtractDestination(txout.scriptPubKey, address)) - { - // Sent to Komodo Address - sub.type = TransactionRecord::SendToAddress; - sub.address = EncodeDestination(address); - } - else - { - // Sent to IP, or other non-address transaction like OP_EVAL - sub.type = TransactionRecord::SendToOther; - sub.address = mapValue["to"]; - } - - CAmount nValue = txout.nValue; - /* Add fee to first output */ - if (nTxFee > 0) - { - nValue += nTxFee; - nTxFee = 0; - } - sub.debit = -nValue; - - parts.append(sub); + + for (int i = 0; i < arcTx.vTReceived.size(); i++) { + auto tx = TransactionRecord(); + tx.archiveType = arcTx.archiveType; + tx.hash = arcTx.txid; + tx.time = arcTx.nTime; + tx.address = arcTx.vTReceived[i].encodedAddress; + tx.debit = arcTx.vTReceived[i].amount; + tx.idx = arcTx.vTReceived[i].vout; + + bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vTReceived[i].encodedAddress) != arcTx.spentFrom.end(); + if (change) { + tx.type = TransactionRecord::SendToSelf; + partsChange.append(tx); + } else { + if (arcTx.coinbase) { + tx.type = TransactionRecord::Generated; + } else { + tx.type = TransactionRecord::RecvWithAddress; } + parts.append(tx); } - else - { - // - // Mixed debit transaction, can't break down payees - // - parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0)); - parts.last().involvesWatchAddress = involvesWatchAddress; + } + + + for (int i = 0; i < arcTx.vZcReceived.size(); i++) { + auto tx = TransactionRecord(); + tx.archiveType = arcTx.archiveType; + tx.hash = arcTx.txid; + tx.time = arcTx.nTime; + tx.address = arcTx.vZcReceived[i].encodedAddress; + tx.debit = arcTx.vZcReceived[i].amount; + tx.idx = arcTx.vZcReceived[i].jsOutIndex; + + bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZcReceived[i].encodedAddress) != arcTx.spentFrom.end(); + if (change) { + tx.type = TransactionRecord::SendToSelf; + partsChange.append(tx); + } else { + tx.type = TransactionRecord::RecvWithAddress; + parts.append(tx); + } + } + + for (int i = 0; i < arcTx.vZsReceived.size(); i++) { + auto tx = TransactionRecord(); + tx.archiveType = arcTx.archiveType; + tx.hash = arcTx.txid; + tx.time = arcTx.nTime; + tx.address = arcTx.vZsReceived[i].encodedAddress; + tx.debit = arcTx.vZsReceived[i].amount; + tx.idx = arcTx.vZsReceived[i].shieldedOutputIndex; + + bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZsReceived[i].encodedAddress) != arcTx.spentFrom.end(); + if (change) { + tx.type = TransactionRecord::SendToSelf; + partsChange.append(tx); + } else { + tx.type = TransactionRecord::RecvWithAddress; + parts.append(tx); } } + if (parts.size() == 0) { + parts.append(partsChange); + } + return parts; } diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index 65da48f85e..1d6dabe2bd 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -13,6 +13,7 @@ class CWallet; class CWalletTx; +class RpcArcTransaction; /** UI model for transaction status. The transaction status is the part of a transaction that will change over time. */ @@ -107,7 +108,7 @@ class TransactionRecord /** Decompose CWallet transaction to model transaction records. */ static bool showTransaction(const CWalletTx &wtx); - static QList decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx); + static QList decomposeTransaction(const RpcArcTransaction &arcTx); /** @name Immutable transaction attributes @{*/ diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index d2c8f583eb..a750eb0097 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -161,131 +161,7 @@ class TransactionTablePriv } - if (arcTx.spentFrom.size() > 0) { - - for (int i = 0; i < arcTx.vTSend.size(); i++) { - auto tx = TransactionRecord(); - tx.archiveType = arcTx.archiveType; - tx.hash = arcTx.txid; - tx.time = arcTx.nTime; - tx.address = arcTx.vTSend[i].encodedAddress; - tx.debit = arcTx.vTSend[i].amount; - tx.idx = arcTx.vTSend[i].vout; - - bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vTSend[i].encodedAddress) != arcTx.spentFrom.end(); - if (change) { - tx.type = TransactionRecord::SendToSelf; - } else { - tx.type = TransactionRecord::SendToAddress; - } - cachedWallet.append(tx); - } - - - CAmount sproutValueReceived = 0; - for (int i = 0; i < arcTx.vZcReceived.size(); i++) { - sproutValueReceived += arcTx.vZcReceived[i].amount; - auto tx = TransactionRecord(); - tx.archiveType = arcTx.archiveType; - tx.hash = arcTx.txid; - tx.time = arcTx.nTime; - tx.address = arcTx.vZcReceived[i].encodedAddress; - tx.credit = -arcTx.vZcReceived[i].amount; - tx.idx = arcTx.vZcReceived[i].jsOutIndex; - - bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZcReceived[i].encodedAddress) != arcTx.spentFrom.end(); - if (change) { - tx.type = TransactionRecord::SendToSelf; - } else { - tx.type = TransactionRecord::SendToAddress; - } - cachedWallet.append(tx); - } - - if (arcTx.sproutValue - arcTx.sproutValueSpent - sproutValueReceived != 0) { - auto tx = TransactionRecord(); - tx.archiveType = arcTx.archiveType; - tx.hash = arcTx.txid; - tx.time = arcTx.nTime; - tx.address = "Private Sprout Address"; - tx.credit = -arcTx.sproutValue - arcTx.sproutValueSpent; - tx.type = TransactionRecord::SendToAddress; - cachedWallet.append(tx); - } - - for (int i = 0; i < arcTx.vZsSend.size(); i++) { - auto tx = TransactionRecord(); - tx.archiveType = arcTx.archiveType; - tx.hash = arcTx.txid; - tx.time = arcTx.nTime; - tx.address = arcTx.vZsSend[i].encodedAddress; - tx.credit = -arcTx.vZsSend[i].amount; - tx.idx = arcTx.vZsSend[i].shieldedOutputIndex; - - bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZsSend[i].encodedAddress) != arcTx.spentFrom.end(); - if (change) { - tx.type = TransactionRecord::SendToSelf; - } else { - tx.type = TransactionRecord::SendToAddress; - } - cachedWallet.append(tx); - } - } - - for (int i = 0; i < arcTx.vTReceived.size(); i++) { - auto tx = TransactionRecord(); - tx.archiveType = arcTx.archiveType; - tx.hash = arcTx.txid; - tx.time = arcTx.nTime; - tx.address = arcTx.vTReceived[i].encodedAddress; - tx.debit = arcTx.vTReceived[i].amount; - tx.idx = arcTx.vTReceived[i].vout; - - bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vTReceived[i].encodedAddress) != arcTx.spentFrom.end(); - if (change) { - tx.type = TransactionRecord::SendToSelf; - } else { - tx.type = TransactionRecord::RecvWithAddress; - } - cachedWallet.append(tx); - } - - - for (int i = 0; i < arcTx.vZcReceived.size(); i++) { - auto tx = TransactionRecord(); - tx.archiveType = arcTx.archiveType; - tx.hash = arcTx.txid; - tx.time = arcTx.nTime; - tx.address = arcTx.vZcReceived[i].encodedAddress; - tx.debit = arcTx.vZcReceived[i].amount; - tx.idx = arcTx.vZcReceived[i].jsOutIndex; - - bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZcReceived[i].encodedAddress) != arcTx.spentFrom.end(); - if (change) { - tx.type = TransactionRecord::SendToSelf; - } else { - tx.type = TransactionRecord::RecvWithAddress; - } - cachedWallet.append(tx); - } - - for (int i = 0; i < arcTx.vZsReceived.size(); i++) { - auto tx = TransactionRecord(); - tx.archiveType = arcTx.archiveType; - tx.hash = arcTx.txid; - tx.time = arcTx.nTime; - tx.address = arcTx.vZsReceived[i].encodedAddress; - tx.debit = arcTx.vZsReceived[i].amount; - tx.idx = arcTx.vZsReceived[i].shieldedOutputIndex; - - bool change = arcTx.spentFrom.size() > 0 && arcTx.spentFrom.find(arcTx.vZsReceived[i].encodedAddress) != arcTx.spentFrom.end(); - if (change) { - tx.type = TransactionRecord::SendToSelf; - } else { - tx.type = TransactionRecord::RecvWithAddress; - } - cachedWallet.append(tx); - } + cachedWallet.append(TransactionRecord::decomposeTransaction(arcTx)); if (cachedWallet.size() >= 200) break; } @@ -334,15 +210,45 @@ class TransactionTablePriv { LOCK2(cs_main, wallet->cs_wallet); // Find transaction in wallet + bool isActiveTx = false; + bool isArchiveTx = false; + RpcArcTransaction arcTx; + bool fIncludeWatchonly = true; + + //get Ovks for sapling decryption + std::vector ovks; + getAllSaplingOVKs(ovks, fIncludeWatchonly); + + //get Ivks for sapling decryption + std::vector ivks; + getAllSaplingIVKs(ivks, fIncludeWatchonly); + + //Try mapWallet first std::map::iterator mi = wallet->mapWallet.find(hash); - if(mi == wallet->mapWallet.end()) - { + if(mi != wallet->mapWallet.end()) { + isActiveTx = true; + CWalletTx& wtx = wallet->mapWallet[hash]; + getRpcArcTx(wtx, arcTx, ivks, ovks, fIncludeWatchonly); + } + + //Try ArcTx is nor found in mapWallet + if (!isActiveTx) { + std::map::iterator ami = wallet->mapArcTxs.find(hash); + if(ami != wallet->mapArcTxs.end()) { + isArchiveTx = true; + uint256 txid = hash; + getRpcArcTx(txid, arcTx, ivks, ovks, fIncludeWatchonly); + } + } + + if (!isActiveTx && !isArchiveTx) { qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet"; break; } + // Added -- insert at the right position QList toInsert = - TransactionRecord::decomposeTransaction(wallet, mi->second); + TransactionRecord::decomposeTransaction(arcTx); if(!toInsert.isEmpty()) /* only if something to insert */ { parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1); @@ -476,7 +382,6 @@ void TransactionTableModel::updateTransaction(const QString &hash, int status, b updated.SetHex(hash.toStdString()); priv->updateWallet(updated, status, showTransaction); - priv->refreshWallet(); //Fix decompose transaction to remove } void TransactionTableModel::updateConfirmations() @@ -580,7 +485,7 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const switch(wtx->type) { case TransactionRecord::RecvWithAddress: - return tr("Received from"); + return tr("Received with"); case TransactionRecord::RecvFromOther: return tr("Received from"); case TransactionRecord::SendToAddress: diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 923fa2fb03..0e81eca27c 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -214,10 +214,10 @@ static const CRPCConvertParam vRPCConvertParams[] = { "getsaplingblocks", 1}, { "getsaplingblocks", 2}, - { "z_createbuildinstuctions", 0 }, - { "z_createbuildinstuctions", 1 }, - { "z_createbuildinstuctions", 2 }, - { "z_createbuildinstuctions", 3 } + { "z_createbuildinstructions", 0 }, + { "z_createbuildinstructions", 1 }, + { "z_createbuildinstructions", 2 }, + { "z_createbuildinstructions", 3 } }; class CRPCConvertTable diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index e0f811163c..d7afc6ea1a 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1577,11 +1577,11 @@ UniValue z_buildrawtransaction(const UniValue& params, bool fHelp, const CPubKey } -UniValue z_createbuildinstuctions(const UniValue& params, bool fHelp, const CPubKey& mypk) +UniValue z_createbuildinstructions(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (fHelp) throw runtime_error( - "z_createbuildinstuctions \n" + "z_createbuildinstructions \n" "\nExamples:\n" "\nArguments:\n" @@ -1608,7 +1608,7 @@ UniValue z_createbuildinstuctions(const UniValue& params, bool fHelp, const CPub "\"transaction\" (string) hex string of the transaction\n" - + HelpExampleCli("z_createbuildinstuctions", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"index\\\":0\\\"type\\\":\\\"sapling\\\"},...]\"") + + HelpExampleCli("z_createbuildinstructions", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"index\\\":0\\\"type\\\":\\\"sapling\\\"},...]\"") ); LOCK(cs_main); @@ -1787,7 +1787,7 @@ static const CRPCCommand commands[] = { "rawtransactions", "sendrawtransaction", &sendrawtransaction, false }, { "rawtransactions", "signrawtransaction", &signrawtransaction, false }, /* uses wallet if enabled */ - { "rawtransactions", "z_createbuildinstuctions", &z_createbuildinstuctions, true }, /* uses wallet if enabled */ + { "rawtransactions", "z_createbuildinstructions", &z_createbuildinstructions, true }, /* uses wallet if enabled */ { "rawtransactions", "z_buildrawtransaction", &z_buildrawtransaction, false }, /* uses wallet if enabled */ { "blockchain", "gettxoutproof", &gettxoutproof, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index ad1a45e8ad..c11778890c 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -444,7 +444,7 @@ extern UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPu extern UniValue gettxoutproof(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue verifytxoutproof(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue z_createbuildinstuctions(const UniValue& params, bool fHelp, const CPubKey& mypk); +extern UniValue z_createbuildinstructions(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue z_buildrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getblockcount(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcblockchain.cpp diff --git a/src/util.cpp b/src/util.cpp index 987335cb7a..51b1b47db6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -481,6 +481,11 @@ bool IsArgSet(const std::string& strArg) return mapArgs.count(strArg); } +void OverrideSetArg(const std::string& strArg, const std::string& strValue) +{ + mapArgs[strArg] = strValue; +} + bool SoftSetArg(const std::string& strArg, const std::string& strValue) { if (mapArgs.count(strArg)) diff --git a/src/util.h b/src/util.h index 6ed4fd5921..66ff7c9658 100644 --- a/src/util.h +++ b/src/util.h @@ -225,6 +225,14 @@ bool GetBoolArg(const std::string& strArg, bool fDefault); */ bool IsArgSet(const std::string& strArg); +/** + * Set an argument even if it already has a value + * + * @param strArg Argument to set (e.g. "-foo") + * @param strValue Value (e.g. "1") + */ +void OverrideSetArg(const std::string& strArg, const std::string& strValue); + /** * Set an argument if it doesn't already have a value * diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8d310ef81e..d15d41d255 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -413,6 +413,9 @@ bool CWallet::LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &meta) bool CWallet::LoadZKeyMetadata(const SproutPaymentAddress &addr, const CKeyMetadata &meta) { AssertLockHeld(cs_wallet); // mapSproutZKeyMetadata + if (meta.nCreateTime && (!nTimeFirstKey || meta.nCreateTime < nTimeFirstKey)) + nTimeFirstKey = meta.nCreateTime; + mapSproutZKeyMetadata[addr] = meta; return true; } @@ -437,6 +440,13 @@ bool CWallet::LoadCryptedSaplingZKey( bool CWallet::LoadSaplingZKeyMetadata(const libzcash::SaplingIncomingViewingKey &ivk, const CKeyMetadata &meta) { AssertLockHeld(cs_wallet); // mapSaplingZKeyMetadata + if (meta.nCreateTime && (!nTimeFirstKey || meta.nCreateTime < nTimeFirstKey)) + nTimeFirstKey = meta.nCreateTime; + + if (meta.seedFp == uint256()) { + nTimeFirstKey = 1; + } + mapSaplingZKeyMetadata[ivk] = meta; return true; } @@ -633,7 +643,6 @@ void CWallet::ChainTip(const CBlockIndex *pindex, SaplingMerkleTree saplingTree, bool added) { - LOCK2(cs_main, cs_wallet); if (added) { // Prevent witness cache building && consolidation transactions @@ -1211,6 +1220,7 @@ int CWallet::SaplingWitnessMinimumHeight(const uint256& nullifier, int nWitnessH int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessOnly) { + LOCK2(cs_main, cs_wallet); int nWitnessTxIncrement = 0; int nWitnessTotalTxCount = mapWallet.size(); @@ -1218,7 +1228,6 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO bool walletHasNotes = false; //Use to enable z_sendmany when no notes are present for (std::pair& wtxItem : mapWallet) { - boost::this_thread::interruption_point(); nWitnessTxIncrement += 1; @@ -1420,6 +1429,7 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly) { + LOCK2(cs_main, cs_wallet); int startHeight = VerifyAndSetInitialWitness(pindex, witnessOnly) + 1; @@ -1439,8 +1449,6 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly) while (pblockindex) { - boost::this_thread::interruption_point(); - if (pblockindex->GetHeight() % 100 == 0 && pblockindex->GetHeight() < height - 5) { LogPrintf("Building Witnesses for block %i %.4f complete\n", pblockindex->GetHeight(), pblockindex->GetHeight() / double(height)); } @@ -1955,7 +1963,7 @@ void CWallet::UpdateNullifierNoteMapForBlock(const CBlock *pblock) { } } -bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb) +bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb, bool fRescan) { uint256 hash = wtxIn.GetHash(); @@ -2057,16 +2065,18 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : "")); // Write to disk and update tx archive map - if (fInsertedNew || fUpdated) + if (fInsertedNew || fUpdated) { AddToArcTxs(hash, ArchiveTxPoint(wtx.hashBlock, wtx.nIndex)); if (!wtx.WriteToDisk(pwalletdb)) return false; + } // Break debit/credit balance caches: wtx.MarkDirty(); // Notify UI of new or updated transaction - NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); + if (!fRescan) + NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); // notify an external script when a wallet transaction comes in or is updated std::string strCmd = GetArg("-walletnotify", ""); @@ -2123,7 +2133,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) * pblock is optional, but should be provided if the transaction is known to be in a block. * If fUpdate is true, existing transactions will be updated. */ -bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) +bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fRescan) { { AssertLockHeld(cs_wallet); @@ -2202,7 +2212,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl // this is safe, as in case of a crash, we rescan the necessary blocks on startup through our SetBestChain-mechanism CWalletDB walletdb(strWalletFile, "r+", false); - return AddToWallet(wtx, false, &walletdb); + return AddToWallet(wtx, false, &walletdb, fRescan); } } return false; @@ -3261,6 +3271,7 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, */ void CWallet::ReorderWalletTransactions(std::map, CWalletTx> &mapSorted, int64_t &maxOrderPos) { + LOCK2(cs_main, cs_wallet); int maxSortNumber = chainActive.Tip()->GetHeight() + 1; @@ -3286,6 +3297,7 @@ void CWallet::ReorderWalletTransactions(std::map, CWalletTx> */ void CWallet::UpdateWalletTransactionOrder(std::map, CWalletTx> &mapSorted, bool resetOrder) { + LOCK2(cs_main, cs_wallet); int64_t previousPosition = 0; std::map mapUpdatedTxs; @@ -3325,6 +3337,7 @@ void CWallet::UpdateWalletTransactionOrder(std::map, CWalletT * Delete transactions from the Wallet */ void CWallet::DeleteTransactions(std::vector &removeTxs) { + LOCK(cs_wallet); CWalletDB walletdb(strWalletFile, "r+", false); @@ -3341,6 +3354,8 @@ void CWallet::DeleteTransactions(std::vector &removeTxs) { void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { + LOCK2(cs_main, cs_wallet); + int nDeleteAfter = (int)fDeleteTransactionsAfterNBlocks; bool runCompact = false; auto startTime = GetTime(); @@ -3366,14 +3381,13 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { if (maxOrderPos > int64_t(mapSorted.size())*10) { //reset the postion when the max postion is 10x bigger than the //number of transactions in the wallet - LogPrint("deletetx","Reorder Tx - maxOrderPos %i mapSorted Size %i\n", maxOrderPos, int64_t(mapSorted.size())*10); UpdateWalletTransactionOrder(mapSorted, true); } else { UpdateWalletTransactionOrder(mapSorted, false); } auto reorderTime = GetTime(); - LogPrintf("Delete Tx - Time to Reorder %s\n", DateTimeStrFormat("%H:%M:%S", reorderTime-startTime)); + LogPrint("deletetx","Delete Tx - Time to Reorder %s\n", DateTimeStrFormat("%H:%M:%S", reorderTime-startTime)); //Process Transactions in sorted order int txConflictCount = 0; @@ -3396,14 +3410,12 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { txUnConfirmed++; if (wtxDepth < nDeleteAfter && wtxDepth >= 0) { - LogPrint("deletetx","DeleteTx - Transaction above minimum depth, tx %s\n", wtx.GetHash().ToString()); deleteTx = false; txSaveCount++; continue; } else if (wtxDepth == -1) { //Enabled by default if (!fTxConflictDeleteEnabled) { - LogPrint("deletetx","DeleteTx - Conflict delete is not enabled tx %s\n", wtx.GetHash().ToString()); deleteTx = false; txSaveCount++; continue; @@ -3416,7 +3428,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { for (auto & pair : wtx.mapSaplingNoteData) { SaplingNoteData nd = pair.second; if (!nd.nullifier || pwalletMain->GetSaplingSpendDepth(*nd.nullifier) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent sapling input tx %s\n", wtx.GetHash().ToString()); deleteTx = false; continue; } @@ -3434,7 +3445,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { const uint256& parentHash = pwalletMain->mapSaplingNullifiersToNotes[spendDesc.nullifier].hash; const CWalletTx* parent = pwalletMain->GetWalletTx(parentHash); if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of sapling tx %s found\n", wtx.GetHash().ToString()); deleteTx = false; continue; } @@ -3450,7 +3460,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { for (auto & pair : wtx.mapSproutNoteData) { SproutNoteData nd = pair.second; if (!nd.nullifier || pwalletMain->GetSproutSpendDepth(*nd.nullifier) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent sprout input tx %s\n", wtx.GetHash().ToString()); deleteTx = false; continue; } @@ -3470,7 +3479,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { const uint256& parentHash = pwalletMain->mapSproutNullifiersToNotes[nullifier].hash; const CWalletTx* parent = pwalletMain->GetWalletTx(parentHash); if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of sprout tx %s found\n", wtx.GetHash().ToString()); deleteTx = false; continue; } @@ -3489,7 +3497,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { ExtractDestination(wtx.vout[i].scriptPubKey, address); if(IsMine(wtx.vout[i])) { if (pwalletMain->GetSpendDepth(wtx.GetHash(), i) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent transparent input tx %s\n", wtx.GetHash().ToString()); deleteTx = false; continue; } @@ -3507,7 +3514,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { const uint256& parentHash = txin.prevout.hash; const CWalletTx* parent = pwalletMain->GetWalletTx(txin.prevout.hash); if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of transparent tx %s found\n", wtx.GetHash().ToString()); deleteTx = false; continue; } @@ -3520,7 +3526,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { //Keep Last N Transactions if (mapSorted.size() - txCount < fKeepLastNTransactions + txConflictCount + txUnConfirmed) { - LogPrint("deletetx","DeleteTx - Transaction set position %i, tx %s\n", mapSorted.size() - txCount, wtxid.ToString()); deleteTx = false; txSaveCount++; continue; @@ -3531,28 +3536,27 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { if (deleteTx && int(removeTxs.size()) < MAX_DELETE_TX_SIZE) { removeTxs.push_back(wtxid); runCompact = true; + } else { + break; //no need to continue with the loop } } auto selectTime = GetTime(); - LogPrintf("Delete Tx - Time to Select %s\n", DateTimeStrFormat("%H:%M:%S", selectTime - reorderTime)); + LogPrint("deletetx","Delete Tx - Time to Select %s\n", DateTimeStrFormat("%H:%M:%S", selectTime - reorderTime)); //Delete Transactions from wallet DeleteTransactions(removeTxs); auto deleteTime = GetTime(); - LogPrintf("Delete Tx - Time to Delete %s\n", DateTimeStrFormat("%H:%M:%S", deleteTime - selectTime)); + LogPrint("deletetx","Delete Tx - Time to Delete %s\n", DateTimeStrFormat("%H:%M:%S", deleteTime - selectTime)); + LogPrint("deletetx","Delete Tx - Total Transaction Count %i, Transactions Deleted %i\n ", txCount, int(removeTxs.size())); - LogPrintf("Delete Tx - Total Transaction Count %i, Transactions Deleted %i\n ", txCount, int(removeTxs.size())); - // if (GetBoolArg("-deletetx", true)) - // uiInterface.InitMessage(_(("Rescanning - Current Wallet Transaction Count " + std::to_string(txCount)).c_str()) + ((" " + std::to_string(scanperc)).c_str()) + ("%")); - //Compress Wallet if (runCompact) CWalletDB::Compact(bitdb,strWalletFile); } auto totalTime = GetTime(); - LogPrintf("Delete Tx - Time to Run Total Function %s\n", DateTimeStrFormat("%H:%M:%S", totalTime - startTime)); + LogPrint("deletetx","Delete Tx - Time to Run Total Function %s\n", DateTimeStrFormat("%H:%M:%S", totalTime - startTime)); } @@ -3587,9 +3591,23 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate, b CBlockIndex* pindex = pindexStart; + std::set txList; + std::set txListOriginal; + { LOCK2(cs_main, cs_wallet); + //Get List of current list of txids + for (map::iterator it = pwalletMain->mapArcTxs.begin(); it != pwalletMain->mapArcTxs.end(); ++it) + { + txListOriginal.insert((*it).first); + } + for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + if (txListOriginal.count((*it).first)) + txListOriginal.insert((*it).first); + } + // no need to read and scan block, if block was created before // our wallet birthday (as adjusted for block time variability) while (!fIgnoreBirthday && pindex && nTimeFirstKey && (pindex->GetBlockTime() < (nTimeFirstKey - 7200))) @@ -3606,11 +3624,15 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate, b uiInterface.ShowProgress(_(("Rescanning - Currently on block " + std::to_string(pindex->GetHeight()) + "...").c_str()), std::max(1, std::min(99, scanperc)), false); uiInterface.InitMessage(_(("Rescanning - Currently on block " + std::to_string(pindex->GetHeight())).c_str()) + ((" " + std::to_string(scanperc)).c_str()) + ("%")); } + + bool blockInvolvesMe = false; CBlock block; ReadBlockFromDisk(block, pindex,1); BOOST_FOREACH(CTransaction& tx, block.vtx) { - if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) { + if (AddToWalletIfInvolvingMe(tx, &block, fUpdate, true)) { + blockInvolvesMe = true; + txList.insert(tx.GetHash()); ret++; } } @@ -3627,11 +3649,12 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate, b } // Build inital witness caches - BuildWitnessCache(pindex, true); + if (blockInvolvesMe) + BuildWitnessCache(pindex, true); //Delete Transactions if (pindex->GetHeight() % fDeleteInterval == 0) - DeleteWalletTransactions(pindex); + DeleteWalletTransactions(pindex); if (GetTime() >= nNow + 60) { nNow = GetTime(); @@ -3644,6 +3667,13 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate, b uiInterface.ShowProgress(_("Rescanning..."), 100, false); // hide progress dialog in GUI } + + for (set::iterator it = txList.begin(); it != txList.end(); ++it) + { + bool fInsertedNew = (txListOriginal.count(*it) == 0); + NotifyTransactionChanged(this, *it, fInsertedNew ? CT_NEW : CT_UPDATED); + } + return ret; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 3e800a541c..fc47d433ef 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -101,7 +101,7 @@ extern unsigned int WITNESS_CACHE_SIZE; static const size_t HD_WALLET_SEED_LENGTH = 32; //Default Transaction Rentention N-BLOCKS -static const int DEFAULT_TX_DELETE_INTERVAL = 1000; +static const int DEFAULT_TX_DELETE_INTERVAL = 10000; //Default Transaction Rentention N-BLOCKS static const unsigned int DEFAULT_TX_RETENTION_BLOCKS = 10000; @@ -1228,11 +1228,11 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface void UpdateSproutNullifierNoteMapWithTx(CWalletTx& wtx); void UpdateSaplingNullifierNoteMapWithTx(CWalletTx& wtx); void UpdateNullifierNoteMapForBlock(const CBlock* pblock); - bool AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb); + bool AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb, bool fRescan = false); void EraseFromWallet(const uint256 &hash); void SyncTransaction(const CTransaction& tx, const CBlock* pblock); void RescanWallet(); - bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate); + bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fRescan = false); void WitnessNoteCommitment( std::vector commitments, std::vector>& witnesses, diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index 3b95a41c92..81bbed3706 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -42,13 +42,6 @@ PREFIX="$(pwd)/depends/$TRIPLET" make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 -#BUILD CCLIB -# WD=$PWD -# cd src/cc -# echo $PWD -# ./makecustom -# cd $WD - ./autogen.sh CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \ CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc\@8/8.3.0/include/c++/8.3.0/ -I$PREFIX/include -fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \ diff --git a/zcutil/build-qt-linux.sh b/zcutil/build-qt-linux.sh index 1811eb2c53..85333a7360 100755 --- a/zcutil/build-qt-linux.sh +++ b/zcutil/build-qt-linux.sh @@ -97,20 +97,8 @@ PREFIX="$(pwd)/depends/$BUILD/" HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh -#CONFIG_SITE="$PWD/depends/$HOST/share/config.site" -#--disable-shared --with-pic - -#./configure --prefix="${PREFIX}" --disable-bip70 --with-gui=qt5 --enable-tests=no --enable-wallet=yes "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g0 -O2' ./configure --prefix="${PREFIX}" --with-gui=qt5 --disable-bip70 --enable-tests=no --enable-wallet=yes "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g0 -O2' -### don't used here, bcz we have cclib static built-in in libbitcoin_server_a -#BUILD CCLIB -#WD=$PWD -#cd src/cc -#echo $PWD -#./makecustom -#cd $WD - "$MAKE" "$@" V=1 cp src/qt/komodo-qt ./pirate-qt-linux diff --git a/zcutil/build-qt-mac.sh b/zcutil/build-qt-mac.sh index 6f724550de..db151cea77 100755 --- a/zcutil/build-qt-mac.sh +++ b/zcutil/build-qt-mac.sh @@ -43,13 +43,6 @@ PREFIX="$(pwd)/depends/$TRIPLET" make "$@" -C ./depends/ V=1 # NO_PROTON=1 -### don't used here, bcz we have cclib static built-in in libbitcoin_server_a -#BUILD CCLIB -#WD=$PWD -#cd src/cc -#echo $PWD -#./makecustom -#cd $WD ./autogen.sh @@ -62,12 +55,6 @@ CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -W CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc\@8/8.3.0/include/c++/8.3.0/ '"-I${PREFIX}/include"' -fwrapv -fno-strict-aliasing -g0 -O2 -Wl,-undefined -Wl,dynamic_lookup' \ ./configure --prefix="${PREFIX}" --disable-bip70 --with-gui=qt5 --enable-tests=no "$HARDENING_ARG" "$LCOV_ARG" -# here we need a small hacks, bcz QT_QPA_PLATFORM_COCOA and QT_STATICPLUGIN still have -# incorect values after configure (TODO: fix it) - -# sed -i -e "s/\/\* #undef QT_QPA_PLATFORM_COCOA \*\//#define QT_QPA_PLATFORM_COCOA 1/" src/config/bitcoin-config.h -# sed -i -e "s/\/\* #undef QT_STATICPLUGIN \*\//#define QT_STATICPLUGIN 1/" src/config/bitcoin-config.h - make "$@" V=1 NO_GTEST=1 STATIC=1 cp src/qt/komodo-qt "$mydir"/pirate-qt-mac diff --git a/zcutil/build-qt-win.sh b/zcutil/build-qt-win.sh index 91beca8c0e..111e777470 100755 --- a/zcutil/build-qt-win.sh +++ b/zcutil/build-qt-win.sh @@ -12,12 +12,6 @@ cd "$(dirname "$(readlink -f "$0")")/.." cd depends/ && make HOST=$HOST V=1 cd ../ -# WD=$PWD -# cd src/cc -# echo $PWD -# ./makecustom -# cd $WD - ./autogen.sh CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site \ diff --git a/zcutil/build-win-dtest.sh b/zcutil/build-win-dtest.sh index 00a64de5bf..fbeec15ee8 100755 --- a/zcutil/build-win-dtest.sh +++ b/zcutil/build-win-dtest.sh @@ -21,4 +21,4 @@ cd $WD CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" CPPFLAGS=-DTESTMODE ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure cd src/ -CC="${CC} -g " CXX="${CXX} -g " make V=1 komodod.exe komodo-cli.exe komodo-tx.exe +CC="${CC} -g " CXX="${CXX} -g " make V=1 pirated.exe pirate-cli.exe pirate-tx.exe diff --git a/zcutil/build-win.sh b/zcutil/build-win.sh index f0ee8fae2c..4fe25f7a79 100755 --- a/zcutil/build-win.sh +++ b/zcutil/build-win.sh @@ -12,14 +12,8 @@ cd "$(dirname "$(readlink -f "$0")")/.." cd depends/ && make HOST=$HOST V=1 NO_QT=1 cd ../ -# WD=$PWD -# cd src/cc -# echo $PWD -# ./makecustom -# cd $WD - ./autogen.sh CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure cd src/ -CC="${CC} -g " CXX="${CXX} -g " make V=1 komodod.exe komodo-cli.exe komodo-tx.exe +CC="${CC} -g " CXX="${CXX} -g " make V=1 pirated.exe pirate-cli.exe pirate-tx.exe diff --git a/zcutil/build.sh b/zcutil/build.sh index 2addb6d98d..ece3f2f311 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -101,11 +101,4 @@ HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" "$CONFIGURE_FLAGS" CXXFLAGS='-g' -# #BUILD CCLIB -# WD=$PWD -# cd src/cc -# echo $PWD -# ./makecustom -# cd $WD - "$MAKE" "$@" V=1 diff --git a/zcutil/res/Info.plist b/zcutil/res/Info.plist index d2267eff87..d00b95751f 100644 --- a/zcutil/res/Info.plist +++ b/zcutil/res/Info.plist @@ -5,15 +5,15 @@ CFBundleDevelopmentRegion en CFBundleExecutable - start.sh + pirate-qt-mac CFBundleIconFile logo.icns CFBundleIdentifier - org.pirate.piratwallet + org.pirate.pirateocean CFBundleInfoDictionaryVersion 6.0 CFBundleName - PirateWallet + PirateOcean CFBundlePackageType APPL CFBundleShortVersionString diff --git a/zcutil/res/SIGNATURES_README b/zcutil/res/SIGNATURES_README index 603e23428e..c3ff80b350 100644 --- a/zcutil/res/SIGNATURES_README +++ b/zcutil/res/SIGNATURES_README @@ -1,12 +1,12 @@ -This directory contains the hashes and signatures for ZeroWallet +This directory contains the hashes and signatures for pirate Verify the hashes by running: sha256sum -c sha256sum-vX.Y.Z.txt Verify signatures: 1. First, import the public key (Available on GitHub - at https://github.com/zerocurrencycoin/zerowallet/blob/master/public_key.asc) + at https://github.com/piratenetwork/pirate/blob/master/public_key.asc) gpg --import public_key.asc -2. Verify signature +2. Verify signature gpg --verify diff --git a/zcutil/res/mac-init.sh b/zcutil/res/mac-init.sh deleted file mode 100755 index 3dd902f1fe..0000000000 --- a/zcutil/res/mac-init.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/bin/bash - -set -eu - -if [[ "$OSTYPE" == "darwin"* ]]; then - PARAMS_DIR="$HOME/Library/Application Support/ZcashParams" -else - PARAMS_DIR="$HOME/.zcash-params" -fi - -SPROUT_PKEY_NAME='sprout-proving.key' -SPROUT_VKEY_NAME='sprout-verifying.key' -SAPLING_SPEND_NAME='sapling-spend.params' -SAPLING_OUTPUT_NAME='sapling-output.params' -SAPLING_SPROUT_GROTH16_NAME='sprout-groth16.params' -SPROUT_URL="https://download.z.cash/downloads" -SPROUT_IPFS="/ipfs/QmZKKx7Xup7LiAtFRhYsE1M7waXcv9ir9eCECyXAFGxhEo" - -SHA256CMD="$(command -v sha256sum || echo shasum)" -SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')" - -WGETCMD="$(command -v wget || echo '')" -IPFSCMD="$(command -v ipfs || echo '')" -CURLCMD="$(command -v curl || echo '')" - -# fetch methods can be disabled with ZC_DISABLE_SOMETHING=1 -ZC_DISABLE_WGET="${ZC_DISABLE_WGET:-}" -ZC_DISABLE_IPFS="${ZC_DISABLE_IPFS:-}" -ZC_DISABLE_CURL="${ZC_DISABLE_CURL:-}" - -function fetch_wget { - if [ -z "$WGETCMD" ] || ! [ -z "$ZC_DISABLE_WGET" ]; then - return 1 - fi - - local filename="$1" - local dlname="$2" - - cat <&2 <&2 - exit 1 - fi - fi -} - -# Use flock to prevent parallel execution. -function lock() { - local lockfile=/tmp/fetch_params.lock - if [[ "$OSTYPE" == "darwin"* ]]; then - if shlock -f ${lockfile} -p $$; then - return 0 - else - return 1 - fi - else - # create lock file - eval "exec 200>$lockfile" - # acquire the lock - flock -n 200 \ - && return 0 \ - || return 1 - fi -} - -function exit_locked_error { - echo "Only one instance of fetch-params.sh can be run at a time." >&2 - exit 1 -} - -function main() { - - lock fetch-params.sh \ - || exit_locked_error - - cat <> "$README_PATH" <