diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f4dfea37..a35b57cd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.15) set(_CLIENT_VERSION_MAJOR 0) -set(_CLIENT_VERSION_MINOR 20) -set(_CLIENT_VERSION_REVISION 19) +set(_CLIENT_VERSION_MINOR 21) +set(_CLIENT_VERSION_REVISION 0) set(_CLIENT_VERSION_BUILD 0) set(_CLIENT_VERSION_IS_RELEASE false) set(_COPYRIGHT_YEAR 2022) @@ -29,7 +29,7 @@ add_compile_definitions(CLIENT_VERSION_MAJOR=${_CLIENT_VERSION_MAJOR} COPYRIGHT_HOLDERS_FINAL=${_COPYRIGHT_HOLDERS_FINAL} HOMEPAGE=${_HOMEPAGE}) -# TODO missing bug report url +# TODO (build): missing bug report url project ( Pocketnet-Core VERSION ${_CLIENT_VERSION_MAJOR}.${_CLIENT_VERSION_MINOR}.${_CLIENT_VERSION_REVISION} diff --git a/Makefile.am b/Makefile.am index d96e20ff9..3bfdc5b59 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,6 +2,10 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +# Pattern rule to print variables, e.g. make print-top_srcdir +print-%: + @echo $* = $($*) + ACLOCAL_AMFLAGS = -I build-aux/m4 SUBDIRS = src if ENABLE_MAN @@ -19,6 +23,8 @@ endif POCKETCOIND_BIN=$(top_builddir)/src/$(POCKETCOIN_DAEMON_NAME)$(EXEEXT) POCKETCOIN_QT_BIN=$(top_builddir)/src/qt/$(POCKETCOIN_GUI_NAME)$(EXEEXT) POCKETCOIN_CLI_BIN=$(top_builddir)/src/$(POCKETCOIN_CLI_NAME)$(EXEEXT) +POCKETCOIN_TX_BIN=$(top_builddir)/src/$(POCKETCOIN_TX_NAME)$(EXEEXT) +# POCKETCOIN_WALLET_BIN=$(top_builddir)/src/$(POCKETCOIN_WALLET_TOOL_NAME)$(EXEEXT) POCKETCOIN_WIN_INSTALLER=$(PACKAGE)_$(PACKAGE_VERSION)_win_x64_setup.exe POCKETCOIN_LINUX_INSTALLER = $(PACKAGE)_$(PACKAGE_VERSION)_linux_x64 POCKETCOIN_LINUX_INSTALLER_NAME = $(PACKAGE)_$(PACKAGE_VERSION)_linux_x64 @@ -37,14 +43,12 @@ OSX_DEPLOY_SCRIPT=$(top_srcdir)/contrib/macdeploy/macdeployqtplus OSX_FANCY_PLIST=$(top_srcdir)/contrib/macdeploy/fancy.plist OSX_INSTALLER_ICONS=$(top_srcdir)/src/qt/res/icons/pocketcoin.icns OSX_PLIST=$(top_builddir)/share/qt/Info.plist #not installed -OSX_QT_TRANSLATIONS = da,de,es,hu,ru,uk,zh_CN,zh_TW - -DIST_DOCS = $(wildcard doc/*.md) $(wildcard doc/release-notes/*.md) -DIST_CONTRIB = $(top_srcdir)/contrib/pocketcoin-cli.bash-completion \ - $(top_srcdir)/contrib/pocketcoin-tx.bash-completion \ - $(top_srcdir)/contrib/pocketcoind.bash-completion \ - $(top_srcdir)/contrib/init \ - $(top_srcdir)/contrib/install_db4.sh +OSX_QT_TRANSLATIONS = ar,bg,ca,cs,da,de,es,fa,fi,fr,gd,gl,he,hu,it,ja,ko,lt,lv,pl,pt,ru,sk,sl,sv,uk,zh_CN,zh_TW + +DIST_CONTRIB = \ + $(top_srcdir)/contrib/linearize/linearize-data.py \ + $(top_srcdir)/contrib/linearize/linearize-hashes.py + DIST_SHARE = \ $(top_srcdir)/share/genbuild.sh \ $(top_srcdir)/share/rpcauth @@ -63,10 +67,10 @@ OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_FANCY_PLIST) $(OSX_INSTALLER_ICONS) \ $(top_srcdir)/contrib/macdeploy/detached-sig-apply.sh \ $(top_srcdir)/contrib/macdeploy/detached-sig-create.sh -COVERAGE_INFO = baseline.info \ +COVERAGE_INFO = $(COV_TOOL_WRAPPER) baseline.info \ test_pocketcoin_filtered.info total_coverage.info \ baseline_filtered.info functional_test.info functional_test_filtered.info \ - test_pocketcoin_coverage.info test_pocketcoin.info + test_pocketcoin_coverage.info test_pocketcoin.info fuzz.info fuzz_filtered.info fuzz_coverage.info dist-hook: -$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf - @@ -74,9 +78,10 @@ dist-hook: $(POCKETCOIN_WIN_INSTALLER): all-recursive $(MKDIR_P) $(top_builddir)/release STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(POCKETCOIND_BIN) $(top_builddir)/release - STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(POCKETCOIN_CLI_BIN) $(top_builddir)/release STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(POCKETCOIN_QT_BIN) $(top_builddir)/release - @test -f $(MAKENSIS) && $(MAKENSIS) -V2 $(top_builddir)/share/setup.nsi || \ + STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(POCKETCOIN_CLI_BIN) $(top_builddir)/release + STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(POCKETCOIN_TX_BIN) $(top_builddir)/release + @test -f $(MAKENSIS) && echo 'OutFile "$@"' | cat $(top_builddir)/share/setup.nsi - | $(MAKENSIS) -V2 - || \ echo error: could not build $@ @echo built $@ @@ -101,7 +106,7 @@ $(OSX_APP)/Contents/PkgInfo: $(OSX_APP)/Contents/Resources/empty.lproj: $(MKDIR_P) $(@D) - @touch $@ + @touch $@ $(OSX_APP)/Contents/Info.plist: $(OSX_PLIST) $(MKDIR_P) $(@D) @@ -187,16 +192,48 @@ $(POCKETCOIND_BIN): FORCE $(POCKETCOIN_CLI_BIN): FORCE $(MAKE) -C src $(@F) -if USE_LCOV -LCOV_FILTER_PATTERN=-p "/usr/include/" -p "src/leveldb/" -p "src/bench/" -p "src/univalue" -p "src/crypto/ctaes" -p "src/secp256k1" +$(POCKETCOIN_TX_BIN): FORCE + $(MAKE) -C src $(@F) + +# $(POCKETCOIN_WALLET_BIN): FORCE +# $(MAKE) -C src $(@F) -baseline.info: +if USE_LCOV +LCOV_FILTER_PATTERN = \ + -p "/usr/local/" \ + -p "/usr/include/" \ + -p "/usr/lib/" \ + -p "/usr/lib64/" \ + -p "src/leveldb/" \ + -p "src/crc32c/" \ + -p "src/bench/" \ + -p "src/univalue" \ + -p "src/crypto/ctaes" \ + -p "src/secp256k1" \ + -p "depends" + +DIR_FUZZ_SEED_CORPUS ?= qa-assets/fuzz_seed_corpus + +$(COV_TOOL_WRAPPER): + @echo 'exec $(COV_TOOL) "$$@"' > $(COV_TOOL_WRAPPER) + @chmod +x $(COV_TOOL_WRAPPER) + +baseline.info: $(COV_TOOL_WRAPPER) $(LCOV) -c -i -d $(abs_builddir)/src -o $@ baseline_filtered.info: baseline.info $(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@ $(LCOV) -a $@ $(LCOV_OPTS) -o $@ +fuzz.info: baseline_filtered.info + @TIMEOUT=15 test/fuzz/test_runner.py $(DIR_FUZZ_SEED_CORPUS) -l DEBUG + $(LCOV) -c $(LCOV_OPTS) -d $(abs_builddir)/src --t fuzz-tests -o $@ + $(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src + +fuzz_filtered.info: fuzz.info + $(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@ + $(LCOV) -a $@ $(LCOV_OPTS) -o $@ + test_pocketcoin.info: baseline_filtered.info $(MAKE) -C src/ check $(LCOV) -c $(LCOV_OPTS) -d $(abs_builddir)/src -t test_pocketcoin -o $@ @@ -207,7 +244,7 @@ test_pocketcoin_filtered.info: test_pocketcoin.info $(LCOV) -a $@ $(LCOV_OPTS) -o $@ functional_test.info: test_pocketcoin_filtered.info - -@TIMEOUT=15 test/functional/test_runner.py $(EXTENDED_FUNCTIONAL_TESTS) + @TIMEOUT=15 test/functional/test_runner.py $(EXTENDED_FUNCTIONAL_TESTS) $(LCOV) -c $(LCOV_OPTS) -d $(abs_builddir)/src --t functional-tests -o $@ $(LCOV) -z $(LCOV_OPTS) -d $(abs_builddir)/src @@ -215,12 +252,19 @@ functional_test_filtered.info: functional_test.info $(abs_builddir)/contrib/filter-lcov.py $(LCOV_FILTER_PATTERN) $< $@ $(LCOV) -a $@ $(LCOV_OPTS) -o $@ +fuzz_coverage.info: fuzz_filtered.info + $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a fuzz_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt + test_pocketcoin_coverage.info: baseline_filtered.info test_pocketcoin_filtered.info $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_pocketcoin_filtered.info -o $@ total_coverage.info: test_pocketcoin_filtered.info functional_test_filtered.info $(LCOV) -a $(LCOV_OPTS) baseline_filtered.info -a test_pocketcoin_filtered.info -a functional_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt +fuzz.coverage/.dirstamp: fuzz_coverage.info + $(GENHTML) -s $(LCOV_OPTS) $< -o $(@D) + @touch $@ + test_pocketcoin.coverage/.dirstamp: test_pocketcoin_coverage.info $(GENHTML) -s $(LCOV_OPTS) $< -o $(@D) @touch $@ @@ -229,13 +273,19 @@ total.coverage/.dirstamp: total_coverage.info $(GENHTML) -s $(LCOV_OPTS) $< -o $(@D) @touch $@ +cov_fuzz: fuzz.coverage/.dirstamp + cov: test_pocketcoin.coverage/.dirstamp total.coverage/.dirstamp endif dist_noinst_SCRIPTS = autogen.sh -EXTRA_DIST = $(DIST_SHARE) test/functional/test_runner.py test/functional $(DIST_CONTRIB) $(DIST_DOCS) $(WINDOWS_PACKAGING) $(OSX_PACKAGING) $(BIN_CHECKS) +EXTRA_DIST = $(DIST_SHARE) $(DIST_CONTRIB) $(WINDOWS_PACKAGING) $(OSX_PACKAGING) $(BIN_CHECKS) + +EXTRA_DIST += \ + test/functional \ + test/fuzz EXTRA_DIST += \ test/util/pocketcoin-util-test.py \ @@ -286,6 +336,8 @@ EXTRA_DIST += \ test/util/data/txcreatescript3.json \ test/util/data/txcreatescript4.hex \ test/util/data/txcreatescript4.json \ + test/util/data/txcreatescript5.hex \ + test/util/data/txcreatescript6.hex \ test/util/data/txcreatesignv1.hex \ test/util/data/txcreatesignv1.json \ test/util/data/txcreatesignv2.hex \ @@ -313,6 +365,17 @@ clean-docs: rm -rf doc/doxygen clean-local: clean-docs - rm -rf coverage_percent.txt test_pocketcoin.coverage/ total.coverage/ test/tmp/ cache/ $(OSX_APP) - rm -rf test/functional/__pycache__ test/functional/test_framework/__pycache__ test/cache + rm -rf coverage_percent.txt test_pocketcoin.coverage/ total.coverage/ fuzz.coverage/ test/tmp/ cache/ $(OSX_APP) + rm -rf test/functional/__pycache__ test/functional/test_framework/__pycache__ test/cache share/rpcauth/__pycache__ + rm -rf osx_volname dist/ dpi36.background.tiff dpi72.background.tiff +test-security-check: +if TARGET_DARWIN + $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_MACHO +endif +if TARGET_WINDOWS + $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_PE +endif +if TARGET_LINUX + $(AM_V_at) $(PYTHON) $(top_srcdir)/contrib/devtools/test-security-check.py TestSecurityChecks.test_ELF +endif diff --git a/build-aux/m4/ax_boost_base.m4 b/build-aux/m4/ax_boost_base.m4 index 650c94fa6..2ae33f714 100644 --- a/build-aux/m4/ax_boost_base.m4 +++ b/build-aux/m4/ax_boost_base.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html +# https://www.gnu.org/software/autoconf-archive/ax_boost_base.html # =========================================================================== # # SYNOPSIS @@ -33,7 +33,15 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 27 +#serial 48 + +# example boost program (need to pass version) +m4_define([_AX_BOOST_BASE_PROGRAM], + [AC_LANG_PROGRAM([[ +#include +]],[[ +(void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))])); +]])]) AC_DEFUN([AX_BOOST_BASE], [ @@ -44,110 +52,123 @@ AC_ARG_WITH([boost], or disable it (ARG=no) @<:@ARG=yes@:>@ ])], [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ac_boost_path="" - else - want_boost="yes" - ac_boost_path="$withval" - fi + AS_CASE([$withval], + [no],[want_boost="no";_AX_BOOST_BASE_boost_path=""], + [yes],[want_boost="yes";_AX_BOOST_BASE_boost_path=""], + [want_boost="yes";_AX_BOOST_BASE_boost_path="$withval"]) ], [want_boost="yes"]) AC_ARG_WITH([boost-libdir], - AS_HELP_STRING([--with-boost-libdir=LIB_DIR], - [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), - [ - if test -d "$withval" - then - ac_boost_lib_path="$withval" - else - AC_MSG_ERROR(--with-boost-libdir expected directory name) - fi - ], - [ac_boost_lib_path=""] -) + [AS_HELP_STRING([--with-boost-libdir=LIB_DIR], + [Force given directory for boost libraries. + Note that this will override library path detection, + so use this parameter only if default library detection fails + and you know exactly where your boost libraries are located.])], + [ + AS_IF([test -d "$withval"], + [_AX_BOOST_BASE_boost_lib_path="$withval"], + [AC_MSG_ERROR([--with-boost-libdir expected directory name])]) + ], + [_AX_BOOST_BASE_boost_lib_path=""]) -if test "x$want_boost" = "xyes"; then - boost_lib_version_req=ifelse([$1], ,1.20.0,$1) - boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` - boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` - boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$boost_lib_version_req_sub_minor" = "x" ; then - boost_lib_version_req_sub_minor="0" - fi - WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` - AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) +BOOST_LDFLAGS="" +BOOST_CPPFLAGS="" +AS_IF([test "x$want_boost" = "xyes"], + [_AX_BOOST_BASE_RUNDETECT([$1],[$2],[$3])]) +AC_SUBST(BOOST_CPPFLAGS) +AC_SUBST(BOOST_LDFLAGS) +]) + + +# convert a version string in $2 to numeric and affect to polymorphic var $1 +AC_DEFUN([_AX_BOOST_BASE_TONUMERICVERSION],[ + AS_IF([test "x$2" = "x"],[_AX_BOOST_BASE_TONUMERICVERSION_req="1.20.0"],[_AX_BOOST_BASE_TONUMERICVERSION_req="$2"]) + _AX_BOOST_BASE_TONUMERICVERSION_req_shorten=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\.[[0-9]]*\)'` + _AX_BOOST_BASE_TONUMERICVERSION_req_major=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\)'` + AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_major" = "x"], + [AC_MSG_ERROR([You should at least specify libboost major version])]) + _AX_BOOST_BASE_TONUMERICVERSION_req_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.\([[0-9]]*\)'` + AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_minor" = "x"], + [_AX_BOOST_BASE_TONUMERICVERSION_req_minor="0"]) + _AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` + AS_IF([test "X$_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor" = "X"], + [_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor="0"]) + _AX_BOOST_BASE_TONUMERICVERSION_RET=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req_major \* 100000 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_minor \* 100 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor` + AS_VAR_SET($1,$_AX_BOOST_BASE_TONUMERICVERSION_RET) +]) + +dnl Run the detection of boost should be run only if $want_boost +AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ + _AX_BOOST_BASE_TONUMERICVERSION(WANT_BOOST_VERSION,[$1]) succeeded=no + + AC_REQUIRE([AC_CANONICAL_HOST]) dnl On 64-bit systems check for system libraries in both lib64 and lib. dnl The former is specified by FHS, but e.g. Debian does not adhere to dnl this (as it rises problems for generic multi-arch support). dnl The last entry in the list is chosen by default when no libraries dnl are found, e.g. when only header-only libraries are installed! - libsubdirs="lib" - ax_arch=`uname -m` - case $ax_arch in - x86_64) - libsubdirs="lib64 libx32 lib lib64" - ;; - ppc64|s390x|sparc64|aarch64|ppc64le) - libsubdirs="lib64 lib lib64" - ;; - esac + AS_CASE([${host_cpu}], + [x86_64],[libsubdirs="lib64 libx32 lib lib64"], + [mips*64*],[libsubdirs="lib64 lib32 lib lib64"], + [ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64],[libsubdirs="lib64 lib lib64"], + [libsubdirs="lib"] + ) dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give dnl them priority over the other paths since, if libs are found there, they dnl are almost assuredly the ones desired. - AC_REQUIRE([AC_CANONICAL_HOST]) - libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs" - - case ${host_cpu} in - i?86) - libsubdirs="lib/i386-${host_os} $libsubdirs" - ;; - esac - - dnl some arches may advertise a cpu type that doesn't line up with their - dnl prefix's cpu type. For example, uname may report armv7l while libs are - dnl installed to /usr/lib/arm-linux-gnueabihf. Try getting the compiler's - dnl value for an extra chance of finding the correct path. - libsubdirs="lib/`$CXX -dumpmachine 2>/dev/null` $libsubdirs" + AS_CASE([${host_cpu}], + [i?86],[multiarch_libsubdir="lib/i386-${host_os}"], + [armv7l],[multiarch_libsubdir="lib/arm-${host_os}"], + [multiarch_libsubdir="lib/${host_cpu}-${host_os}"] + ) dnl first we check the system location for boost libraries dnl this location ist chosen if boost libraries are installed with the --layout=system option dnl or if you install boost with RPM - if test "$ac_boost_path" != ""; then - BOOST_CPPFLAGS="-I$ac_boost_path/include" - for ac_boost_path_tmp in $libsubdirs; do - if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then - BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" - break - fi - done - elif test "$cross_compiling" != yes; then - for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then - for libsubdir in $libsubdirs ; do - if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + AS_IF([test "x$_AX_BOOST_BASE_boost_path" != "x"],[ + AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) includes in "$_AX_BOOST_BASE_boost_path/include"]) + AS_IF([test -d "$_AX_BOOST_BASE_boost_path/include" && test -r "$_AX_BOOST_BASE_boost_path/include"],[ + AC_MSG_RESULT([yes]) + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include" + for _AX_BOOST_BASE_boost_path_tmp in $multiarch_libsubdir $libsubdirs; do + AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) lib path in "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp"]) + AS_IF([test -d "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" && test -r "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" ],[ + AC_MSG_RESULT([yes]) + BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp"; + break; + ], + [AC_MSG_RESULT([no])]) + done],[ + AC_MSG_RESULT([no])]) + ],[ + if test X"$cross_compiling" = Xyes; then + search_libsubdirs=$multiarch_libsubdir + else + search_libsubdirs="$multiarch_libsubdir $libsubdirs" + fi + for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do + if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then + for libsubdir in $search_libsubdirs ; do + if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done - BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" - BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" + BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path_tmp/$libsubdir" + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path_tmp/include" break; fi done - fi + ]) dnl overwrite ld flags if we have required special directory with dnl --with-boost-libdir parameter - if test "$ac_boost_lib_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_lib_path" - fi + AS_IF([test "x$_AX_BOOST_BASE_boost_lib_path" != "x"], + [BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_lib_path"]) + AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION)]) CPPFLAGS_SAVED="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS @@ -158,15 +179,7 @@ if test "x$want_boost" = "xyes"; then AC_REQUIRE([AC_PROG_CXX]) AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ + AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes @@ -178,40 +191,50 @@ if test "x$want_boost" = "xyes"; then dnl if we found no boost with system layout we search for boost libraries dnl built and installed without the --layout=system option or for a staged(not installed) version - if test "x$succeeded" != "xyes"; then + if test "x$succeeded" != "xyes" ; then CPPFLAGS="$CPPFLAGS_SAVED" LDFLAGS="$LDFLAGS_SAVED" BOOST_CPPFLAGS= - BOOST_LDFLAGS= + if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then + BOOST_LDFLAGS= + fi _version=0 - if test "$ac_boost_path" != ""; then - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + if test -n "$_AX_BOOST_BASE_boost_path" ; then + if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path"; then + for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then + if test "x$V_CHECK" = "x1" ; then _version=$_version_tmp fi VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include/boost-$VERSION_UNDERSCORE" done dnl if nothing found search for layout used in Windows distributions if test -z "$BOOST_CPPFLAGS"; then - if test -d "$ac_boost_path/boost" && test -r "$ac_boost_path/boost"; then - BOOST_CPPFLAGS="-I$ac_boost_path" + if test -d "$_AX_BOOST_BASE_boost_path/boost" && test -r "$_AX_BOOST_BASE_boost_path/boost"; then + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path" fi fi + dnl if we found something and BOOST_LDFLAGS was unset before + dnl (because "$_AX_BOOST_BASE_boost_lib_path" = ""), set it here. + if test -n "$BOOST_CPPFLAGS" && test -z "$BOOST_LDFLAGS"; then + for libsubdir in $libsubdirs ; do + if ls "$_AX_BOOST_BASE_boost_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$libsubdir" + fi fi else - if test "$cross_compiling" != yes; then - for ac_boost_path in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + if test "x$cross_compiling" != "xyes" ; then + for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do + if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then + for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then + if test "x$V_CHECK" = "x1" ; then _version=$_version_tmp - best_path=$ac_boost_path + best_path=$_AX_BOOST_BASE_boost_path fi done fi @@ -219,7 +242,7 @@ if test "x$want_boost" = "xyes"; then VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" - if test "$ac_boost_lib_path" = ""; then + if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then for libsubdir in $libsubdirs ; do if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done @@ -227,7 +250,7 @@ if test "x$want_boost" = "xyes"; then fi fi - if test "x$BOOST_ROOT" != "x"; then + if test -n "$BOOST_ROOT" ; then for libsubdir in $libsubdirs ; do if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done @@ -236,7 +259,7 @@ if test "x$want_boost" = "xyes"; then stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` V_CHECK=`expr $stage_version_shorten \>\= $_version` - if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then + if test "x$V_CHECK" = "x1" && test -z "$_AX_BOOST_BASE_boost_lib_path" ; then AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) BOOST_CPPFLAGS="-I$BOOST_ROOT" BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" @@ -251,15 +274,7 @@ if test "x$want_boost" = "xyes"; then export LDFLAGS AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ + AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes @@ -268,17 +283,15 @@ if test "x$want_boost" = "xyes"; then AC_LANG_POP([C++]) fi - if test "$succeeded" != "yes" ; then - if test "$_version" = "0" ; then - AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) + if test "x$succeeded" != "xyes" ; then + if test "x$_version" = "x0" ; then + AC_MSG_NOTICE([[We could not detect the boost libraries (version $1 or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) else AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) fi # execute ACTION-IF-NOT-FOUND (if present): ifelse([$3], , :, [$3]) else - AC_SUBST(BOOST_CPPFLAGS) - AC_SUBST(BOOST_LDFLAGS) AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) # execute ACTION-IF-FOUND (if present): ifelse([$2], , :, [$2]) @@ -286,6 +299,5 @@ if test "x$want_boost" = "xyes"; then CPPFLAGS="$CPPFLAGS_SAVED" LDFLAGS="$LDFLAGS_SAVED" -fi ]) diff --git a/build-aux/m4/ax_boost_chrono.m4 b/build-aux/m4/ax_boost_chrono.m4 deleted file mode 100644 index 6ea77b9b3..000000000 --- a/build-aux/m4/ax_boost_chrono.m4 +++ /dev/null @@ -1,118 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_boost_chrono.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_BOOST_CHRONO -# -# DESCRIPTION -# -# Test for Chrono library from the Boost C++ libraries. The macro requires -# a preceding call to AX_BOOST_BASE. Further documentation is available at -# . -# -# This macro calls: -# -# AC_SUBST(BOOST_CHRONO_LIB) -# -# And sets: -# -# HAVE_BOOST_CHRONO -# -# LICENSE -# -# Copyright (c) 2012 Xiyue Deng -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 4 - -AC_DEFUN([AX_BOOST_CHRONO], -[ - AC_ARG_WITH([boost-chrono], - AS_HELP_STRING([--with-boost-chrono@<:@=special-lib@:>@], - [use the Chrono library from boost - it is possible to specify a certain library for the linker - e.g. --with-boost-chrono=boost_chrono-gcc-mt ]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ax_boost_user_chrono_lib="" - else - want_boost="yes" - ax_boost_user_chrono_lib="$withval" - fi - ], - [want_boost="yes"] - ) - - if test "x$want_boost" = "xyes"; then - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_BUILD]) - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_CACHE_CHECK(whether the Boost::Chrono library is available, - ax_cv_boost_chrono, - [AC_LANG_PUSH([C++]) - CXXFLAGS_SAVE=$CXXFLAGS - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], - [[boost::chrono::system_clock::time_point* time = new boost::chrono::system_clock::time_point; delete time;]])], - ax_cv_boost_chrono=yes, ax_cv_boost_chrono=no) - CXXFLAGS=$CXXFLAGS_SAVE - AC_LANG_POP([C++]) - ]) - if test "x$ax_cv_boost_chrono" = "xyes"; then - AC_SUBST(BOOST_CPPFLAGS) - - AC_DEFINE(HAVE_BOOST_CHRONO,,[define if the Boost::Chrono library is available]) - BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` - - LDFLAGS_SAVE=$LDFLAGS - if test "x$ax_boost_user_chrono_lib" = "x"; then - for libextension in `ls $BOOSTLIBDIR/libboost_chrono*.so* $BOOSTLIBDIR/libboost_chrono*.dylib* $BOOSTLIBDIR/libboost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_chrono.*\)\.so.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.a.*$;\1;'` ; do - ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break], - [link_chrono="no"]) - done - if test "x$link_chrono" != "xyes"; then - for libextension in `ls $BOOSTLIBDIR/boost_chrono*.dll* $BOOSTLIBDIR/boost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_chrono.*\)\.dll.*$;\1;' -e 's;^\(boost_chrono.*\)\.a.*$;\1;'` ; do - ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break], - [link_chrono="no"]) - done - fi - - else - for ax_lib in $ax_boost_user_chrono_lib boost_chrono-$ax_boost_user_chrono_lib; do - AC_CHECK_LIB($ax_lib, exit, - [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break], - [link_chrono="no"]) - done - - fi - if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the library!) - fi - if test "x$link_chrono" = "xno"; then - AC_MSG_ERROR(Could not link against $ax_lib !) - fi - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" - fi -]) diff --git a/build-aux/m4/ax_boost_filesystem.m4 b/build-aux/m4/ax_boost_filesystem.m4 index f5c9d5647..12f7bc5e2 100644 --- a/build-aux/m4/ax_boost_filesystem.m4 +++ b/build-aux/m4/ax_boost_filesystem.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html +# https://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html # =========================================================================== # # SYNOPSIS @@ -31,7 +31,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 26 +#serial 28 AC_DEFUN([AX_BOOST_FILESYSTEM], [ @@ -80,7 +80,6 @@ AC_DEFUN([AX_BOOST_FILESYSTEM], if test "x$ax_cv_boost_filesystem" = "xyes"; then AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available]) BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` - ax_lib= if test "x$ax_boost_user_filesystem_lib" = "x"; then for libextension in `ls -r $BOOSTLIBDIR/libboost_filesystem* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do ax_lib=${libextension} @@ -105,7 +104,7 @@ AC_DEFUN([AX_BOOST_FILESYSTEM], fi if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the boost_filesystem library!) + AC_MSG_ERROR(Could not find a version of the Boost::Filesystem library!) fi if test "x$link_filesystem" != "xyes"; then AC_MSG_ERROR(Could not link against $ax_lib !) diff --git a/build-aux/m4/ax_boost_process.m4 b/build-aux/m4/ax_boost_process.m4 new file mode 100644 index 000000000..5d20e6746 --- /dev/null +++ b/build-aux/m4/ax_boost_process.m4 @@ -0,0 +1,121 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_boost_process.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_PROCESS +# +# DESCRIPTION +# +# Test for Process library from the Boost C++ libraries. The macro +# requires a preceding call to AX_BOOST_BASE. Further documentation is +# available at . +# +# This macro calls: +# +# AC_SUBST(BOOST_PROCESS_LIB) +# +# And sets: +# +# HAVE_BOOST_PROCESS +# +# LICENSE +# +# Copyright (c) 2008 Thomas Porschberg +# Copyright (c) 2008 Michael Tindal +# Copyright (c) 2008 Daniel Casimiro +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_BOOST_PROCESS], +[ + AC_ARG_WITH([boost-process], + AS_HELP_STRING([--with-boost-process@<:@=special-lib@:>@], + [use the Process library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-process=boost_process-gcc-mt ]), + [ + if test "$withval" = "no"; then + want_boost_process="no" + elif test "$withval" = "yes"; then + want_boost_process="yes" + ax_boost_user_process_lib="" + else + want_boost_process="yes" + ax_boost_user_process_lib="$withval" + fi + ], + [want_boost_process="yes"] + ) + + if test "x$want_boost_process" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::Process library is available, + ax_cv_boost_process, + [AC_LANG_PUSH([C++]) + CXXFLAGS_SAVE=$CXXFLAGS + CXXFLAGS= + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[boost::process::child* child = new boost::process::child; delete child;]])], + ax_cv_boost_process=yes, ax_cv_boost_process=no) + CXXFLAGS=$CXXFLAGS_SAVE + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_process" = "xyes"; then + AC_SUBST(BOOST_CPPFLAGS) + + AC_DEFINE(HAVE_BOOST_PROCESS,,[define if the Boost::Process library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + + LDFLAGS_SAVE=$LDFLAGS + if test "x$ax_boost_user_process_lib" = "x"; then + for libextension in `ls -r $BOOSTLIBDIR/libboost_process* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break], + [link_process="no"]) + done + if test "x$link_process" != "xyes"; then + for libextension in `ls -r $BOOSTLIBDIR/boost_process* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break], + [link_process="no"]) + done + fi + + else + for ax_lib in $ax_boost_user_process_lib boost_process-$ax_boost_user_process_lib; do + AC_CHECK_LIB($ax_lib, exit, + [BOOST_PROCESS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROCESS_LIB) link_process="yes"; break], + [link_process="no"]) + done + + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the Boost::Process library!) + fi + if test "x$link_process" = "xno"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/build-aux/m4/ax_boost_system.m4 b/build-aux/m4/ax_boost_system.m4 index 1c05450cb..323e2a676 100644 --- a/build-aux/m4/ax_boost_system.m4 +++ b/build-aux/m4/ax_boost_system.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_boost_system.html +# https://www.gnu.org/software/autoconf-archive/ax_boost_system.html # =========================================================================== # # SYNOPSIS @@ -31,7 +31,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 18 +#serial 20 AC_DEFUN([AX_BOOST_SYSTEM], [ @@ -84,7 +84,6 @@ AC_DEFUN([AX_BOOST_SYSTEM], LDFLAGS_SAVE=$LDFLAGS if test "x$ax_boost_user_system_lib" = "x"; then - ax_lib= for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do ax_lib=${libextension} AC_CHECK_LIB($ax_lib, exit, @@ -109,7 +108,7 @@ AC_DEFUN([AX_BOOST_SYSTEM], fi if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the boost_system library!) + AC_MSG_ERROR(Could not find a version of the Boost::System library!) fi if test "x$link_system" = "xno"; then AC_MSG_ERROR(Could not link against $ax_lib !) diff --git a/build-aux/m4/ax_boost_thread.m4 b/build-aux/m4/ax_boost_thread.m4 index 9f0bd0b23..75e80e6e7 100644 --- a/build-aux/m4/ax_boost_thread.m4 +++ b/build-aux/m4/ax_boost_thread.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_boost_thread.html +# https://www.gnu.org/software/autoconf-archive/ax_boost_thread.html # =========================================================================== # # SYNOPSIS @@ -30,73 +30,96 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 27 +#serial 33 AC_DEFUN([AX_BOOST_THREAD], [ - AC_ARG_WITH([boost-thread], - AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], - [use the Thread library from boost - it is possible to specify a certain library for the linker - e.g. --with-boost-thread=boost_thread-gcc-mt ]), + AC_ARG_WITH([boost-thread], + AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], + [use the Thread library from boost - + it is possible to specify a certain library for the linker + e.g. --with-boost-thread=boost_thread-gcc-mt ]), [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then + if test "$withval" = "yes"; then want_boost="yes" ax_boost_user_thread_lib="" else - want_boost="yes" - ax_boost_user_thread_lib="$withval" - fi + want_boost="yes" + ax_boost_user_thread_lib="$withval" + fi ], [want_boost="yes"] - ) + ) - if test "x$want_boost" = "xyes"; then + if test "x$want_boost" = "xyes"; then AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_BUILD]) - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS AC_CACHE_CHECK(whether the Boost::Thread library is available, - ax_cv_boost_thread, + ax_cv_boost_thread, [AC_LANG_PUSH([C++]) - CXXFLAGS_SAVE=$CXXFLAGS + CXXFLAGS_SAVE=$CXXFLAGS + + case "x$host_os" in + xsolaris ) + CXXFLAGS="-pthreads $CXXFLAGS" + break; + ;; + xmingw32 ) + CXXFLAGS="-mthreads $CXXFLAGS" + break; + ;; + *android* ) + break; + ;; + * ) + CXXFLAGS="-pthread $CXXFLAGS" + break; + ;; + esac - if test "x$host_os" = "xsolaris" ; then - CXXFLAGS="-pthreads $CXXFLAGS" - elif test "x$host_os" = "xmingw32" ; then - CXXFLAGS="-mthreads $CXXFLAGS" - else - CXXFLAGS="-pthread $CXXFLAGS" - fi - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], - [[boost::thread_group thrds; - return 0;]])], - ax_cv_boost_thread=yes, ax_cv_boost_thread=no) - CXXFLAGS=$CXXFLAGS_SAVE + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[@%:@include ]], + [[boost::thread_group thrds; + return 0;]])], + ax_cv_boost_thread=yes, ax_cv_boost_thread=no) + CXXFLAGS=$CXXFLAGS_SAVE AC_LANG_POP([C++]) - ]) - if test "x$ax_cv_boost_thread" = "xyes"; then - if test "x$host_os" = "xsolaris" ; then - BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" - elif test "x$host_os" = "xmingw32" ; then - BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" - else - BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" - fi + ]) + if test "x$ax_cv_boost_thread" = "xyes"; then + case "x$host_os" in + xsolaris ) + BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" + break; + ;; + xmingw32 ) + BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" + break; + ;; + *android* ) + break; + ;; + * ) + BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" + break; + ;; + esac - AC_SUBST(BOOST_CPPFLAGS) + AC_SUBST(BOOST_CPPFLAGS) - AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available]) + AC_DEFINE(HAVE_BOOST_THREAD,, + [define if the Boost::Thread library is available]) BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` - LDFLAGS_SAVE=$LDFLAGS + LDFLAGS_SAVE=$LDFLAGS case "x$host_os" in *bsd* ) LDFLAGS="-pthread $LDFLAGS" @@ -104,47 +127,61 @@ AC_DEFUN([AX_BOOST_THREAD], ;; esac if test "x$ax_boost_user_thread_lib" = "x"; then - ax_lib= for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + AC_CHECK_LIB($ax_lib, exit, + [link_thread="yes"; break], [link_thread="no"]) - done + done if test "x$link_thread" != "xyes"; then for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do ax_lib=${libextension} - AC_CHECK_LIB($ax_lib, exit, - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + AC_CHECK_LIB($ax_lib, exit, + [link_thread="yes"; break], [link_thread="no"]) - done + done fi else for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do - AC_CHECK_LIB($ax_lib, exit, - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + AC_CHECK_LIB($ax_lib, exit, + [link_thread="yes"; break], [link_thread="no"]) done fi if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the boost_thread library!) + AC_MSG_ERROR(Could not find a version of the Boost::Thread library!) fi - if test "x$link_thread" = "xno"; then - AC_MSG_ERROR(Could not link against $ax_lib !) - else - case "x$host_os" in - *bsd* ) - BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS" - break; - ;; - esac - - fi - fi + if test "x$link_thread" = "xno"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + else + BOOST_THREAD_LIB="-l$ax_lib" + case "x$host_os" in + *bsd* ) + BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS" + break; + ;; + xsolaris ) + BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread" + break; + ;; + xmingw32 ) + break; + ;; + *android* ) + break; + ;; + * ) + BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread" + break; + ;; + esac + AC_SUBST(BOOST_THREAD_LIB) + fi + fi - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" - fi + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi ]) diff --git a/build-aux/m4/ax_boost_unit_test_framework.m4 b/build-aux/m4/ax_boost_unit_test_framework.m4 index 3d8e93e96..4cca32fcf 100644 --- a/build-aux/m4/ax_boost_unit_test_framework.m4 +++ b/build-aux/m4/ax_boost_unit_test_framework.m4 @@ -29,7 +29,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 21 +#serial 22 AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK], [ @@ -124,7 +124,7 @@ AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK], done fi if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the library!) + AC_MSG_ERROR(Could not find a version of the Boost::Unit_Test_Framework library!) fi if test "x$link_unit_test_framework" != "xyes"; then AC_MSG_ERROR(Could not link against $ax_lib !) diff --git a/build-aux/m4/ax_cxx_compile_stdcxx.m4 b/build-aux/m4/ax_cxx_compile_stdcxx.m4 index 9e9eaedaa..deb0bc083 100644 --- a/build-aux/m4/ax_cxx_compile_stdcxx.m4 +++ b/build-aux/m4/ax_cxx_compile_stdcxx.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS diff --git a/build-aux/m4/ax_pthread.m4 b/build-aux/m4/ax_pthread.m4 index 4c4051ea3..1598d077f 100644 --- a/build-aux/m4/ax_pthread.m4 +++ b/build-aux/m4/ax_pthread.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# https://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS @@ -55,6 +55,7 @@ # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. +# Copyright (c) 2019 Marc Stevens # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -67,7 +68,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see . +# with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -82,7 +83,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 23 +#serial 27 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ @@ -123,10 +124,12 @@ fi # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. +# Create a list of thread flags to try. Items with a "," contain both +# C compiler flags (before ",") and linker flags (after ","). Other items +# starting with a "-" are C compiler flags, and remaining items are +# library names, except for "none" which indicates that we try without +# any flags at all, and "pthread-config" which is a program returning +# the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" @@ -194,14 +197,47 @@ case $host_os in # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). - ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" + ax_pthread_flags="-mt,-lpthread pthread $ax_pthread_flags" ;; esac +# Are we compiling with Clang? + +AC_CACHE_CHECK([whether $CC is Clang], + [ax_cv_PTHREAD_CLANG], + [ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + ], + [ax_cv_PTHREAD_CLANG=yes]) + fi + ]) +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + + # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) +# Note that for GCC and Clang -pthread generally implies -lpthread, +# except when -nostdlib is passed. +# This is problematic using libtool to build C++ shared libraries with pthread: +# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 +# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 +# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 +# To solve this, first try -pthread together with -lpthread for GCC + AS_IF([test "x$GCC" = "xyes"], - [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) + [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) + +# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first + +AS_IF([test "x$ax_pthread_clang" = "xyes"], + [ax_pthread_flags="-pthread,-lpthread -pthread"]) + # The presence of a feature test macro requesting re-entrant function # definitions is, on some systems, a strong hint that pthreads support is @@ -224,25 +260,86 @@ AS_IF([test "x$ax_pthread_check_macro" = "x--"], [ax_pthread_check_cond=0], [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) -# Are we compiling with Clang? -AC_CACHE_CHECK([whether $CC is Clang], - [ax_cv_PTHREAD_CLANG], - [ax_cv_PTHREAD_CLANG=no - # Note that Autoconf sets GCC=yes for Clang as well as GCC - if test "x$GCC" = "xyes"; then - AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], - [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ -# if defined(__clang__) && defined(__llvm__) - AX_PTHREAD_CC_IS_CLANG -# endif - ], - [ax_cv_PTHREAD_CLANG=yes]) - fi - ]) -ax_pthread_clang="$ax_cv_PTHREAD_CLANG" +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + *,*) + PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` + PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` + AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) + PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) + PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif + static void *some_global = NULL; + static void routine(void *a) + { + /* To avoid any unused-parameter or + unused-but-set-parameter warning. */ + some_global = a; + } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi -ax_pthread_clang_warning=no # Clang needs special handling, because older versions handle the -pthread # option in a rather... idiosyncratic way @@ -261,11 +358,6 @@ if test "x$ax_pthread_clang" = "xyes"; then # -pthread does define _REENTRANT, and while the Darwin headers # ignore this macro, third-party headers might not.) - PTHREAD_CFLAGS="-pthread" - PTHREAD_LIBS= - - ax_pthread_ok=yes - # However, older versions of Clang make a point of warning the user # that, in an invocation where only linking and no compilation is # taking place, the -pthread option has no effect ("argument unused @@ -320,78 +412,7 @@ if test "x$ax_pthread_clang" = "xyes"; then fi # $ax_pthread_clang = yes -if test "x$ax_pthread_ok" = "xno"; then -for ax_pthread_try_flag in $ax_pthread_flags; do - - case $ax_pthread_try_flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -mt,pthread) - AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) - PTHREAD_CFLAGS="-mt" - PTHREAD_LIBS="-lpthread" - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) - PTHREAD_CFLAGS="$ax_pthread_try_flag" - ;; - - pthread-config) - AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) - AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - *) - AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) - PTHREAD_LIBS="-l$ax_pthread_try_flag" - ;; - esac - - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include -# if $ax_pthread_check_cond -# error "$ax_pthread_check_macro must be defined" -# endif - static void routine(void *a) { a = 0; } - static void *start_routine(void *a) { return a; }], - [pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */])], - [ax_pthread_ok=yes], - []) - - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - AC_MSG_RESULT([$ax_pthread_ok]) - AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then @@ -438,7 +459,8 @@ if test "x$ax_pthread_ok" = "xyes"; then AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[int i = PTHREAD_PRIO_INHERIT;]])], + [[int i = PTHREAD_PRIO_INHERIT; + return i;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) diff --git a/build-aux/m4/l_socket.m4 b/build-aux/m4/l_socket.m4 new file mode 100644 index 000000000..38923a98f --- /dev/null +++ b/build-aux/m4/l_socket.m4 @@ -0,0 +1,36 @@ +# Illumos/SmartOS requires linking with -lsocket if +# using getifaddrs & freeifaddrs + +m4_define([_CHECK_SOCKET_testbody], [[ + #include + #include + + int main() { + struct ifaddrs *ifaddr; + getifaddrs(&ifaddr); + freeifaddrs(ifaddr); + } +]]) + +AC_DEFUN([CHECK_SOCKET], [ + + AC_LANG_PUSH(C++) + + AC_MSG_CHECKING([whether ifaddrs funcs can be used without link library]) + + AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_SOCKET_testbody])],[ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + LIBS="$LIBS -lsocket" + AC_MSG_CHECKING([whether getifaddrs needs -lsocket]) + AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_SOCKET_testbody])],[ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([cannot figure out how to use getifaddrs]) + ]) + ]) + + AC_LANG_POP +]) diff --git a/build-aux/m4/pocketcoin_find_bdb48.m4 b/build-aux/m4/pocketcoin_find_bdb48.m4 index 031eccec7..e7cbe9c7e 100644 --- a/build-aux/m4/pocketcoin_find_bdb48.m4 +++ b/build-aux/m4/pocketcoin_find_bdb48.m4 @@ -61,7 +61,7 @@ AC_DEFUN([POCKETCOIN_FIND_BDB48],[ BDB_CPPFLAGS=${BDB_CFLAGS} fi AC_SUBST(BDB_CPPFLAGS) - + if test "x$BDB_LIBS" = "x"; then # TODO: Ideally this could find the library version and make sure it matches the headers being used for searchlib in db_cxx-4.8 db_cxx db4_cxx; do diff --git a/build-aux/m4/pocketcoin_qt.m4 b/build-aux/m4/pocketcoin_qt.m4 index 94a583f60..45f2f533f 100644 --- a/build-aux/m4/pocketcoin_qt.m4 +++ b/build-aux/m4/pocketcoin_qt.m4 @@ -72,32 +72,33 @@ AC_DEFUN([POCKETCOIN_QT_INIT],[ AC_ARG_WITH([qtdbus], [AS_HELP_STRING([--with-qtdbus], - [enable DBus support (default is yes if qt is enabled and QtDBus is found)])], + [enable DBus support (default is yes if qt is enabled and QtDBus is found, except on Android)])], [use_dbus=$withval], [use_dbus=auto]) + dnl Android doesn't support D-Bus and certainly doesn't use it for notifications + case $host in + *android*) + if test "x$use_dbus" != xyes; then + use_dbus=no + fi + ;; + esac + AC_SUBST(QT_TRANSLATION_DIR,$qt_translation_path) ]) -dnl Find the appropriate version of Qt libraries and includes. -dnl Inputs: $1: Whether or not pkg-config should be used. yes|no. Default: yes. -dnl Inputs: $2: If $1 is "yes" and --with-gui=auto, which qt version should be -dnl tried first. -dnl Outputs: See _POCKETCOIN_QT_FIND_LIBS_* +dnl Find Qt libraries and includes. +dnl +dnl POCKETCOIN_QT_CONFIGURE([MINIMUM-VERSION]) +dnl +dnl Outputs: See _POCKETCOIN_QT_FIND_LIBS dnl Outputs: Sets variables for all qt-related tools. dnl Outputs: pocketcoin_enable_qt, pocketcoin_enable_qt_dbus, pocketcoin_enable_qt_test AC_DEFUN([POCKETCOIN_QT_CONFIGURE],[ - use_pkgconfig=$1 - - if test "x$use_pkgconfig" = x; then - use_pkgconfig=yes - fi - - if test "x$use_pkgconfig" = xyes; then - POCKETCOIN_QT_CHECK([_POCKETCOIN_QT_FIND_LIBS_WITH_PKGCONFIG]) - else - POCKETCOIN_QT_CHECK([_POCKETCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG]) - fi + qt_version=">= $1" + qt_lib_prefix="Qt5" + POCKETCOIN_QT_CHECK([_POCKETCOIN_QT_FIND_LIBS]) dnl This is ugly and complicated. Yuck. Works as follows: dnl For Qt5, we can check a header to find out whether Qt is build @@ -116,26 +117,10 @@ AC_DEFUN([POCKETCOIN_QT_CONFIGURE],[ if test "x$pocketcoin_cv_static_qt" = xyes; then _POCKETCOIN_QT_FIND_STATIC_PLUGINS AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static]) - AC_CACHE_CHECK(for Qt < 5.4, pocketcoin_cv_need_acc_widget,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #ifndef QT_VERSION - # include - #endif - ]], - [[ - #if QT_VERSION >= 0x050400 - choke - #endif - ]])], - [pocketcoin_cv_need_acc_widget=yes], - [pocketcoin_cv_need_acc_widget=no]) - ]) - if test "x$pocketcoin_cv_need_acc_widget" = xyes; then - _POCKETCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets]) + if test "x$TARGET_OS" != xandroid; then + _POCKETCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal]) + AC_DEFINE(QT_QPA_PLATFORM_MINIMAL, 1, [Define this symbol if the minimal qt platform exists]) fi - _POCKETCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal]) - AC_DEFINE(QT_QPA_PLATFORM_MINIMAL, 1, [Define this symbol if the minimal qt platform exists]) if test "x$TARGET_OS" = xwindows; then _POCKETCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows]) AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows]) @@ -146,13 +131,16 @@ AC_DEFUN([POCKETCOIN_QT_CONFIGURE],[ AX_CHECK_LINK_FLAG([[-framework IOKit]],[QT_LIBS="$QT_LIBS -framework IOKit"],[AC_MSG_ERROR(could not iokit framework)]) _POCKETCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa]) AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa]) + elif test "x$TARGET_OS" = xandroid; then + QT_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lqtforandroid -ljnigraphics -landroid -lqtfreetype -lQt5EglSupport $QT_LIBS" + AC_DEFINE(QT_QPA_PLATFORM_ANDROID, 1, [Define this symbol if the qt platform is android]) fi fi CPPFLAGS=$TEMP_CPPFLAGS CXXFLAGS=$TEMP_CXXFLAGS ]) - if test "x$use_pkgconfig$qt_bin_path" = xyes; then + if test "x$qt_bin_path" = x; then qt_bin_path="`$PKG_CONFIG --variable=host_bins Qt5Core 2>/dev/null`" fi @@ -226,7 +214,7 @@ AC_DEFUN([POCKETCOIN_QT_CONFIGURE],[ dnl enable qt support - AC_MSG_CHECKING(whether to build ]AC_PACKAGE_NAME[ GUI) + AC_MSG_CHECKING([whether to build ]AC_PACKAGE_NAME[ GUI]) POCKETCOIN_QT_CHECK([ pocketcoin_enable_qt=yes pocketcoin_enable_qt_test=yes @@ -246,7 +234,11 @@ AC_DEFUN([POCKETCOIN_QT_CONFIGURE],[ ],[ pocketcoin_enable_qt=no ]) - AC_MSG_RESULT([$pocketcoin_enable_qt (Qt5)]) + if test x$pocketcoin_enable_qt = xyes; then + AC_MSG_RESULT([$pocketcoin_enable_qt ($qt_lib_prefix)]) + else + AC_MSG_RESULT([$pocketcoin_enable_qt]) + fi AC_SUBST(QT_PIE_FLAGS) AC_SUBST(QT_INCLUDES) @@ -264,57 +256,15 @@ dnl All macros below are internal and should _not_ be used from the main dnl configure.ac. dnl ---- -dnl Internal. Check if the included version of Qt is Qt5. -dnl Requires: INCLUDES must be populated as necessary. -dnl Output: pocketcoin_cv_qt5=yes|no -AC_DEFUN([_POCKETCOIN_QT_CHECK_QT5],[ - AC_CACHE_CHECK(for Qt 5, pocketcoin_cv_qt5,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #ifndef QT_VERSION - # include - #endif - ]], - [[ - #if QT_VERSION < 0x050000 || QT_VERSION_MAJOR < 5 - choke - #endif - ]])], - [pocketcoin_cv_qt5=yes], - [pocketcoin_cv_qt5=no]) -])]) - -dnl Internal. Check if the included version of Qt is greater than Qt58. -dnl Requires: INCLUDES must be populated as necessary. -dnl Output: pocketcoin_cv_qt5=yes|no -AC_DEFUN([_POCKETCOIN_QT_CHECK_QT58],[ - AC_CACHE_CHECK(for > Qt 5.7, pocketcoin_cv_qt58,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #ifndef QT_VERSION - # include - #endif - ]], - [[ - #if QT_VERSION_MINOR < 8 - choke - #endif - ]])], - [pocketcoin_cv_qt58=yes], - [pocketcoin_cv_qt58=no]) -])]) - - dnl Internal. Check if the linked version of Qt was built as static libs. dnl Requires: Qt5. dnl Requires: INCLUDES and LIBS must be populated as necessary. dnl Output: pocketcoin_cv_static_qt=yes|no -dnl Output: Defines QT_STATICPLUGIN if plugins are static. AC_DEFUN([_POCKETCOIN_QT_IS_STATIC],[ AC_CACHE_CHECK(for static Qt, pocketcoin_cv_static_qt,[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - #ifndef QT_VERSION OR QT_VERSION_STR + #ifndef QT_VERSION # include #endif ]], @@ -326,9 +276,6 @@ AC_DEFUN([_POCKETCOIN_QT_IS_STATIC],[ [pocketcoin_cv_static_qt=yes], [pocketcoin_cv_static_qt=no]) ]) - if test "x$pocketcoin_cv_static_qt" = xyes; then - AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol for static Qt plugins]) - fi ]) dnl Internal. Check if the link-requirements for static plugins are met. @@ -359,172 +306,52 @@ AC_DEFUN([_POCKETCOIN_QT_FIND_STATIC_PLUGINS],[ if test -d "$qt_plugin_path/accessible"; then QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible" fi - if test "x$use_pkgconfig" = xyes; then - : dnl - m4_ifdef([PKG_CHECK_MODULES],[ - if test x$pocketcoin_cv_qt58 = xno; then - PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"]) - else - PKG_CHECK_MODULES([QTFONTDATABASE], [Qt5FontDatabaseSupport], [QT_LIBS="-lQt5FontDatabaseSupport $QT_LIBS"]) - PKG_CHECK_MODULES([QTEVENTDISPATCHER], [Qt5EventDispatcherSupport], [QT_LIBS="-lQt5EventDispatcherSupport $QT_LIBS"]) - PKG_CHECK_MODULES([QTTHEME], [Qt5ThemeSupport], [QT_LIBS="-lQt5ThemeSupport $QT_LIBS"]) - PKG_CHECK_MODULES([QTDEVICEDISCOVERY], [Qt5DeviceDiscoverySupport], [QT_LIBS="-lQt5DeviceDiscoverySupport $QT_LIBS"]) - PKG_CHECK_MODULES([QTACCESSIBILITY], [Qt5AccessibilitySupport], [QT_LIBS="-lQt5AccessibilitySupport $QT_LIBS"]) - PKG_CHECK_MODULES([QTFB], [Qt5FbSupport], [QT_LIBS="-lQt5FbSupport $QT_LIBS"]) - fi - if test "x$TARGET_OS" = xlinux; then - PKG_CHECK_MODULES([X11XCB], [x11-xcb], [QT_LIBS="$X11XCB_LIBS $QT_LIBS"]) - if ${PKG_CONFIG} --exists "Qt5Core >= 5.5" 2>/dev/null; then - PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"]) - fi - elif test "x$TARGET_OS" = xdarwin; then - PKG_CHECK_MODULES([QTCLIPBOARD], [Qt5ClipboardSupport], [QT_LIBS="-lQt5ClipboardSupport $QT_LIBS"]) - PKG_CHECK_MODULES([QTGRAPHICS], [Qt5GraphicsSupport], [QT_LIBS="-lQt5GraphicsSupport $QT_LIBS"]) - PKG_CHECK_MODULES([QTCGL], [Qt5CglSupport], [QT_LIBS="-lQt5CglSupport $QT_LIBS"]) - fi - ]) - else - if test "x$TARGET_OS" = xwindows; then - AC_CACHE_CHECK(for Qt >= 5.6, pocketcoin_cv_need_platformsupport,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #ifndef QT_VERSION - # include - #endif - ]], - [[ - #if QT_VERSION < 0x050600 || QT_VERSION_MINOR < 6 - choke - #endif - ]])], - [pocketcoin_cv_need_platformsupport=yes], - [pocketcoin_cv_need_platformsupport=no]) - ]) - if test "x$pocketcoin_cv_need_platformsupport" = xyes; then - if test x$pocketcoin_cv_qt58 = xno; then - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}PlatformSupport],[main],,POCKETCOIN_QT_FAIL(lib$QT_LIB_PREFIXPlatformSupport not found))) - else - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}FontDatabaseSupport],[main],,POCKETCOIN_QT_FAIL(lib$QT_LIB_PREFIXFontDatabaseSupport not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}EventDispatcherSupport],[main],,POCKETCOIN_QT_FAIL(lib$QT_LIB_PREFIXEventDispatcherSupport not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}ThemeSupport],[main],,POCKETCOIN_QT_FAIL(lib$QT_LIB_PREFIXThemeSupport not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}FbSupport],[main],,POCKETCOIN_QT_FAIL(lib$QT_LIB_PREFIXFbSupport not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}DeviceDiscoverySupport],[main],,POCKETCOIN_QT_FAIL(lib$QT_LIB_PREFIXDeviceDiscoverySupport not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}AccessibilitySupport],[main],,POCKETCOIN_QT_FAIL(lib$QT_LIB_PREFIXAccessibilitySupport not found))) - QT_LIBS="$QT_LIBS -lversion -ldwmapi -luxtheme" - fi - fi - fi - fi - fi -]) - -dnl Internal. Find Qt libraries using pkg-config. -dnl Inputs: pocketcoin_qt_want_version (from --with-gui=). The version to check -dnl first. -dnl Inputs: $1: If pocketcoin_qt_want_version is "auto", check for this version -dnl first. -dnl Outputs: All necessary QT_* variables are set. -dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no. -AC_DEFUN([_POCKETCOIN_QT_FIND_LIBS_WITH_PKGCONFIG],[ - m4_ifdef([PKG_CHECK_MODULES],[ - QT_LIB_PREFIX=Qt5 - qt5_modules="Qt5Core Qt5Gui Qt5Network Qt5Widgets" - POCKETCOIN_QT_CHECK([ - PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" have_qt=yes],[have_qt=no]) - - if test "x$have_qt" != xyes; then - have_qt=no - POCKETCOIN_QT_FAIL([Qt dependencies not found]) + if test -d "$qt_plugin_path/platforms/android"; then + QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms/android -lqtfreetype -lEGL" fi - ]) - POCKETCOIN_QT_CHECK([ - PKG_CHECK_MODULES([QT_TEST], [${QT_LIB_PREFIX}Test], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no]) - if test "x$use_dbus" != xno; then - PKG_CHECK_MODULES([QT_DBUS], [${QT_LIB_PREFIX}DBus], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no]) + PKG_CHECK_MODULES([QTFONTDATABASE], [Qt5FontDatabaseSupport], [QT_LIBS="-lQt5FontDatabaseSupport $QT_LIBS"]) + PKG_CHECK_MODULES([QTEVENTDISPATCHER], [Qt5EventDispatcherSupport], [QT_LIBS="-lQt5EventDispatcherSupport $QT_LIBS"]) + PKG_CHECK_MODULES([QTTHEME], [Qt5ThemeSupport], [QT_LIBS="-lQt5ThemeSupport $QT_LIBS"]) + PKG_CHECK_MODULES([QTDEVICEDISCOVERY], [Qt5DeviceDiscoverySupport], [QT_LIBS="-lQt5DeviceDiscoverySupport $QT_LIBS"]) + PKG_CHECK_MODULES([QTACCESSIBILITY], [Qt5AccessibilitySupport], [QT_LIBS="-lQt5AccessibilitySupport $QT_LIBS"]) + PKG_CHECK_MODULES([QTFB], [Qt5FbSupport], [QT_LIBS="-lQt5FbSupport $QT_LIBS"]) + if test "x$TARGET_OS" = xlinux; then + PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"]) + elif test "x$TARGET_OS" = xdarwin; then + PKG_CHECK_MODULES([QTCLIPBOARD], [Qt5ClipboardSupport], [QT_LIBS="-lQt5ClipboardSupport $QT_LIBS"]) + PKG_CHECK_MODULES([QTGRAPHICS], [Qt5GraphicsSupport], [QT_LIBS="-lQt5GraphicsSupport $QT_LIBS"]) + PKG_CHECK_MODULES([QTCGL], [Qt5CglSupport], [QT_LIBS="-lQt5CglSupport $QT_LIBS"]) fi - ]) - ]) - true; dnl + fi ]) -dnl Internal. Find Qt libraries without using pkg-config. Version is deduced -dnl from the discovered headers. -dnl Inputs: pocketcoin_qt_want_version (from --with-gui=). The version to use. -dnl If "auto", the version will be discovered by _POCKETCOIN_QT_CHECK_QT5. +dnl Internal. Find Qt libraries using pkg-config. dnl Outputs: All necessary QT_* variables are set. dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no. -AC_DEFUN([_POCKETCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[ - TEMP_CPPFLAGS="$CPPFLAGS" - TEMP_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$PIC_FLAGS $CXXFLAGS" - TEMP_LIBS="$LIBS" +AC_DEFUN([_POCKETCOIN_QT_FIND_LIBS],[ POCKETCOIN_QT_CHECK([ - if test "x$qt_include_path" != x; then - QT_INCLUDES="-I$qt_include_path -I$qt_include_path/QtCore -I$qt_include_path/QtGui -I$qt_include_path/QtWidgets -I$qt_include_path/QtNetwork -I$qt_include_path/QtTest -I$qt_include_path/QtDBus" - CPPFLAGS="$QT_INCLUDES $CPPFLAGS" - fi + PKG_CHECK_MODULES([QT_CORE], [${qt_lib_prefix}Core $qt_version], [], + [POCKETCOIN_QT_FAIL([${qt_lib_prefix}Core $qt_version not found])]) ]) - - POCKETCOIN_QT_CHECK([AC_CHECK_HEADER([QtPlugin],,POCKETCOIN_QT_FAIL(QtCore headers missing))]) - POCKETCOIN_QT_CHECK([AC_CHECK_HEADER([QApplication],, POCKETCOIN_QT_FAIL(QtGui headers missing))]) - POCKETCOIN_QT_CHECK([AC_CHECK_HEADER([QLocalSocket],, POCKETCOIN_QT_FAIL(QtNetwork headers missing))]) - POCKETCOIN_QT_CHECK([ - if test "x$pocketcoin_qt_want_version" = xauto; then - _POCKETCOIN_QT_CHECK_QT5 - _POCKETCOIN_QT_CHECK_QT58 - fi - QT_LIB_PREFIX=Qt5 + PKG_CHECK_MODULES([QT_GUI], [${qt_lib_prefix}Gui $qt_version], [], + [POCKETCOIN_QT_FAIL([${qt_lib_prefix}Gui $qt_version not found])]) ]) - POCKETCOIN_QT_CHECK([ - LIBS= - if test "x$qt_lib_path" != x; then - LIBS="$LIBS -L$qt_lib_path" - fi - - if test "x$TARGET_OS" = xwindows; then - AC_CHECK_LIB([imm32], [main],, POCKETCOIN_QT_FAIL(libimm32 not found)) - fi + PKG_CHECK_MODULES([QT_WIDGETS], [${qt_lib_prefix}Widgets $qt_version], [], + [POCKETCOIN_QT_FAIL([${qt_lib_prefix}Widgets $qt_version not found])]) ]) - - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in]))) - POCKETCOIN_QT_CHECK(AC_SEARCH_LIBS([jpeg_create_decompress] ,[qtjpeg jpeg],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in]))) - if test x$pocketcoin_cv_qt58 = xno; then - POCKETCOIN_QT_CHECK(AC_SEARCH_LIBS([png_error] ,[qtpng png],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in]))) - POCKETCOIN_QT_CHECK(AC_SEARCH_LIBS([pcre16_exec], [qtpcre pcre16],,AC_MSG_WARN([libpcre16 not found. Assuming qt has it built-in]))) - else - POCKETCOIN_QT_CHECK(AC_SEARCH_LIBS([png_error] ,[qtlibpng png],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in]))) - POCKETCOIN_QT_CHECK(AC_SEARCH_LIBS([pcre2_match_16], [qtpcre2 libqtpcre2],,AC_MSG_WARN([libqtpcre2 not found. Assuming qt has it built-in]))) - fi - POCKETCOIN_QT_CHECK(AC_SEARCH_LIBS([hb_ot_tags_from_script] ,[qtharfbuzzng qtharfbuzz harfbuzz],,AC_MSG_WARN([libharfbuzz not found. Assuming qt has it built-in or support is disabled]))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core] ,[main],,POCKETCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Core not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui] ,[main],,POCKETCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Gui not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,POCKETCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Network not found))) - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Widgets],[main],,POCKETCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Widgets not found))) - QT_LIBS="$LIBS" - LIBS="$TEMP_LIBS" + POCKETCOIN_QT_CHECK([ + PKG_CHECK_MODULES([QT_NETWORK], [${qt_lib_prefix}Network $qt_version], [], + [POCKETCOIN_QT_FAIL([${qt_lib_prefix}Network $qt_version not found])]) + ]) + QT_INCLUDES="$QT_CORE_CFLAGS $QT_GUI_CFLAGS $QT_WIDGETS_CFLAGS $QT_NETWORK_CFLAGS" + QT_LIBS="$QT_CORE_LIBS $QT_GUI_LIBS $QT_WIDGETS_LIBS $QT_NETWORK_LIBS" POCKETCOIN_QT_CHECK([ - LIBS= - if test "x$qt_lib_path" != x; then - LIBS="-L$qt_lib_path" - fi - AC_CHECK_LIB([${QT_LIB_PREFIX}Test], [main],, have_qt_test=no) - AC_CHECK_HEADER([QTest],, have_qt_test=no) - QT_TEST_LIBS="$LIBS" + PKG_CHECK_MODULES([QT_TEST], [${qt_lib_prefix}Test $qt_version], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no]) if test "x$use_dbus" != xno; then - LIBS= - if test "x$qt_lib_path" != x; then - LIBS="-L$qt_lib_path" - fi - AC_CHECK_LIB([${QT_LIB_PREFIX}DBus], [main],, have_qt_dbus=no) - AC_CHECK_HEADER([QtDBus],, have_qt_dbus=no) - QT_DBUS_LIBS="$LIBS" + PKG_CHECK_MODULES([QT_DBUS], [${qt_lib_prefix}DBus $qt_version], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no]) fi ]) - CPPFLAGS="$TEMP_CPPFLAGS" - CXXFLAGS="$TEMP_CXXFLAGS" - LIBS="$TEMP_LIBS" ]) - diff --git a/build_msvc/pocketcoin_config.h b/build_msvc/pocketcoin_config.h index 898d86e87..57a880834 100644 --- a/build_msvc/pocketcoin_config.h +++ b/build_msvc/pocketcoin_config.h @@ -11,10 +11,10 @@ #define CLIENT_VERSION_MAJOR 0 /* Minor version */ -#define CLIENT_VERSION_MINOR 20 +#define CLIENT_VERSION_MINOR 21 /* Build revision */ -#define CLIENT_VERSION_REVISION 19 +#define CLIENT_VERSION_REVISION 0 /* Version Build */ #define CLIENT_VERSION_BUILD 0 @@ -346,7 +346,7 @@ #define PACKAGE_NAME "Pocketnet Core" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "Pocketnet Core 0.20.19" +#define PACKAGE_STRING "Pocketnet Core 0.21.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "pocketcoin" @@ -355,7 +355,7 @@ #define PACKAGE_URL "https://github.com/pocketnetteam" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.20.19" +#define PACKAGE_VERSION "0.21.0" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ diff --git a/configure.ac b/configure.ac index ddaaf90b6..590fb6fc0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,23 +1,30 @@ -dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) -AC_PREREQ([2.60]) +AC_PREREQ([2.69]) define(_CLIENT_VERSION_MAJOR, 0) -define(_CLIENT_VERSION_MINOR, 20) -define(_CLIENT_VERSION_REVISION, 19) +define(_CLIENT_VERSION_MINOR, 21) +define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_BUILD, 0) +define(_CLIENT_VERSION_RC, 0) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2022) define(_COPYRIGHT_HOLDERS,[The %s developers]) define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Pocketnet]]) -AC_INIT([Pocketnet Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/pocketnetteam/pocketnet.core/issues],[pocketnetcore],[https://github.com/pocketnetteam/]) +AC_INIT([Pocketnet Core],m4_join([.], _CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MINOR, _CLIENT_VERSION_REVISION, m4_if(_CLIENT_VERSION_BUILD, [0], [], _CLIENT_VERSION_BUILD))m4_if(_CLIENT_VERSION_RC, [0], [], [rc]_CLIENT_VERSION_RC),[https://github.com/pocketnetteam/pocketnet.core/issues],[pocketnetcore],[https://github.com/pocketnetteam/]) AC_CONFIG_SRCDIR([src/validation.cpp]) AC_CONFIG_HEADERS([src/config/pocketcoin-config.h]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([build-aux/m4]) +m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR([PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh])]) +PKG_PROG_PKG_CONFIG +if test "x$PKG_CONFIG" = x; then + AC_MSG_ERROR([pkg-config not found]) +fi + POCKETCOIN_DAEMON_NAME=pocketcoind POCKETCOIN_GUI_NAME=pocketcoin-qt POCKETCOIN_CLI_NAME=pocketcoin-cli POCKETCOIN_TX_NAME=pocketcoin-tx +# POCKETCOIN_WALLET_TOOL_NAME=pocketcoin-wallet dnl Unless the user specified ARFLAGS, force it to be cr AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to if not set]) @@ -35,14 +42,14 @@ dnl faketime breaks configure and is only needed for make. Disable it here. unset FAKETIME dnl Automake init set-up and checks -AM_INIT_AUTOMAKE([no-define subdir-objects foreign]) +AM_INIT_AUTOMAKE([1.13 no-define subdir-objects foreign]) dnl faketime messes with timestamps and causes configure to be re-run. dnl --disable-maintainer-mode can be used to bypass this. AM_MAINTAINER_MODE([enable]) dnl make the compilation flags quiet unless V=1 is used -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +AM_SILENT_RULES([yes]) dnl Compiler checks (here before libtool). if test "x${CXXFLAGS+set}" = "xset"; then @@ -60,8 +67,9 @@ case $host in lt_cv_deplibs_check_method="pass_all" ;; esac -dnl Require C++11 compiler (no GNU extensions) -AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory], [nodefault]) + +AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) + dnl Check if -latomic is required for CHECK_ATOMIC @@ -74,6 +82,10 @@ fi AC_PROG_OBJCXX ]) +dnl Since libtool 1.5.2 (released 2004-01-25), on Linux libtool no longer +dnl sets RPATH for any directories in the dynamic linker search path. +dnl See more: https://wiki.debian.org/RpathIssue +LT_PREREQ([1.5.2]) dnl Libtool init checks. LT_INIT([pic-only]) @@ -82,9 +94,10 @@ AC_PATH_TOOL(AR, ar) AC_PATH_TOOL(RANLIB, ranlib) AC_PATH_TOOL(STRIP, strip) AC_PATH_TOOL(GCOV, gcov) +AC_PATH_TOOL(LLVM_COV, llvm-cov) AC_PATH_PROG(LCOV, lcov) -dnl Python 3.x is supported from 3.4 on (see https://github.com/pocketcoin/pocketcoin/issues/7893) -AC_PATH_PROGS([PYTHON], [python3.7 python3.6 python3.5 python3.4 python3 python]) +dnl Python 3.5 is specified in .python-version and should be used if available, see doc/dependencies.md +AC_PATH_PROGS([PYTHON], [python3.5 python3.6 python3.7 python3.8 python3 python]) AC_PATH_PROG(GENHTML, genhtml) AC_PATH_PROG([GIT], [git]) AC_PATH_PROG(CCACHE,ccache) @@ -94,20 +107,24 @@ AC_PATH_TOOL(READELF, readelf) AC_PATH_TOOL(CPPFILT, c++filt) AC_PATH_TOOL(OBJCOPY, objcopy) AC_PATH_PROG(DOXYGEN, doxygen) -if test -z "$DOXYGEN"; then - AC_MSG_WARN([Doxygen not found]) -fi AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) AC_ARG_VAR(PYTHONPATH, Augments the default search path for python module files) -# Enable wallet AC_ARG_ENABLE([wallet], [AS_HELP_STRING([--disable-wallet], [disable wallet (enabled by default)])], [enable_wallet=$enableval], [enable_wallet=yes]) +# We are using bundled sqlite so explicitly disable it here to avoid autotools finding it on system +# AC_ARG_WITH([sqlite], +# [AS_HELP_STRING([--with-sqlite=yes|no|auto], +# [enable sqlite wallet support (default: auto, i.e., enabled if wallet is enabled and sqlite is found)])], +# [use_sqlite=$withval], +# [use_sqlite=auto]) +use_sqlite=yes + AC_ARG_WITH([miniupnpc], [AS_HELP_STRING([--with-miniupnpc], [enable UPNP (default is yes if libminiupnpc is found)])], @@ -130,12 +147,6 @@ AC_ARG_ENABLE([gui-tests], [use_gui_tests=$enableval], [use_gui_tests=$use_tests]) -AC_ARG_WITH([rapidcheck], - [AS_HELP_STRING([--with-rapidcheck], - [enable RapidCheck property based tests (default is yes if librapidcheck is found)])], - [use_rapidcheck=$withval], - [use_rapidcheck=auto]) - AC_ARG_ENABLE(bench, AS_HELP_STRING([--disable-bench],[do not compile benchmarks (default is to compile)]), [use_bench=$enableval], @@ -146,6 +157,12 @@ AC_ARG_ENABLE([extended-functional-tests], [use_extended_functional_tests=$enableval], [use_extended_functional_tests=no]) +AC_ARG_ENABLE([fuzz], + AS_HELP_STRING([--enable-fuzz], + [enable building of fuzz targets (default no). enabling this will disable all other targets]), + [enable_fuzz=$enableval], + [enable_fuzz=no]) + AC_ARG_WITH([qrencode], [AS_HELP_STRING([--with-qrencode], [enable QR code support (default is yes if qt is enabled and libqrencode is found)])], @@ -170,6 +187,16 @@ AC_ARG_ENABLE([ccache], [use_ccache=$enableval], [use_ccache=auto]) +dnl Suppress warnings from external headers (e.g. Boost, Qt). +dnl May be useful if warnings from external headers clutter the build output +dnl too much, so that it becomes difficult to spot Pocketcoin Core warnings +dnl or if they cause a build failure with --enable-werror. +AC_ARG_ENABLE([suppress-external-warnings], + [AS_HELP_STRING([--enable-suppress-external-warnings], + [Suppress warnings from external headers (default is no)])], + [suppress_external_warnings=$enableval], + [suppress_external_warnings=no]) + AC_ARG_ENABLE([lcov], [AS_HELP_STRING([--enable-lcov], [enable lcov testing (default is no)])], @@ -188,9 +215,15 @@ AC_ARG_ENABLE([glibc-back-compat], [use_glibc_compat=$enableval], [use_glibc_compat=no]) +AC_ARG_ENABLE([threadlocal], + [AS_HELP_STRING([--enable-threadlocal], + [enable features that depend on the c++ thread_local keyword (currently just thread names in debug logs). (default is to enabled if there is platform support and glibc-back-compat is not enabled)])], + [use_thread_local=$enableval], + [use_thread_local=auto]) + AC_ARG_ENABLE([asm], - [AS_HELP_STRING([--enable-asm], - [Enable assembly routines (default is yes)])], + [AS_HELP_STRING([--disable-asm], + [disable assembly routines (enabled by default)])], [use_asm=$enableval], [use_asm=yes]) @@ -210,7 +243,23 @@ AC_ARG_ENABLE([zmq], [use_zmq=$enableval], [use_zmq=yes]) -AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], []) +AC_ARG_WITH([libmultiprocess], + [AS_HELP_STRING([--with-libmultiprocess=yes|no|auto], + [Build with libmultiprocess library. (default: auto, i.e. detect with pkg-config)])], + [with_libmultiprocess=$withval], + [with_libmultiprocess=auto]) + +AC_ARG_WITH([mpgen], + [AS_HELP_STRING([--with-mpgen=yes|no|auto|PREFIX], + [Build with libmultiprocess codegen tool. Useful to specify different libmultiprocess host system library and build system codegen tool prefixes when cross-compiling (default is host system libmultiprocess prefix)])], + [with_mpgen=$withval], + [with_mpgen=auto]) + +AC_ARG_ENABLE([multiprocess], + [AS_HELP_STRING([--enable-multiprocess], + [build multiprocess pocketcoin-node, and pocketcoin-gui executables in addition to monolithic pocketcoind and pocketcoin-qt executables. Requires libmultiprocess library. Experimental (default is no)])], + [enable_multiprocess=$enableval], + [enable_multiprocess=no]) AC_ARG_ENABLE(man, [AS_HELP_STRING([--disable-man], @@ -218,27 +267,34 @@ AC_ARG_ENABLE(man, enable_man=yes) AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no) -# Enable debug +dnl Enable debug AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], - [use debug compiler flags and macros (default is no)])], + [use compiler flags and macros suited for debugging (default is no)])], [enable_debug=$enableval], [enable_debug=no]) -# Enable different -fsanitize options +dnl Enable different -fsanitize options AC_ARG_WITH([sanitizers], [AS_HELP_STRING([--with-sanitizers], [comma separated list of extra sanitizers to build with (default is none enabled)])], [use_sanitizers=$withval]) -# Enable gprof profiling +dnl Enable gprof profiling AC_ARG_ENABLE([gprof], [AS_HELP_STRING([--enable-gprof], [use gprof profiling compiler flags (default is no)])], [enable_gprof=$enableval], [enable_gprof=no]) -# Turn warnings into errors +dnl Pass compiler & linker flags that make builds deterministic +AC_ARG_ENABLE([determinism], + [AS_HELP_STRING([--enable-determinism], + [Enable compilation flags that make builds deterministic (default is no)])], + [enable_determinism=$enableval], + [enable_determinism=no]) + +dnl Turn warnings into errors AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat certain compiler warnings as errors (default is no)])], @@ -246,21 +302,40 @@ AC_ARG_ENABLE([werror], [enable_werror=no]) AC_LANG_PUSH([C++]) + +dnl Check for a flag to turn compiler warnings into errors. This is helpful for checks which may +dnl appear to succeed because by default they merely emit warnings when they fail. +dnl +dnl Note that this is not necessarily a check to see if -Werror is supported, but rather to see if +dnl a compile with -Werror can succeed. This is important because the compiler may already be +dnl warning about something unrelated, for example about some path issue. If that is the case, +dnl -Werror cannot be used because all of those warnings would be turned into errors. AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""]) +dnl Check for a flag to turn linker warnings into errors. When flags are passed to linkers via the +dnl compiler driver using a -Wl,-foo flag, linker warnings may be swallowed rather than bubbling up. +dnl See note above, the same applies here as well. +dnl +dnl LDFLAG_WERROR Should only be used when testing -Wl,* +case $host in + *darwin*) + AX_CHECK_LINK_FLAG([-Wl,-fatal_warnings],[LDFLAG_WERROR="-Wl,-fatal_warnings"],[LDFLAG_WERROR=""]) + ;; + *) + AX_CHECK_LINK_FLAG([-Wl,--fatal-warnings],[LDFLAG_WERROR="-Wl,--fatal-warnings"],[LDFLAG_WERROR=""]) + ;; +esac + if test "x$enable_debug" = xyes; then - # Clear default -g -O2 flags + dnl Clear default -g -O2 flags if test "x$CXXFLAGS_overridden" = xno; then CXXFLAGS="" fi - # Prefer -Og, fall back to -O0 if that is unavailable. - AX_CHECK_COMPILE_FLAG( - [-Og], - [[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Og"]], - [AX_CHECK_COMPILE_FLAG([-O0],[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -O0"]],,[[$CXXFLAG_WERROR]])], - [[$CXXFLAG_WERROR]]) - # Prefer -g3, fall back to -g if that is unavailable. + dnl Disable all optimizations + AX_CHECK_COMPILE_FLAG([-O0], [[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -O0"]],,[[$CXXFLAG_WERROR]]) + + dnl Prefer -g3, fall back to -g if that is unavailable. AX_CHECK_COMPILE_FLAG( [-g3], [[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g3"]], @@ -273,23 +348,30 @@ if test "x$enable_debug" = xyes; then fi if test x$use_sanitizers != x; then - # First check if the compiler accepts flags. If an incompatible pair like - # -fsanitize=address,thread is used here, this check will fail. This will also - # fail if a bad argument is passed, e.g. -fsanitize=undfeined + dnl First check if the compiler accepts flags. If an incompatible pair like + dnl -fsanitize=address,thread is used here, this check will fail. This will also + dnl fail if a bad argument is passed, e.g. -fsanitize=undfeined AX_CHECK_COMPILE_FLAG( [[-fsanitize=$use_sanitizers]], [[SANITIZER_CXXFLAGS=-fsanitize=$use_sanitizers]], [AC_MSG_ERROR([compiler did not accept requested flags])]) - # Some compilers (e.g. GCC) require additional libraries like libasan, - # libtsan, libubsan, etc. Make sure linking still works with the sanitize - # flag. This is a separate check so we can give a better error message when - # the sanitize flags are supported by the compiler but the actual sanitizer - # libs are missing. + dnl Some compilers (e.g. GCC) require additional libraries like libasan, + dnl libtsan, libubsan, etc. Make sure linking still works with the sanitize + dnl flag. This is a separate check so we can give a better error message when + dnl the sanitize flags are supported by the compiler but the actual sanitizer + dnl libs are missing. AX_CHECK_LINK_FLAG( [[-fsanitize=$use_sanitizers]], [[SANITIZER_LDFLAGS=-fsanitize=$use_sanitizers]], - [AC_MSG_ERROR([linker did not accept requested flags, you are missing required libraries])]) + [AC_MSG_ERROR([linker did not accept requested flags, you are missing required libraries])], + [], + [AC_LANG_PROGRAM([[ + #include + #include + extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { return 0; } + __attribute__((weak)) // allow for libFuzzer linking + ]],[[]])]) fi ERROR_CXXFLAGS= @@ -297,33 +379,74 @@ if test "x$enable_werror" = "xyes"; then if test "x$CXXFLAG_WERROR" = "x"; then AC_MSG_ERROR("enable-werror set but -Werror is not usable") fi + AX_CHECK_COMPILE_FLAG([-Werror=gnu],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=gnu"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=thread-safety-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety-analysis"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=shadow-field],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=shadow-field"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=switch],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=switch"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=thread-safety],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=range-loop-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=range-loop-analysis"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]]) + dnl -Wsuggest-override is broken with GCC before 9.2 + dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010 + AX_CHECK_COMPILE_FLAG([-Werror=suggest-override],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=suggest-override"],,[[$CXXFLAG_WERROR]], + [AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])]) + AX_CHECK_COMPILE_FLAG([-Werror=unreachable-code-loop-increment],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]]) fi if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wall],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wextra],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wformat],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wgnu],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wgnu"],,[[$CXXFLAG_WERROR]]) + dnl some compilers will ignore -Wformat-security without -Wformat, so just combine the two here. + AX_CHECK_COMPILE_FLAG([-Wformat -Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat -Wformat-security"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wthread-safety-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety-analysis"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wshadow-field],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-field"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wswitch],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wswitch"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wthread-safety],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wrange-loop-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wrange-loop-analysis"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"],,[[$CXXFLAG_WERROR]]) - - ## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all - ## unknown options if any other warning is produced. Test the -Wfoo case, and - ## set the -Wno-foo case if it works. + AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wsign-compare],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsign-compare"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wduplicated-branches],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wduplicated-branches"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wduplicated-cond],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wduplicated-cond"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wlogical-op],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wlogical-op"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Woverloaded-virtual],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Woverloaded-virtual"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]], + [AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])]) + AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]]) + + dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all + dnl unknown options if any other warning is produced. Test the -Wfoo case, and + dnl set the -Wno-foo case if it works. AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wself-assign],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-copy"],,[[$CXXFLAG_WERROR]]) fi -# Check for optional instruction set support. Enabling these does _not_ imply that all code will -# be compiled with them, rather that specific objects/libs may use them after checking for runtime -# compatibility. +dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. +AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CXXFLAGS="$CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]]) + +enable_sse42=no +enable_sse41=no +enable_avx2=no +enable_shani=no + +if test "x$use_asm" = "xyes"; then + +dnl Check for optional instruction set support. Enabling these does _not_ imply that all code will +dnl be compiled with them, rather that specific objects/libs may use them after checking for runtime +dnl compatibility. + +dnl x86 AX_CHECK_COMPILE_FLAG([-msse4.2],[[SSE42_CXXFLAGS="-msse4.2"]],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-msse4.1],[[SSE41_CXXFLAGS="-msse4.1"]],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-mavx -mavx2],[[AVX2_CXXFLAGS="-mavx -mavx2"]],,[[$CXXFLAG_WERROR]]) @@ -331,7 +454,7 @@ AX_CHECK_COMPILE_FLAG([-msse4 -msha],[[SHANI_CXXFLAGS="-msse4 -msha"]],,[[$CXXFL TEMP_CXXFLAGS="$CXXFLAGS" CXXFLAGS="$CXXFLAGS $SSE42_CXXFLAGS" -AC_MSG_CHECKING(for assembler crc32 support) +AC_MSG_CHECKING(for SSE4.2 intrinsics) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #if defined(_MSC_VER) @@ -346,7 +469,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ l = _mm_crc32_u64(l, 0); return l; ]])], - [ AC_MSG_RESULT(yes); enable_hwcrc32=yes], + [ AC_MSG_RESULT(yes); enable_sse42=yes], [ AC_MSG_RESULT(no)] ) CXXFLAGS="$TEMP_CXXFLAGS" @@ -398,6 +521,26 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ) CXXFLAGS="$TEMP_CXXFLAGS" +# ARM +AX_CHECK_COMPILE_FLAG([-march=armv8-a+crc+crypto],[[ARM_CRC_CXXFLAGS="-march=armv8-a+crc+crypto"]],,[[$CXXFLAG_WERROR]]) + +TEMP_CXXFLAGS="$CXXFLAGS" +CXXFLAGS="$CXXFLAGS $ARM_CRC_CXXFLAGS" +AC_MSG_CHECKING(for ARM CRC32 intrinsics) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]],[[ + __crc32cb(0, 0); __crc32ch(0, 0); __crc32cw(0, 0); __crc32cd(0, 0); + vmull_p64(0, 0); + ]])], + [ AC_MSG_RESULT(yes); enable_arm_crc=yes; ], + [ AC_MSG_RESULT(no)] +) +CXXFLAGS="$TEMP_CXXFLAGS" + +fi + CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS" AC_ARG_WITH([utils], @@ -406,6 +549,24 @@ AC_ARG_WITH([utils], [build_pocketcoin_utils=$withval], [build_pocketcoin_utils=yes]) +AC_ARG_ENABLE([util-cli], + [AS_HELP_STRING([--enable-util-cli], + [build pocketcoin-cli])], + [build_pocketcoin_cli=$enableval], + [build_pocketcoin_cli=$build_pocketcoin_utils]) + +AC_ARG_ENABLE([util-tx], + [AS_HELP_STRING([--enable-util-tx], + [build pocketcoin-tx])], + [build_pocketcoin_tx=$enableval], + [build_pocketcoin_tx=$build_pocketcoin_utils]) + +# AC_ARG_ENABLE([util-wallet], +# [AS_HELP_STRING([--enable-util-wallet], +# [build pocketcoin-wallet])], +# [build_pocketcoin_wallet=$enableval], +# [build_pocketcoin_wallet=$build_pocketcoin_utils]) + AC_ARG_WITH([libs], [AS_HELP_STRING([--with-libs], [build libraries (default=yes)])], @@ -418,36 +579,34 @@ AC_ARG_WITH([daemon], [build_pocketcoind=$withval], [build_pocketcoind=yes]) -use_pkgconfig=yes -case $host in - *mingw*) +dnl Restore openssl that was removed from bitcoin 0.21 +AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) +AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) - #pkgconfig does more harm than good with MinGW - use_pkgconfig=no +AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),) +AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing)) +case $host in + *mingw*) TARGET_OS=windows - AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(libmingwthrd missing)) - AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(libkernel32 missing)) - AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(libuser32 missing)) - AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(libgdi32 missing)) - AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(libcomdlg32 missing)) - AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(libwinspool missing)) - AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(libwinmm missing)) - AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(libshell32 missing)) - AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(libcomctl32 missing)) - AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(libole32 missing)) - AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(liboleaut32 missing)) - AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(libuuid missing)) - AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(librpcrt4 missing)) - AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(libadvapi32 missing)) - AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(libws2_32 missing)) - AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(libmswsock missing)) - AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(libshlwapi missing)) - AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(libiphlpapi missing)) - AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(libcrypt32 missing)) - - # -static is interpreted by libtool, where it has a different meaning. - # In libtool-speak, it's -all-static. + AC_CHECK_LIB([kernel32], [GetModuleFileNameA],, AC_MSG_ERROR(libkernel32 missing)) + AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(libuser32 missing)) + AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(libgdi32 missing)) + AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(libcomdlg32 missing)) + AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(libwinmm missing)) + AC_CHECK_LIB([shell32], [SHGetSpecialFolderPathW],, AC_MSG_ERROR(libshell32 missing)) + AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(libcomctl32 missing)) + AC_CHECK_LIB([ole32], [CoCreateInstance],, AC_MSG_ERROR(libole32 missing)) + AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(liboleaut32 missing)) + AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(libuuid missing)) + AC_CHECK_LIB([advapi32], [CryptAcquireContextW],, AC_MSG_ERROR(libadvapi32 missing)) + AC_CHECK_LIB([ws2_32], [WSAStartup],, AC_MSG_ERROR(libws2_32 missing)) + AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(libmswsock missing)) + AC_CHECK_LIB([shlwapi], [PathRemoveFileSpecW],, AC_MSG_ERROR(libshlwapi missing)) + AC_CHECK_LIB([iphlpapi], [GetAdaptersAddresses],, AC_MSG_ERROR(libiphlpapi missing)) + + dnl -static is interpreted by libtool, where it has a different meaning. + dnl In libtool-speak, it's -all-static. AX_CHECK_LINK_FLAG([[-static]],[LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"]) AC_PATH_PROG([MAKENSIS], [makensis], none) @@ -460,17 +619,8 @@ case $host in AC_MSG_ERROR("windres not found") fi - CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB" - LEVELDB_TARGET_FLAGS="-DOS_WINDOWS" - if test "x$CXXFLAGS_overridden" = "xno"; then - CXXFLAGS="$CXXFLAGS -w" - fi - case $host in - i?86-*) WINDOWS_BITS=32 ;; - x86_64-*) WINDOWS_BITS=64 ;; - *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;; - esac - AC_SUBST(WINDOWS_BITS) + CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" + case $host in i?86-*) LINUX_BITS=32 ;; x86_64-*) LINUX_BITS=64 ;; @@ -486,23 +636,13 @@ case $host in archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib" postdeps_CXX= + dnl We require Windows 7 (NT 6.1) or later + AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[LDFLAGS="$LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]]) ;; *darwin*) TARGET_OS=darwin - LEVELDB_TARGET_FLAGS="-DOS_MACOSX" if test x$cross_compiling != xyes; then BUILD_OS=darwin - AC_CHECK_PROG([PORT],port, port) - if test x$PORT = xport; then - dnl add default macports paths - CPPFLAGS="$CPPFLAGS -isystem /opt/local/include" - LIBS="$LIBS -L/opt/local/lib" - if test -d /opt/local/include/db48; then - CPPFLAGS="$CPPFLAGS -I/opt/local/include/db48" - LIBS="$LIBS -L/opt/local/lib/db48" - fi - fi - AC_PATH_PROGS([RSVG_CONVERT], [rsvg-convert rsvg],rsvg-convert) AC_CHECK_PROG([BREW],brew, brew) if test x$BREW = xbrew; then @@ -512,20 +652,15 @@ case $host in dnl It's safe to add these paths even if the functionality is disabled by dnl the user (--without-wallet or --without-gui for example). - openssl_prefix=`$BREW --prefix openssl 2>/dev/null` - bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null` - qt5_prefix=`$BREW --prefix qt5 2>/dev/null` - if test x$openssl_prefix != x; then - PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" - export PKG_CONFIG_PATH + if test "x$use_bdb" != xno && $BREW list --versions berkeley-db4 >/dev/null && test "x$BDB_CFLAGS" = "x" && test "x$BDB_LIBS" = "x"; then + bdb_prefix=$($BREW --prefix berkeley-db4 2>/dev/null) + dnl This must precede the call to POCKETCOIN_FIND_BDB48 below. + BDB_CFLAGS="-I$bdb_prefix/include" + BDB_LIBS="-L$bdb_prefix/lib -ldb_cxx-4.8" fi - if test x$bdb_prefix != x; then - CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include" - LIBS="$LIBS -L$bdb_prefix/lib" - fi - if test x$qt5_prefix != x; then - PKG_CONFIG_PATH="$qt5_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" - export PKG_CONFIG_PATH + + if $BREW list --versions qt5 >/dev/null; then + export PKG_CONFIG_PATH="$($BREW --prefix qt5 2>/dev/null)/lib/pkgconfig:$PKG_CONFIG_PATH" fi fi else @@ -534,6 +669,7 @@ case $host in BUILD_OS=darwin ;; *) + AC_PATH_TOOL([DSYMUTIL], [dsymutil], dsymutil) AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool) AC_PATH_TOOL([OTOOL], [otool], otool) AC_PATH_PROGS([GENISOIMAGE], [genisoimage mkisofs],genisoimage) @@ -550,54 +686,19 @@ case $host in esac fi - AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"]) + AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"],, [[$LDFLAG_WERROR]]) CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0" OBJCXXFLAGS="$CXXFLAGS" ;; *android*) dnl make sure android stays above linux for hosts like *linux-android* - LEVELDB_TARGET_FLAGS="-DOS_ANDROID" + TARGET_OS=android ;; *linux*) TARGET_OS=linux - LEVELDB_TARGET_FLAGS="-DOS_LINUX" - ;; - *kfreebsd*) - LEVELDB_TARGET_FLAGS="-DOS_KFREEBSD" - ;; - *freebsd*) - LEVELDB_TARGET_FLAGS="-DOS_FREEBSD" - ;; - *openbsd*) - LEVELDB_TARGET_FLAGS="-DOS_OPENBSD" - ;; - *netbsd*) - LEVELDB_TARGET_FLAGS="-DOS_NETBSD" - ;; - *dragonfly*) - LEVELDB_TARGET_FLAGS="-DOS_DRAGONFLYBSD" - ;; - *solaris*) - LEVELDB_TARGET_FLAGS="-DOS_SOLARIS" - ;; - *hpux*) - LEVELDB_TARGET_FLAGS="-DOS_HPUX" - ;; - *) - AC_MSG_ERROR(Cannot build leveldb for $host. Please file a bug report.) ;; esac -if test x$use_pkgconfig = xyes; then - m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR(PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh.)]) - m4_ifdef([PKG_PROG_PKG_CONFIG], [ - PKG_PROG_PKG_CONFIG - if test x"$PKG_CONFIG" = "x"; then - AC_MSG_ERROR(pkg-config not found.) - fi - ]) -fi - if test x$use_extended_functional_tests != xno; then AC_SUBST(EXTENDED_FUNCTIONAL_TESTS, --extended) fi @@ -606,21 +707,41 @@ if test x$use_lcov = xyes; then if test x$LCOV = x; then AC_MSG_ERROR("lcov testing requested but lcov not found") fi - if test x$GCOV = x; then - AC_MSG_ERROR("lcov testing requested but gcov not found") - fi if test x$PYTHON = x; then AC_MSG_ERROR("lcov testing requested but python not found") fi if test x$GENHTML = x; then AC_MSG_ERROR("lcov testing requested but genhtml not found") fi - LCOV="$LCOV --gcov-tool=$GCOV" + + AC_MSG_CHECKING([whether compiler is Clang]) + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ + #if defined(__clang__) && defined(__llvm__) + // Compiler is Clang + #else + # error Compiler is not Clang + #endif + ]])],[ + AC_MSG_RESULT([yes]) + if test x$LLVM_COV = x; then + AC_MSG_ERROR([lcov testing requested but llvm-cov not found]) + fi + COV_TOOL="$LLVM_COV gcov" + ],[ + AC_MSG_RESULT([no]) + if test x$GCOV = x; then + AC_MSG_ERROR([lcov testing requested but gcov not found]) + fi + COV_TOOL="$GCOV" + ]) + AC_SUBST(COV_TOOL) + AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh") + LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER" + AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"], [AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")]) AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"], [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")]) - AC_DEFINE(USE_COVERAGE, 1, [Define this symbol if coverage is enabled]) CXXFLAGS="$CXXFLAGS -Og" fi @@ -634,11 +755,11 @@ AC_C_BIGENDIAN dnl Check for pthread compile/link requirements AX_PTHREAD -# The following macro will add the necessary defines to pocketcoin-config.h, but -# they also need to be passed down to any subprojects. Pull the results out of -# the cache and add them to CPPFLAGS. +dnl The following macro will add the necessary defines to pocketcoin-config.h, but +dnl they also need to be passed down to any subprojects. Pull the results out of +dnl the cache and add them to CPPFLAGS. AC_SYS_LARGEFILE -# detect POSIX or GNU variant of strerror_r +dnl detect POSIX or GNU variant of strerror_r AC_FUNC_STRERROR_R if test x$ac_cv_sys_file_offset_bits != x && @@ -653,31 +774,11 @@ if test x$ac_cv_sys_large_files != x && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" fi -AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"]) - AX_GCC_FUNC_ATTRIBUTE([visibility]) AX_GCC_FUNC_ATTRIBUTE([dllexport]) AX_GCC_FUNC_ATTRIBUTE([dllimport]) if test x$use_glibc_compat != xno; then - - #glibc absorbed clock_gettime in 2.17. librt (its previous location) is safe to link - #in anyway for back-compat. - AC_CHECK_LIB([rt],[clock_gettime],, AC_MSG_ERROR(librt missing)) - - #__fdelt_chk's params and return type have changed from long unsigned int to long int. - # See which one is present here. - AC_MSG_CHECKING(__fdelt_chk type) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef _FORTIFY_SOURCE - #undef _FORTIFY_SOURCE - #endif - #define _FORTIFY_SOURCE 2 - #include - extern "C" long unsigned int __fdelt_warn(long unsigned int);]],[[]])], - [ fdelt_type="long unsigned int"], - [ fdelt_type="long int"]) - AC_MSG_RESULT($fdelt_type) - AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk]) AX_CHECK_LINK_FLAG([[-Wl,--wrap=__divmoddi4]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"]) AX_CHECK_LINK_FLAG([[-Wl,--wrap=log2f]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"]) else @@ -702,27 +803,45 @@ if test "x$enable_gprof" = xyes; then fi if test x$TARGET_OS != xwindows; then - # All windows code is PIC, forcing it on just adds useless compile warnings + dnl All windows code is PIC, forcing it on just adds useless compile warnings AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"]) fi +dnl All versions of gcc that we commonly use for building are subject to bug +dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set +dnl -fstack-reuse=none for all gcc builds. (Only gcc understands this flag) +AX_CHECK_COMPILE_FLAG([-fstack-reuse=none],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-reuse=none"]) if test x$use_hardening != xno; then use_hardening=yes AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"]) AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"]) - AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[ - AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ - HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE" + AX_CHECK_COMPILE_FLAG([-fcf-protection=full],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fcf-protection=full"]) + + dnl stack-clash-protection does not work properly when building for Windows. + dnl We use the test case from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458 + dnl to determine if it can be enabled. + AX_CHECK_COMPILE_FLAG([-fstack-clash-protection],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-clash-protection"],[],["-O0"], + [AC_LANG_SOURCE([[class D {public: unsigned char buf[32768];}; int main() {D d; return 0;}]])]) + + dnl When enable_debug is yes, all optimizations are disabled. + dnl However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning. + dnl Since FORTIFY_SOURCE is a no-op without optimizations, do not enable it when enable_debug is yes. + if test x$enable_debug != xyes; then + AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[ + AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ + HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE" + ]) + HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2" ]) - HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2" - ]) + fi - AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"]) - AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"]) - AX_CHECK_LINK_FLAG([[-Wl,--high-entropy-va]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"]) - AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"]) - AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"]) + AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,--high-entropy-va]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-z,separate-code]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,separate-code"],, [[$LDFLAG_WERROR]]) AX_CHECK_LINK_FLAG([[-fPIE -pie]], [PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],, [[$CXXFLAG_WERROR]]) case $host in @@ -732,20 +851,30 @@ if test x$use_hardening != xno; then esac fi -dnl this flag screws up non-darwin gcc even when the check fails. special-case it. +dnl These flags are specific to ld64, and may cause issues with other linkers. +dnl For example: GNU ld will interpret -dead_strip as -de and then try and use +dnl "ad_strip" as the symbol for the entry point. if test x$TARGET_OS = xdarwin; then - AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"]) + AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-bind_at_load]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-bind_at_load"],, [[$LDFLAG_WERROR]]) +fi + +if test x$enable_determinism = xyes; then + if test x$TARGET_OS = xwindows; then + AX_CHECK_LINK_FLAG([[-Wl,--no-insert-timestamp]], [LDFLAGS="$LDFLAGS -Wl,--no-insert-timestamp"],, [[$LDFLAG_WERROR]]) + fi fi -AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h]) +AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h]) -AC_CHECK_DECLS([getifaddrs, freeifaddrs],,, +AC_CHECK_DECLS([getifaddrs, freeifaddrs],[CHECK_SOCKET],, [#include #include ] ) AC_CHECK_DECLS([strnlen]) -# Check for daemon(3), unrelated to --with-daemon (although used by it) +dnl Check for daemon(3), unrelated to --with-daemon (although used by it) AC_CHECK_DECLS([daemon]) AC_CHECK_DECLS([le16toh, le32toh, le64toh, htole16, htole32, htole64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64],,, @@ -760,7 +889,21 @@ AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64],,, #include #endif]) -AC_CHECK_DECLS([__builtin_clz, __builtin_clzl, __builtin_clzll]) +AC_MSG_CHECKING(for __builtin_clzl) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ + (void) __builtin_clzl(0); + ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_BUILTIN_CLZL, 1, [Define this symbol if you have __builtin_clzl])], + [ AC_MSG_RESULT(no)] +) + +AC_MSG_CHECKING(for __builtin_clzll) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ + (void) __builtin_clzll(0); + ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_BUILTIN_CLZLL, 1, [Define this symbol if you have __builtin_clzll])], + [ AC_MSG_RESULT(no)] +) dnl Check for malloc_info (for memory statistics information in getmemoryinfo) AC_MSG_CHECKING(for getmemoryinfo) @@ -778,6 +921,22 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [ AC_MSG_RESULT(no)] ) +dnl Check for posix_fallocate +AC_MSG_CHECKING(for posix_fallocate) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + // same as in src/util/system.cpp + #ifdef __linux__ + #ifdef _POSIX_C_SOURCE + #undef _POSIX_C_SOURCE + #endif + #define _POSIX_C_SOURCE 200112L + #endif // __linux__ + #include ]], + [[ int f = posix_fallocate(0, 0, 0); ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_POSIX_FALLOCATE, 1,[Define this symbol if you have posix_fallocate]) ], + [ AC_MSG_RESULT(no)] +) + AC_MSG_CHECKING([for visibility attribute]) AC_LINK_IFELSE([AC_LANG_SOURCE([ int foo_def( void ) __attribute__((visibility("default"))); @@ -795,29 +954,65 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([ ] ) -TEMP_LDFLAGS="$LDFLAGS" -LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS" -AC_MSG_CHECKING([for thread_local support]) -AC_LINK_IFELSE([AC_LANG_SOURCE([ - #include - static thread_local int foo = 0; - static void run_thread() { foo++;} - int main(){ - for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();} - return foo; - } - ])], - [ - AC_DEFINE(HAVE_THREAD_LOCAL,1,[Define if thread_local is supported.]) - AC_MSG_RESULT(yes) - ], - [ - AC_MSG_RESULT(no) +dnl thread_local is currently disabled when building with glibc back compat. +dnl Our minimum supported glibc is 2.17, however support for thread_local +dnl did not arrive in glibc until 2.18. +if test "x$use_thread_local" = xyes || { test "x$use_thread_local" = xauto && test "x$use_glibc_compat" = xno; }; then + TEMP_LDFLAGS="$LDFLAGS" + LDFLAGS="$TEMP_LDFLAGS $PTHREAD_CFLAGS" + AC_MSG_CHECKING([for thread_local support]) + AC_LINK_IFELSE([AC_LANG_SOURCE([ + #include + static thread_local int foo = 0; + static void run_thread() { foo++;} + int main(){ + for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();} + return foo; + } + ])], + [ + case $host in + *mingw*) + dnl mingw32's implementation of thread_local has also been shown to behave + dnl erroneously under concurrent usage; see: + dnl https://gist.github.com/jamesob/fe9a872051a88b2025b1aa37bfa98605 + AC_MSG_RESULT(no) + ;; + *freebsd*) + dnl FreeBSD's implementation of thread_local is also buggy (per + dnl https://groups.google.com/d/msg/bsdmailinglist/22ncTZAbDp4/Dii_pII5AwAJ) + AC_MSG_RESULT(no) + ;; + *) + AC_DEFINE(HAVE_THREAD_LOCAL,1,[Define if thread_local is supported.]) + AC_MSG_RESULT(yes) + ;; + esac + ], + [ + AC_MSG_RESULT(no) + ] + ) + LDFLAGS="$TEMP_LDFLAGS" +fi + +dnl check for gmtime_r(), fallback to gmtime_s() if that is unavailable +dnl fail if neither are available. +AC_MSG_CHECKING(for gmtime_r) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ gmtime_r((const time_t *) nullptr, (struct tm *) nullptr); ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_GMTIME_R, 1, [Define this symbol if gmtime_r is available]) ], + [ AC_MSG_RESULT(no); + AC_MSG_CHECKING(for gmtime_s); + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ gmtime_s((struct tm *) nullptr, (const time_t *) nullptr); ]])], + [ AC_MSG_RESULT(yes)], + [ AC_MSG_RESULT(no); AC_MSG_ERROR(Both gmtime_r and gmtime_s are unavailable) ] + ) ] ) -LDFLAGS="$TEMP_LDFLAGS" -# Check for different ways of gathering OS randomness +dnl Check for different ways of gathering OS randomness AC_MSG_CHECKING(for Linux getrandom syscall) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include #include @@ -842,10 +1037,24 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include [ AC_MSG_RESULT(no)] ) +AC_MSG_CHECKING(for sysctl) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + #include ]], + [[ #ifdef __linux__ + #error "Don't use sysctl on Linux, it's deprecated even when it works" + #endif + sysctl(nullptr, 2, nullptr, nullptr, nullptr, 0); ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL, 1,[Define this symbol if the BSD sysctl() is available]) ], + [ AC_MSG_RESULT(no)] +) + AC_MSG_CHECKING(for sysctl KERN_ARND) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include #include ]], - [[ static const int name[2] = {CTL_KERN, KERN_ARND}; + [[ #ifdef __linux__ + #error "Don't use sysctl on Linux, it's deprecated even when it works" + #endif + static int name[2] = {CTL_KERN, KERN_ARND}; sysctl(name, 2, nullptr, nullptr, nullptr, 0); ]])], [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL_ARND, 1,[Define this symbol if the BSD sysctl(KERN_ARND) is available]) ], [ AC_MSG_RESULT(no)] @@ -859,12 +1068,100 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include [ AC_MSG_RESULT(no)] ) -# Check for reduced exports +AC_MSG_CHECKING(for fdatasync) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ fdatasync(0); ]])], + [ AC_MSG_RESULT(yes); HAVE_FDATASYNC=1 ], + [ AC_MSG_RESULT(no); HAVE_FDATASYNC=0 ] +) +AC_DEFINE_UNQUOTED([HAVE_FDATASYNC], [$HAVE_FDATASYNC], [Define to 1 if fdatasync is available.]) + +AC_MSG_CHECKING(for F_FULLFSYNC) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ fcntl(0, F_FULLFSYNC, 0); ]])], + [ AC_MSG_RESULT(yes); HAVE_FULLFSYNC=1 ], + [ AC_MSG_RESULT(no); HAVE_FULLFSYNC=0 ] +) + +AC_MSG_CHECKING(for O_CLOEXEC) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ open("", O_CLOEXEC); ]])], + [ AC_MSG_RESULT(yes); HAVE_O_CLOEXEC=1 ], + [ AC_MSG_RESULT(no); HAVE_O_CLOEXEC=0 ] +) + +dnl crc32c platform checks +AC_MSG_CHECKING(for __builtin_prefetch) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ + char data = 0; + const char* address = &data; + __builtin_prefetch(address, 0, 0); + ]])], + [ AC_MSG_RESULT(yes); HAVE_BUILTIN_PREFETCH=1 ], + [ AC_MSG_RESULT(no); HAVE_BUILTIN_PREFETCH=0 ] +) + +AC_MSG_CHECKING(for _mm_prefetch) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ + char data = 0; + const char* address = &data; + _mm_prefetch(address, _MM_HINT_NTA); + ]])], + [ AC_MSG_RESULT(yes); HAVE_MM_PREFETCH=1 ], + [ AC_MSG_RESULT(no); HAVE_MM_PREFETCH=0 ] +) + +AC_MSG_CHECKING(for strong getauxval support in the system headers) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + ]], [[ + getauxval(AT_HWCAP); + ]])], + [ AC_MSG_RESULT(yes); HAVE_STRONG_GETAUXVAL=1 ], + [ AC_MSG_RESULT(no); HAVE_STRONG_GETAUXVAL=0 ] +) + +AC_MSG_CHECKING(for weak getauxval support in the compiler) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + unsigned long getauxval(unsigned long type) __attribute__((weak)); + #define AT_HWCAP 16 + ]], [[ + getauxval(AT_HWCAP); + ]])], + [ AC_MSG_RESULT(yes); HAVE_WEAK_GETAUXVAL=1 ], + [ AC_MSG_RESULT(no); HAVE_WEAK_GETAUXVAL=0 ] +) + +dnl Check for reduced exports if test x$use_reduce_exports = xyes; then AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"], [AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])]) fi +AC_MSG_CHECKING([for std::system]) +AC_LINK_IFELSE( + [ AC_LANG_PROGRAM( + [[ #include ]], + [[ int nErr = std::system(""); ]] + )], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STD__SYSTEM, 1, Define to 1 if std::system is available.)], + [ AC_MSG_RESULT(no) ] +) + +AC_MSG_CHECKING([for ::_wsystem]) +AC_LINK_IFELSE( + [ AC_LANG_PROGRAM( + [[ ]], + [[ int nErr = ::_wsystem(""); ]] + )], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WSYSTEM, 1, Define to 1 if ::wsystem is available.)], + [ AC_MSG_RESULT(no) ] +) + +AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [std::system or ::wsystem]) + LEVELDB_CPPFLAGS= LIBLEVELDB= LIBMEMENV= @@ -873,9 +1170,69 @@ AC_SUBST(LEVELDB_CPPFLAGS) AC_SUBST(LIBLEVELDB) AC_SUBST(LIBMEMENV) +dnl SUPPRESSED_CPPFLAGS=SUPPRESS_WARNINGS([$SOME_CPPFLAGS]) +dnl Replace -I with -isystem in $SOME_CPPFLAGS to suppress warnings from +dnl headers from its include directories and return the result. +dnl See -isystem documentation: +dnl https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html +dnl https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-isystem-directory +dnl Do not change "-I/usr/include" to "-isystem /usr/include" because that +dnl is not necessary (/usr/include is already a system directory) and because +dnl it would break GCC's #include_next. +AC_DEFUN([SUPPRESS_WARNINGS], + [$(echo $1 |${SED} -E -e 's/(^| )-I/\1-isystem /g' -e 's;-isystem /usr/include([/ ]|$);-I/usr/include\1;g')]) + +dnl enable-fuzz should disable all other targets +if test "x$enable_fuzz" = "xyes"; then + AC_MSG_WARN(enable-fuzz will disable all other targets) + build_pocketcoin_utils=no + build_pocketcoin_cli=no + build_pocketcoin_tx=no + build_pocketcoin_wallet=no + build_pocketcoind=no + build_pocketcoin_libs=no + pocketcoin_enable_qt=no + pocketcoin_enable_qt_test=no + pocketcoin_enable_qt_dbus=no + enable_wallet=no + use_bench=no + use_upnp=no + use_zmq=no + + AC_MSG_CHECKING([whether main function is needed]) + AX_CHECK_LINK_FLAG( + [[-fsanitize=$use_sanitizers]], + [AC_MSG_RESULT([no])], + [AC_MSG_RESULT([yes]) + CPPFLAGS="$CPPFLAGS -DPROVIDE_MAIN_FUNCTION"], + [], + [AC_LANG_PROGRAM([[ + #include + #include + extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { return 0; } + /* unterminated comment to remove the main function ... + ]],[[]])]) +else + POCKETCOIN_QT_INIT + + dnl sets $pocketcoin_enable_qt, $pocketcoin_enable_qt_test, $pocketcoin_enable_qt_dbus + POCKETCOIN_QT_CONFIGURE([5.5.1]) + + dnl Keep a copy of the original $QT_INCLUDES and use it when invoking qt's moc + QT_INCLUDES_UNSUPPRESSED=$QT_INCLUDES + if test x$suppress_external_warnings != xno ; then + QT_INCLUDES=SUPPRESS_WARNINGS($QT_INCLUDES) + QT_DBUS_INCLUDES=SUPPRESS_WARNINGS($QT_DBUS_INCLUDES) + QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES) + fi +fi + if test x$enable_wallet != xno; then dnl Check for libdb_cxx only if wallet enabled POCKETCOIN_FIND_BDB48 + if test x$suppress_external_warnings != xno ; then + BDB_CPPFLAGS=SUPPRESS_WARNINGS($BDB_CPPFLAGS) + fi fi dnl Check for libminiupnpc (optional) @@ -885,25 +1242,36 @@ if test x$use_upnp != xno; then [AC_CHECK_LIB([miniupnpc], [upnpDiscover], [MINIUPNPC_LIBS=-lminiupnpc], [have_miniupnpc=no])], [have_miniupnpc=no] ) +dnl The minimum supported miniUPnPc API version is set to 10. This keeps compatibility +dnl with Ubuntu 16.04 LTS and Debian 8 libminiupnpc-dev packages. +if test x$have_miniupnpc != xno; then + AC_MSG_CHECKING([whether miniUPnPc API version is supported]) + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if MINIUPNPC_API_VERSION >= 10 + // Everything is okay + #else + # error miniUPnPc API version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + ],[ + AC_MSG_RESULT(no) + AC_MSG_WARN([miniUPnPc API version < 10 is unsupported, disabling UPnP support.]) + have_miniupnpc=no + ]) fi - -POCKETCOIN_QT_INIT - -dnl sets $pocketcoin_enable_qt, $pocketcoin_enable_qt_test, $pocketcoin_enable_qt_dbus -POCKETCOIN_QT_CONFIGURE([$use_pkgconfig]) - -if test x$build_pocketcoin_utils$build_pocketcoind$pocketcoin_enable_qt$use_tests$use_bench = xnonononono; then - use_boost=no -else - use_boost=yes fi +use_boost=yes + if test x$use_boost = xyes; then dnl Minimum required Boost version -define(MINIMUM_REQUIRED_BOOST, 1.47.0) +define(MINIMUM_REQUIRED_BOOST, 1.58.0) -dnl Check for boost libs +dnl Check for Boost libs AX_BOOST_BASE([MINIMUM_REQUIRED_BOOST]) if test x$want_boost = xno; then AC_MSG_ERROR([[only libpocketcoinconsensus can be built without boost]]) @@ -911,37 +1279,25 @@ fi AX_BOOST_SYSTEM AX_BOOST_FILESYSTEM AX_BOOST_THREAD -AX_BOOST_CHRONO + +dnl Opt-in to boost-process +AS_IF([ test x$with_boost_process != x ], [ AX_BOOST_PROCESS ], [ ax_cv_boost_process=no ] ) + +if test x$suppress_external_warnings != xno; then + BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS) +fi dnl Boost 1.56 through 1.62 allow using std::atomic instead of its own atomic dnl counter implementations. In 1.63 and later the std::atomic approach is default. m4_pattern_allow(DBOOST_AC_USE_STD_ATOMIC) dnl otherwise it's treated like a macro BOOST_CPPFLAGS="-DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC $BOOST_CPPFLAGS" -if test x$use_reduce_exports = xyes; then - AC_MSG_CHECKING([for working boost reduced exports]) - TEMP_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS" - AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= 104900 - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - ],[ - AC_MSG_ERROR([boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduce-exports.]) - ]) - CPPFLAGS="$TEMP_CPPFLAGS" -fi +BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_THREAD_LIB" fi if test x$use_reduce_exports = xyes; then CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS" - AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"]) + AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"],, [[$LDFLAG_WERROR]]) fi if test x$use_tests = xyes; then @@ -950,7 +1306,6 @@ if test x$use_tests = xyes; then AC_MSG_ERROR(hexdump is required for tests) fi - if test x$use_boost = xyes; then AX_BOOST_UNIT_TEST_FRAMEWORK @@ -976,253 +1331,127 @@ if test x$use_tests = xyes; then fi fi -if test x$use_boost = xyes; then +dnl libevent check -BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB" - - -dnl If boost (prior to 1.57) was built without c++11, it emulated scoped enums -dnl using c++98 constructs. Unfortunately, this implementation detail leaked into -dnl the abi. This was fixed in 1.57. - -dnl When building against that installed version using c++11, the headers pick up -dnl on the native c++11 scoped enum support and enable it, however it will fail to -dnl link. This can be worked around by disabling c++11 scoped enums if linking will -dnl fail. -dnl BOOST_NO_SCOPED_ENUMS was changed to BOOST_NO_CXX11_SCOPED_ENUMS in 1.51. - -TEMP_LIBS="$LIBS" -LIBS="$BOOST_LIBS $LIBS" -TEMP_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" -AC_MSG_CHECKING([for mismatched boost c++11 scoped enums]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - #if !defined(BOOST_NO_SCOPED_ENUMS) && !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && BOOST_VERSION < 105700 - #define BOOST_NO_SCOPED_ENUMS - #define BOOST_NO_CXX11_SCOPED_ENUMS - #define CHECK - #endif - #include - ]],[[ - #if defined(CHECK) - boost::filesystem::copy_file("foo", "bar"); - #else - choke; - #endif - ]])], - [AC_MSG_RESULT(mismatched); BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_SCOPED_ENUMS -DBOOST_NO_CXX11_SCOPED_ENUMS"], [AC_MSG_RESULT(ok)]) -LIBS="$TEMP_LIBS" -CPPFLAGS="$TEMP_CPPFLAGS" - -dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however -dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if -dnl a working version is available, else fall back to sleep. sleep was removed -dnl after 1.56. -dnl If neither is available, abort. -TEMP_LIBS="$LIBS" -LIBS="$BOOST_LIBS $LIBS" -TEMP_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - ]],[[ - #if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200) - boost::this_thread::sleep_for(boost::chrono::milliseconds(0)); - #else - choke me - #endif - ]])], - [boost_sleep=yes; - AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])], - [boost_sleep=no]) -LIBS="$TEMP_LIBS" -CPPFLAGS="$TEMP_CPPFLAGS" - -if test x$boost_sleep != xyes; then -TEMP_LIBS="$LIBS" -LIBS="$BOOST_LIBS $LIBS" -TEMP_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" -AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - #include - ]],[[ - #if BOOST_VERSION <= 105600 - boost::this_thread::sleep(boost::posix_time::milliseconds(0)); - #else - choke me - #endif - ]])], - [boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])], - [boost_sleep=no]) -LIBS="$TEMP_LIBS" -CPPFLAGS="$TEMP_CPPFLAGS" +if test x$build_pocketcoin_cli$build_pocketcoind$pocketcoin_enable_qt$use_tests$use_bench != xnonononono; then + PKG_CHECK_MODULES([EVENT], [libevent >= 2.0.21], [use_libevent=yes], [AC_MSG_ERROR([libevent version 2.0.21 or greater not found.])]) + if test x$TARGET_OS != xwindows; then + PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads >= 2.0.21],, [AC_MSG_ERROR([libevent_pthreads version 2.0.21 or greater not found.])]) + fi fi -if test x$boost_sleep != xyes; then - AC_MSG_ERROR(No working boost sleep implementation found.) -fi +dnl QR Code encoding library check +if test "x$use_qr" != xno; then + POCKETCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])]) fi -if test x$use_pkgconfig = xyes; then - : dnl - m4_ifdef( - [PKG_CHECK_MODULES], - [ - PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) - PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) - POCKETCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [POCKETCOIN_QT_FAIL(libprotobuf not found)])]) - if test x$use_qr != xno; then - POCKETCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])]) - fi - if test x$build_pocketcoin_utils$build_pocketcoind$pocketcoin_enable_qt$use_tests != xnononono; then - PKG_CHECK_MODULES([EVENT], [libevent],, [AC_MSG_ERROR(libevent not found.)]) - if test x$TARGET_OS != xwindows; then - PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads],, [AC_MSG_ERROR(libevent_pthreads not found.)]) - fi - fi +dnl ZMQ check - if test "x$use_zmq" = "xyes"; then - PKG_CHECK_MODULES([ZMQ],[libzmq >= 4], - [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])], - [AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions]) - AC_MSG_WARN([libzmq version 4.x or greater not found, disabling]) - use_zmq=no]) - else - AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions]) - fi - ] - ) +if test "x$use_zmq" = xyes; then + PKG_CHECK_MODULES([ZMQ], [libzmq >= 4], + AC_DEFINE([ENABLE_ZMQ], [1], [Define to 1 to enable ZMQ functions]), + [AC_DEFINE([ENABLE_ZMQ], [0], [Define to 1 to enable ZMQ functions]) + AC_MSG_WARN([libzmq version 4.x or greater not found, disabling]) + use_zmq=no]) else - AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) - AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) - - AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),) - AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing)) - - if test x$build_pocketcoin_utils$build_pocketcoind$pocketcoin_enable_qt$use_tests != xnononono; then - AC_CHECK_HEADER([event2/event.h],, AC_MSG_ERROR(libevent headers missing),) - AC_CHECK_LIB([event],[main],EVENT_LIBS=-levent,AC_MSG_ERROR(libevent missing)) - if test x$TARGET_OS != xwindows; then - AC_CHECK_LIB([event_pthreads],[main],EVENT_PTHREADS_LIBS=-levent_pthreads,AC_MSG_ERROR(libevent_pthreads missing)) - fi - fi - - if test "x$use_zmq" = "xyes"; then - AC_CHECK_HEADER([zmq.h], - [AC_DEFINE([ENABLE_ZMQ],[1],[Define to 1 to enable ZMQ functions])], - [AC_MSG_WARN([zmq.h not found, disabling zmq support]) - use_zmq=no - AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])]) - AC_CHECK_LIB([zmq],[zmq_ctx_shutdown],ZMQ_LIBS=-lzmq, - [AC_MSG_WARN([libzmq >= 4.0 not found, disabling zmq support]) - use_zmq=no - AC_DEFINE([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions])]) - else - AC_DEFINE_UNQUOTED([ENABLE_ZMQ],[0],[Define to 1 to enable ZMQ functions]) - fi - - if test "x$use_zmq" = "xyes"; then - dnl Assume libzmq was built for static linking - case $host in - *mingw*) - ZMQ_CFLAGS="$ZMQ_CFLAGS -DZMQ_STATIC" - ;; - esac - fi - - POCKETCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], POCKETCOIN_QT_FAIL(libprotobuf not found))) - if test x$use_qr != xno; then - POCKETCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])]) - POCKETCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)]) - fi + AC_DEFINE_UNQUOTED([ENABLE_ZMQ], [0], [Define to 1 to enable ZMQ functions]) fi -save_CXXFLAGS="${CXXFLAGS}" -CXXFLAGS="${CXXFLAGS} ${CRYPTO_CFLAGS} ${SSL_CFLAGS}" -AC_CHECK_DECLS([EVP_MD_CTX_new],,,[AC_INCLUDES_DEFAULT -#include -]) -CXXFLAGS="${save_CXXFLAGS}" - -dnl RapidCheck Property Based Testing - -enable_property_tests=no -if test "x$use_rapidcheck" = xauto; then - AC_CHECK_HEADERS([rapidcheck.h], [enable_property_tests=yes]) -elif test "x$use_rapidcheck" != xno; then - enable_property_tests=yes -fi - -RAPIDCHECK_LIBS= -if test "x$enable_property_tests" = xyes; then - RAPIDCHECK_LIBS=-lrapidcheck +if test "x$use_zmq" = xyes; then + dnl Assume libzmq was built for static linking + case $host in + *mingw*) + ZMQ_CFLAGS="$ZMQ_CFLAGS -DZMQ_STATIC" + ;; + esac fi -AC_SUBST(RAPIDCHECK_LIBS) -AM_CONDITIONAL([ENABLE_PROPERTY_TESTS], [test x$enable_property_tests = xyes]) dnl univalue check need_bundled_univalue=yes - -if test x$build_pocketcoin_utils$build_pocketcoind$pocketcoin_enable_qt$use_tests$use_bench = xnonononono; then +if test x$build_pocketcoin_wallet$build_pocketcoin_cli$build_pocketcoin_tx$build_pocketcoind$pocketcoin_enable_qt$use_tests$use_bench = xnonononononono; then need_bundled_univalue=no else - -if test x$system_univalue != xno ; then - found_univalue=no - if test x$use_pkgconfig = xyes; then - : #NOP - m4_ifdef( - [PKG_CHECK_MODULES], - [ - PKG_CHECK_MODULES([UNIVALUE],[libunivalue >= 1.0.4],[found_univalue=yes],[true]) - ] - ) - else - AC_CHECK_HEADER([univalue.h],[ - AC_CHECK_LIB([univalue], [main],[ - UNIVALUE_LIBS=-lunivalue - found_univalue=yes - ],[true]) - ],[true]) + if test x$system_univalue != xno; then + PKG_CHECK_MODULES([UNIVALUE], [libunivalue >= 1.0.4], [found_univalue=yes], [found_univalue=no]) + if test x$found_univalue = xyes; then + system_univalue=yes + need_bundled_univalue=no + elif test x$system_univalue = xyes; then + AC_MSG_ERROR([univalue not found]) + else + system_univalue=no + fi fi - if test x$found_univalue = xyes ; then - system_univalue=yes - need_bundled_univalue=no - elif test x$system_univalue = xyes ; then - AC_MSG_ERROR([univalue not found]) - else - system_univalue=no + if test x$need_bundled_univalue = xyes; then + UNIVALUE_CFLAGS='-I$(srcdir)/univalue/include' + UNIVALUE_LIBS='univalue/libunivalue.la' fi fi -if test x$need_bundled_univalue = xyes ; then - UNIVALUE_CFLAGS='-I$(srcdir)/univalue/include' - UNIVALUE_LIBS='univalue/libunivalue.la' +AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes]) +AC_SUBST(UNIVALUE_CFLAGS) +AC_SUBST(UNIVALUE_LIBS) + +dnl libmultiprocess library check + +libmultiprocess_found=no +if test "x$with_libmultiprocess" = xyes || test "x$with_libmultiprocess" = xauto; then + m4_ifdef([PKG_CHECK_MODULES], [PKG_CHECK_MODULES([LIBMULTIPROCESS], [libmultiprocess], [ + libmultiprocess_found=yes; + libmultiprocess_prefix=`$PKG_CONFIG --variable=prefix libmultiprocess`; + ], [true])]) +elif test "x$with_libmultiprocess" != xno; then + AC_MSG_ERROR([--with-libmultiprocess=$with_libmultiprocess value is not yes, auto, or no]) fi +AC_SUBST(LIBMULTIPROCESS_CFLAGS) +AC_SUBST(LIBMULTIPROCESS_LIBS) + +dnl Enable multiprocess check +if test "x$enable_multiprocess" = xyes; then + if test "x$libmultiprocess_found" != xyes; then + AC_MSG_ERROR([--enable-multiprocess=yes option specified but libmultiprocess library was not found. May need to install libmultiprocess library, or specify install path with PKG_CONFIG_PATH environment variable. Running 'pkg-config --debug libmultiprocess' may be helpful for debugging.]) + fi + build_multiprocess=yes +elif test "x$enable_multiprocess" = xauto; then + build_multiprocess=$libmultiprocess_found +else + build_multiprocess=no fi -AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes]) -AC_SUBST(UNIVALUE_CFLAGS) -AC_SUBST(UNIVALUE_LIBS) +AM_CONDITIONAL([BUILD_MULTIPROCESS],[test "x$build_multiprocess" = xyes]) +AM_CONDITIONAL([BUILD_POCKETCOIN_NODE], [test "x$build_multiprocess" = xyes]) +AM_CONDITIONAL([BUILD_POCKETCOIN_GUI], [test "x$build_multiprocess" = xyes]) + +dnl codegen tools check -POCKETCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path) +if test x$build_multiprocess != xno; then + if test "x$with_mpgen" = xyes || test "x$with_mpgen" = xauto; then + MPGEN_PREFIX="$libmultiprocess_prefix" + elif test "x$with_mpgen" != xno; then + MPGEN_PREFIX="$with_mpgen"; + fi + AC_SUBST(MPGEN_PREFIX) +fi AC_MSG_CHECKING([whether to build pocketcoind]) AM_CONDITIONAL([BUILD_POCKETCOIND], [test x$build_pocketcoind = xyes]) AC_MSG_RESULT($build_pocketcoind) -AC_MSG_CHECKING([whether to build utils (pocketcoin-cli pocketcoin-tx)]) -AM_CONDITIONAL([BUILD_POCKETCOIN_UTILS], [test x$build_pocketcoin_utils = xyes]) -AC_MSG_RESULT($build_pocketcoin_utils) +AC_MSG_CHECKING([whether to build pocketcoin-cli]) +AM_CONDITIONAL([BUILD_POCKETCOIN_CLI], [test x$build_pocketcoin_cli = xyes]) +AC_MSG_RESULT($build_pocketcoin_cli) + +AC_MSG_CHECKING([whether to build pocketcoin-tx]) +AM_CONDITIONAL([BUILD_POCKETCOIN_TX], [test x$build_pocketcoin_tx = xyes]) +AC_MSG_RESULT($build_pocketcoin_tx) + +AC_MSG_CHECKING([whether to build pocketcoin-wallet]) +AM_CONDITIONAL([BUILD_POCKETCOIN_WALLET], [test x$build_pocketcoin_wallet = xyes]) +AC_MSG_RESULT($build_pocketcoin_wallet) AC_MSG_CHECKING([whether to build libraries]) AM_CONDITIONAL([BUILD_POCKETCOIN_LIBS], [test x$build_pocketcoin_libs = xyes]) @@ -1249,9 +1478,6 @@ if test "x$use_ccache" != "xno"; then fi AC_MSG_RESULT($use_ccache) fi -if test "x$use_ccache" = "xyes"; then - AX_CHECK_PREPROC_FLAG([-Qunused-arguments],[CPPFLAGS="-Qunused-arguments $CPPFLAGS"]) -fi dnl enable wallet AC_MSG_CHECKING([if wallet should be enabled]) @@ -1267,9 +1493,10 @@ dnl enable upnp support AC_MSG_CHECKING([whether to build with support for UPnP]) if test x$have_miniupnpc = xno; then if test x$use_upnp = xyes; then - AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc") + AC_MSG_ERROR("UPnP requested but cannot be built. Use --without-miniupnpc.") fi AC_MSG_RESULT(no) + use_upnp=no else if test x$use_upnp != xno; then AC_MSG_RESULT(yes) @@ -1304,18 +1531,16 @@ if test x$pocketcoin_enable_qt != xno; then AC_MSG_CHECKING([whether to build GUI with support for QR codes]) if test x$have_qrencode = xno; then if test x$use_qr = xyes; then - AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode") + AC_MSG_ERROR([QR support requested but cannot be built. Use --without-qrencode]) fi - AC_MSG_RESULT(no) + use_qr=no else if test x$use_qr != xno; then - AC_MSG_RESULT(yes) AC_DEFINE([USE_QRCODE],[1],[Define if QR support should be compiled in]) use_qr=yes - else - AC_MSG_RESULT(no) fi fi + AC_MSG_RESULT([$use_qr]) if test x$XGETTEXT = x; then AC_MSG_WARN("xgettext is required to update qt translations") @@ -1348,28 +1573,36 @@ else AC_MSG_RESULT([no]) fi -if test x$build_pocketcoin_utils$build_pocketcoin_libs$build_pocketcoind$pocketcoin_enable_qt$use_bench$use_tests = xnononononono; then +if test x$build_pocketcoin_wallet$build_pocketcoin_cli$build_pocketcoin_tx$build_pocketcoin_libs$build_pocketcoind$pocketcoin_enable_qt$use_bench$use_tests = xnononononononono; then AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui --enable-bench or --enable-tests]) fi +# Forced using sqlite +AC_DEFINE([USE_SQLITE],[1],[Define if sqlite support should be compiled in]) + AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin]) AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin]) -AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows]) AM_CONDITIONAL([TARGET_LINUX], [test x$TARGET_OS = xlinux]) +AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows]) AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes]) +AM_CONDITIONAL([USE_SQLITE], [test "x$use_sqlite" = "xyes"]) AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes]) +AM_CONDITIONAL([ENABLE_FUZZ],[test x$enable_fuzz = xyes]) AM_CONDITIONAL([ENABLE_QT],[test x$pocketcoin_enable_qt = xyes]) AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes]) AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes]) AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes]) AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes]) +AM_CONDITIONAL([USE_LIBEVENT],[test x$use_libevent = xyes]) AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes]) AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes]) -AM_CONDITIONAL([ENABLE_HWCRC32],[test x$enable_hwcrc32 = xyes]) +AM_CONDITIONAL([ENABLE_SSE42],[test x$enable_sse42 = xyes]) AM_CONDITIONAL([ENABLE_SSE41],[test x$enable_sse41 = xyes]) AM_CONDITIONAL([ENABLE_AVX2],[test x$enable_avx2 = xyes]) AM_CONDITIONAL([ENABLE_SHANI],[test x$enable_shani = xyes]) +AM_CONDITIONAL([ENABLE_ARM_CRC],[test x$enable_arm_crc = xyes]) AM_CONDITIONAL([USE_ASM],[test x$use_asm = xyes]) +AM_CONDITIONAL([WORDS_BIGENDIAN],[test x$ac_cv_c_bigendian = xyes]) AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version]) AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version]) @@ -1394,6 +1627,7 @@ AC_SUBST(POCKETCOIN_DAEMON_NAME) AC_SUBST(POCKETCOIN_GUI_NAME) AC_SUBST(POCKETCOIN_CLI_NAME) AC_SUBST(POCKETCOIN_TX_NAME) +# AC_SUBST(POCKETCOIN_WALLET_TOOL_NAME) AC_SUBST(RELDFLAGS) AC_SUBST(DEBUG_CPPFLAGS) @@ -1415,26 +1649,38 @@ AC_SUBST(SSE42_CXXFLAGS) AC_SUBST(SSE41_CXXFLAGS) AC_SUBST(AVX2_CXXFLAGS) AC_SUBST(SHANI_CXXFLAGS) +AC_SUBST(ARM_CRC_CXXFLAGS) AC_SUBST(LIBTOOL_APP_LDFLAGS) +AC_SUBST(USE_SQLITE) AC_SUBST(USE_UPNP) AC_SUBST(USE_QRCODE) AC_SUBST(BOOST_LIBS) +AC_SUBST(SQLITE_LIBS) +AC_SUBST(CRYPTO_LIBS) +AC_SUBST(SSL_LIBS) AC_SUBST(TESTDEFS) -AC_SUBST(LEVELDB_TARGET_FLAGS) AC_SUBST(MINIUPNPC_CPPFLAGS) AC_SUBST(MINIUPNPC_LIBS) -AC_SUBST(CRYPTO_LIBS) -AC_SUBST(SSL_LIBS) AC_SUBST(EVENT_LIBS) AC_SUBST(EVENT_PTHREADS_LIBS) AC_SUBST(ZMQ_LIBS) -AC_SUBST(PROTOBUF_LIBS) AC_SUBST(QR_LIBS) +AC_SUBST(HAVE_GMTIME_R) +AC_SUBST(HAVE_FDATASYNC) +AC_SUBST(HAVE_FULLFSYNC) +AC_SUBST(HAVE_O_CLOEXEC) +AC_SUBST(HAVE_BUILTIN_PREFETCH) +AC_SUBST(HAVE_MM_PREFETCH) +AC_SUBST(HAVE_STRONG_GETAUXVAL) +AC_SUBST(HAVE_WEAK_GETAUXVAL) AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini]) AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh]) AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])]) +AC_CONFIG_LINKS([contrib/devtools/security-check.py:contrib/devtools/security-check.py]) +AC_CONFIG_LINKS([contrib/devtools/test-security-check.py:contrib/devtools/test-security-check.py]) AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py]) AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py]) +AC_CONFIG_LINKS([test/fuzz/test_runner.py:test/fuzz/test_runner.py]) AC_CONFIG_LINKS([test/util/pocketcoin-util-test.py:test/util/pocketcoin-util-test.py]) AC_CONFIG_LINKS([test/util/rpcauth-test.py:test/util/rpcauth-test.py]) @@ -1465,25 +1711,13 @@ if test x$need_bundled_univalue = xyes; then AC_CONFIG_SUBDIRS([src/univalue]) fi -# TODO probably make this optional AC_CONFIG_SUBDIRS([src/sqlite]) -ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no --enable-module-recovery --disable-jni" +ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --with-bignum=no --enable-module-recovery --enable-module-schnorrsig --enable-experimental" AC_CONFIG_SUBDIRS([src/secp256k1]) AC_OUTPUT -dnl Taken from https://wiki.debian.org/RpathIssue -case $host in - *-*-linux-gnu) - AC_MSG_RESULT([Fixing libtool for -rpath problems.]) - sed < libtool > libtool-2 \ - 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/' - mv libtool-2 libtool - chmod 755 libtool - ;; -esac - dnl Replace the BUILDDIR path with the correct Windows path if compiling on Native Windows case ${OS} in *Windows*) @@ -1494,13 +1728,21 @@ esac echo echo "Options used to compile and link:" +echo " boost process = $ax_cv_boost_process" +echo " multiprocess = $build_multiprocess" echo " with wallet = $enable_wallet" +if test "x$enable_wallet" != "xno"; then + echo " with sqlite = $use_sqlite" +fi echo " with gui / qt = $pocketcoin_enable_qt" if test x$pocketcoin_enable_qt != xno; then echo " with qr = $use_qr" fi echo " with zmq = $use_zmq" echo " with test = $use_tests" +if test x$use_tests != xno; then + echo " with fuzz = $enable_fuzz" +fi echo " with bench = $use_bench" echo " with upnp = $use_upnp" echo " use asm = $use_asm" @@ -1510,13 +1752,13 @@ echo " gprof enabled = $enable_gprof" echo " werror = $enable_werror" echo echo " target os = $TARGET_OS" -echo " build os = $BUILD_OS" +echo " build os = $build_os" echo echo " CC = $CC" -echo " CFLAGS = $CFLAGS" +echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS" echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS" echo " CXX = $CXX" echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS" -echo " LDFLAGS = $PTHREAD_CFLAGS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS" +echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS" echo " ARFLAGS = $ARFLAGS" echo diff --git a/doc/architecture.md b/doc/architecture.md index 7f88a9022..15147481c 100644 --- a/doc/architecture.md +++ b/doc/architecture.md @@ -113,35 +113,7 @@ Pocket sqlite database сохраняет все транзакции в раз > Здесь и далее `main.Transactions.TxOut` - `..` означает SQLite базу данных Pocket Social Data - `pocketdb/main.sqlite3` -Все типы транзакций, хранящиеся в `main.Transactions` определены как Enum и имеют зафиксированное целое значение - [src/pocketdb/models/base/Base.hpp]() -```c++ -enum TxType -{ - NOT_SUPPORTED = 0, - - USER_ACCOUNT = 100, - VIDEO_SERVER_ACCOUNT = 101, - MESSAGE_SERVER_ACCOUNT = 102, - - POST_CONTENT = 200, - VIDEO_CONTENT = 201, - TRANSLATE_CONTENT = 202, - SERVERPING_CONTENT = 203, - COMMENT_CONTENT = 204, - - SCORE_POST_ACTION = 300, - SCORE_COMMENT_ACTION = 301, - - SUBSCRIBE_ACTION = 302, - SUBSCRIBE_PRIVATE_ACTION = 303, - SUBSCRIBE_CANCEL_ACTION = 304, - - BLOCKING_ACTION = 305, - BLOCKING_CANCEL_ACTION = 306, - - COMPLAIN_ACTION = 307, -}; -``` +Все типы транзакций, хранящиеся в `main.Transactions` определены как Enum и имеют зафиксированное целое значение - [src/pocketdb/models/base/PocketTypes.h]() Сформированный блок (1) подключается к цепи (2). diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am index 7ee18e4fa..90606c80d 100644 --- a/doc/man/Makefile.am +++ b/doc/man/Makefile.am @@ -8,6 +8,16 @@ if ENABLE_QT dist_man1_MANS+=pocketcoin-qt.1 endif -if BUILD_POCKETCOIN_UTILS - dist_man1_MANS+=pocketcoin-cli.1 pocketcoin-tx.1 +if BUILD_POCKETCOIN_CLI + dist_man1_MANS+=pocketcoin-cli.1 +endif + +if BUILD_POCKETCOIN_TX + dist_man1_MANS+=pocketcoin-tx.1 +endif + +if ENABLE_WALLET +if BUILD_POCKETCOIN_WALLET + dist_man1_MANS+=pocketcoin-wallet.1 +endif endif diff --git a/doc/man/pocketcoin-cli.1 b/doc/man/pocketcoin-cli.1 index 18002840c..70b422727 100644 --- a/doc/man/pocketcoin-cli.1 +++ b/doc/man/pocketcoin-cli.1 @@ -1,22 +1,26 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. -.TH POCKETCOIN-CLI "1" "July 2018" "pocketcoin-cli v0.18" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. +.TH POCKETCOIN-CLI "1" "August 2021" "pocketcoin-cli v0.18" "User Commands" .SH NAME pocketcoin-cli \- manual page for pocketcoin-cli v0.18 +.SH SYNOPSIS +.B pocketcoin-cli +[\fI\,options\/\fR] \fI\, \/\fR[\fI\,params\/\fR] \fI\,Send command to Pocketcoin Core\/\fR +.br +.B pocketcoin-cli +[\fI\,options\/\fR] \fI\,-named \/\fR[\fI\,name=value\/\fR]... \fI\,Send command to Pocketcoin Core (with named arguments)\/\fR +.br +.B pocketcoin-cli +[\fI\,options\/\fR] \fI\,help List commands\/\fR +.br +.B pocketcoin-cli +[\fI\,options\/\fR] \fI\,help Get help for a command\/\fR .SH DESCRIPTION Pocketcoin Core RPC client version v0.18 -.SS "Usage:" -.TP -pocketcoin\-cli [options] [params] -Send command to Pocketcoin Core -.IP -pocketcoin\-cli [options] \fB\-named\fR [name=value] ... Send command to Pocketcoin Core (with named arguments) -pocketcoin\-cli [options] help List commands -pocketcoin\-cli [options] help Get help for a command .SH OPTIONS .HP \-? .IP -This help message +Print this help message and exit .HP \fB\-conf=\fR .IP @@ -27,6 +31,15 @@ location. (default: pocketcoin.conf) .IP Specify data directory .HP +\fB\-generate\fR +.IP +Generate blocks immediately, equivalent to RPC generatenewaddress +followed by RPC generatetoaddress. Optional positional integer +arguments are number of blocks to generate (default: 1) and +maximum iterations to try (default: 1000000), equivalent to RPC +generatetoaddress nblocks and maxtries arguments. Example: +pocketcoin\-cli \fB\-generate\fR 4 1000 +.HP \fB\-getinfo\fR .IP Get general information from the remote server. Note that unlike @@ -39,6 +52,12 @@ be as of a different block from the chain state reported) .IP Pass named instead of positional arguments (default: false) .HP +\fB\-netinfo\fR +.IP +Get network peer connection information from the remote server. An +optional integer argument from 0 to 4 can be passed for different +peers listings (default: 0). +.HP \fB\-rpcclienttimeout=\fR .IP Timeout in seconds during HTTP requests, or 0 for no timeout. (default: @@ -59,12 +78,13 @@ Password for JSON\-RPC connections .HP \fB\-rpcport=\fR .IP -Connect to JSON\-RPC on (default: 37071 or testnet: 36061) +Connect to JSON\-RPC on (default: 37071, testnet: 36061, signet: +38332, regtest: 11011) .HP \fB\-publicrpcport=\fR .IP -Listen for public JSON\-RPC requests on (default: 38081 or -testnet: 39091) +Listen for public JSON\-RPC requests on (default: 38081, testnet: 39091, signet: +38334, regtest: 12021) .HP \fB\-rpcuser=\fR .IP @@ -77,32 +97,65 @@ Wait for RPC server to start \fB\-rpcwallet=\fR .IP Send RPC for non\-default wallet on RPC server (needs to exactly match -corresponding \fB\-wallet\fR option passed to pocketcoind) +corresponding \fB\-wallet\fR option passed to pocketcoind). This changes +the RPC endpoint used, e.g. +http://127.0.0.1:8332/wallet/ .HP \fB\-stdin\fR .IP Read extra arguments from standard input, one per line until EOF/Ctrl\-D -(recommended for sensitive information such as passphrases). -When combined with \fB\-stdinrpcpass\fR, the first line from standard -input is used for the RPC password. +(recommended for sensitive information such as passphrases). When +combined with \fB\-stdinrpcpass\fR, the first line from standard input +is used for the RPC password. .HP \fB\-stdinrpcpass\fR -.TP -Read RPC password from standard input as a single line. -When combined .IP +Read RPC password from standard input as a single line. When combined with \fB\-stdin\fR, the first line from standard input is used for the -RPC password. +RPC password. When combined with \fB\-stdinwalletpassphrase\fR, +\fB\-stdinrpcpass\fR consumes the first line, and \fB\-stdinwalletpassphrase\fR +consumes the second. +.HP +\fB\-stdinwalletpassphrase\fR +.IP +Read wallet passphrase from standard input as a single line. When +combined with \fB\-stdin\fR, the first line from standard input is used +for the wallet passphrase. .HP \fB\-version\fR .IP Print version and exit .PP +Debugging/Testing options: +.PP Chain selection options: .HP +\fB\-chain=\fR +.IP +Use the chain (default: main). Allowed values: main, test, +signet, regtest +.HP +\fB\-signet\fR +.IP +Use the signet chain. Equivalent to \fB\-chain\fR=\fI\,signet\/\fR. Note that the network +is defined by the \fB\-signetchallenge\fR parameter +.HP +\fB\-signetchallenge\fR +.IP +Blocks must satisfy the given script to be considered valid (only for +signet networks; defaults to the global default signet test +network challenge) +.HP +\fB\-signetseednode\fR +.IP +Specify a seed node for the signet network, in the hostname[:port] +format, e.g. sig.net:1234 (may be used multiple times to specify +multiple seed nodes; defaults to the global default signet test +network seed node(s)) +.HP \fB\-testnet\fR .IP -Use the test chain +Use the test chain. Equivalent to \fB\-chain\fR=\fI\,test\/\fR. .SH COPYRIGHT Copyright (C) 2013-2019 The Bitcoin Core developers Copyright (C) 2018-2022 The Pocketnet developers diff --git a/doc/man/pocketcoin-qt.1 b/doc/man/pocketcoin-qt.1 index 959594f72..1a86140f2 100644 --- a/doc/man/pocketcoin-qt.1 +++ b/doc/man/pocketcoin-qt.1 @@ -1,12 +1,12 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. -.TH POCKETCOIN-QT "1" "July 2018" "pocketcoin-qt v0.18" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. +.TH POCKETCOIN-QT "1" "August 2021" "pocketcoin-qt v0.18" "User Commands" .SH NAME pocketcoin-qt \- manual page for pocketcoin-qt v0.18 +.SH SYNOPSIS +.B pocketcoin-qt +[\fI\,command-line options\/\fR] .SH DESCRIPTION -Pocketcoin Core version v0.18 (64\-bit) -Usage: -.IP -pocketcoin\-qt [command\-line options] +Pocketcoin Core version v0.18 .SH OPTIONS .HP \-? @@ -23,9 +23,17 @@ long fork (%s in cmd is replaced by message) If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: -0000000000000000005214481d2d96f898e3d5416e43359c145944a909d242e0, +0000000000000000000b9d2ec5a352ecba0592946514a92f14319dc2b367fc72, testnet: -0000000002e9e7b00e1f6dc5123a04aad68dd0f0968d8c7aa45f6640795c37b1) +000000000000006433d1efec504c53ca332b64963c425395515b01977bd7b3b0, +signet: +0000002a1de0f46379358c1fd09906f7ac59adf3712323ed90eb59e4c183c020) +.HP +\fB\-blockfilterindex=\fR +.IP +Maintain an index of compact filters by block (default: 0, values: +basic). If is not supplied or if = 1, indexes for +all known types are enabled. .HP \fB\-blocknotify=\fR .IP @@ -39,12 +47,20 @@ Extra transactions to keep in memory for compact block reconstructions .HP \fB\-blocksdir=\fR .IP -Specify blocks directory (default: /blocks) +Specify directory to hold blocks subdirectory for *.dat files (default: +) +.HP +\fB\-blocksonly\fR +.IP +Whether to reject transactions from network peers. Automatic broadcast +and rebroadcast of any transactions from inbound peers is +disabled, unless the peer has the 'forcerelay' permission. RPC +transactions are not affected. (default: 0) .HP \fB\-conf=\fR .IP -Specify configuration file. Relative paths will be prefixed by datadir -location. (default: pocketcoin.conf) +Specify path to read\-only configuration file. Relative paths will be +prefixed by datadir location. (default: pocketcoin.conf) .HP \fB\-daemon\fR .IP @@ -56,12 +72,15 @@ Specify data directory .HP \fB\-dbcache=\fR .IP -Set database cache size in megabytes (4 to 16384, default: 450) +Maximum database cache size MiB (4 to 16384, default: 450). In +addition, unused mempool memory is shared for this cache (see +\fB\-maxmempool\fR). .HP \fB\-debuglogfile=\fR .IP Specify location of debug log file. Relative paths will be prefixed by a -net\-specific datadir location. (0 to disable; default: debug.log) +net\-specific datadir location. (\fB\-nodebuglogfile\fR to disable; +default: debug.log) .HP \fB\-includeconf=\fR .IP @@ -70,7 +89,7 @@ Specify additional configuration file, relative to the \fB\-datadir\fR path .HP \fB\-loadblock=\fR .IP -Imports blocks from external blk000??.dat file on startup +Imports blocks from external file on startup .HP \fB\-maxmempool=\fR .IP @@ -87,7 +106,7 @@ Do not keep transactions in the mempool longer than hours (default: .HP \fB\-par=\fR .IP -Set the number of script verification threads (\fB\-8\fR to 16, 0 = auto, <0 = +Set the number of script verification threads (\fB\-6\fR to 15, 0 = auto, <0 = leave that many cores free, default: 0) .HP \fB\-persistmempool\fR @@ -108,7 +127,7 @@ blocks if a target size in MiB is provided. This mode is incompatible with \fB\-txindex\fR and \fB\-rescan\fR. Warning: Reverting this setting requires re\-downloading the entire blockchain. (default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, ->550 = automatically prune block files to stay under the +>=550 = automatically prune block files to stay under the specified target size in MiB) .HP \fB\-reindex\fR @@ -117,7 +136,21 @@ Rebuild chain state and block index from the blk*.dat files on disk .HP \fB\-reindex\-chainstate\fR .IP -Rebuild chain state from the currently indexed blocks +Rebuild chain state from the currently indexed blocks. When in pruning +mode or if blocks on disk might be corrupted, use full \fB\-reindex\fR +instead. +.HP +\fB\-settings=\fR +.IP +Specify path to dynamic settings data file. Can be disabled with +\fB\-nosettings\fR. File is written at runtime and not meant to be +edited by users (use pocketcoin.conf instead for custom settings). +Relative paths will be prefixed by datadir location. (default: +settings.json) +.HP +\fB\-startupnotify=\fR +.IP +Execute command on startup. .HP \fB\-sysperms\fR .IP @@ -141,23 +174,28 @@ Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info). This option can be specified multiple times to add multiple nodes. .HP -\fB\-banscore=\fR +\fB\-asmap=\fR .IP -Threshold for disconnecting misbehaving peers (default: 100) +Specify asn mapping used for bucketing of the peers (default: +ip_asn.map). Relative paths will be prefixed by the net\-specific +datadir location. .HP \fB\-bantime=\fR .IP -Number of seconds to keep misbehaving peers from reconnecting (default: +Default duration (in seconds) of manually configured bans (default: 86400) .HP -\fB\-bind=\fR +\fB\-bind=\fR[:][=onion] .IP -Bind to given address and always listen on it. Use [host]:port notation -for IPv6 +Bind to given address and always listen on it (default: 0.0.0.0). Use +[host]:port notation for IPv6. Append =onion to tag any incoming +connections to that address and port as incoming Tor connections +(default: 127.0.0.1:8334=onion, testnet: 127.0.0.1:18334=onion, +signet: 127.0.0.1:38334=onion, regtest: 127.0.0.1:18445=onion) .HP \fB\-connect=\fR .IP -Connect only to the specified node; \fB\-connect\fR=\fI\,0\/\fR disables automatic +Connect only to the specified node; \fB\-noconnect\fR disables automatic connections (the rules for this peer are the same as for \fB\-addnode\fR). This option can be specified multiple times to connect to multiple nodes. @@ -176,10 +214,6 @@ Allow DNS lookups for \fB\-addnode\fR, \fB\-seednode\fR and \fB\-connect\fR (def Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless \fB\-connect\fR used) .HP -\fB\-enablebip61\fR -.IP -Send reject messages per BIP61 (default: 1) -.HP \fB\-externalip=\fR .IP Specify your own public address @@ -194,7 +228,7 @@ Accept connections from outside (default: 1 if no \fB\-proxy\fR or \fB\-connect\ .HP \fB\-listenonion\fR .IP -Automatically create Tor hidden service (default: 1) +Automatically create Tor onion service (default: 1) .HP \fB\-maxconnections=\fR .IP @@ -216,13 +250,19 @@ amount. (default: 4200 seconds) .HP \fB\-maxuploadtarget=\fR .IP -Tries to keep outbound traffic under the given target (in MiB per 24h), -0 = no limit (default: 0) +Tries to keep outbound traffic under the given target (in MiB per 24h). +Limit does not apply to peers with 'download' permission. 0 = no +limit (default: 0) +.HP +\fB\-networkactive\fR +.IP +Enable all P2P network activity (default: 1). Can be changed by the +setnetworkactive RPC command .HP \fB\-onion=\fR .IP -Use separate SOCKS5 proxy to reach peers via Tor hidden services -(default: \fB\-proxy\fR) +Use separate SOCKS5 proxy to reach peers via Tor onion services, set +\fB\-noonion\fR to disable (default: \fB\-proxy\fR) .HP \fB\-onlynet=\fR .IP @@ -231,10 +271,14 @@ onion). Incoming connections are not affected by this option. This option can be specified multiple times to allow multiple networks. .HP +\fB\-peerblockfilters\fR +.IP +Serve compact block filters to peers per BIP 157 (default: 0) +.HP \fB\-peerbloomfilters\fR .IP Support filtering of blocks and transaction with bloom filters (default: -1) +0) .HP \fB\-permitbaremultisig\fR .IP @@ -242,11 +286,14 @@ Relay non\-P2SH multisig (default: 1) .HP \fB\-port=\fR .IP -Listen for connections on (default: 8333 or testnet: 18333) +Listen for connections on . Nodes not using the default ports +(default: 8333, testnet: 18333, signet: 38333, regtest: 18444) +are unlikely to get incoming connections. .HP \fB\-proxy=\fR .IP -Connect through SOCKS5 proxy +Connect through SOCKS5 proxy, set \fB\-noproxy\fR to disable (default: +disabled) .HP \fB\-proxyrandomize\fR .IP @@ -276,25 +323,35 @@ Tor control port password (default: empty) .IP Use UPnP to map the listening port (default: 0) .HP -\fB\-whitebind=\fR -.IP -Bind to given address and whitelist peers connecting to it. Use -[host]:port notation for IPv6 -.HP -\fB\-whitelist=\fR -.IP -Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or -CIDR notated network (e.g. 1.2.3.0/24). Can be specified multiple -times. Whitelisted peers cannot be DoS banned and their -transactions are always relayed, even if they are already in the -mempool, useful e.g. for a gateway +\fB\-whitebind=\fR<[permissions@]addr> +.IP +Bind to the given address and add permission flags to the peers +connecting to it. Use [host]:port notation for IPv6. Allowed +permissions: bloomfilter (allow requesting BIP37 filtered blocks +and transactions), noban (do not ban for misbehavior; implies +download), forcerelay (relay transactions that are already in the +mempool; implies relay), relay (relay even in \fB\-blocksonly\fR mode, +and unlimited transaction announcements), mempool (allow +requesting BIP35 mempool contents), download (allow getheaders +during IBD, no disconnect after maxuploadtarget limit), addr +(responses to GETADDR avoid hitting the cache and contain random +records with the most up\-to\-date info). Specify multiple +permissions separated by commas (default: +download,noban,mempool,relay). Can be specified multiple times. +.HP +\fB\-whitelist=\fR<[permissions@]IP address or network> +.IP +Add permission flags to the peers connecting from the given IP address +(e.g. 1.2.3.4) or CIDR\-notated network (e.g. 1.2.3.0/24). Uses +the same permissions as \fB\-whitebind\fR. Can be specified multiple +times. .PP Wallet options: .HP \fB\-addresstype\fR .IP What type of addresses to use ("legacy", "p2sh\-segwit", or "bech32", -default: "p2sh\-segwit") +default: "bech32") .HP \fB\-avoidpartialspends\fR .IP @@ -302,7 +359,8 @@ Group outputs by address, selecting all or none, instead of selecting on a per\-output basis. Privacy is improved as an address is only used once (unless someone sends to it after spending from it), but may result in slightly higher fees as suboptimal coin -selection may result due to the added limitation (default: 0) +selection may result due to the added limitation (default: 0 +(always enabled for wallets with "avoid_reuse" enabled)) .HP \fB\-changetype\fR .IP @@ -330,7 +388,15 @@ insufficient data (default: 0.0002) .HP \fB\-keypool=\fR .IP -Set key pool size to (default: 1000) +Set key pool size to (default: 1000). Warning: Smaller sizes may +increase the risk of losing funds when restoring from an old +backup, if none of the addresses in the original keypool have +been used. +.HP +\fB\-maxapsfee=\fR +.IP +Spend up to this amount in additional (absolute) fees (in POC) if it +allows the use of partial spend avoidance (default: 0.00) .HP \fB\-mintxfee=\fR .IP @@ -345,10 +411,6 @@ Fee (in PKOIN/kB) to add to transactions you send (default: 0.00) .IP Rescan the block chain for missing wallet transactions on startup .HP -\fB\-salvagewallet\fR -.IP -Attempt to recover private keys from a corrupt wallet on startup -.HP \fB\-spendzeroconfchange\fR .IP Spend unconfirmed change when sending transactions (default: 1) @@ -358,18 +420,15 @@ Spend unconfirmed change when sending transactions (default: 1) If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: 6) .HP -\fB\-upgradewallet\fR -.IP -Upgrade wallet to latest format on startup -.HP \fB\-wallet=\fR .IP -Specify wallet database path. Can be specified multiple times to load -multiple wallets. Path is interpreted relative to if -it is not absolute, and will be created if it does not exist (as -a directory containing a wallet.dat file and log files). For -backwards compatibility this will also accept names of existing -data files in .) +Specify wallet path to load at startup. Can be used multiple times to +load multiple wallets. Path is to a directory containing wallet +data and log files. If the path is not absolute, it is +interpreted relative to . This only loads existing +wallets and does not create new ones. For backwards compatibility +this also accepts names of existing top\-level data files in +. .HP \fB\-walletbroadcast\fR .IP @@ -382,19 +441,15 @@ exists, otherwise ) .HP \fB\-walletnotify=\fR .IP -Execute command when a wallet transaction changes (%s in cmd is replaced -by TxID) +Execute command when a wallet transaction changes. %s in cmd is replaced +by TxID and %w is replaced by wallet name. %w is not currently +implemented on windows. On systems where %w is supported, it +should NOT be quoted because this would break shell escaping used +to invoke the command. .HP \fB\-walletrbf\fR .IP Send transactions with full\-RBF opt\-in enabled (RPC only, default: 0) -.HP -\fB\-zapwallettxes=\fR -.IP -Delete all wallet transactions and only recover those parts of the -blockchain through \fB\-rescan\fR on startup (1 = keep tx meta data e.g. -account owner and payment request information, 2 = drop tx meta -data) .PP ZeroMQ notification options: .HP @@ -402,28 +457,54 @@ ZeroMQ notification options: .IP Enable publish hash block in
.HP +\fB\-zmqpubhashblockhwm=\fR +.IP +Set publish hash block outbound message high water mark (default: 1000) +.HP \fB\-zmqpubhashtx=\fR
.IP Enable publish hash transaction in
.HP +\fB\-zmqpubhashtxhwm=\fR +.IP +Set publish hash transaction outbound message high water mark (default: +1000) +.HP \fB\-zmqpubrawblock=\fR
.IP Enable publish raw block in
.HP +\fB\-zmqpubrawblockhwm=\fR +.IP +Set publish raw block outbound message high water mark (default: 1000) +.HP \fB\-zmqpubrawtx=\fR
.IP Enable publish raw transaction in
+.HP +\fB\-zmqpubrawtxhwm=\fR +.IP +Set publish raw transaction outbound message high water mark (default: +1000) +.HP +\fB\-zmqpubsequence=\fR
+.IP +Enable publish hash block and tx sequence in
+.HP +\fB\-zmqpubsequencehwm=\fR +.IP +Set publish hash sequence message high water mark (default: 1000) .PP Debugging/Testing options: .HP \fB\-debug=\fR .IP -Output debugging information (default: 0, supplying is +Output debugging information (default: \fB\-nodebug\fR, supplying is optional). If is not supplied or if = 1, output all debugging information. can be: net, tor, -mempool, http, bench, zmq, db, rpc, estimatefee, addrman, +mempool, http, bench, zmq, walletdb, rpc, estimatefee, addrman, selectcoins, reindex, cmpctblock, rand, prune, proxy, mempoolrej, -libevent, coindb, qt, leveldb. +libevent, coindb, qt, leveldb, validation. .HP \fB\-debugexclude=\fR .IP @@ -433,12 +514,17 @@ or more specified categories. .HP \fB\-help\-debug\fR .IP -Show all debugging options (usage: \fB\-\-help\fR \fB\-help\-debug\fR) +Print help message with debugging options and exit .HP \fB\-logips\fR .IP Include IP addresses in debug output (default: 0) .HP +\fB\-logthreadnames\fR +.IP +Prepend debug output with name of the originating thread (only available +on platforms supporting thread_local) (default: 0) +.HP \fB\-logtimestamps\fR .IP Prepend debug output with timestamp (default: 1) @@ -452,7 +538,7 @@ transaction; setting this too low may abort large transactions \fB\-printtoconsole\fR .IP Send trace/debug info to console (default: 1 when no \fB\-daemon\fR. To disable -logging to file, set debuglogfile=0) +logging to file, set \fB\-nodebuglogfile\fR) .HP \fB\-shrinkdebugfile\fR .IP @@ -464,9 +550,32 @@ Append comment to the user agent string .PP Chain selection options: .HP +\fB\-chain=\fR +.IP +Use the chain (default: main). Allowed values: main, test, +signet, regtest +.HP +\fB\-signet\fR +.IP +Use the signet chain. Equivalent to \fB\-chain\fR=\fI\,signet\/\fR. Note that the network +is defined by the \fB\-signetchallenge\fR parameter +.HP +\fB\-signetchallenge\fR +.IP +Blocks must satisfy the given script to be considered valid (only for +signet networks; defaults to the global default signet test +network challenge) +.HP +\fB\-signetseednode\fR +.IP +Specify a seed node for the signet network, in the hostname[:port] +format, e.g. sig.net:1234 (may be used multiple times to specify +multiple seed nodes; defaults to the global default signet test +network seed node(s)) +.HP \fB\-testnet\fR .IP -Use the test chain +Use the test chain. Equivalent to \fB\-chain\fR=\fI\,test\/\fR. .PP Node relay options: .HP @@ -484,10 +593,6 @@ Relay and mine data carrier transactions (default: 1) Maximum size of data in data carrier transactions we relay and mine (default: 83) .HP -\fB\-mempoolreplacement\fR -.IP -Enable transaction replacement in the memory pool (default: 1) -.HP \fB\-minrelaytxfee=\fR .IP Fees (in PKOIN/kB) smaller than this are considered zero fee for relaying, @@ -495,13 +600,15 @@ mining and transaction creation (default: 0.00001) .HP \fB\-whitelistforcerelay\fR .IP -Force relay of transactions from whitelisted peers even if they violate -local relay policy (default: 1) +Add 'forcerelay' permission to whitelisted inbound peers with default +permissions. This will relay transactions even if the +transactions were already in the mempool. (default: 0) .HP \fB\-whitelistrelay\fR .IP -Accept relayed transactions received from whitelisted peers even when -not relaying transactions (default: 1) +Add 'relay' permission to whitelisted inbound peers with default +permissions. This will accept relayed transactions even when not +relaying transactions (default: 1) .PP Block creation options: .HP @@ -529,8 +636,8 @@ option can be specified multiple times .HP \fB\-rpcauth=\fR .IP -Username and hashed password for JSON\-RPC connections. The field - comes in the format: :$. A +Username and HMAC\-SHA\-256 hashed password for JSON\-RPC connections. The +field comes in the format: :$. A canonical python script is included in share/rpcauth. The client then connects normally using the rpcuser=/rpcpassword= pair of arguments. This @@ -538,12 +645,12 @@ option can be specified multiple times .HP \fB\-rpcbind=\fR[:port] .IP -Bind to given address to listen for JSON\-RPC connections. This option is -ignored unless \fB\-rpcallowip\fR is also passed. Port is optional and -overrides \fB\-rpcport\fR. Use [host]:port notation for IPv6. This -option can be specified multiple times (default: 127.0.0.1 and -::1 i.e., localhost, or if \fB\-rpcallowip\fR has been specified, -0.0.0.0 and :: i.e., all addresses) +Bind to given address to listen for JSON\-RPC connections. Do not expose +the RPC server to untrusted networks such as the public internet! +This option is ignored unless \fB\-rpcallowip\fR is also passed. Port is +optional and overrides \fB\-rpcport\fR. Use [host]:port notation for +IPv6. This option can be specified multiple times (default: +127.0.0.1 and ::1 i.e., localhost) .HP \fB\-rpccookiefile=\fR .IP @@ -576,6 +683,23 @@ Set the number of threads to service RPC calls (default: 4) .IP Username for JSON\-RPC connections .HP +\fB\-rpcwhitelist=\fR +.IP +Set a whitelist to filter incoming RPC calls for a specific user. The +field comes in the format: :,,...,. If multiple whitelists are set for a given user, +they are set\-intersected. See \fB\-rpcwhitelistdefault\fR documentation +for information on default whitelist behavior. +.HP +\fB\-rpcwhitelistdefault\fR +.IP +Sets default behavior for rpc whitelisting. Unless rpcwhitelistdefault +is set to 0, if any \fB\-rpcwhitelist\fR is set, the rpc server acts as +if all rpc users are subject to empty\-unless\-otherwise\-specified +whitelists. If rpcwhitelistdefault is set to 1 and no +\fB\-rpcwhitelist\fR is set, rpc server acts as if all rpc users are +subject to empty whitelists. +.HP \fB\-server\fR .IP Accept command line and JSON\-RPC commands @@ -598,10 +722,6 @@ Start minimized .IP Reset all settings changed in the GUI .HP -\fB\-rootcertificates=\fR -.IP -Set SSL root certificates for payment request (default: \fB\-system\-\fR) -.HP \fB\-splash\fR .IP Show splash screen on startup (default: 1) diff --git a/doc/man/pocketcoin-tx.1 b/doc/man/pocketcoin-tx.1 index e6ec1e777..e9f9eeb25 100644 --- a/doc/man/pocketcoin-tx.1 +++ b/doc/man/pocketcoin-tx.1 @@ -1,21 +1,20 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. -.TH POCKETCOIN-TX "1" "July 2018" "pocketcoin-tx v0.18" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. +.TH POCKETCOIN-TX "1" "August 2021" "pocketcoin-tx v0.18" "User Commands" .SH NAME pocketcoin-tx \- manual page for pocketcoin-tx v0.18 +.SH SYNOPSIS +.B pocketcoin-tx +[\fI\,options\/\fR] \fI\, \/\fR[\fI\,commands\/\fR] \fI\,Update hex-encoded pocketcoin transaction\/\fR +.br +.B pocketcoin-tx +[\fI\,options\/\fR] \fI\,-create \/\fR[\fI\,commands\/\fR] \fI\,Create hex-encoded pocketcoin transaction\/\fR .SH DESCRIPTION Pocketcoin Core pocketcoin\-tx utility version v0.18 -.SS "Usage:" -.TP -pocketcoin\-tx [options] [commands] -Update hex\-encoded pocketcoin transaction -.TP -pocketcoin\-tx [options] \fB\-create\fR [commands] -Create hex\-encoded pocketcoin transaction .SH OPTIONS .HP \-? .IP -This help message +Print this help message and exit .HP \fB\-create\fR .IP @@ -29,11 +28,36 @@ Select JSON output .IP Output only the hex\-encoded transaction id of the resultant transaction. .PP +Debugging/Testing options: +.PP Chain selection options: .HP +\fB\-chain=\fR +.IP +Use the chain (default: main). Allowed values: main, test, +signet, regtest +.HP +\fB\-signet\fR +.IP +Use the signet chain. Equivalent to \fB\-chain\fR=\fI\,signet\/\fR. Note that the network +is defined by the \fB\-signetchallenge\fR parameter +.HP +\fB\-signetchallenge\fR +.IP +Blocks must satisfy the given script to be considered valid (only for +signet networks; defaults to the global default signet test +network challenge) +.HP +\fB\-signetseednode\fR +.IP +Specify a seed node for the signet network, in the hostname[:port] +format, e.g. sig.net:1234 (may be used multiple times to specify +multiple seed nodes; defaults to the global default signet test +network seed node(s)) +.HP \fB\-testnet\fR .IP -Use the test chain +Use the test chain. Equivalent to \fB\-chain\fR=\fI\,test\/\fR. .PP Commands: .IP @@ -93,7 +117,7 @@ sign=SIGHASH\-FLAGS .IP Add zero or more signatures to transaction. This command requires JSON registers:prevtxs=JSON object, privatekeys=JSON object. See -signrawtransaction docs for format of sighash flags, JSON +signrawtransactionwithkey docs for format of sighash flags, JSON objects. .PP Register Commands: diff --git a/doc/man/pocketcoin-wallet.1 b/doc/man/pocketcoin-wallet.1 new file mode 100644 index 000000000..6db5ef59e --- /dev/null +++ b/doc/man/pocketcoin-wallet.1 @@ -0,0 +1,95 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. +.TH POCKETCOIN-WALLET "1" "August 2021" "pocketcoin-wallet v0.18" "User Commands" +.SH NAME +pocketcoin-wallet \- manual page for pocketcoin-wallet v0.18 +.SH DESCRIPTION +Pocketcoin Core pocketcoin\-wallet version v0.18 +.PP +pocketcoin\-wallet is an offline tool for creating and interacting with Pocketcoin Core wallet files. +By default pocketcoin\-wallet will act on wallets in the default mainnet wallet directory in the datadir. +To change the target wallet, use the \fB\-datadir\fR, \fB\-wallet\fR and \fB\-testnet\fR/\-regtest arguments. +.SS "Usage:" +.IP +pocketcoin\-wallet [options] +.SH OPTIONS +.HP +\-? +.IP +Print this help message and exit +.HP +\fB\-datadir=\fR +.IP +Specify data directory +.HP +\fB\-wallet=\fR +.IP +Specify wallet name +.PP +Debugging/Testing options: +.HP +\fB\-debug=\fR +.IP +Output debugging information (default: 0). +.HP +\fB\-printtoconsole\fR +.IP +Send trace/debug info to console (default: 1 when no \fB\-debug\fR is true, 0 +otherwise). +.PP +Chain selection options: +.HP +\fB\-chain=\fR +.IP +Use the chain (default: main). Allowed values: main, test, +signet, regtest +.HP +\fB\-signet\fR +.IP +Use the signet chain. Equivalent to \fB\-chain\fR=\fI\,signet\/\fR. Note that the network +is defined by the \fB\-signetchallenge\fR parameter +.HP +\fB\-signetchallenge\fR +.IP +Blocks must satisfy the given script to be considered valid (only for +signet networks; defaults to the global default signet test +network challenge) +.HP +\fB\-signetseednode\fR +.IP +Specify a seed node for the signet network, in the hostname[:port] +format, e.g. sig.net:1234 (may be used multiple times to specify +multiple seed nodes; defaults to the global default signet test +network seed node(s)) +.HP +\fB\-testnet\fR +.IP +Use the test chain. Equivalent to \fB\-chain\fR=\fI\,test\/\fR. +.PP +Commands: +.IP +create +.IP +Create new wallet file +.IP +info +.IP +Get wallet info +.IP +salvage +.IP +Attempt to recover private keys from a corrupt wallet. Warning: +\&'salvage' is experimental. +.SH COPYRIGHT +Copyright (C) 2018-2021 The Pocketnet Core developers + +Please contribute if you find Pocketnet Core useful. Visit + for further information about the software. +The source code is available from . + +This is experimental software. +Distributed under the Apache 2.0 software license, see the accompanying file COPYING +or + +This product includes software developed by the OpenSSL Project for use in the +OpenSSL Toolkit and cryptographic software written by +Eric Young and UPnP software written by Thomas Bernard. diff --git a/doc/man/pocketcoind.1 b/doc/man/pocketcoind.1 index f262ea705..8ea7c6820 100644 --- a/doc/man/pocketcoind.1 +++ b/doc/man/pocketcoind.1 @@ -1,13 +1,12 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. -.TH POCKETCOIND "1" "July 2018" "pocketcoind v0.18" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. +.TH POCKETCOIND "1" "August 2021" "pocketcoind v0.18" "User Commands" .SH NAME pocketcoind \- manual page for pocketcoind v0.18 +.SH SYNOPSIS +.B pocketcoind +[\fI\,options\/\fR] \fI\,Start Pocketcoin Core\/\fR .SH DESCRIPTION -Pocketcoin Core Daemon version v0.18 -.SS "Usage:" -.TP -pocketcoind [options] -Start Pocketcoin Core Daemon +Pocketcoin Core version v0.18 .SH OPTIONS .HP \-? @@ -24,9 +23,17 @@ long fork (%s in cmd is replaced by message) If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: -0000000000000000005214481d2d96f898e3d5416e43359c145944a909d242e0, +0000000000000000000b9d2ec5a352ecba0592946514a92f14319dc2b367fc72, testnet: -0000000002e9e7b00e1f6dc5123a04aad68dd0f0968d8c7aa45f6640795c37b1) +000000000000006433d1efec504c53ca332b64963c425395515b01977bd7b3b0, +signet: +0000002a1de0f46379358c1fd09906f7ac59adf3712323ed90eb59e4c183c020) +.HP +\fB\-blockfilterindex=\fR +.IP +Maintain an index of compact filters by block (default: 0, values: +basic). If is not supplied or if = 1, indexes for +all known types are enabled. .HP \fB\-blocknotify=\fR .IP @@ -40,12 +47,20 @@ Extra transactions to keep in memory for compact block reconstructions .HP \fB\-blocksdir=\fR .IP -Specify blocks directory (default: /blocks) +Specify directory to hold blocks subdirectory for *.dat files (default: +) +.HP +\fB\-blocksonly\fR +.IP +Whether to reject transactions from network peers. Automatic broadcast +and rebroadcast of any transactions from inbound peers is +disabled, unless the peer has the 'forcerelay' permission. RPC +transactions are not affected. (default: 0) .HP \fB\-conf=\fR .IP -Specify configuration file. Relative paths will be prefixed by datadir -location. (default: pocketcoin.conf) +Specify path to read\-only configuration file. Relative paths will be +prefixed by datadir location. (default: pocketcoin.conf) .HP \fB\-daemon\fR .IP @@ -57,12 +72,15 @@ Specify data directory .HP \fB\-dbcache=\fR .IP -Set database cache size in megabytes (4 to 16384, default: 450) +Maximum database cache size MiB (4 to 16384, default: 450). In +addition, unused mempool memory is shared for this cache (see +\fB\-maxmempool\fR). .HP \fB\-debuglogfile=\fR .IP Specify location of debug log file. Relative paths will be prefixed by a -net\-specific datadir location. (0 to disable; default: debug.log) +net\-specific datadir location. (\fB\-nodebuglogfile\fR to disable; +default: debug.log) .HP \fB\-includeconf=\fR .IP @@ -71,7 +89,7 @@ Specify additional configuration file, relative to the \fB\-datadir\fR path .HP \fB\-loadblock=\fR .IP -Imports blocks from external blk000??.dat file on startup +Imports blocks from external file on startup .HP \fB\-maxmempool=\fR .IP @@ -88,7 +106,7 @@ Do not keep transactions in the mempool longer than hours (default: .HP \fB\-par=\fR .IP -Set the number of script verification threads (\fB\-8\fR to 16, 0 = auto, <0 = +Set the number of script verification threads (\fB\-6\fR to 15, 0 = auto, <0 = leave that many cores free, default: 0) .HP \fB\-persistmempool\fR @@ -109,7 +127,7 @@ blocks if a target size in MiB is provided. This mode is incompatible with \fB\-txindex\fR and \fB\-rescan\fR. Warning: Reverting this setting requires re\-downloading the entire blockchain. (default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, ->550 = automatically prune block files to stay under the +>=550 = automatically prune block files to stay under the specified target size in MiB) .HP \fB\-reindex\fR @@ -118,7 +136,21 @@ Rebuild chain state and block index from the blk*.dat files on disk .HP \fB\-reindex\-chainstate\fR .IP -Rebuild chain state from the currently indexed blocks +Rebuild chain state from the currently indexed blocks. When in pruning +mode or if blocks on disk might be corrupted, use full \fB\-reindex\fR +instead. +.HP +\fB\-settings=\fR +.IP +Specify path to dynamic settings data file. Can be disabled with +\fB\-nosettings\fR. File is written at runtime and not meant to be +edited by users (use pocketcoin.conf instead for custom settings). +Relative paths will be prefixed by datadir location. (default: +settings.json) +.HP +\fB\-startupnotify=\fR +.IP +Execute command on startup. .HP \fB\-sysperms\fR .IP @@ -142,23 +174,28 @@ Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info). This option can be specified multiple times to add multiple nodes. .HP -\fB\-banscore=\fR +\fB\-asmap=\fR .IP -Threshold for disconnecting misbehaving peers (default: 100) +Specify asn mapping used for bucketing of the peers (default: +ip_asn.map). Relative paths will be prefixed by the net\-specific +datadir location. .HP \fB\-bantime=\fR .IP -Number of seconds to keep misbehaving peers from reconnecting (default: +Default duration (in seconds) of manually configured bans (default: 86400) .HP -\fB\-bind=\fR +\fB\-bind=\fR[:][=onion] .IP -Bind to given address and always listen on it. Use [host]:port notation -for IPv6 +Bind to given address and always listen on it (default: 0.0.0.0). Use +[host]:port notation for IPv6. Append =onion to tag any incoming +connections to that address and port as incoming Tor connections +(default: 127.0.0.1:8334=onion, testnet: 127.0.0.1:18334=onion, +signet: 127.0.0.1:38334=onion, regtest: 127.0.0.1:18445=onion) .HP \fB\-connect=\fR .IP -Connect only to the specified node; \fB\-connect\fR=\fI\,0\/\fR disables automatic +Connect only to the specified node; \fB\-noconnect\fR disables automatic connections (the rules for this peer are the same as for \fB\-addnode\fR). This option can be specified multiple times to connect to multiple nodes. @@ -177,10 +214,6 @@ Allow DNS lookups for \fB\-addnode\fR, \fB\-seednode\fR and \fB\-connect\fR (def Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless \fB\-connect\fR used) .HP -\fB\-enablebip61\fR -.IP -Send reject messages per BIP61 (default: 1) -.HP \fB\-externalip=\fR .IP Specify your own public address @@ -195,7 +228,7 @@ Accept connections from outside (default: 1 if no \fB\-proxy\fR or \fB\-connect\ .HP \fB\-listenonion\fR .IP -Automatically create Tor hidden service (default: 1) +Automatically create Tor onion service (default: 1) .HP \fB\-maxconnections=\fR .IP @@ -217,13 +250,19 @@ amount. (default: 4200 seconds) .HP \fB\-maxuploadtarget=\fR .IP -Tries to keep outbound traffic under the given target (in MiB per 24h), -0 = no limit (default: 0) +Tries to keep outbound traffic under the given target (in MiB per 24h). +Limit does not apply to peers with 'download' permission. 0 = no +limit (default: 0) +.HP +\fB\-networkactive\fR +.IP +Enable all P2P network activity (default: 1). Can be changed by the +setnetworkactive RPC command .HP \fB\-onion=\fR .IP -Use separate SOCKS5 proxy to reach peers via Tor hidden services -(default: \fB\-proxy\fR) +Use separate SOCKS5 proxy to reach peers via Tor onion services, set +\fB\-noonion\fR to disable (default: \fB\-proxy\fR) .HP \fB\-onlynet=\fR .IP @@ -232,10 +271,14 @@ onion). Incoming connections are not affected by this option. This option can be specified multiple times to allow multiple networks. .HP +\fB\-peerblockfilters\fR +.IP +Serve compact block filters to peers per BIP 157 (default: 0) +.HP \fB\-peerbloomfilters\fR .IP Support filtering of blocks and transaction with bloom filters (default: -1) +0) .HP \fB\-permitbaremultisig\fR .IP @@ -243,11 +286,14 @@ Relay non\-P2SH multisig (default: 1) .HP \fB\-port=\fR .IP -Listen for connections on (default: 8333 or testnet: 18333) +Listen for connections on . Nodes not using the default ports +(default: 8333, testnet: 18333, signet: 38333, regtest: 18444) +are unlikely to get incoming connections. .HP \fB\-proxy=\fR .IP -Connect through SOCKS5 proxy +Connect through SOCKS5 proxy, set \fB\-noproxy\fR to disable (default: +disabled) .HP \fB\-proxyrandomize\fR .IP @@ -277,25 +323,35 @@ Tor control port password (default: empty) .IP Use UPnP to map the listening port (default: 0) .HP -\fB\-whitebind=\fR -.IP -Bind to given address and whitelist peers connecting to it. Use -[host]:port notation for IPv6 -.HP -\fB\-whitelist=\fR -.IP -Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or -CIDR notated network (e.g. 1.2.3.0/24). Can be specified multiple -times. Whitelisted peers cannot be DoS banned and their -transactions are always relayed, even if they are already in the -mempool, useful e.g. for a gateway +\fB\-whitebind=\fR<[permissions@]addr> +.IP +Bind to the given address and add permission flags to the peers +connecting to it. Use [host]:port notation for IPv6. Allowed +permissions: bloomfilter (allow requesting BIP37 filtered blocks +and transactions), noban (do not ban for misbehavior; implies +download), forcerelay (relay transactions that are already in the +mempool; implies relay), relay (relay even in \fB\-blocksonly\fR mode, +and unlimited transaction announcements), mempool (allow +requesting BIP35 mempool contents), download (allow getheaders +during IBD, no disconnect after maxuploadtarget limit), addr +(responses to GETADDR avoid hitting the cache and contain random +records with the most up\-to\-date info). Specify multiple +permissions separated by commas (default: +download,noban,mempool,relay). Can be specified multiple times. +.HP +\fB\-whitelist=\fR<[permissions@]IP address or network> +.IP +Add permission flags to the peers connecting from the given IP address +(e.g. 1.2.3.4) or CIDR\-notated network (e.g. 1.2.3.0/24). Uses +the same permissions as \fB\-whitebind\fR. Can be specified multiple +times. .PP Wallet options: .HP \fB\-addresstype\fR .IP What type of addresses to use ("legacy", "p2sh\-segwit", or "bech32", -default: "p2sh\-segwit") +default: "bech32") .HP \fB\-avoidpartialspends\fR .IP @@ -303,7 +359,8 @@ Group outputs by address, selecting all or none, instead of selecting on a per\-output basis. Privacy is improved as an address is only used once (unless someone sends to it after spending from it), but may result in slightly higher fees as suboptimal coin -selection may result due to the added limitation (default: 0) +selection may result due to the added limitation (default: 0 +(always enabled for wallets with "avoid_reuse" enabled)) .HP \fB\-changetype\fR .IP @@ -331,7 +388,15 @@ insufficient data (default: 0.0002) .HP \fB\-keypool=\fR .IP -Set key pool size to (default: 1000) +Set key pool size to (default: 1000). Warning: Smaller sizes may +increase the risk of losing funds when restoring from an old +backup, if none of the addresses in the original keypool have +been used. +.HP +\fB\-maxapsfee=\fR +.IP +Spend up to this amount in additional (absolute) fees (in POC) if it +allows the use of partial spend avoidance (default: 0.00) .HP \fB\-mintxfee=\fR .IP @@ -346,10 +411,6 @@ Fee (in PKOIN/kB) to add to transactions you send (default: 0.00) .IP Rescan the block chain for missing wallet transactions on startup .HP -\fB\-salvagewallet\fR -.IP -Attempt to recover private keys from a corrupt wallet on startup -.HP \fB\-spendzeroconfchange\fR .IP Spend unconfirmed change when sending transactions (default: 1) @@ -359,18 +420,15 @@ Spend unconfirmed change when sending transactions (default: 1) If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: 6) .HP -\fB\-upgradewallet\fR -.IP -Upgrade wallet to latest format on startup -.HP \fB\-wallet=\fR .IP -Specify wallet database path. Can be specified multiple times to load -multiple wallets. Path is interpreted relative to if -it is not absolute, and will be created if it does not exist (as -a directory containing a wallet.dat file and log files). For -backwards compatibility this will also accept names of existing -data files in .) +Specify wallet path to load at startup. Can be used multiple times to +load multiple wallets. Path is to a directory containing wallet +data and log files. If the path is not absolute, it is +interpreted relative to . This only loads existing +wallets and does not create new ones. For backwards compatibility +this also accepts names of existing top\-level data files in +. .HP \fB\-walletbroadcast\fR .IP @@ -383,19 +441,15 @@ exists, otherwise ) .HP \fB\-walletnotify=\fR .IP -Execute command when a wallet transaction changes (%s in cmd is replaced -by TxID) +Execute command when a wallet transaction changes. %s in cmd is replaced +by TxID and %w is replaced by wallet name. %w is not currently +implemented on windows. On systems where %w is supported, it +should NOT be quoted because this would break shell escaping used +to invoke the command. .HP \fB\-walletrbf\fR .IP Send transactions with full\-RBF opt\-in enabled (RPC only, default: 0) -.HP -\fB\-zapwallettxes=\fR -.IP -Delete all wallet transactions and only recover those parts of the -blockchain through \fB\-rescan\fR on startup (1 = keep tx meta data e.g. -account owner and payment request information, 2 = drop tx meta -data) .PP ZeroMQ notification options: .HP @@ -403,28 +457,54 @@ ZeroMQ notification options: .IP Enable publish hash block in
.HP +\fB\-zmqpubhashblockhwm=\fR +.IP +Set publish hash block outbound message high water mark (default: 1000) +.HP \fB\-zmqpubhashtx=\fR
.IP Enable publish hash transaction in
.HP +\fB\-zmqpubhashtxhwm=\fR +.IP +Set publish hash transaction outbound message high water mark (default: +1000) +.HP \fB\-zmqpubrawblock=\fR
.IP Enable publish raw block in
.HP +\fB\-zmqpubrawblockhwm=\fR +.IP +Set publish raw block outbound message high water mark (default: 1000) +.HP \fB\-zmqpubrawtx=\fR
.IP Enable publish raw transaction in
+.HP +\fB\-zmqpubrawtxhwm=\fR +.IP +Set publish raw transaction outbound message high water mark (default: +1000) +.HP +\fB\-zmqpubsequence=\fR
+.IP +Enable publish hash block and tx sequence in
+.HP +\fB\-zmqpubsequencehwm=\fR +.IP +Set publish hash sequence message high water mark (default: 1000) .PP Debugging/Testing options: .HP \fB\-debug=\fR .IP -Output debugging information (default: 0, supplying is +Output debugging information (default: \fB\-nodebug\fR, supplying is optional). If is not supplied or if = 1, output all debugging information. can be: net, tor, -mempool, http, bench, zmq, db, rpc, estimatefee, addrman, +mempool, http, bench, zmq, walletdb, rpc, estimatefee, addrman, selectcoins, reindex, cmpctblock, rand, prune, proxy, mempoolrej, -libevent, coindb, qt, leveldb. +libevent, coindb, qt, leveldb, validation. .HP \fB\-debugexclude=\fR .IP @@ -434,12 +514,17 @@ or more specified categories. .HP \fB\-help\-debug\fR .IP -Show all debugging options (usage: \fB\-\-help\fR \fB\-help\-debug\fR) +Print help message with debugging options and exit .HP \fB\-logips\fR .IP Include IP addresses in debug output (default: 0) .HP +\fB\-logthreadnames\fR +.IP +Prepend debug output with name of the originating thread (only available +on platforms supporting thread_local) (default: 0) +.HP \fB\-logtimestamps\fR .IP Prepend debug output with timestamp (default: 1) @@ -453,7 +538,7 @@ transaction; setting this too low may abort large transactions \fB\-printtoconsole\fR .IP Send trace/debug info to console (default: 1 when no \fB\-daemon\fR. To disable -logging to file, set debuglogfile=0) +logging to file, set \fB\-nodebuglogfile\fR) .HP \fB\-shrinkdebugfile\fR .IP @@ -465,9 +550,32 @@ Append comment to the user agent string .PP Chain selection options: .HP +\fB\-chain=\fR +.IP +Use the chain (default: main). Allowed values: main, test, +signet, regtest +.HP +\fB\-signet\fR +.IP +Use the signet chain. Equivalent to \fB\-chain\fR=\fI\,signet\/\fR. Note that the network +is defined by the \fB\-signetchallenge\fR parameter +.HP +\fB\-signetchallenge\fR +.IP +Blocks must satisfy the given script to be considered valid (only for +signet networks; defaults to the global default signet test +network challenge) +.HP +\fB\-signetseednode\fR +.IP +Specify a seed node for the signet network, in the hostname[:port] +format, e.g. sig.net:1234 (may be used multiple times to specify +multiple seed nodes; defaults to the global default signet test +network seed node(s)) +.HP \fB\-testnet\fR .IP -Use the test chain +Use the test chain. Equivalent to \fB\-chain\fR=\fI\,test\/\fR. .PP Node relay options: .HP @@ -485,10 +593,6 @@ Relay and mine data carrier transactions (default: 1) Maximum size of data in data carrier transactions we relay and mine (default: 83) .HP -\fB\-mempoolreplacement\fR -.IP -Enable transaction replacement in the memory pool (default: 1) -.HP \fB\-minrelaytxfee=\fR .IP Fees (in PKOIN/kB) smaller than this are considered zero fee for relaying, @@ -496,13 +600,15 @@ mining and transaction creation (default: 0.00001) .HP \fB\-whitelistforcerelay\fR .IP -Force relay of transactions from whitelisted peers even if they violate -local relay policy (default: 1) +Add 'forcerelay' permission to whitelisted inbound peers with default +permissions. This will relay transactions even if the +transactions were already in the mempool. (default: 0) .HP \fB\-whitelistrelay\fR .IP -Accept relayed transactions received from whitelisted peers even when -not relaying transactions (default: 1) +Add 'relay' permission to whitelisted inbound peers with default +permissions. This will accept relayed transactions even when not +relaying transactions (default: 1) .PP Block creation options: .HP @@ -530,8 +636,8 @@ option can be specified multiple times .HP \fB\-rpcauth=\fR .IP -Username and hashed password for JSON\-RPC connections. The field - comes in the format: :$. A +Username and HMAC\-SHA\-256 hashed password for JSON\-RPC connections. The +field comes in the format: :$. A canonical python script is included in share/rpcauth. The client then connects normally using the rpcuser=/rpcpassword= pair of arguments. This @@ -539,12 +645,12 @@ option can be specified multiple times .HP \fB\-rpcbind=\fR[:port] .IP -Bind to given address to listen for JSON\-RPC connections. This option is -ignored unless \fB\-rpcallowip\fR is also passed. Port is optional and -overrides \fB\-rpcport\fR. Use [host]:port notation for IPv6. This -option can be specified multiple times (default: 127.0.0.1 and -::1 i.e., localhost, or if \fB\-rpcallowip\fR has been specified, -0.0.0.0 and :: i.e., all addresses) +Bind to given address to listen for JSON\-RPC connections. Do not expose +the RPC server to untrusted networks such as the public internet! +This option is ignored unless \fB\-rpcallowip\fR is also passed. Port is +optional and overrides \fB\-rpcport\fR. Use [host]:port notation for +IPv6. This option can be specified multiple times (default: +127.0.0.1 and ::1 i.e., localhost) .HP \fB\-rpccookiefile=\fR .IP @@ -577,6 +683,23 @@ Set the number of threads to service RPC calls (default: 4) .IP Username for JSON\-RPC connections .HP +\fB\-rpcwhitelist=\fR +.IP +Set a whitelist to filter incoming RPC calls for a specific user. The +field comes in the format: :,,...,. If multiple whitelists are set for a given user, +they are set\-intersected. See \fB\-rpcwhitelistdefault\fR documentation +for information on default whitelist behavior. +.HP +\fB\-rpcwhitelistdefault\fR +.IP +Sets default behavior for rpc whitelisting. Unless rpcwhitelistdefault +is set to 0, if any \fB\-rpcwhitelist\fR is set, the rpc server acts as +if all rpc users are subject to empty\-unless\-otherwise\-specified +whitelists. If rpcwhitelistdefault is set to 1 and no +\fB\-rpcwhitelist\fR is set, rpc server acts as if all rpc users are +subject to empty whitelists. +.HP \fB\-server\fR .IP Accept command line and JSON\-RPC commands diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37194e52b..2918e4690 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,10 @@ include(CheckFunctionExists) include(CheckCXXSourceCompiles) +include(CheckCXXSymbolExists) include(CheckSymbolExists) include(CheckCXXCompilerFlag) include(CheckCXXSourceRuns) +include(CheckIncludeFileCXX) set(CMAKE_CXX_STANDARD 17) @@ -56,7 +58,7 @@ option(WITH_INCOMPATIBLE_BDB "Allow using a bdb version greater than 4.8" OFF) option(DISABLE_MAN "do not install man pages (default is to install)" OFF) if (NOT DISABLE_MAM) - # TODO it doesn't go anywhere + # TODO (build): build man set(ENABLE_MAN ON) endif () @@ -97,13 +99,11 @@ endif () set(CMAKE_POSITION_INDEPENDENT_CODE ON) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - # Check endian headers include(CmakeCheckEndian.cmake) # LevelDB -# TODO only if EMBEDDED_LVLDB defined +# TODO (build): only if EMBEDDED_LVLDB defined add_subdirectory(leveldb/) @@ -119,7 +119,6 @@ add_subdirectory(secp256k1/) set(WITH_PIC ${WITH_PIC_BACKUP} CACHE BOOL "Enable fPIC" FORCE) # Finding boost -# TODO minimal boost version is increased to 1.66 because websockets (websocket/ws.h) are using lambdas as WriteHandler. This functional was implemented in 1.66. find_package(Boost 1.66 REQUIRED COMPONENTS system thread chrono filesystem date_time) ######## Boost sleep functions validation set(CHECK_BOOST_SLEEP "#include @@ -159,6 +158,179 @@ else () endif () # Common checks + +# AC_CHECK_HEADERS analog +foreach(_HEADER endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h) + check_include_file_cxx(${_HEADER} _RES_${_HEADER}) + if (_RES_${_HEADER}) + # Replace all non letter and number symbols with "_" + string (REGEX REPLACE "[^a-zA-Z0-9]" "_" _HEADER ${_HEADER}) + # All letters to upper + string (TOUPPER ${_HEADER} _HEADER) + string (CONCAT _TODECLARE "HAVE_" ${_HEADER}) + add_compile_definitions(${_TODECLARE}=1) + endif() +endforeach() + +# Checking for getifaddrs and freeifaddrs +set(_ADDRS_STUFF_COUNT 0) +foreach(_SYMBOL getifaddrs freeifaddrs) + check_cxx_symbol_exists(${_SYMBOL} "sys/types.h;ifaddrs.h" _RES_${_SYMBOL}) + if (_RES_${_SYMBOL}) + # Replace all non letter and number symbols with "_" + string (REGEX REPLACE "[^a-zA-Z0-9]" "_" _SYMBOL ${_SYMBOL}) + # All letters to upper + string (TOUPPER ${_SYMBOL} _SYMBOL) + string (CONCAT _TODECLARE "HAVE_DECL_" ${_SYMBOL}) + add_compile_definitions(${_TODECLARE}=1) + MATH(EXPR _ADDRS_STUFF_COUNT "${_ADDRS_STUFF_COUNT}+1") + endif() +endforeach() + +# Checking for bswap functions +foreach(_SYMBOL bswap_16 bswap_32 bswap_64) + check_cxx_symbol_exists(${_SYMBOL} byteswap.h _RES_${_SYMBOL}) + # Replace all non letter and number symbols with "_" + string (REGEX REPLACE "[^a-zA-Z0-9]" "_" _TODECLARE ${_SYMBOL}) + # All letters to upper + string (TOUPPER ${_TODECLARE} _TODECLARE) + string (CONCAT _TODECLARE "HAVE_DECL_" ${_TODECLARE}) + if (_RES_${_SYMBOL}) + add_compile_definitions(${_TODECLARE}=1) + else() + add_compile_definitions(${_TODECLARE}=0) + endif() +endforeach() + +if(${_ADDRS_STUFF_COUNT} EQUAL 2) # Means we succeed with both getifaddrs and freeifaddrs functions checking + # Trying to use noticed functions without linking "socket" lib + set(_CHECK_SOCKET_testbody "#include + #include + + int main() { + struct ifaddrs *ifaddr; + getifaddrs(&ifaddr); + freeifaddrs(ifaddr); + }") + check_cxx_source_runs("${_CHECK_SOCKET_testbody}" _CHECK_SOCKET_RES_WITHOUT_LIBSOCKET) + if(_CHECK_SOCKET_RES_WITHOUT_LIBSOCKET) + set(REQUIRED_SOCKET_LIB OFF) + else() + set(CMAKE_REQUIRED_LIBS_BACKUP ${CMAKE_REQUIRED_LIBS}) + set(CMAKE_REQUIRED_LIBS ${CMAKE_REQUIRED_LIBS} socket) + check_cxx_source_runs("${_CHECK_SOCKET_testbody}" _CHECK_SOCKET_RES_WITH_LIBSOCKET) + if(_CHECK_SOCKET_RES_WITH_LIBSOCKET) + set(REQUIRED_SOCKET_LIB ON) + else() + message(FATAL_ERROR "cannot figure out how to use getifaddrs") + endif() + set (CMAKE_REQUIRED_LIBS ${CMAKE_REQUIRED_LIBS_BACKUP}) + endif() +endif() + +# Non-posix method from bsd and macos that should be enabled by specific option. +# Checking for daemon function +check_cxx_symbol_exists(daemon unistd.h _RES_DAEMON) +if (_RES_DAEMON) + add_compile_definitions(HAVE_DECL_DAEMON=1) +endif() + +# Checking for __builtin_clzll +check_cxx_source_compiles("int main() + { + (void) __builtin_clzll(0); + return 0; + }" HAVE_BUILTIN_CLZLL) +if(HAVE_BUILTIN_CLZLL) + add_compile_definitions(HAVE_BUILTIN_CLZLL=1) +endif() + +# Checking for posix_fallocate +check_cxx_source_compiles("#ifdef __linux__ + #ifdef _POSIX_C_SOURCE + #undef _POSIX_C_SOURCE + #endif + #define _POSIX_C_SOURCE 200112L + #endif // __linux__ + #include + int main() + { + int f = posix_fallocate(0, 0, 0); + return 0; + }" HAVE_POSIX_FALLOCATE) +if(HAVE_POSIX_FALLOCATE) + add_compile_definitions(HAVE_POSIX_FALLOCATE=1) +endif() + +# Checking for sysctl +check_cxx_source_compiles("#include + #include + int main() + { + #ifdef __linux__ + #error \"Don't use sysctl on Linux, it's deprecated even when it works\" + #endif + sysctl(nullptr, 2, nullptr, nullptr, nullptr, 0); + return 0; + }" HAVE_SYSCTL) +if(HAVE_SYSCTL) + add_compile_definitions(HAVE_SYSCTL=1) +endif() + +# Checking for sysctl +check_cxx_source_compiles("#include + #include + int main() + { + #ifdef __linux__ + #error \"Don't use sysctl on Linux, it's deprecated even when it works\" + #endif + static int name[2] = {CTL_KERN, KERN_ARND}; + sysctl(name, 2, nullptr, nullptr, nullptr, 0); + return 0; + }" HAVE_SYSCTL_ARND) +if(HAVE_SYSCTL_ARND) + add_compile_definitions(HAVE_SYSCTL_ARND=1) +endif() + +# Checking for fdatasync +check_cxx_source_compiles("#include + int main() + { + fdatasync(0); + return 0; + }" HAVE_FDATASYNC) +if(HAVE_FDATASYNC) + add_compile_definitions(HAVE_FDATASYNC=1) +else() + add_compile_definitions(HAVE_FDATASYNC=0) +endif() + +# Checking for std::system +check_cxx_source_compiles("#include + int main() + { + int nErr = std::system(\"\"); + return 0; + }" HAVE_STD__SYSTEM) +if(HAVE_STD__SYSTEM) + add_compile_definitions(HAVE_STD__SYSTEM=1) +endif() + +# Checking for ::_wsystem +check_cxx_source_compiles("int main() + { + int nErr = ::_wsystem(\"\"); + return 0; + }" HAVE_WSYSTEM) +if(HAVE_WSYSTEM) + add_compile_definitions(HAVE_WSYSTEM=1) +endif() + +if(HAVE_STD__SYSTEM OR HAVE_WSYSTEM) + add_compile_definitions(HAVE_SYSTEM=1) +endif() + set(CMAKE_REQUIRED_FLAGS -msse4.1) check_cxx_source_runs( "#include #include @@ -232,16 +404,37 @@ elseif (ENABLE_REDUCE_EXPORTS) message(FATAL_ERROR "Cannot find a working visibility attribute. Use -DENABLE_REDUCE_EXPORTS=OFF.") endif () -check_cxx_source_compiles(" #include - static thread_local int foo = 0; - static void run_thread() { foo++;} - int main(){ - for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();} - return foo; - }" HAVE_THREAD_LOCAL) -if (HAVE_THREAD_LOCAL) - add_compile_definitions(HAVE_THREAD_LOCAL=1) -endif () +check_cxx_source_compiles("#include + int main() { + gmtime_r((const time_t *) nullptr, (struct tm *) nullptr); + }" HAVE_GMTIME_R) +if(HAVE_GMTIME_R) + add_compile_definitions(HAVE_GMTIME_R=1) +else() + check_cxx_source_compiles("#include + int main() { + gmtime_s((struct tm *) nullptr, (const time_t *) nullptr); + }" HAVE_GMTIME_S) + if(NOT HAVE_GMTIME_S) + message(FATAL_ERROR "Both gmtime_r and gmtime_s are unavailable") + endif() +endif() + +# TODO (build): make an option to allow disabling this +if (NOT MINGW) # TODO (build): also this is required for freebsd but probably we do not support it + check_cxx_source_compiles(" #include + static thread_local int foo = 0; + static void run_thread() { foo++;} + int main(){ + for(int i = 0; i < 10; i++) { std::thread(run_thread).detach();} + return foo; + }" HAVE_THREAD_LOCAL) + if (HAVE_THREAD_LOCAL) + add_compile_definitions(HAVE_THREAD_LOCAL=1) + endif () +endif() + +# TODO (build): add libmultiprocess stuff check_cxx_source_compiles(" #include #include @@ -279,7 +472,7 @@ if (CHAR_EQUALS_INT8) endif () if (ENABLE_REDUCE_EXPORTS) - # TODO It doesn't go anywhere + # TODO (build): It doesn't go anywhere check_cxx_compiler_flag(-fvisibility=hidden VISIBILITY_HIDDEN) if (NOT VISIBILITY_HIDDEN) message(FATAL_ERROR "Cannot set default symbol visibility. Use -DENABLE_REDUCE_EXPORTS=OFF") @@ -295,6 +488,7 @@ set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_BACKUP}) find_package(Event 2.0 REQUIRED) add_subdirectory(sqlite/) +add_compile_definitions(USE_SQLITE=1) find_package(OpenSSL REQUIRED) @@ -309,7 +503,7 @@ endif (HAVE_DECL_STRNLEN) # Univalue library if (WITH_SYSTEM_UNIVALUE) - # TODO write find_package script + # TODO (build): write find_package script find_library(UNIVALUE univalue) if (NOT UNIVALUE) message(FATAL_ERROR "System univalue requested but not found") @@ -322,30 +516,36 @@ endif () # Common library set(POCKETCOIN_COMMON pocketcoin_common) add_library(${POCKETCOIN_COMMON} + attributes.h cuckoocache.h eventloop.h indirectmap.h - limitedmap.h + # limitedmap.h memusage.h version.h reverse_iterator.h - reverselock.h + # reverselock.h streams.h undo.h span.h prevector.h protectedmap.h compat.h + compat/assumptions.h compat/byteswap.h + compat/cpuid.h compat/endian.h compat/sanity.h compat/glibc_sanity.cpp compat/glibcxx_sanity.cpp compat/strnlen.cpp + compat/stdin.h + compat/stdin.cpp + optional.h amount.h tinyformat.h ) - +target_include_directories(${POCKETCOIN_COMMON} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # Pocket DB functional library. # It is divided to pocketdb-server part and this functional part @@ -363,6 +563,7 @@ add_library(${POCKETDB} pocketdb/models/base/SocialTransaction.h pocketdb/models/base/Rating.h pocketdb/models/base/ReturnDtoModels.h + pocketdb/models/dto/Empty.h pocketdb/models/dto/Default.h pocketdb/models/dto/Coinbase.h pocketdb/models/dto/Coinstake.h @@ -391,6 +592,7 @@ add_library(${POCKETDB} pocketdb/models/base/TransactionOutput.cpp pocketdb/models/base/SocialTransaction.cpp pocketdb/models/base/Rating.cpp + pocketdb/models/dto/Empty.cpp pocketdb/models/dto/Default.cpp pocketdb/models/dto/Coinbase.cpp pocketdb/models/dto/Coinstake.cpp @@ -436,46 +638,83 @@ add_library(${POCKETCOIN_SUPPORT} support/allocators/secure.h support/allocators/zeroafterfree.h ) - +target_include_directories(${POCKETCOIN_SUPPORT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # Pocketcoin util library set(POCKETCOIN_UTIL pocketcoin_util) add_library(${POCKETCOIN_UTIL} + randomenv.h + randomenv.cpp clientversion.h clientversion.cpp + flatfile.h + flatfile.cpp fs.h fs.cpp logging.h logging.cpp + logging/timer.h sync.h sync.cpp threadsafety.h threadinterrupt.h threadinterrupt.cpp - utilmemory.h - utilmoneystr.h - utilmoneystr.cpp - utiltime.h - utiltime.cpp - utils/html.h - utils/html.cpp + util/memory.h + util/moneystr.h + util/moneystr.cpp + util/time.h + util/time.cpp + util/html.h + util/html.cpp + util/asmap.cpp + util/asmap.h + util/bip32.cpp + util/bip32.h + util/bytevectorhash.cpp + util/bytevectorhash.h + util/check.h + util/error.cpp + util/error.h + util/fees.cpp + util/fees.h + util/golombrice.h + util/macros.h + util/message.cpp + util/message.h + util/rbf.cpp + util/rbf.h + util/ref.h + util/settings.cpp + util/settings.h + util/spanparsing.cpp + util/spanparsing.h + util/string.cpp + util/string.h + util/threadnames.cpp + util/threadnames.h + util/translation.h + util/ui_change_type.h + util/url.cpp + util/url.h + util/vector.h random.h random.cpp timedata.h timedata.cpp netaddress.h netaddress.cpp - ui_interface.h - ui_interface.cpp - util.h - util.cpp + node/ui_interface.h + node/ui_interface.cpp + node/utxo_snapshot.h + util/system.h + util/system.cpp chainparamsbase.h chainparamsbase.cpp chainparamsseeds.h warnings.h warnings.cpp ) -target_link_libraries(${POCKETCOIN_UTIL} PRIVATE ${POCKETCOIN_SUPPORT} ${POCKETCOIN_COMMON} ${POCKETCOIN_CRYPTO} OpenSSL::Crypto ${CRYPT32} Boost::thread Boost::chrono Boost::date_time Event::event) +target_link_libraries(${POCKETCOIN_UTIL} PRIVATE ${POCKETCOIN_SUPPORT} ${POCKETCOIN_COMMON} ${POCKETCOIN_CRYPTO} OpenSSL::Crypto ${CRYPT32} Boost::thread Boost::chrono Boost::date_time Event::event univalue) target_link_libraries(${POCKETCOIN_UTIL} PUBLIC Boost::filesystem) if(WIN32) target_link_libraries(${POCKETCOIN_UTIL} PRIVATE ws2_32 crypt32 wsock32) @@ -484,6 +723,10 @@ endif () if (ENABLE_GLIBC_BACK_COMPAT) target_sources(${POCKETCOIN_UTIL} PRIVATE compat/glibc_compat.cpp) endif () +if (REQUIRED_SOCKET_LIB) + # Linking to a socket library if getifaddrs freeifaddrs functions require it (see _CHECK_SOCKET_RES_WITHOUT_LIBSOCKET) + target_link_libraries(${POCKETCOIN_UTIL} PRIVATE socket) +endif() target_include_directories(${POCKETCOIN_UTIL} PUBLIC ${Boost_INCLUDE_DIRS}) ######## Crypto @@ -491,6 +734,8 @@ set(POCKETCOIN_CRYPTO pocketcoin_crypto) add_library(${POCKETCOIN_CRYPTO} crypto/sha256_sse4.cpp crypto/sha256.cpp + crypto/sha3.h + crypto/sha3.cpp crypto/chacha20.cpp crypto/aes.h crypto/hmac_sha256.cpp @@ -501,11 +746,19 @@ add_library(${POCKETCOIN_CRYPTO} crypto/ripemd160.h crypto/hmac_sha512.h crypto/chacha20.h + crypto/chacha_poly_aead.h + crypto/chacha_poly_aead.cpp + crypto/hkdf_sha256_32.h + crypto/hkdf_sha256_32.cpp crypto/sha512.cpp crypto/sha1.cpp crypto/common.h + crypto/poly1305.h + crypto/poly1305.cpp crypto/hmac_sha256.h crypto/sha256.h + crypto/siphash.h + crypto/siphash.cpp crypto/aes.cpp uint256.h uint256.cpp @@ -518,17 +771,17 @@ add_library(${POCKETCOIN_CRYPTO} serialize.h arith_uint256.cpp arith_uint256.h - utilstrencodings.h - utilstrencodings.cpp + util/strencodings.h # TODO (build): maybe move to utils + util/strencodings.cpp ) target_link_libraries(${POCKETCOIN_CRYPTO} PRIVATE ${POCKETCOIN_COMMON} ${POCKETCOIN_SUPPORT} secp256k1) if (ENABLE_SSE41) target_sources(${POCKETCOIN_CRYPTO} PRIVATE crypto/sha256_sse41.cpp) if (MSVC) - # TODO it seems like windows fails with everything exept sse2 that is enabled by default - # Futhermore there are cmake scripts to find sse4.1 or avx support where they are always hardcoded as false for Windows - # https://github.com/magic-sph/magic/blob/master/cmake/FindSSE.cmake - # target_compile_options(${POCKETCOIN_CRYPTO} PRIVATE /arch:SSE4.1) + # TODO (build): it seems like windows fails with everything exept sse2 that is enabled by default + # Futhermore there are cmake scripts to find sse4.1 or avx support where they are always hardcoded as false for Windows: + # https://github.com/magic-sph/magic/blob/master/cmake/FindSSE.cmake + # target_compile_options(${POCKETCOIN_CRYPTO} PRIVATE /arch:SSE4.1) else () target_compile_definitions(${POCKETCOIN_CRYPTO} PRIVATE ENABLE_SSE41) target_compile_options(${POCKETCOIN_CRYPTO} PRIVATE -msse4.1) @@ -562,9 +815,10 @@ add_library(${POCKETCOIN_SYSTEM} scheduler.cpp shutdown.cpp ) target_link_libraries(${POCKETCOIN_SYSTEM} PRIVATE ${POCKETCOIN_UTIL} ${POCKETCOIN_CRYPTO}) +target_include_directories(${POCKETCOIN_SYSTEM} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # Consensus -# TODO probably completely move this to server +# TODO (build): probably completely move this to server set(POCKETCOIN_CONSENSUS pocketcoin_consensus) add_library(${POCKETCOIN_CONSENSUS} protocol.h @@ -575,7 +829,7 @@ add_library(${POCKETCOIN_CONSENSUS} key.cpp ) target_link_libraries(${POCKETCOIN_CONSENSUS} PRIVATE ${POCKETCOIN_UTIL} ${POCKETCOIN_COMMON} ${POCKETCOIN_CRYPTO} ${POCKETDB} univalue secp256k1) -# TODO hadrdcoded because we are always building consensus +# TODO (build): hadrdcoded because we are always building consensus add_compile_definitions(HAVE_CONSENSUS_LIB=1) @@ -583,19 +837,43 @@ add_compile_definitions(HAVE_CONSENSUS_LIB=1) set(POCKETCOIN_COMMON_RPC pocketcoin_common_rpc) add_library(${POCKETCOIN_COMMON_RPC} rpc/protocol.h - rpc/protocol.cpp) -target_link_libraries(${POCKETCOIN_COMMON_RPC} PRIVATE ${POCKETCOIN_CRYPTO} ${POCKETCOIN_UTIL}) + # TODO (build): request is shared between cli and daemon. + # Currently it is using DBConnection that is a part of server. + # This is OK for now because we have shared headers but this should be reworked. + # PocketDB stuff should be extracted to a different lib. Specially "pocketdb/SQLiteConnection.h" + # Also sqlite should be publically linked to this new lib and removed from linking here + rpc/request.h + rpc/request.cpp + ) +target_link_libraries(${POCKETCOIN_COMMON_RPC} PRIVATE ${POCKETCOIN_CRYPTO} ${POCKETCOIN_UTIL} univalue) +target_link_libraries(${POCKETCOIN_COMMON_RPC} PUBLIC sqlite3) +target_include_directories(${POCKETCOIN_COMMON_RPC} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) ########### Server set(POCKETCOIN_SERVER pocketcoin_server) add_library(${POCKETCOIN_SERVER} + + node/coin.h + node/coin.cpp + node/coinstats.h + node/coinstats.cpp + node/context.h + node/context.cpp + node/psbt.h + node/psbt.cpp + node/transaction.h + node/transaction.cpp + interfaces/chain.h + interfaces/chain.cpp interfaces/node.h interfaces/node.cpp chainparams.h chainparams.cpp consensus/tx_verify.h consensus/tx_verify.cpp + consensus/tx_check.h + consensus/tx_check.cpp consensus/merkle.h consensus/merkle.cpp chain.h @@ -614,9 +892,14 @@ add_library(${POCKETCOIN_SERVER} index/base.cpp index/txindex.h index/txindex.cpp + index/blockfilterindex.h + index/blockfilterindex.cpp + index/disktxpos.h checkpoints.h checkpoints.cpp checkqueue.h + banman.h + banman.cpp blockencodings.h blockencodings.cpp blockfilter.h @@ -650,8 +933,10 @@ add_library(${POCKETCOIN_SERVER} txdb.cpp versionbits.h versionbits.cpp - keystore.h - keystore.cpp + versionbitsinfo.h + versionbitsinfo.cpp + # keystore.h + # keystore.cpp compressor.h compressor.cpp key_io.h @@ -672,10 +957,15 @@ add_library(${POCKETCOIN_SERVER} policy/policy.cpp policy/rbf.h policy/rbf.cpp + policy/settings.h + policy/settings.cpp + signet.h + signet.cpp + script/keyorigin.h script/descriptor.h script/descriptor.cpp - script/ismine.h - script/ismine.cpp + script/signingprovider.h + script/signingprovider.cpp script/sigcache.h script/sigcache.cpp script/sign.h @@ -692,6 +982,8 @@ add_library(${POCKETCOIN_SERVER} script/script.h txmempool.h txmempool.cpp + txrequest.h + txrequest.cpp net.h net.cpp primitives/block.h @@ -702,7 +994,10 @@ add_library(${POCKETCOIN_SERVER} netbase.cpp net_processing.h net_processing.cpp + net_permissions.h + net_permissions.cpp netmessagemaker.h + net_types.h addrdb.h addrdb.cpp addrman.h @@ -717,13 +1012,17 @@ add_library(${POCKETCOIN_SERVER} rpc/mining.cpp rpc/misc.cpp rpc/net.cpp - rpc/rawtransaction.h + # rpc/rawtransaction.h rpc/rawtransaction.cpp + rpc/rawtransaction_util.h + rpc/rawtransaction_util.cpp rpc/register.h rpc/server.cpp rpc/server.h rpc/util.cpp rpc/util.h + psbt.h + psbt.cpp rpc/cache.h rpc/cache.cpp walletinitinterface.h @@ -822,14 +1121,19 @@ add_library(${POCKETCOIN_SERVER} pocketdb/consensus/Base.cpp pocketdb/consensus/Lottery.cpp ) -target_link_libraries(${POCKETCOIN_SERVER} PRIVATE ${POCKETCOIN_COMMON_RPC} ${POCKETCOIN_UTIL} ${POCKETCOIN_COMMON} ${POCKETCOIN_SYSTEM} ${POCKETCOIN_CONSENSUS} ${POCKETCOIN_CRYPTO} Event::event leveldb OpenSSL::Crypto ${CRYPT32} Boost::boost Boost::date_time) +target_link_libraries(${POCKETCOIN_SERVER} PRIVATE ${POCKETCOIN_COMMON_RPC} ${POCKETCOIN_UTIL} ${POCKETCOIN_COMMON} ${POCKETCOIN_SYSTEM} ${POCKETCOIN_CONSENSUS} ${POCKETCOIN_CRYPTO} Event::event OpenSSL::Crypto ${CRYPT32} Boost::boost Boost::date_time) target_include_directories(${POCKETCOIN_SERVER} PRIVATE ${OPENSSL_INCLUDE_DIR} ${Event_INCLUDE_DIRS}) -target_link_libraries(${POCKETCOIN_SERVER} PUBLIC sqlite3 univalue) +target_link_libraries(${POCKETCOIN_SERVER} PUBLIC sqlite3 univalue leveldb) +target_include_directories(${POCKETCOIN_SERVER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if (NOT DISABLE_WALLET) target_sources(${POCKETCOIN_SERVER} PRIVATE + wallet/bdb.h + wallet/bdb.cpp wallet/coincontrol.h wallet/coincontrol.cpp + wallet/context.h + wallet/context.cpp wallet/crypter.h wallet/crypter.cpp wallet/db.h @@ -839,6 +1143,9 @@ if (NOT DISABLE_WALLET) wallet/fees.h wallet/fees.cpp wallet/init.cpp + wallet/ismine.h + wallet/load.h + wallet/load.cpp wallet/rpcdump.cpp wallet/rpcwallet.h wallet/rpcwallet.cpp @@ -846,10 +1153,17 @@ if (NOT DISABLE_WALLET) wallet/wallet.cpp wallet/walletdb.h wallet/walletdb.cpp + wallet/wallettool.h wallet/walletutil.h wallet/walletutil.cpp wallet/coinselection.h wallet/coinselection.cpp + wallet/salvage.h + wallet/scriptpubkeyman.h + wallet/scriptpubkeyman.cpp + + wallet/sqlite.h + wallet/sqlite.cpp interfaces/wallet.h interfaces/wallet.cpp staker.h @@ -861,7 +1175,12 @@ else () target_sources(${POCKETCOIN_SERVER} PRIVATE dummywallet.cpp) endif () -# TODO USE_UPNP +if(REQUIRED_SOCKET_LIB) + # same as for above for POCKETCOIN_UTIL + target_link_libraries(${POCKETCOIN_SERVER} PRIVATE socket) +endif() + +# TODO (build): USE_UPNP # ZMQ if (NOT DISABLE_ZMQ) @@ -870,17 +1189,19 @@ if (NOT DISABLE_ZMQ) if (MSVC AND MSVC_FORCE_STATIC) target_compile_definitions(${POCKETCOIN_SERVER} PRIVATE ZMQ_STATIC) endif () - add_compile_definitions(ENABLE_ZMQ) + add_compile_definitions(ENABLE_ZMQ=1) set(POCKETCOIN_ZMQ_SOURCES zmq/zmqabstractnotifier.h zmq/zmqabstractnotifier.cpp zmq/zmqnotificationinterface.h zmq/zmqnotificationinterface.cpp zmq/zmqpublishnotifier.h - zmq/zmqconfig.h + # zmq/zmqconfig.h zmq/zmqpublishnotifier.cpp zmq/zmqrpc.h zmq/zmqrpc.cpp + zmq/zmqutil.h + zmq/zmqutil.cpp ) target_sources(${POCKETCOIN_SERVER} PRIVATE ${POCKETCOIN_ZMQ_SOURCES}) target_link_libraries(${POCKETCOIN_SERVER} PRIVATE ZMQ::zmq) @@ -888,24 +1209,28 @@ if (NOT DISABLE_ZMQ) else () message(WARNING "ZMQ not found, disabling") endif () +else() + add_compile_definitions(ENABLE_ZMQ=0) endif () set(POCKETCOIND pocketcoind) add_executable(${POCKETCOIND} pocketcoind.cpp) -target_link_libraries(${POCKETCOIND} PRIVATE ${POCKETCOIN_SERVER} ${POCKETCOIN_COMMON_RPC} ${POCKETDB} ${POCKETCOIN_UTIL} ${POCKETCOIN_CONSENSUS} ${POCKETCOIN_SYSTEM} OpenSSL::Crypto ${CRYPT32} Event::event sqlite3 univalue secp256k1 memenv) +target_link_libraries(${POCKETCOIND} PRIVATE ${POCKETCOIN_SERVER} ${POCKETCOIN_COMMON_RPC} ${POCKETDB} ${POCKETCOIN_UTIL} ${POCKETCOIN_CONSENSUS} ${POCKETCOIN_SYSTEM} OpenSSL::Crypto ${CRYPT32} Event::event sqlite3 univalue secp256k1 leveldb) target_include_directories(${POCKETCOIND} PRIVATE ${OPENSSL_INCLUDE_DIR} ${Event_INCLUDE_DIRS}) add_library(libpocketcoin_cli rpc/client.h rpc/client.cpp) target_link_libraries(libpocketcoin_cli PRIVATE univalue ${POCKETCOIN_UTIL} ${POCKETCOIN_COMMON_RPC}) -set(POCKETCOIN_CLI pocketcoin_cli) +target_include_directories(libpocketcoin_cli PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +set(POCKETCOIN_CLI pocketcoin-cli) add_executable(${POCKETCOIN_CLI} pocketcoin-cli.cpp ) -target_link_libraries(${POCKETCOIN_CLI} PRIVATE ${POCKETCOIN_UTIL} ${POCKETCOIN_COMMON_RPC} univalue Event::event libpocketcoin_cli) +# TODO (build): remove leveldb after header fix +target_link_libraries(${POCKETCOIN_CLI} PRIVATE ${POCKETCOIN_UTIL} ${POCKETCOIN_COMMON_RPC} univalue Event::event libpocketcoin_cli leveldb) target_include_directories(${POCKETCOIN_CLI} PRIVATE ${Event_INCLUDE_DIRS}) -set(POCKETCOIN_TX pocketcoin_tx) +set(POCKETCOIN_TX pocketcoin-tx) add_executable(${POCKETCOIN_TX} pocketcoin-tx.cpp) target_link_libraries(${POCKETCOIN_TX} PRIVATE ${POCKETCOIN_SERVER} ${POCKETCOIN_UTIL} ${POCKETDB} ${POCKETCOIN_CRYPTO} ${POCKETCOIN_CONSENSUS} univalue sqlite3) if(NOT DISABLE_GUI) add_subdirectory(qt/) -endif() \ No newline at end of file +endif() diff --git a/src/Makefile.am b/src/Makefile.am index 027d3ad6d..24c6f5dee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,10 +4,11 @@ DIST_SUBDIRS = sqlite secp256k1 univalue -AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) +AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) AM_LIBTOOLFLAGS = --preserve-dup-deps +PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) EXTRA_LIBRARIES = if EMBEDDED_UNIVALUE @@ -19,8 +20,8 @@ else LIBUNIVALUE = $(UNIVALUE_LIBS) endif -POCKETCOIN_INCLUDES=-I$(builddir) $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) -POCKETCOIN_INCLUDES += -I$(srcdir)/secp256k1/include +POCKETCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/secp256k1/include $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) + POCKETCOIN_INCLUDES += -I$(srcdir)/sqlite/include POCKETCOIN_INCLUDES += $(UNIVALUE_CFLAGS) @@ -42,6 +43,7 @@ LIBPOCKETCOINCONSENSUS=libpocketcoinconsensus.la endif if ENABLE_WALLET LIBPOCKETCOIN_WALLET=libpocketcoin_wallet.a +LIBPOCKETCOIN_WALLET_TOOL=libpocketcoin_wallet_tool.a endif LIBPOCKETCOIN_CRYPTO= $(LIBPOCKETCOIN_CRYPTO_BASE) @@ -74,7 +76,8 @@ EXTRA_LIBRARIES += \ $(LIBPOCKETCOIN_SERVER) \ $(LIBPOCKETCOIN_CLI) \ $(LIBPOCKETCOIN_WALLET) \ - $(LIBPOCKETCOIN_ZMQ) + $(LIBPOCKETCOIN_WALLET_TOOL) \ + $(LIBPOCKETCOIN_ZMQ) lib_LTLIBRARIES = $(LIBPOCKETCOINCONSENSUS) @@ -87,8 +90,20 @@ if BUILD_POCKETCOIND bin_PROGRAMS += pocketcoind endif -if BUILD_POCKETCOIN_UTILS - bin_PROGRAMS += pocketcoin-cli pocketcoin-tx +if BUILD_POCKETCOIN_NODE + bin_PROGRAMS += pocketcoin-node +endif + +if BUILD_POCKETCOIN_CLI + bin_PROGRAMS += pocketcoin-cli +endif +if BUILD_POCKETCOIN_TX + bin_PROGRAMS += pocketcoin-tx +endif +if ENABLE_WALLET +# if BUILD_POCKETCOIN_WALLET +# bin_PROGRAMS += pocketcoin-wallet +# endif endif .PHONY: FORCE check-symbols check-security @@ -177,6 +192,7 @@ POCKETDB_H = \ pocketdb/models/base/Payload.h \ pocketdb/models/base/ReturnDtoModels.h \ \ + pocketdb/models/dto/Empty.h \ pocketdb/models/dto/Default.h \ pocketdb/models/dto/Coinbase.h \ pocketdb/models/dto/Coinstake.h \ @@ -261,6 +277,7 @@ POCKETDB_CPP = \ pocketdb/web/PocketRpc.cpp \ pocketdb/web/WebRpcUtils.cpp \ \ + pocketdb/models/dto/Empty.cpp \ pocketdb/models/dto/Default.cpp \ pocketdb/models/dto/Coinbase.cpp \ pocketdb/models/dto/Coinstake.cpp \ @@ -291,86 +308,107 @@ POCKETCOIN_CORE_H = \ addrdb.h \ addrman.h \ attributes.h \ + banman.h \ base58.h \ bech32.h \ - bloom.h \ blockencodings.h \ blockfilter.h \ + bloom.h \ chain.h \ chainparams.h \ chainparamsbase.h \ chainparamsseeds.h \ - checkpoints.h \ checkqueue.h \ clientversion.h \ coins.h \ compat.h \ + compat/assumptions.h \ compat/byteswap.h \ + compat/cpuid.h \ compat/endian.h \ compat/sanity.h \ compressor.h \ consensus/consensus.h \ + consensus/tx_check.h \ consensus/tx_verify.h \ core_io.h \ core_memusage.h \ cuckoocache.h \ - eventloop.h \ + dbwrapper.h \ + ldb/ldb.h \ + flatfile.h \ fs.h \ + eventloop.h \ httprpc.h \ httpserver.h \ index/base.h \ + index/blockfilterindex.h \ + index/disktxpos.h \ index/txindex.h \ indirectmap.h \ init.h \ + interfaces/chain.h \ interfaces/handler.h \ interfaces/node.h \ interfaces/wallet.h \ key.h \ key_io.h \ - keystore.h \ - dbwrapper.h \ - ldb/ldb.h \ - limitedmap.h \ logging.h \ + logging/timer.h \ memusage.h \ merkleblock.h \ miner.h \ net.h \ + net_permissions.h \ net_processing.h \ + net_types.h \ netaddress.h \ netbase.h \ netmessagemaker.h \ + node/coin.h \ + node/coinstats.h \ + node/context.h \ + node/psbt.h \ + node/transaction.h \ + node/ui_interface.h \ + node/utxo_snapshot.h \ noui.h \ + optional.h \ outputtype.h \ policy/feerate.h \ policy/fees.h \ policy/policy.h \ policy/rbf.h \ + policy/settings.h \ pos.h \ pow.h \ protectedmap.h \ protocol.h \ + psbt.h \ random.h \ + randomenv.h \ reverse_iterator.h \ - reverselock.h \ rpc/blockchain.h \ rpc/cache.h \ rpc/client.h \ rpc/mining.h \ rpc/protocol.h \ - rpc/server.h \ - rpc/rawtransaction.h \ + rpc/rawtransaction_util.h \ rpc/register.h \ + rpc/request.h \ + rpc/server.h \ rpc/util.h \ statistic.hpp \ scheduler.h \ script/descriptor.h \ - script/ismine.h \ + script/keyorigin.h \ script/sigcache.h \ script/sign.h \ + script/signingprovider.h \ script/standard.h \ shutdown.h \ staker.h \ + signet.h \ streams.h \ support/allocators/secure.h \ support/allocators/zeroafterfree.h \ @@ -378,41 +416,69 @@ POCKETCOIN_CORE_H = \ support/events.h \ support/lockedpool.h \ sync.h \ - threadsafety.h \ threadinterrupt.h \ + threadsafety.h \ timedata.h \ torcontrol.h \ txdb.h \ + txrequest.h \ txmempool.h \ - ui_interface.h \ undo.h \ - util.h \ - utilmemory.h \ - utilmoneystr.h \ - utiltime.h \ + util/asmap.h \ + util/bip32.h \ + util/bytevectorhash.h \ + util/check.h \ + util/error.h \ + util/fees.h \ + util/golombrice.h \ + util/macros.h \ + util/memory.h \ + util/message.h \ + util/moneystr.h \ + util/rbf.h \ + util/ref.h \ + util/settings.h \ + util/spanparsing.h \ + util/string.h \ + util/system.h \ + util/threadnames.h \ + util/time.h \ + util/translation.h \ + util/ui_change_type.h \ + util/url.h \ + util/vector.h \ + util/html.h \ validation.h \ validationinterface.h \ versionbits.h \ - walletinitinterface.h \ + versionbitsinfo.h \ + wallet/bdb.h \ wallet/coincontrol.h \ + wallet/coinselection.h \ + wallet/context.h \ wallet/crypter.h \ wallet/db.h \ wallet/feebumper.h \ wallet/fees.h \ + wallet/ismine.h \ + wallet/load.h \ wallet/rpcwallet.h \ + wallet/salvage.h \ + wallet/scriptpubkeyman.h \ + wallet/sqlite.h \ wallet/wallet.h \ wallet/walletdb.h \ + wallet/wallettool.h \ wallet/walletutil.h \ - wallet/coinselection.h \ + walletinitinterface.h \ warnings.h \ zmq/zmqabstractnotifier.h \ - zmq/zmqconfig.h\ zmq/zmqnotificationinterface.h \ zmq/zmqpublishnotifier.h \ zmq/zmqrpc.h \ + zmq/zmqutil.h \ websocket/ws.h \ websocket/notifyprocessor.h \ - utils/html.h \ $(POCKETDB_H) @@ -423,35 +489,43 @@ obj/build.h: FORCE libpocketcoin_util_a-clientversion.$(OBJEXT): obj/build.h # server: shared between pocketcoind and pocketcoin-qt +# Contains code accessing mempool and chain state that is meant to be separated +# from wallet and gui code (see node/README.md). Shared code should go in +# libpocketcoin_common or libpocketcoin_util libraries, instead. libpocketcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) libpocketcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libpocketcoin_server_a_SOURCES = \ addrdb.cpp \ addrman.cpp \ - bloom.cpp \ + banman.cpp \ blockencodings.cpp \ blockfilter.cpp \ chain.cpp \ - checkpoints.cpp \ consensus/tx_verify.cpp \ + dbwrapper.cpp \ + flatfile.cpp \ httprpc.cpp \ httpserver.cpp \ index/base.cpp \ + index/blockfilterindex.cpp \ index/txindex.cpp \ - interfaces/handler.cpp \ - interfaces/node.cpp \ - init.cpp \ + init.cpp \ ldb/ldb.cpp \ - dbwrapper.cpp \ - merkleblock.cpp \ + interfaces/chain.cpp \ + interfaces/node.cpp \ miner.cpp \ net.cpp \ net_processing.cpp \ + node/coin.cpp \ + node/coinstats.cpp \ + node/context.cpp \ + node/psbt.cpp \ + node/transaction.cpp \ + node/ui_interface.cpp \ noui.cpp \ - outputtype.cpp \ policy/fees.cpp \ - policy/policy.cpp \ policy/rbf.cpp \ + policy/settings.cpp \ pos.cpp \ pow.cpp \ rest.cpp \ @@ -462,36 +536,39 @@ libpocketcoin_server_a_SOURCES = \ rpc/net.cpp \ rpc/rawtransaction.cpp \ rpc/server.cpp \ - rpc/util.cpp \ script/sigcache.cpp \ shutdown.cpp \ staker.cpp \ + signet.cpp \ timedata.cpp \ torcontrol.cpp \ txdb.cpp \ + txrequest.cpp \ txmempool.cpp \ - ui_interface.cpp \ validation.cpp \ validationinterface.cpp \ versionbits.cpp \ websocket/ws.cpp \ websocket/notifyprocessor.cpp \ - utils/html.cpp \ $(POCKETDB_CPP) \ $(POCKETCOIN_CORE_H) +if ENABLE_WALLET +libpocketcoin_server_a_SOURCES += wallet/init.cpp +endif if !ENABLE_WALLET libpocketcoin_server_a_SOURCES += dummywallet.cpp endif if ENABLE_ZMQ -libpocketcoin_zmq_a_CPPFLAGS = $(POCKETCOIN_INCLUDES) $(ZMQ_CFLAGS) +libpocketcoin_zmq_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(ZMQ_CFLAGS) libpocketcoin_zmq_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libpocketcoin_zmq_a_SOURCES = \ zmq/zmqabstractnotifier.cpp \ zmq/zmqnotificationinterface.cpp \ zmq/zmqpublishnotifier.cpp \ - zmq/zmqrpc.cpp + zmq/zmqrpc.cpp \ + zmq/zmqutil.cpp endif @@ -501,41 +578,65 @@ libpocketcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) libpocketcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libpocketcoin_wallet_a_SOURCES = \ interfaces/wallet.cpp \ + wallet/bdb.cpp \ wallet/coincontrol.cpp \ + wallet/context.cpp \ wallet/crypter.cpp \ wallet/db.cpp \ wallet/feebumper.cpp \ wallet/fees.cpp \ - wallet/init.cpp \ + wallet/load.cpp \ wallet/rpcdump.cpp \ wallet/rpcwallet.cpp \ + wallet/salvage.cpp \ + wallet/scriptpubkeyman.cpp \ wallet/wallet.cpp \ wallet/walletdb.cpp \ wallet/walletutil.cpp \ wallet/coinselection.cpp \ $(POCKETCOIN_CORE_H) +if USE_SQLITE +libpocketcoin_wallet_a_SOURCES += wallet/sqlite.cpp +endif + +libpocketcoin_wallet_tool_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +libpocketcoin_wallet_tool_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +libpocketcoin_wallet_tool_a_SOURCES = \ + wallet/wallettool.cpp \ + $(POCKETCOIN_CORE_H) + # crypto primitives library crypto_libpocketcoin_crypto_base_a_CPPFLAGS = $(AM_CPPFLAGS) crypto_libpocketcoin_crypto_base_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) crypto_libpocketcoin_crypto_base_a_SOURCES = \ crypto/aes.cpp \ crypto/aes.h \ + crypto/chacha_poly_aead.h \ + crypto/chacha_poly_aead.cpp \ crypto/chacha20.h \ crypto/chacha20.cpp \ crypto/common.h \ + crypto/hkdf_sha256_32.cpp \ + crypto/hkdf_sha256_32.h \ crypto/hmac_sha256.cpp \ crypto/hmac_sha256.h \ crypto/hmac_sha512.cpp \ crypto/hmac_sha512.h \ + crypto/poly1305.h \ + crypto/poly1305.cpp \ crypto/ripemd160.cpp \ crypto/ripemd160.h \ crypto/sha1.cpp \ crypto/sha1.h \ crypto/sha256.cpp \ crypto/sha256.h \ + crypto/sha3.cpp \ + crypto/sha3.h \ crypto/sha512.cpp \ - crypto/sha512.h + crypto/sha512.h \ + crypto/siphash.cpp \ + crypto/siphash.h if USE_ASM crypto_libpocketcoin_crypto_base_a_SOURCES += crypto/sha256_sse4.cpp @@ -569,6 +670,7 @@ libpocketcoin_consensus_a_SOURCES = \ consensus/merkle.cpp \ consensus/merkle.h \ consensus/params.h \ + consensus/tx_check.cpp \ consensus/validation.h \ hash.cpp \ hash.h \ @@ -591,8 +693,8 @@ libpocketcoin_consensus_a_SOURCES = \ tinyformat.h \ uint256.cpp \ uint256.h \ - utilstrencodings.cpp \ - utilstrencodings.h \ + util/strencodings.cpp \ + util/strencodings.h \ version.h # common: shared between pocketcoind, and pocketcoin-qt and non-server tools @@ -601,6 +703,7 @@ libpocketcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libpocketcoin_common_a_SOURCES = \ base58.cpp \ bech32.cpp \ + bloom.cpp \ chainparams.cpp \ coins.cpp \ compressor.cpp \ @@ -608,16 +711,23 @@ libpocketcoin_common_a_SOURCES = \ core_write.cpp \ key.cpp \ key_io.cpp \ - keystore.cpp \ + merkleblock.cpp \ netaddress.cpp \ netbase.cpp \ + net_permissions.cpp \ + outputtype.cpp \ policy/feerate.cpp \ + policy/policy.cpp \ protocol.cpp \ + psbt.cpp \ + rpc/rawtransaction_util.cpp \ + rpc/util.cpp \ scheduler.cpp \ script/descriptor.cpp \ - script/ismine.cpp \ script/sign.cpp \ + script/signingprovider.cpp \ script/standard.cpp \ + versionbitsinfo.cpp \ warnings.cpp \ $(POCKETCOIN_CORE_H) @@ -634,18 +744,36 @@ libpocketcoin_util_a_SOURCES = \ compat/glibcxx_sanity.cpp \ compat/strnlen.cpp \ fs.cpp \ + interfaces/handler.cpp \ logging.cpp \ random.cpp \ - rpc/protocol.cpp \ + randomenv.cpp \ + rpc/request.cpp \ support/cleanse.cpp \ sync.cpp \ threadinterrupt.cpp \ - util.cpp \ - utilmoneystr.cpp \ - utilstrencodings.cpp \ - utiltime.cpp \ + util/asmap.cpp \ + util/bip32.cpp \ + util/bytevectorhash.cpp \ + util/error.cpp \ + util/fees.cpp \ + util/html.cpp \ + util/system.cpp \ + util/message.cpp \ + util/moneystr.cpp \ + util/rbf.cpp \ + util/settings.cpp \ + util/threadnames.cpp \ + util/spanparsing.cpp \ + util/strencodings.cpp \ + util/string.cpp \ + util/time.cpp \ $(POCKETCOIN_CORE_H) +if USE_LIBEVENT +libpocketcoin_util_a_SOURCES += util/url.cpp +endif + if GLIBC_BACK_COMPAT libpocketcoin_util_a_SOURCES += compat/glibc_compat.cpp AM_LDFLAGS += $(COMPAT_LDFLAGS) @@ -655,28 +783,29 @@ endif libpocketcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) libpocketcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libpocketcoin_cli_a_SOURCES = \ + compat/stdin.h \ + compat/stdin.cpp \ rpc/client.cpp \ $(POCKETCOIN_CORE_H) nodist_libpocketcoin_util_a_SOURCES = $(srcdir)/obj/build.h # -# pocketcoind binary # -pocketcoind_SOURCES = pocketcoind.cpp -pocketcoind_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -pocketcoind_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -pocketcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +# pocketcoind & pocketcoin-node binaries # +pocketcoin_daemon_sources = pocketcoind.cpp +pocketcoin_bin_cppflags = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +pocketcoin_bin_cxxflags = $(AM_CXXFLAGS) $(PIE_FLAGS) +pocketcoin_bin_ldflags = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) if TARGET_WINDOWS -pocketcoind_SOURCES += pocketcoind-res.rc +pocketcoin_daemon_sources += pocketcoind-res.rc endif -pocketcoind_LDADD = \ - $(LIBPOCKETCOIN_SERVER) \ +pocketcoin_bin_ldadd = \ $(LIBPOCKETCOIN_WALLET) \ $(LIBPOCKETCOIN_COMMON) \ - $(LIBUNIVALUE) \ $(LIBPOCKETCOIN_UTIL) \ + $(LIBUNIVALUE) \ $(LIBPOCKETCOIN_ZMQ) \ $(LIBPOCKETCOIN_CONSENSUS) \ $(LIBPOCKETCOIN_CRYPTO) \ @@ -686,13 +815,25 @@ pocketcoind_LDADD = \ $(LIBSECP256K1) \ $(LIBSQLITE3) -pocketcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) +pocketcoin_bin_ldadd += $(BOOST_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) $(CRYPTO_LIBS) $(SSL_LIBS) + +pocketcoind_SOURCES = $(pocketcoin_daemon_sources) +pocketcoind_CPPFLAGS = $(pocketcoin_bin_cppflags) +pocketcoind_CXXFLAGS = $(pocketcoin_bin_cxxflags) +pocketcoind_LDFLAGS = $(pocketcoin_bin_ldflags) +pocketcoind_LDADD = $(LIBPOCKETCOIN_SERVER) $(pocketcoin_bin_ldadd) + +pocketcoin_node_SOURCES = $(pocketcoin_daemon_sources) +pocketcoin_node_CPPFLAGS = $(pocketcoin_bin_cppflags) +pocketcoin_node_CXXFLAGS = $(pocketcoin_bin_cxxflags) +pocketcoin_node_LDFLAGS = $(pocketcoin_bin_ldflags) +pocketcoin_node_LDADD = $(LIBPOCKETCOIN_SERVER) $(pocketcoin_bin_ldadd) # pocketcoin-cli binary # pocketcoin_cli_SOURCES = pocketcoin-cli.cpp pocketcoin_cli_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(EVENT_CFLAGS) pocketcoin_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -pocketcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +pocketcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) if TARGET_WINDOWS pocketcoin_cli_SOURCES += pocketcoin-cli-res.rc @@ -704,13 +845,14 @@ pocketcoin_cli_LDADD = \ $(LIBPOCKETCOIN_UTIL) \ $(LIBPOCKETCOIN_CRYPTO) -pocketcoin_cli_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS) +pocketcoin_cli_LDADD += $(BOOST_LIBS) $(EVENT_LIBS) +# # pocketcoin-tx binary # pocketcoin_tx_SOURCES = pocketcoin-tx.cpp pocketcoin_tx_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) pocketcoin_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -pocketcoin_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +pocketcoin_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) if TARGET_WINDOWS pocketcoin_tx_SOURCES += pocketcoin-tx-res.rc @@ -724,13 +866,25 @@ pocketcoin_tx_LDADD = \ $(LIBPOCKETCOIN_CRYPTO) \ $(LIBSECP256K1) -pocketcoin_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) +pocketcoin_tx_LDADD += $(BOOST_LIBS) +# + +# pocketcoin-wallet binary # +# pocketcoin_wallet_SOURCES = pocketcoin-wallet.cpp # +# pocketcoin_wallet_CPPFLAGS = $(pocketcoin_bin_cppflags) # +# pocketcoin_wallet_CXXFLAGS = $(pocketcoin_bin_cxxflags) # +# pocketcoin_wallet_LDFLAGS = $(pocketcoin_bin_ldflags) # +# pocketcoin_wallet_LDADD = $(LIBPOCKETCOIN_WALLET_TOOL) $(pocketcoin_bin_ldadd) # + +# if TARGET_WINDOWS +# pocketcoin_wallet_SOURCES += pocketcoin-wallet-res.rc +# endif # # pocketcoinconsensus library # if BUILD_POCKETCOIN_LIBS include_HEADERS = script/pocketcoinconsensus.h -libpocketcoinconsensus_la_SOURCES = $(crypto_libpocketcoin_crypto_base_a_SOURCES) $(libpocketcoin_consensus_a_SOURCES) +libpocketcoinconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libpocketcoin_crypto_base_a_SOURCES) $(libpocketcoin_consensus_a_SOURCES) if GLIBC_BACK_COMPAT libpocketcoinconsensus_la_SOURCES += compat/glibc_compat.cpp @@ -755,12 +909,18 @@ CLEANFILES = $(EXTRA_LIBRARIES) CLEANFILES += *.gcda *.gcno CLEANFILES += compat/*.gcda compat/*.gcno CLEANFILES += consensus/*.gcda consensus/*.gcno +CLEANFILES += crc32c/src/*.gcda crc32c/src/*.gcno CLEANFILES += crypto/*.gcda crypto/*.gcno +CLEANFILES += index/*.gcda index/*.gcno +CLEANFILES += interfaces/*.gcda interfaces/*.gcno +CLEANFILES += node/*.gcda node/*.gcno CLEANFILES += policy/*.gcda policy/*.gcno CLEANFILES += primitives/*.gcda primitives/*.gcno +CLEANFILES += rpc/*.gcda rpc/*.gcno CLEANFILES += script/*.gcda script/*.gcno CLEANFILES += support/*.gcda support/*.gcno CLEANFILES += univalue/*.gcda univalue/*.gcno +CLEANFILES += util/*.gcda util/*.gcno CLEANFILES += wallet/*.gcda wallet/*.gcno CLEANFILES += wallet/test/*.gcda wallet/test/*.gcno CLEANFILES += zmq/*.gcda zmq/*.gcno @@ -789,25 +949,35 @@ clean-local: $(AM_V_GEN) $(WINDRES) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) -DWINDRES_PREPROC -i $< -o $@ check-symbols: $(bin_PROGRAMS) +if TARGET_DARWIN + @echo "Checking macOS dynamic libraries..." + $(AM_V_at) OTOOL=$(OTOOL) $(PYTHON) $(top_srcdir)/contrib/devtools/symbol-check.py $(bin_PROGRAMS) +endif + +if TARGET_WINDOWS + @echo "Checking Windows dynamic libraries..." + $(AM_V_at) OBJDUMP=$(OBJDUMP) $(PYTHON) $(top_srcdir)/contrib/devtools/symbol-check.py $(bin_PROGRAMS) +endif + if GLIBC_BACK_COMPAT @echo "Checking glibc back compat..." - $(AM_V_at) READELF=$(READELF) CPPFILT=$(CPPFILT) $(top_srcdir)/contrib/devtools/symbol-check.py < $(bin_PROGRAMS) + $(AM_V_at) READELF=$(READELF) CPPFILT=$(CPPFILT) $(PYTHON) $(top_srcdir)/contrib/devtools/symbol-check.py $(bin_PROGRAMS) endif check-security: $(bin_PROGRAMS) if HARDEN @echo "Checking binary security..." - $(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS) + $(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) OTOOL=$(OTOOL) $(PYTHON) $(top_srcdir)/contrib/devtools/security-check.py $(bin_PROGRAMS) endif -%.pb.cc %.pb.h: %.proto - @test -f $(PROTOC) - $(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$( "$@.new" && mv -f "$@.new" "$@" diff --git a/src/Makefile.crc32c.include b/src/Makefile.crc32c.include new file mode 100644 index 000000000..febeb0535 --- /dev/null +++ b/src/Makefile.crc32c.include @@ -0,0 +1,75 @@ +# Copyright (c) 2019 The Pocketcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +LIBCRC32C_INT = crc32c/libcrc32c.a +LIBLEVELDB_SSE42_INT = leveldb/libleveldb_sse42.a + +EXTRA_LIBRARIES += $(LIBCRC32C_INT) + +LIBCRC32C = $(LIBCRC32C_INT) + +CRC32C_CPPFLAGS_INT = +CRC32C_CPPFLAGS_INT += -I$(srcdir)/crc32c/include +CRC32C_CPPFLAGS_INT += -DHAVE_BUILTIN_PREFETCH=@HAVE_BUILTIN_PREFETCH@ +CRC32C_CPPFLAGS_INT += -DHAVE_MM_PREFETCH=@HAVE_MM_PREFETCH@ +CRC32C_CPPFLAGS_INT += -DHAVE_STRONG_GETAUXVAL=@HAVE_STRONG_GETAUXVAL@ +CRC32C_CPPFLAGS_INT += -DHAVE_WEAK_GETAUXVAL=@HAVE_WEAK_GETAUXVAL@ +CRC32C_CPPFLAGS_INT += -DCRC32C_TESTS_BUILT_WITH_GLOG=0 + +if ENABLE_SSE42 +CRC32C_CPPFLAGS_INT += -DHAVE_SSE42=1 +else +CRC32C_CPPFLAGS_INT += -DHAVE_SSE42=0 +endif + +if ENABLE_ARM_CRC +CRC32C_CPPFLAGS_INT += -DHAVE_ARM64_CRC32C=1 +else +CRC32C_CPPFLAGS_INT += -DHAVE_ARM64_CRC32C=0 +endif + +if WORDS_BIGENDIAN +CRC32C_CPPFLAGS_INT += -DBYTE_ORDER_BIG_ENDIAN=1 +else +CRC32C_CPPFLAGS_INT += -DBYTE_ORDER_BIG_ENDIAN=0 +endif + +crc32c_libcrc32c_a_CPPFLAGS = $(AM_CPPFLAGS) $(CRC32C_CPPFLAGS_INT) $(CRC32C_CPPFLAGS) +crc32c_libcrc32c_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) + +crc32c_libcrc32c_a_SOURCES = +crc32c_libcrc32c_a_SOURCES += crc32c/include/crc32c/crc32c.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_arm64.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_arm64_linux_check.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_internal.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_prefetch.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_read_le.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_round_up.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_sse42_check.h +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_sse42.h + +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c.cc +crc32c_libcrc32c_a_SOURCES += crc32c/src/crc32c_portable.cc + +if ENABLE_SSE42 +LIBCRC32C_SSE42_INT = crc32c/libcrc32c_sse42.a +EXTRA_LIBRARIES += $(LIBCRC32C_SSE42_INT) +LIBCRC32C += $(LIBCRC32C_SSE42_INT) + +crc32c_libcrc32c_sse42_a_CPPFLAGS = $(crc32c_libcrc32c_a_CPPFLAGS) +crc32c_libcrc32c_sse42_a_CXXFLAGS = $(crc32c_libcrc32c_a_CXXFLAGS) $(SSE42_CXXFLAGS) + +crc32c_libcrc32c_sse42_a_SOURCES = crc32c/src/crc32c_sse42.cc +endif + +if ENABLE_ARM_CRC +LIBCRC32C_ARM_CRC_INT = crc32c/libcrc32c_arm_crc.a +EXTRA_LIBRARIES += $(LIBCRC32C_ARM_CRC_INT) +LIBCRC32C += $(LIBCRC32C_ARM_CRC_INT) + +crc32c_libcrc32c_arm_crc_a_CPPFLAGS = $(crc32c_libcrc32c_a_CPPFLAGS) +crc32c_libcrc32c_arm_crc_a_CXXFLAGS = $(crc32c_libcrc32c_a_CXXFLAGS) $(ARM_CRC_CXXFLAGS) + +crc32c_libcrc32c_arm_crc_a_SOURCES = crc32c/src/crc32c_arm64.cc +endif diff --git a/src/Makefile.leveldb.include b/src/Makefile.leveldb.include index 833f3d2a1..8a28f4f24 100644 --- a/src/Makefile.leveldb.include +++ b/src/Makefile.leveldb.include @@ -4,41 +4,43 @@ LIBLEVELDB_INT = leveldb/libleveldb.a LIBMEMENV_INT = leveldb/libmemenv.a -LIBLEVELDB_SSE42_INT = leveldb/libleveldb_sse42.a EXTRA_LIBRARIES += $(LIBLEVELDB_INT) EXTRA_LIBRARIES += $(LIBMEMENV_INT) -EXTRA_LIBRARIES += $(LIBLEVELDB_SSE42_INT) -LIBLEVELDB += $(LIBLEVELDB_INT) +LIBLEVELDB += $(LIBLEVELDB_INT) $(LIBCRC32C) LIBMEMENV += $(LIBMEMENV_INT) -LIBLEVELDB_SSE42 = $(LIBLEVELDB_SSE42_INT) LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/include LEVELDB_CPPFLAGS += -I$(srcdir)/leveldb/helpers/memenv LEVELDB_CPPFLAGS_INT = LEVELDB_CPPFLAGS_INT += -I$(srcdir)/leveldb -LEVELDB_CPPFLAGS_INT += $(LEVELDB_TARGET_FLAGS) -LEVELDB_CPPFLAGS_INT += -DLEVELDB_ATOMIC_PRESENT +LEVELDB_CPPFLAGS_INT += -I$(srcdir)/crc32c/include LEVELDB_CPPFLAGS_INT += -D__STDC_LIMIT_MACROS +LEVELDB_CPPFLAGS_INT += -DHAVE_SNAPPY=0 -DHAVE_CRC32C=1 +LEVELDB_CPPFLAGS_INT += -DHAVE_FDATASYNC=@HAVE_FDATASYNC@ +LEVELDB_CPPFLAGS_INT += -DHAVE_FULLFSYNC=@HAVE_FULLFSYNC@ +LEVELDB_CPPFLAGS_INT += -DHAVE_O_CLOEXEC=@HAVE_O_CLOEXEC@ + +if WORDS_BIGENDIAN +LEVELDB_CPPFLAGS_INT += -DLEVELDB_IS_BIG_ENDIAN=1 +else +LEVELDB_CPPFLAGS_INT += -DLEVELDB_IS_BIG_ENDIAN=0 +endif if TARGET_WINDOWS -LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_WINDOWS -DWINVER=0x0500 -D__USE_MINGW_ANSI_STDIO=1 +LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_WINDOWS -D_UNICODE -DUNICODE -D__USE_MINGW_ANSI_STDIO=1 else LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_POSIX endif leveldb_libleveldb_a_CPPFLAGS = $(AM_CPPFLAGS) $(LEVELDB_CPPFLAGS_INT) $(LEVELDB_CPPFLAGS) -leveldb_libleveldb_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +leveldb_libleveldb_a_CXXFLAGS = $(filter-out -Wconditional-uninitialized -Werror=conditional-uninitialized -Wsuggest-override -Werror=suggest-override, $(AM_CXXFLAGS)) $(PIE_FLAGS) leveldb_libleveldb_a_SOURCES= -leveldb_libleveldb_a_SOURCES += leveldb/port/atomic_pointer.h -leveldb_libleveldb_a_SOURCES += leveldb/port/port_example.h -leveldb_libleveldb_a_SOURCES += leveldb/port/port_posix.h -leveldb_libleveldb_a_SOURCES += leveldb/port/win/stdint.h +leveldb_libleveldb_a_SOURCES += leveldb/port/port_stdcxx.h leveldb_libleveldb_a_SOURCES += leveldb/port/port.h -leveldb_libleveldb_a_SOURCES += leveldb/port/port_win.h leveldb_libleveldb_a_SOURCES += leveldb/port/thread_annotations.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/db.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/options.h @@ -47,6 +49,7 @@ leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/filter_policy.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/slice.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/table_builder.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/env.h +leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/export.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/c.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/iterator.h leveldb_libleveldb_a_SOURCES += leveldb/include/leveldb/cache.h @@ -78,6 +81,7 @@ leveldb_libleveldb_a_SOURCES += leveldb/table/format.h leveldb_libleveldb_a_SOURCES += leveldb/table/iterator_wrapper.h leveldb_libleveldb_a_SOURCES += leveldb/util/crc32c.h leveldb_libleveldb_a_SOURCES += leveldb/util/env_posix_test_helper.h +leveldb_libleveldb_a_SOURCES += leveldb/util/env_windows_test_helper.h leveldb_libleveldb_a_SOURCES += leveldb/util/arena.h leveldb_libleveldb_a_SOURCES += leveldb/util/random.h leveldb_libleveldb_a_SOURCES += leveldb/util/posix_logger.h @@ -87,7 +91,9 @@ leveldb_libleveldb_a_SOURCES += leveldb/util/coding.h leveldb_libleveldb_a_SOURCES += leveldb/util/testutil.h leveldb_libleveldb_a_SOURCES += leveldb/util/mutexlock.h leveldb_libleveldb_a_SOURCES += leveldb/util/logging.h +leveldb_libleveldb_a_SOURCES += leveldb/util/no_destructor.h leveldb_libleveldb_a_SOURCES += leveldb/util/testharness.h +leveldb_libleveldb_a_SOURCES += leveldb/util/windows_logger.h leveldb_libleveldb_a_SOURCES += leveldb/db/builder.cc leveldb_libleveldb_a_SOURCES += leveldb/db/c.cc @@ -120,7 +126,6 @@ leveldb_libleveldb_a_SOURCES += leveldb/util/coding.cc leveldb_libleveldb_a_SOURCES += leveldb/util/comparator.cc leveldb_libleveldb_a_SOURCES += leveldb/util/crc32c.cc leveldb_libleveldb_a_SOURCES += leveldb/util/env.cc -leveldb_libleveldb_a_SOURCES += leveldb/util/env_posix.cc leveldb_libleveldb_a_SOURCES += leveldb/util/filter_policy.cc leveldb_libleveldb_a_SOURCES += leveldb/util/hash.cc leveldb_libleveldb_a_SOURCES += leveldb/util/histogram.cc @@ -129,21 +134,12 @@ leveldb_libleveldb_a_SOURCES += leveldb/util/options.cc leveldb_libleveldb_a_SOURCES += leveldb/util/status.cc if TARGET_WINDOWS -leveldb_libleveldb_a_SOURCES += leveldb/util/env_win.cc -leveldb_libleveldb_a_SOURCES += leveldb/port/port_win.cc +leveldb_libleveldb_a_SOURCES += leveldb/util/env_windows.cc else -leveldb_libleveldb_a_SOURCES += leveldb/port/port_posix.cc +leveldb_libleveldb_a_SOURCES += leveldb/util/env_posix.cc endif leveldb_libmemenv_a_CPPFLAGS = $(leveldb_libleveldb_a_CPPFLAGS) leveldb_libmemenv_a_CXXFLAGS = $(leveldb_libleveldb_a_CXXFLAGS) leveldb_libmemenv_a_SOURCES = leveldb/helpers/memenv/memenv.cc leveldb_libmemenv_a_SOURCES += leveldb/helpers/memenv/memenv.h - -leveldb_libleveldb_sse42_a_CPPFLAGS = $(leveldb_libleveldb_a_CPPFLAGS) -leveldb_libleveldb_sse42_a_CXXFLAGS = $(leveldb_libleveldb_a_CXXFLAGS) -if ENABLE_HWCRC32 -leveldb_libleveldb_sse42_a_CPPFLAGS += -DLEVELDB_PLATFORM_POSIX_SSE -leveldb_libleveldb_sse42_a_CXXFLAGS += $(SSE42_CXXFLAGS) -endif -leveldb_libleveldb_sse42_a_SOURCES = leveldb/port/port_posix_sse.cc diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 7ec997869..f9e94a320 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -3,101 +3,21 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. bin_PROGRAMS += qt/pocketcoin-qt + +if BUILD_POCKETCOIN_GUI + bin_PROGRAMS += pocketcoin-gui +endif + EXTRA_LIBRARIES += qt/libpocketcoinqt.a # pocketcoin qt core # -QT_TS = \ - qt/locale/pocketcoin_af.ts \ - qt/locale/pocketcoin_af_ZA.ts \ - qt/locale/pocketcoin_ar.ts \ - qt/locale/pocketcoin_be_BY.ts \ - qt/locale/pocketcoin_bg_BG.ts \ - qt/locale/pocketcoin_bg.ts \ - qt/locale/pocketcoin_ca_ES.ts \ - qt/locale/pocketcoin_ca.ts \ - qt/locale/pocketcoin_ca@valencia.ts \ - qt/locale/pocketcoin_cs.ts \ - qt/locale/pocketcoin_cy.ts \ - qt/locale/pocketcoin_da.ts \ - qt/locale/pocketcoin_de.ts \ - qt/locale/pocketcoin_el_GR.ts \ - qt/locale/pocketcoin_el.ts \ - qt/locale/pocketcoin_en_GB.ts \ - qt/locale/pocketcoin_en.ts \ - qt/locale/pocketcoin_eo.ts \ - qt/locale/pocketcoin_es_AR.ts \ - qt/locale/pocketcoin_es_CL.ts \ - qt/locale/pocketcoin_es_CO.ts \ - qt/locale/pocketcoin_es_DO.ts \ - qt/locale/pocketcoin_es_ES.ts \ - qt/locale/pocketcoin_es_MX.ts \ - qt/locale/pocketcoin_es.ts \ - qt/locale/pocketcoin_es_UY.ts \ - qt/locale/pocketcoin_es_VE.ts \ - qt/locale/pocketcoin_et_EE.ts \ - qt/locale/pocketcoin_et.ts \ - qt/locale/pocketcoin_eu_ES.ts \ - qt/locale/pocketcoin_fa_IR.ts \ - qt/locale/pocketcoin_fa.ts \ - qt/locale/pocketcoin_fi.ts \ - qt/locale/pocketcoin_fr_CA.ts \ - qt/locale/pocketcoin_fr_FR.ts \ - qt/locale/pocketcoin_fr.ts \ - qt/locale/pocketcoin_gl.ts \ - qt/locale/pocketcoin_he.ts \ - qt/locale/pocketcoin_hi_IN.ts \ - qt/locale/pocketcoin_hr.ts \ - qt/locale/pocketcoin_hu.ts \ - qt/locale/pocketcoin_id_ID.ts \ - qt/locale/pocketcoin_it_IT.ts \ - qt/locale/pocketcoin_it.ts \ - qt/locale/pocketcoin_ja.ts \ - qt/locale/pocketcoin_ka.ts \ - qt/locale/pocketcoin_kk_KZ.ts \ - qt/locale/pocketcoin_ko_KR.ts \ - qt/locale/pocketcoin_ku_IQ.ts \ - qt/locale/pocketcoin_ky.ts \ - qt/locale/pocketcoin_la.ts \ - qt/locale/pocketcoin_lt.ts \ - qt/locale/pocketcoin_lv_LV.ts \ - qt/locale/pocketcoin_mk_MK.ts \ - qt/locale/pocketcoin_mn.ts \ - qt/locale/pocketcoin_ms_MY.ts \ - qt/locale/pocketcoin_nb.ts \ - qt/locale/pocketcoin_ne.ts \ - qt/locale/pocketcoin_nl.ts \ - qt/locale/pocketcoin_pam.ts \ - qt/locale/pocketcoin_pl.ts \ - qt/locale/pocketcoin_pt_BR.ts \ - qt/locale/pocketcoin_pt_PT.ts \ - qt/locale/pocketcoin_ro_RO.ts \ - qt/locale/pocketcoin_ro.ts \ - qt/locale/pocketcoin_ru_RU.ts \ - qt/locale/pocketcoin_ru.ts \ - qt/locale/pocketcoin_sk.ts \ - qt/locale/pocketcoin_sl_SI.ts \ - qt/locale/pocketcoin_sq.ts \ - qt/locale/pocketcoin_sr@latin.ts \ - qt/locale/pocketcoin_sr.ts \ - qt/locale/pocketcoin_sv.ts \ - qt/locale/pocketcoin_ta.ts \ - qt/locale/pocketcoin_th_TH.ts \ - qt/locale/pocketcoin_tr_TR.ts \ - qt/locale/pocketcoin_tr.ts \ - qt/locale/pocketcoin_uk.ts \ - qt/locale/pocketcoin_ur_PK.ts \ - qt/locale/pocketcoin_uz@Cyrl.ts \ - qt/locale/pocketcoin_vi.ts \ - qt/locale/pocketcoin_vi_VN.ts \ - qt/locale/pocketcoin_zh_CN.ts \ - qt/locale/pocketcoin_zh_HK.ts \ - qt/locale/pocketcoin_zh.ts \ - qt/locale/pocketcoin_zh_TW.ts +include Makefile.qt_locale.include QT_FORMS_UI = \ qt/forms/addressbookpage.ui \ qt/forms/askpassphrasedialog.ui \ qt/forms/coincontroldialog.ui \ + qt/forms/createwalletdialog.ui \ qt/forms/editaddressdialog.ui \ qt/forms/updatenotificationdialog.ui \ qt/forms/helpmessagedialog.ui \ @@ -106,6 +26,7 @@ QT_FORMS_UI = \ qt/forms/openuridialog.ui \ qt/forms/optionsdialog.ui \ qt/forms/overviewpage.ui \ + qt/forms/psbtoperationsdialog.ui \ qt/forms/receivecoinsdialog.ui \ qt/forms/receiverequestdialog.ui \ qt/forms/debugwindow.ui \ @@ -118,12 +39,13 @@ QT_MOC_CPP = \ qt/moc_addressbookpage.cpp \ qt/moc_addresstablemodel.cpp \ qt/moc_askpassphrasedialog.cpp \ + qt/moc_createwalletdialog.cpp \ qt/moc_bantablemodel.cpp \ qt/moc_pocketcoinaddressvalidator.cpp \ qt/moc_pocketcoinamountfield.cpp \ + qt/moc_pocketcoin.cpp \ qt/moc_pocketcoingui.cpp \ qt/moc_pocketcoinunits.cpp \ - qt/moc_callback.cpp \ qt/moc_clientmodel.cpp \ qt/moc_coincontroldialog.cpp \ qt/moc_coincontroltreewidget.cpp \ @@ -142,6 +64,8 @@ QT_MOC_CPP = \ qt/moc_overviewpage.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_paymentserver.cpp \ + qt/moc_psbtoperationsdialog.cpp \ + qt/moc_qrimagewidget.cpp \ qt/moc_qvalidatedlineedit.cpp \ qt/moc_qvaluecombobox.cpp \ qt/moc_receivecoinsdialog.cpp \ @@ -156,21 +80,22 @@ QT_MOC_CPP = \ qt/moc_transactiondesc.cpp \ qt/moc_transactiondescdialog.cpp \ qt/moc_transactionfilterproxy.cpp \ + qt/moc_transactionoverviewwidget.cpp \ qt/moc_transactiontablemodel.cpp \ qt/moc_transactionview.cpp \ qt/moc_utilitydialog.cpp \ + qt/moc_walletcontroller.cpp \ qt/moc_walletframe.cpp \ qt/moc_walletmodel.cpp \ qt/moc_walletview.cpp POCKETCOIN_MM = \ qt/macdockiconhandler.mm \ - qt/macnotificationhandler.mm + qt/macnotificationhandler.mm \ + qt/macos_appnap.mm QT_MOC = \ - qt/pocketcoin.moc \ qt/pocketcoinamountfield.moc \ - qt/callback.moc \ qt/intro.moc \ qt/overviewpage.moc \ qt/rpcconsole.moc @@ -180,10 +105,6 @@ QT_QRC = qt/pocketcoin.qrc QT_QRC_LOCALE_CPP = qt/qrc_pocketcoin_locale.cpp QT_QRC_LOCALE = qt/pocketcoin_locale.qrc -PROTOBUF_CC = qt/paymentrequest.pb.cc -PROTOBUF_H = qt/paymentrequest.pb.h -PROTOBUF_PROTO = qt/paymentrequest.proto - POCKETCOIN_QT_H = \ qt/addressbookpage.h \ qt/addresstablemodel.h \ @@ -191,12 +112,13 @@ POCKETCOIN_QT_H = \ qt/bantablemodel.h \ qt/pocketcoinaddressvalidator.h \ qt/pocketcoinamountfield.h \ + qt/pocketcoin.h \ qt/pocketcoingui.h \ qt/pocketcoinunits.h \ - qt/callback.h \ qt/clientmodel.h \ qt/coincontroldialog.h \ qt/coincontroltreewidget.h \ + qt/createwalletdialog.h \ qt/csvmodelwriter.h \ qt/editaddressdialog.h \ qt/updatenotificationdialog.h \ @@ -205,6 +127,7 @@ POCKETCOIN_QT_H = \ qt/intro.h \ qt/macdockiconhandler.h \ qt/macnotificationhandler.h \ + qt/macos_appnap.h \ qt/modaloverlay.h \ qt/networkstyle.h \ qt/notificator.h \ @@ -212,10 +135,11 @@ POCKETCOIN_QT_H = \ qt/optionsdialog.h \ qt/optionsmodel.h \ qt/overviewpage.h \ - qt/paymentrequestplus.h \ qt/paymentserver.h \ qt/peertablemodel.h \ qt/platformstyle.h \ + qt/psbtoperationsdialog.h \ + qt/qrimagewidget.h \ qt/qvalidatedlineedit.h \ qt/qvaluecombobox.h \ qt/receivecoinsdialog.h \ @@ -224,16 +148,19 @@ POCKETCOIN_QT_H = \ qt/rpcconsole.h \ qt/sendcoinsdialog.h \ qt/sendcoinsentry.h \ + qt/sendcoinsrecipient.h \ qt/signverifymessagedialog.h \ qt/splashscreen.h \ qt/trafficgraphwidget.h \ qt/transactiondesc.h \ qt/transactiondescdialog.h \ qt/transactionfilterproxy.h \ + qt/transactionoverviewwidget.h \ qt/transactionrecord.h \ qt/transactiontablemodel.h \ qt/transactionview.h \ qt/utilitydialog.h \ + qt/walletcontroller.h \ qt/walletframe.h \ qt/walletmodel.h \ qt/walletmodeltransaction.h \ @@ -243,8 +170,6 @@ POCKETCOIN_QT_H = \ RES_ICONS = \ qt/res/icons/add.png \ qt/res/icons/address-book.png \ - qt/res/icons/about.png \ - qt/res/icons/about_qt.png \ qt/res/icons/pocketcoin.ico \ qt/res/icons/pocketcoin_testnet.ico \ qt/res/icons/pocketcoin.png \ @@ -254,13 +179,11 @@ RES_ICONS = \ qt/res/icons/clock3.png \ qt/res/icons/clock4.png \ qt/res/icons/clock5.png \ - qt/res/icons/configure.png \ qt/res/icons/connect0.png \ qt/res/icons/connect1.png \ qt/res/icons/connect2.png \ qt/res/icons/connect3.png \ qt/res/icons/connect4.png \ - qt/res/icons/debugwindow.png \ qt/res/icons/edit.png \ qt/res/icons/editcopy.png \ qt/res/icons/editpaste.png \ @@ -268,21 +191,16 @@ RES_ICONS = \ qt/res/icons/eye.png \ qt/res/icons/eye_minus.png \ qt/res/icons/eye_plus.png \ - qt/res/icons/filesave.png \ qt/res/icons/fontbigger.png \ qt/res/icons/fontsmaller.png \ qt/res/icons/hd_disabled.png \ qt/res/icons/hd_enabled.png \ qt/res/icons/history.png \ - qt/res/icons/info.png \ - qt/res/icons/key.png \ qt/res/icons/lock_closed.png \ qt/res/icons/lock_open.png \ qt/res/icons/network_disabled.png \ - qt/res/icons/open.png \ qt/res/icons/overview.png \ qt/res/icons/proxy.png \ - qt/res/icons/quit.png \ qt/res/icons/receive.png \ qt/res/icons/remove.png \ qt/res/icons/send.png \ @@ -295,11 +213,11 @@ RES_ICONS = \ qt/res/icons/tx_input.png \ qt/res/icons/tx_output.png \ qt/res/icons/tx_mined.png \ - qt/res/icons/warning.png \ - qt/res/icons/verify.png + qt/res/icons/warning.png POCKETCOIN_QT_BASE_CPP = \ qt/bantablemodel.cpp \ + qt/pocketcoin.cpp \ qt/pocketcoinaddressvalidator.cpp \ qt/pocketcoinamountfield.cpp \ qt/pocketcoingui.cpp \ @@ -330,12 +248,14 @@ POCKETCOIN_QT_WALLET_CPP = \ qt/askpassphrasedialog.cpp \ qt/coincontroldialog.cpp \ qt/coincontroltreewidget.cpp \ + qt/createwalletdialog.cpp \ qt/editaddressdialog.cpp \ qt/updatenotificationdialog.cpp \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ - qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ + qt/psbtoperationsdialog.cpp \ + qt/qrimagewidget.cpp \ qt/receivecoinsdialog.cpp \ qt/receiverequestdialog.cpp \ qt/recentrequeststablemodel.cpp \ @@ -348,6 +268,7 @@ POCKETCOIN_QT_WALLET_CPP = \ qt/transactionrecord.cpp \ qt/transactiontablemodel.cpp \ qt/transactionview.cpp \ + qt/walletcontroller.cpp \ qt/walletframe.cpp \ qt/walletmodel.cpp \ qt/walletmodeltransaction.cpp \ @@ -359,26 +280,26 @@ POCKETCOIN_QT_CPP += $(POCKETCOIN_QT_WINDOWS_CPP) endif if ENABLE_WALLET POCKETCOIN_QT_CPP += $(POCKETCOIN_QT_WALLET_CPP) -endif - -RES_IMAGES = +endif # ENABLE_WALLET -RES_MOVIES = $(wildcard $(srcdir)/qt/res/movies/spinner-*.png) +RES_ANIMATION = $(wildcard $(srcdir)/qt/res/animation/spinner-*.png) POCKETCOIN_RC = qt/res/pocketcoin-qt-res.rc POCKETCOIN_QT_INCLUDES = -DQT_NO_KEYWORDS qt_libpocketcoinqt_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(POCKETCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(QT_DBUS_INCLUDES) $(PROTOBUF_CFLAGS) $(QR_CFLAGS) + $(QT_INCLUDES) $(QT_DBUS_INCLUDES) $(QR_CFLAGS) qt_libpocketcoinqt_a_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) qt_libpocketcoinqt_a_OBJCXXFLAGS = $(AM_OBJCXXFLAGS) $(QT_PIE_FLAGS) qt_libpocketcoinqt_a_SOURCES = $(POCKETCOIN_QT_CPP) $(POCKETCOIN_QT_H) $(QT_FORMS_UI) \ - $(QT_QRC) $(QT_QRC_LOCALE) $(QT_TS) $(PROTOBUF_PROTO) $(RES_ICONS) $(RES_IMAGES) $(RES_MOVIES) + $(QT_QRC) $(QT_QRC_LOCALE) $(QT_TS) $(RES_ICONS) $(RES_ANIMATION) +if TARGET_DARWIN + qt_libpocketcoinqt_a_SOURCES += $(POCKETCOIN_MM) +endif -nodist_qt_libpocketcoinqt_a_SOURCES = $(QT_MOC_CPP) $(QT_MOC) $(PROTOBUF_CC) \ - $(PROTOBUF_H) $(QT_QRC_CPP) $(QT_QRC_LOCALE_CPP) +nodist_qt_libpocketcoinqt_a_SOURCES = $(QT_MOC_CPP) $(QT_MOC) $(QT_QRC_CPP) $(QT_QRC_LOCALE_CPP) # forms/foo.h -> forms/ui_foo.h QT_FORMS_H=$(join $(dir $(QT_FORMS_UI)),$(addprefix ui_, $(notdir $(QT_FORMS_UI:.ui=.h)))) @@ -386,46 +307,52 @@ QT_FORMS_H=$(join $(dir $(QT_FORMS_UI)),$(addprefix ui_, $(notdir $(QT_FORMS_UI: # Most files will depend on the forms and moc files as includes. Generate them # before anything else. $(QT_MOC): $(QT_FORMS_H) -$(qt_libpocketcoinqt_a_OBJECTS) $(qt_pocketcoin_qt_OBJECTS) : | $(QT_MOC) - -#Generating these with a half-written protobuf header leads to wacky results. -#This makes sure it's done. -$(QT_MOC): $(PROTOBUF_H) -$(QT_MOC_CPP): $(PROTOBUF_H) +$(qt_libpocketcoinqt_a_OBJECTS) $(qt_pocketcoin_qt_OBJECTS) $(pocketcoin_gui_OBJECTS) : | $(QT_MOC) -# pocketcoin-qt binary # -qt_pocketcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(POCKETCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(PROTOBUF_CFLAGS) $(QR_CFLAGS) -qt_pocketcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) +# pocketcoin-qt and pocketcoin-gui binaries # +pocketcoin_qt_cppflags = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(POCKETCOIN_QT_INCLUDES) \ + $(QT_INCLUDES) $(QR_CFLAGS) +pocketcoin_qt_cxxflags = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) -qt_pocketcoin_qt_SOURCES = qt/pocketcoin.cpp -if TARGET_DARWIN - qt_pocketcoin_qt_SOURCES += $(POCKETCOIN_MM) -endif +pocketcoin_qt_sources = qt/main.cpp if TARGET_WINDOWS - qt_pocketcoin_qt_SOURCES += $(POCKETCOIN_RC) + pocketcoin_qt_sources += $(POCKETCOIN_RC) endif -qt_pocketcoin_qt_LDADD = qt/libpocketcoinqt.a $(LIBPOCKETCOIN_SERVER) +pocketcoin_qt_ldadd = qt/libpocketcoinqt.a $(LIBPOCKETCOIN_SERVER) if ENABLE_WALLET -qt_pocketcoin_qt_LDADD += $(LIBPOCKETCOIN_UTIL) $(LIBPOCKETCOIN_WALLET) +pocketcoin_qt_ldadd += $(LIBPOCKETCOIN_UTIL) $(LIBPOCKETCOIN_WALLET) endif if ENABLE_ZMQ -qt_pocketcoin_qt_LDADD += $(LIBPOCKETCOIN_ZMQ) $(ZMQ_LIBS) +pocketcoin_qt_ldadd += $(LIBPOCKETCOIN_ZMQ) $(ZMQ_LIBS) endif -qt_pocketcoin_qt_LDADD += $(LIBPOCKETCOIN_CLI) $(LIBPOCKETCOIN_COMMON) $(LIBPOCKETCOIN_UTIL) $(LIBPOCKETCOIN_CONSENSUS) $(LIBPOCKETCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \ - $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBSQLITE3) -qt_pocketcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -qt_pocketcoin_qt_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag CXX +pocketcoin_qt_ldadd += $(LIBPOCKETCOIN_CLI) $(LIBPOCKETCOIN_COMMON) $(LIBPOCKETCOIN_UTIL) $(LIBPOCKETCOIN_CONSENSUS) $(LIBPOCKETCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \ + $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBSQLITE3) $(CRYPTO_LIBS) $(SSL_LIBS) +pocketcoin_qt_ldflags = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) +pocketcoin_qt_libtoolflags = $(AM_LIBTOOLFLAGS) --tag CXX + +qt_pocketcoin_qt_CPPFLAGS = $(pocketcoin_qt_cppflags) +qt_pocketcoin_qt_CXXFLAGS = $(pocketcoin_qt_cxxflags) +qt_pocketcoin_qt_SOURCES = $(pocketcoin_qt_sources) +qt_pocketcoin_qt_LDADD = $(pocketcoin_qt_ldadd) +qt_pocketcoin_qt_LDFLAGS = $(pocketcoin_qt_ldflags) +qt_pocketcoin_qt_LIBTOOLFLAGS = $(pocketcoin_qt_libtoolflags) + +pocketcoin_gui_CPPFLAGS = $(pocketcoin_qt_cppflags) +pocketcoin_gui_CXXFLAGS = $(pocketcoin_qt_cxxflags) +pocketcoin_gui_SOURCES = $(pocketcoin_qt_sources) +pocketcoin_gui_LDADD = $(pocketcoin_qt_ldadd) +pocketcoin_gui_LDFLAGS = $(pocketcoin_qt_ldflags) +pocketcoin_gui_LIBTOOLFLAGS = $(pocketcoin_qt_libtoolflags) #locale/foo.ts -> locale/foo.qm QT_QM=$(QT_TS:.ts=.qm) SECONDARY: $(QT_QM) -$(srcdir)/qt/pocketcoinstrings.cpp: $(libpocketcoin_server_a_SOURCES) $(libpocketcoin_wallet_a_SOURCES) $(libpocketcoin_common_a_SOURCES) $(libpocketcoin_zmq_a_SOURCES) $(libpocketcoin_consensus_a_SOURCES) $(libpocketcoin_util_a_SOURCES) +$(srcdir)/qt/pocketcoinstrings.cpp: FORCE @test -n $(XGETTEXT) || echo "xgettext is required for updating translations" - $(AM_V_GEN) cd $(srcdir); XGETTEXT=$(XGETTEXT) PACKAGE_NAME="$(PACKAGE_NAME)" COPYRIGHT_HOLDERS="$(COPYRIGHT_HOLDERS)" COPYRIGHT_HOLDERS_SUBSTITUTION="$(COPYRIGHT_HOLDERS_SUBSTITUTION)" $(PYTHON) ../share/qt/extract_strings_qt.py $^ + $(AM_V_GEN) cd $(srcdir); XGETTEXT=$(XGETTEXT) COPYRIGHT_HOLDERS="$(COPYRIGHT_HOLDERS)" $(PYTHON) ../share/qt/extract_strings_qt.py $(libpocketcoin_server_a_SOURCES) $(libpocketcoin_wallet_a_SOURCES) $(libpocketcoin_common_a_SOURCES) $(libpocketcoin_zmq_a_SOURCES) $(libpocketcoin_consensus_a_SOURCES) $(libpocketcoin_util_a_SOURCES) translate: $(srcdir)/qt/pocketcoinstrings.cpp $(QT_FORMS_UI) $(QT_FORMS_UI) $(POCKETCOIN_QT_BASE_CPP) qt/pocketcoin.cpp $(POCKETCOIN_QT_WINDOWS_CPP) $(POCKETCOIN_QT_WALLET_CPP) $(POCKETCOIN_QT_H) $(POCKETCOIN_MM) @test -n $(LUPDATE) || echo "lupdate is required for updating translations" @@ -438,7 +365,7 @@ $(QT_QRC_LOCALE_CPP): $(QT_QRC_LOCALE) $(QT_QM) $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ @rm $(@D)/temp_$( $@ @@ -458,11 +385,11 @@ ui_%.h: %.ui $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(UIC) -o $@ $< || (echo "Error creating $@"; false) %.moc: %.cpp - $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(MOC) $(DEFAULT_INCLUDES) $(QT_INCLUDES) $(MOC_DEFS) $< | \ + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(MOC) $(DEFAULT_INCLUDES) $(QT_INCLUDES_UNSUPPRESSED) $(MOC_DEFS) $< | \ $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ moc_%.cpp: %.h - $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(MOC) $(DEFAULT_INCLUDES) $(QT_INCLUDES) $(MOC_DEFS) $< | \ + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(MOC) $(DEFAULT_INCLUDES) $(QT_INCLUDES_UNSUPPRESSED) $(MOC_DEFS) $< | \ $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ %.qm: %.ts diff --git a/src/Makefile.qt_locale.include b/src/Makefile.qt_locale.include new file mode 100644 index 000000000..c29f995e2 --- /dev/null +++ b/src/Makefile.qt_locale.include @@ -0,0 +1,94 @@ +QT_TS = \ + qt/locale/pocketcoin_af.ts \ + qt/locale/pocketcoin_am.ts \ + qt/locale/pocketcoin_ar.ts \ + qt/locale/pocketcoin_az.ts \ + qt/locale/pocketcoin_be.ts \ + qt/locale/pocketcoin_bg.ts \ + qt/locale/pocketcoin_bn.ts \ + qt/locale/pocketcoin_bs.ts \ + qt/locale/pocketcoin_ca.ts \ + qt/locale/pocketcoin_cs.ts \ + qt/locale/pocketcoin_cy.ts \ + qt/locale/pocketcoin_da.ts \ + qt/locale/pocketcoin_de.ts \ + qt/locale/pocketcoin_el.ts \ + qt/locale/pocketcoin_en.ts \ + qt/locale/pocketcoin_en_GB.ts \ + qt/locale/pocketcoin_eo.ts \ + qt/locale/pocketcoin_es.ts \ + qt/locale/pocketcoin_es_CL.ts \ + qt/locale/pocketcoin_es_CO.ts \ + qt/locale/pocketcoin_es_DO.ts \ + qt/locale/pocketcoin_es_MX.ts \ + qt/locale/pocketcoin_es_VE.ts \ + qt/locale/pocketcoin_et.ts \ + qt/locale/pocketcoin_eu.ts \ + qt/locale/pocketcoin_fa.ts \ + qt/locale/pocketcoin_fi.ts \ + qt/locale/pocketcoin_fil.ts \ + qt/locale/pocketcoin_fr.ts \ + qt/locale/pocketcoin_ga.ts \ + qt/locale/pocketcoin_gl.ts \ + qt/locale/pocketcoin_gl_ES.ts \ + qt/locale/pocketcoin_gu.ts \ + qt/locale/pocketcoin_he.ts \ + qt/locale/pocketcoin_hi.ts \ + qt/locale/pocketcoin_hr.ts \ + qt/locale/pocketcoin_hu.ts \ + qt/locale/pocketcoin_id.ts \ + qt/locale/pocketcoin_is.ts \ + qt/locale/pocketcoin_it.ts \ + qt/locale/pocketcoin_ja.ts \ + qt/locale/pocketcoin_ka.ts \ + qt/locale/pocketcoin_kk.ts \ + qt/locale/pocketcoin_kl.ts \ + qt/locale/pocketcoin_km.ts \ + qt/locale/pocketcoin_ko.ts \ + qt/locale/pocketcoin_ku_IQ.ts \ + qt/locale/pocketcoin_ky.ts \ + qt/locale/pocketcoin_la.ts \ + qt/locale/pocketcoin_lt.ts \ + qt/locale/pocketcoin_lv.ts \ + qt/locale/pocketcoin_mk.ts \ + qt/locale/pocketcoin_ml.ts \ + qt/locale/pocketcoin_mn.ts \ + qt/locale/pocketcoin_mr_IN.ts \ + qt/locale/pocketcoin_ms.ts \ + qt/locale/pocketcoin_my.ts \ + qt/locale/pocketcoin_nb.ts \ + qt/locale/pocketcoin_ne.ts \ + qt/locale/pocketcoin_nl.ts \ + qt/locale/pocketcoin_no.ts \ + qt/locale/pocketcoin_pam.ts \ + qt/locale/pocketcoin_pl.ts \ + qt/locale/pocketcoin_pt.ts \ + qt/locale/pocketcoin_pt_BR.ts \ + qt/locale/pocketcoin_ro.ts \ + qt/locale/pocketcoin_ru.ts \ + qt/locale/pocketcoin_si.ts \ + qt/locale/pocketcoin_sk.ts \ + qt/locale/pocketcoin_sl.ts \ + qt/locale/pocketcoin_sn.ts \ + qt/locale/pocketcoin_sq.ts \ + qt/locale/pocketcoin_sr.ts \ + qt/locale/pocketcoin_sr@latin.ts \ + qt/locale/pocketcoin_sv.ts \ + qt/locale/pocketcoin_szl.ts \ + qt/locale/pocketcoin_ta.ts \ + qt/locale/pocketcoin_te.ts \ + qt/locale/pocketcoin_th.ts \ + qt/locale/pocketcoin_tr.ts \ + qt/locale/pocketcoin_ug.ts \ + qt/locale/pocketcoin_uk.ts \ + qt/locale/pocketcoin_ur.ts \ + qt/locale/pocketcoin_uz@Cyrl.ts \ + qt/locale/pocketcoin_uz@Latn.ts \ + qt/locale/pocketcoin_vi.ts \ + qt/locale/pocketcoin_yo.ts \ + qt/locale/pocketcoin_zh-Hans.ts \ + qt/locale/pocketcoin_zh.ts \ + qt/locale/pocketcoin_zh_CN.ts \ + qt/locale/pocketcoin_zh_HK.ts \ + qt/locale/pocketcoin_zh_TW.ts \ + qt/locale/pocketcoin_zu.ts diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index d50187ac8..702dd5563 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -6,6 +6,7 @@ bin_PROGRAMS += qt/test/test_pocketcoin-qt TESTS += qt/test/test_pocketcoin-qt TEST_QT_MOC_CPP = \ + qt/test/moc_apptests.cpp \ qt/test/moc_compattests.cpp \ qt/test/moc_rpcnestedtests.cpp \ qt/test/moc_uritests.cpp @@ -13,49 +14,39 @@ TEST_QT_MOC_CPP = \ if ENABLE_WALLET TEST_QT_MOC_CPP += \ qt/test/moc_addressbooktests.cpp \ - qt/test/moc_paymentservertests.cpp \ qt/test/moc_wallettests.cpp -endif +endif # ENABLE_WALLET TEST_QT_H = \ qt/test/addressbooktests.h \ + qt/test/apptests.h \ qt/test/compattests.h \ qt/test/rpcnestedtests.h \ qt/test/uritests.h \ qt/test/util.h \ - qt/test/paymentrequestdata.h \ - qt/test/paymentservertests.h \ qt/test/wallettests.h -TEST_POCKETCOIN_CPP = \ - test/test_pocketcoin.cpp - -TEST_POCKETCOIN_H = \ - test/test_pocketcoin.h - qt_test_test_pocketcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(POCKETCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(PROTOBUF_CFLAGS) + $(QT_INCLUDES) $(QT_TEST_INCLUDES) qt_test_test_pocketcoin_qt_SOURCES = \ + qt/test/apptests.cpp \ qt/test/compattests.cpp \ qt/test/rpcnestedtests.cpp \ qt/test/test_main.cpp \ qt/test/uritests.cpp \ qt/test/util.cpp \ - $(TEST_QT_H) \ - $(TEST_POCKETCOIN_CPP) \ - $(TEST_POCKETCOIN_H) + $(TEST_QT_H) if ENABLE_WALLET qt_test_test_pocketcoin_qt_SOURCES += \ qt/test/addressbooktests.cpp \ - qt/test/paymentservertests.cpp \ qt/test/wallettests.cpp \ wallet/test/wallet_test_fixture.cpp -endif +endif # ENABLE_WALLET nodist_qt_test_test_pocketcoin_qt_SOURCES = $(TEST_QT_MOC_CPP) -qt_test_test_pocketcoin_qt_LDADD = $(LIBPOCKETCOINQT) $(LIBPOCKETCOIN_SERVER) +qt_test_test_pocketcoin_qt_LDADD = $(LIBPOCKETCOINQT) $(LIBPOCKETCOIN_SERVER) $(LIBTEST_UTIL) if ENABLE_WALLET qt_test_test_pocketcoin_qt_LDADD += $(LIBPOCKETCOIN_UTIL) $(LIBPOCKETCOIN_WALLET) endif @@ -64,9 +55,9 @@ qt_test_test_pocketcoin_qt_LDADD += $(LIBPOCKETCOIN_ZMQ) $(ZMQ_LIBS) endif qt_test_test_pocketcoin_qt_LDADD += $(LIBPOCKETCOIN_CLI) $(LIBPOCKETCOIN_COMMON) $(LIBPOCKETCOIN_UTIL) $(LIBPOCKETCOIN_CONSENSUS) $(LIBPOCKETCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \ $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ - $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) -qt_test_test_pocketcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) + $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBSQLITE3) +qt_test_test_pocketcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qt_test_test_pocketcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) CLEAN_POCKETCOIN_QT_TEST = $(TEST_QT_MOC_CPP) qt/test/*.gcda qt/test/*.gcno diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 5bc40bcd2..eaa5f0191 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -2,8 +2,170 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +FUZZ_TARGETS = \ + test/fuzz/addition_overflow \ + test/fuzz/addr_info_deserialize \ + test/fuzz/addrdb \ + test/fuzz/address_deserialize \ + test/fuzz/addrman \ + test/fuzz/addrman_deserialize \ + test/fuzz/asmap \ + test/fuzz/asmap_direct \ + test/fuzz/autofile \ + test/fuzz/banentry_deserialize \ + test/fuzz/banman \ + test/fuzz/base_encode_decode \ + test/fuzz/bech32 \ + test/fuzz/block \ + test/fuzz/block_deserialize \ + test/fuzz/block_file_info_deserialize \ + test/fuzz/block_filter_deserialize \ + test/fuzz/block_header \ + test/fuzz/block_header_and_short_txids_deserialize \ + test/fuzz/blockfilter \ + test/fuzz/blockheader_deserialize \ + test/fuzz/blocklocator_deserialize \ + test/fuzz/blockmerkleroot \ + test/fuzz/blocktransactions_deserialize \ + test/fuzz/blocktransactionsrequest_deserialize \ + test/fuzz/blockundo_deserialize \ + test/fuzz/bloom_filter \ + test/fuzz/bloomfilter_deserialize \ + test/fuzz/buffered_file \ + test/fuzz/chain \ + test/fuzz/checkqueue \ + test/fuzz/coins_deserialize \ + test/fuzz/coins_view \ + test/fuzz/connman \ + test/fuzz/crypto \ + test/fuzz/crypto_aes256 \ + test/fuzz/crypto_aes256cbc \ + test/fuzz/crypto_chacha20 \ + test/fuzz/crypto_chacha20_poly1305_aead \ + test/fuzz/crypto_common \ + test/fuzz/crypto_hkdf_hmac_sha256_l32 \ + test/fuzz/crypto_poly1305 \ + test/fuzz/cuckoocache \ + test/fuzz/decode_tx \ + test/fuzz/descriptor_parse \ + test/fuzz/diskblockindex_deserialize \ + test/fuzz/eval_script \ + test/fuzz/fee_rate \ + test/fuzz/fee_rate_deserialize \ + test/fuzz/fees \ + test/fuzz/flat_file_pos_deserialize \ + test/fuzz/flatfile \ + test/fuzz/float \ + test/fuzz/golomb_rice \ + test/fuzz/hex \ + test/fuzz/http_request \ + test/fuzz/integer \ + test/fuzz/inv_deserialize \ + test/fuzz/key \ + test/fuzz/key_io \ + test/fuzz/key_origin_info_deserialize \ + test/fuzz/kitchen_sink \ + test/fuzz/load_external_block_file \ + test/fuzz/locale \ + test/fuzz/merkle_block_deserialize \ + test/fuzz/merkleblock \ + test/fuzz/message \ + test/fuzz/messageheader_deserialize \ + test/fuzz/multiplication_overflow \ + test/fuzz/net \ + test/fuzz/net_permissions \ + test/fuzz/netaddr_deserialize \ + test/fuzz/netaddress \ + test/fuzz/out_point_deserialize \ + test/fuzz/p2p_transport_deserializer \ + test/fuzz/parse_hd_keypath \ + test/fuzz/parse_iso8601 \ + test/fuzz/parse_numbers \ + test/fuzz/parse_script \ + test/fuzz/parse_univalue \ + test/fuzz/partial_merkle_tree_deserialize \ + test/fuzz/partially_signed_transaction_deserialize \ + test/fuzz/policy_estimator \ + test/fuzz/policy_estimator_io \ + test/fuzz/pow \ + test/fuzz/prefilled_transaction_deserialize \ + test/fuzz/prevector \ + test/fuzz/primitives_transaction \ + test/fuzz/process_message \ + test/fuzz/process_message_addr \ + test/fuzz/process_message_block \ + test/fuzz/process_message_blocktxn \ + test/fuzz/process_message_cmpctblock \ + test/fuzz/process_message_feefilter \ + test/fuzz/process_message_filteradd \ + test/fuzz/process_message_filterclear \ + test/fuzz/process_message_filterload \ + test/fuzz/process_message_getaddr \ + test/fuzz/process_message_getblocks \ + test/fuzz/process_message_getblocktxn \ + test/fuzz/process_message_getdata \ + test/fuzz/process_message_getheaders \ + test/fuzz/process_message_headers \ + test/fuzz/process_message_inv \ + test/fuzz/process_message_mempool \ + test/fuzz/process_message_notfound \ + test/fuzz/process_message_ping \ + test/fuzz/process_message_pong \ + test/fuzz/process_message_sendcmpct \ + test/fuzz/process_message_sendheaders \ + test/fuzz/process_message_tx \ + test/fuzz/process_message_verack \ + test/fuzz/process_message_version \ + test/fuzz/process_messages \ + test/fuzz/protocol \ + test/fuzz/psbt \ + test/fuzz/psbt_input_deserialize \ + test/fuzz/psbt_output_deserialize \ + test/fuzz/pub_key_deserialize \ + test/fuzz/random \ + test/fuzz/rbf \ + test/fuzz/rolling_bloom_filter \ + test/fuzz/script \ + test/fuzz/script_pocketcoin_consensus \ + test/fuzz/script_descriptor_cache \ + test/fuzz/script_deserialize \ + test/fuzz/script_flags \ + test/fuzz/script_interpreter \ + test/fuzz/script_assets_test_minimizer \ + test/fuzz/script_ops \ + test/fuzz/script_sigcache \ + test/fuzz/script_sign \ + test/fuzz/scriptnum_ops \ + test/fuzz/secp256k1_ec_seckey_import_export_der \ + test/fuzz/secp256k1_ecdsa_signature_parse_der_lax \ + test/fuzz/service_deserialize \ + test/fuzz/signature_checker \ + test/fuzz/signet \ + test/fuzz/snapshotmetadata_deserialize \ + test/fuzz/span \ + test/fuzz/spanparsing \ + test/fuzz/string \ + test/fuzz/strprintf \ + test/fuzz/sub_net_deserialize \ + test/fuzz/system \ + test/fuzz/timedata \ + test/fuzz/transaction \ + test/fuzz/tx_in \ + test/fuzz/tx_in_deserialize \ + test/fuzz/tx_out \ + test/fuzz/txoutcompressor_deserialize \ + test/fuzz/txrequest \ + test/fuzz/txundo_deserialize \ + test/fuzz/uint160_deserialize \ + test/fuzz/uint256_deserialize \ + test/fuzz/versionbits + +if ENABLE_FUZZ +noinst_PROGRAMS += $(FUZZ_TARGETS:=) +else bin_PROGRAMS += test/test_pocketcoin -noinst_PROGRAMS += test/test_pocketcoin_fuzzy +endif + TEST_SRCDIR = test TEST_BINARY=test/test_pocketcoin$(EXEEXT) @@ -18,13 +180,32 @@ JSON_TEST_FILES = \ test/data/tx_invalid.json \ test/data/tx_valid.json -RAW_TEST_FILES = +RAW_TEST_FILES = \ + test/data/asmap.raw GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h) POCKETCOIN_TEST_SUITE = \ test/main.cpp \ - test/test_pocketcoin.cpp + $(TEST_UTIL_H) + +FUZZ_SUITE_LD_COMMON = \ + $(LIBPOCKETCOIN_SERVER) \ + $(LIBPOCKETCOIN_COMMON) \ + $(LIBPOCKETCOIN_UTIL) \ + $(LIBTEST_UTIL) \ + $(LIBTEST_FUZZ) \ + $(LIBPOCKETCOIN_CONSENSUS) \ + $(LIBPOCKETCOIN_CRYPTO) \ + $(LIBPOCKETCOIN_CLI) \ + $(LIBUNIVALUE) \ + $(LIBLEVELDB) \ + $(LIBLEVELDB_SSE42) \ + $(BOOST_LIBS) \ + $(LIBMEMENV) \ + $(LIBSECP256K1) \ + $(EVENT_LIBS) \ + $(EVENT_PTHREADS_LIBS) # test_pocketcoin binary # # Disabled tests: @@ -34,18 +215,22 @@ POCKETCOIN_TEST_SUITE = \ # test/key_io_tests.cpp # test/key_tests.cpp # test/main_tests.cpp -# test/mempool_tests.cpp # test/merkle_tests.cpp # test/merkleblock_tests.cpp # test/miner_tests.cpp # test/pow_tests.cpp -# test/prevector_tests.cppj +# test/prevector_tests.cpp # test/rpc_tests.cpp # test/sighash_tests.cpp # test/txindex_tests.cpp -# test/txvalidation_tests.cpp -# test/validation_block_tests.cpp +# test/txrequest_tests.cpp \ +# test/validation_block_tests.cpp \ +# test/validation_chainstate_tests.cpp \ +# test/validation_chainstatemanager_tests.cpp \ +# test/validation_flush_tests.cpp \ +# test/validationinterface_tests.cpp \ # test/versionbits_tests.cpp +# test/validation_block_tests.cpp # Intermittant failure in validation_block_tests POCKETCOIN_TESTS =\ @@ -62,65 +247,78 @@ POCKETCOIN_TESTS =\ test/blockchain_tests.cpp \ test/blockencodings_tests.cpp \ test/blockfilter_tests.cpp \ + test/blockfilter_index_tests.cpp \ test/bloom_tests.cpp \ test/bswap_tests.cpp \ test/checkqueue_tests.cpp \ test/coins_tests.cpp \ + test/compilerbug_tests.cpp \ test/compress_tests.cpp \ test/crypto_tests.cpp \ test/cuckoocache_tests.cpp \ + test/flatfile_tests.cpp \ + test/fs_tests.cpp \ test/getarg_tests.cpp \ - test/limitedmap_tests.cpp \ + test/interfaces_tests.cpp \ + test/logging_tests.cpp \ test/dbwrapper_tests.cpp \ + test/validation_tests.cpp \ + test/mempool_tests.cpp \ test/multisig_tests.cpp \ test/net_tests.cpp \ test/netbase_tests.cpp \ + test/pocketnet_block_tests.cpp \ + test/pocketnet_social_tests.cpp \ test/pmt_tests.cpp \ + test/policy_fee_tests.cpp \ test/policyestimator_tests.cpp \ test/raii_event_tests.cpp \ test/random_tests.cpp \ + test/ref_tests.cpp \ test/reverselock_tests.cpp \ test/sanity_tests.cpp \ test/scheduler_tests.cpp \ test/script_p2sh_tests.cpp \ - test/script_standard_tests.cpp \ test/script_tests.cpp \ + test/script_standard_tests.cpp \ test/scriptnum_tests.cpp \ test/serialize_tests.cpp \ + test/settings_tests.cpp \ test/sigopcount_tests.cpp \ test/skiplist_tests.cpp \ test/streams_tests.cpp \ test/sync_tests.cpp \ + test/system_tests.cpp \ + test/util_threadnames_tests.cpp \ test/timedata_tests.cpp \ test/torcontrol_tests.cpp \ test/transaction_tests.cpp \ + test/txvalidation_tests.cpp \ + test/txvalidationcache_tests.cpp \ test/uint256_tests.cpp \ test/util_tests.cpp -if ENABLE_PROPERTY_TESTS -POCKETCOIN_TESTS += \ - test/key_properties.cpp - -POCKETCOIN_TEST_SUITE += \ - test/gen/crypto_gen.cpp \ - test/gen/crypto_gen.h -endif - if ENABLE_WALLET -# POCKETCOIN_TESTS += \ -# wallet/test/psbt_wallet_tests.cpp \ -# wallet/test/wallet_tests.cpp \ -# wallet/test/wallet_crypto_tests.cpp \ -# wallet/test/coinselector_tests.cpp +POCKETCOIN_TESTS += \ + wallet/test/db_tests.cpp \ + wallet/test/psbt_wallet_tests.cpp \ + wallet/test/wallet_tests.cpp \ + wallet/test/wallet_crypto_tests.cpp \ + wallet/test/coinselector_tests.cpp \ + wallet/test/init_tests.cpp \ + wallet/test/ismine_tests.cpp \ + wallet/test/scriptpubkeyman_tests.cpp POCKETCOIN_TEST_SUITE += \ wallet/test/wallet_test_fixture.cpp \ - wallet/test/wallet_test_fixture.h + wallet/test/wallet_test_fixture.h \ + wallet/test/init_test_fixture.cpp \ + wallet/test/init_test_fixture.h endif test_test_pocketcoin_SOURCES = $(POCKETCOIN_TEST_SUITE) $(POCKETCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES) test_test_pocketcoin_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(TESTDEFS) $(EVENT_CFLAGS) -test_test_pocketcoin_LDADD = +test_test_pocketcoin_LDADD = $(LIBTEST_UTIL) if ENABLE_WALLET test_test_pocketcoin_LDADD += $(LIBPOCKETCOIN_WALLET) endif @@ -133,7 +331,6 @@ test_test_pocketcoin_LDADD += \ $(LIBPOCKETCOIN_CONSENSUS) \ $(LIBPOCKETCOIN_CRYPTO) \ $(LIBPOCKETCOIN_WALLET) \ - $(LIBPOCKETCOIN_ZMQ) \ $(LIBUNIVALUE) \ $(LIBLEVELDB) \ $(LIBLEVELDB_SSE42) \ @@ -147,45 +344,972 @@ test_test_pocketcoin_LDADD += \ test_test_pocketcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_pocketcoin_LDADD += $(LIBPOCKETCOIN_CONSENSUS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(RAPIDCHECK_LIBS) -test_test_pocketcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static +test_test_pocketcoin_LDADD += $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) +test_test_pocketcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) -static if ENABLE_ZMQ -test_test_pocketcoin_LDADD += $(ZMQ_LIBS) +test_test_pocketcoin_LDADD += $(LIBPOCKETCOIN_ZMQ) $(ZMQ_LIBS) endif -# -# test_pocketcoin_fuzzy binary # -test_test_pocketcoin_fuzzy_SOURCES = test/test_pocketcoin_fuzzy.cpp -test_test_pocketcoin_fuzzy_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -test_test_pocketcoin_fuzzy_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_pocketcoin_fuzzy_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +if ENABLE_FUZZ -test_test_pocketcoin_fuzzy_LDADD = \ - $(LIBUNIVALUE) \ - $(LIBPOCKETCOIN_SERVER) \ - $(LIBPOCKETCOIN_COMMON) \ - $(LIBPOCKETCOIN_UTIL) \ - $(LIBPOCKETCOIN_CONSENSUS) \ - $(LIBPOCKETCOIN_CRYPTO) \ - $(LIBPOCKETCOIN_CRYPTO_SSE41) \ - $(LIBPOCKETCOIN_CRYPTO_AVX2) \ - $(LIBPOCKETCOIN_CRYPTO_SHANI) \ - $(LIBSECP256K1) \ - $(LIBSQLITE3) +FUZZ_SUITE_LDFLAGS_COMMON = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) + +test_fuzz_addition_overflow_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_addition_overflow_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_addition_overflow_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_addition_overflow_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_addition_overflow_SOURCES = test/fuzz/addition_overflow.cpp + +test_fuzz_addr_info_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DADDR_INFO_DESERIALIZE=1 +test_fuzz_addr_info_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_addr_info_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_addr_info_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_addr_info_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_addrdb_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_addrdb_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_addrdb_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_addrdb_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_addrdb_SOURCES = test/fuzz/addrdb.cpp + +test_fuzz_address_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DADDRESS_DESERIALIZE=1 +test_fuzz_address_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_address_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_address_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_address_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_addrman_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_addrman_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_addrman_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_addrman_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_addrman_SOURCES = test/fuzz/addrman.cpp + +test_fuzz_addrman_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DADDRMAN_DESERIALIZE=1 +test_fuzz_addrman_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_addrman_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_addrman_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_addrman_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_asmap_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_asmap_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_asmap_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_asmap_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_asmap_SOURCES = test/fuzz/asmap.cpp + +test_fuzz_asmap_direct_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_asmap_direct_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_asmap_direct_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_asmap_direct_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_asmap_direct_SOURCES = test/fuzz/asmap_direct.cpp + +test_fuzz_autofile_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_autofile_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_autofile_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_autofile_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_autofile_SOURCES = test/fuzz/autofile.cpp + +test_fuzz_banentry_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBANENTRY_DESERIALIZE=1 +test_fuzz_banentry_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_banentry_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_banentry_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_banentry_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_banman_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_banman_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_banman_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_banman_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_banman_SOURCES = test/fuzz/banman.cpp + +test_fuzz_base_encode_decode_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_base_encode_decode_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_base_encode_decode_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_base_encode_decode_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_base_encode_decode_SOURCES = test/fuzz/base_encode_decode.cpp + +test_fuzz_bech32_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_bech32_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_bech32_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_bech32_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_bech32_SOURCES = test/fuzz/bech32.cpp + +test_fuzz_block_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_block_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_block_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_block_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_block_SOURCES = test/fuzz/block.cpp + +test_fuzz_block_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCK_DESERIALIZE=1 +test_fuzz_block_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_block_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_block_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_block_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_block_file_info_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCK_FILE_INFO_DESERIALIZE=1 +test_fuzz_block_file_info_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_block_file_info_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_block_file_info_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_block_file_info_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_block_filter_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCK_FILTER_DESERIALIZE=1 +test_fuzz_block_filter_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_block_filter_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_block_filter_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_block_filter_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_block_header_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_block_header_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_block_header_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_block_header_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_block_header_SOURCES = test/fuzz/block_header.cpp + +test_fuzz_block_header_and_short_txids_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCK_HEADER_AND_SHORT_TXIDS_DESERIALIZE=1 +test_fuzz_block_header_and_short_txids_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_block_header_and_short_txids_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_block_header_and_short_txids_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_block_header_and_short_txids_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_blockfilter_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_blockfilter_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_blockfilter_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_blockfilter_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_blockfilter_SOURCES = test/fuzz/blockfilter.cpp + +test_fuzz_blockheader_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCKHEADER_DESERIALIZE=1 +test_fuzz_blockheader_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_blockheader_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_blockheader_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_blockheader_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_blocklocator_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCKLOCATOR_DESERIALIZE=1 +test_fuzz_blocklocator_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_blocklocator_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_blocklocator_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_blocklocator_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_blockmerkleroot_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCKMERKLEROOT=1 +test_fuzz_blockmerkleroot_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_blockmerkleroot_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_blockmerkleroot_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_blockmerkleroot_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_blocktransactions_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCKTRANSACTIONS_DESERIALIZE=1 +test_fuzz_blocktransactions_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_blocktransactions_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_blocktransactions_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_blocktransactions_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_blocktransactionsrequest_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCKTRANSACTIONSREQUEST_DESERIALIZE=1 +test_fuzz_blocktransactionsrequest_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_blocktransactionsrequest_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_blocktransactionsrequest_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_blocktransactionsrequest_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_blockundo_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOCKUNDO_DESERIALIZE=1 +test_fuzz_blockundo_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_blockundo_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_blockundo_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_blockundo_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_bloom_filter_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_bloom_filter_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_bloom_filter_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_bloom_filter_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_bloom_filter_SOURCES = test/fuzz/bloom_filter.cpp + +test_fuzz_bloomfilter_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DBLOOMFILTER_DESERIALIZE=1 +test_fuzz_bloomfilter_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_bloomfilter_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_bloomfilter_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_bloomfilter_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_buffered_file_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_buffered_file_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_buffered_file_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_buffered_file_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_buffered_file_SOURCES = test/fuzz/buffered_file.cpp + +test_fuzz_chain_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_chain_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_chain_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_chain_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_chain_SOURCES = test/fuzz/chain.cpp + +test_fuzz_checkqueue_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_checkqueue_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_checkqueue_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_checkqueue_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_checkqueue_SOURCES = test/fuzz/checkqueue.cpp + +test_fuzz_coins_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DCOINS_DESERIALIZE=1 +test_fuzz_coins_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_coins_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_coins_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_coins_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_coins_view_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_coins_view_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_coins_view_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_coins_view_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_coins_view_SOURCES = test/fuzz/coins_view.cpp + +test_fuzz_connman_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_connman_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_connman_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_connman_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_connman_SOURCES = test/fuzz/connman.cpp + +test_fuzz_crypto_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_SOURCES = test/fuzz/crypto.cpp + +test_fuzz_crypto_aes256_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_aes256_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_aes256_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_aes256_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_aes256_SOURCES = test/fuzz/crypto_aes256.cpp + +test_fuzz_crypto_aes256cbc_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_aes256cbc_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_aes256cbc_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_aes256cbc_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_aes256cbc_SOURCES = test/fuzz/crypto_aes256cbc.cpp + +test_fuzz_crypto_chacha20_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_chacha20_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_chacha20_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_chacha20_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_chacha20_SOURCES = test/fuzz/crypto_chacha20.cpp + +test_fuzz_crypto_chacha20_poly1305_aead_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_chacha20_poly1305_aead_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_chacha20_poly1305_aead_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_chacha20_poly1305_aead_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_chacha20_poly1305_aead_SOURCES = test/fuzz/crypto_chacha20_poly1305_aead.cpp + +test_fuzz_crypto_common_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_common_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_common_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_common_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_common_SOURCES = test/fuzz/crypto_common.cpp + +test_fuzz_crypto_hkdf_hmac_sha256_l32_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_hkdf_hmac_sha256_l32_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_hkdf_hmac_sha256_l32_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_hkdf_hmac_sha256_l32_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_hkdf_hmac_sha256_l32_SOURCES = test/fuzz/crypto_hkdf_hmac_sha256_l32.cpp + +test_fuzz_crypto_poly1305_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_crypto_poly1305_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_crypto_poly1305_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_crypto_poly1305_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_crypto_poly1305_SOURCES = test/fuzz/crypto_poly1305.cpp + +test_fuzz_cuckoocache_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_cuckoocache_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_cuckoocache_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_cuckoocache_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_cuckoocache_SOURCES = test/fuzz/cuckoocache.cpp + +test_fuzz_decode_tx_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_decode_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_decode_tx_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_decode_tx_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_decode_tx_SOURCES = test/fuzz/decode_tx.cpp + +test_fuzz_descriptor_parse_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_descriptor_parse_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_descriptor_parse_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_descriptor_parse_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_descriptor_parse_SOURCES = test/fuzz/descriptor_parse.cpp + +test_fuzz_diskblockindex_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DDISKBLOCKINDEX_DESERIALIZE=1 +test_fuzz_diskblockindex_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_diskblockindex_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_diskblockindex_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_diskblockindex_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_eval_script_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_eval_script_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_eval_script_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_eval_script_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_eval_script_SOURCES = test/fuzz/eval_script.cpp + +test_fuzz_fee_rate_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_fee_rate_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_fee_rate_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_fee_rate_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_fee_rate_SOURCES = test/fuzz/fee_rate.cpp + +test_fuzz_fee_rate_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DFEE_RATE_DESERIALIZE=1 +test_fuzz_fee_rate_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_fee_rate_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_fee_rate_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_fee_rate_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_fees_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_fees_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_fees_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_fees_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_fees_SOURCES = test/fuzz/fees.cpp + +test_fuzz_flat_file_pos_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DFLAT_FILE_POS_DESERIALIZE=1 +test_fuzz_flat_file_pos_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_flat_file_pos_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_flat_file_pos_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_flat_file_pos_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_flatfile_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_flatfile_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_flatfile_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_flatfile_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_flatfile_SOURCES = test/fuzz/flatfile.cpp + +test_fuzz_float_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_float_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_float_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_float_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_float_SOURCES = test/fuzz/float.cpp + +test_fuzz_golomb_rice_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_golomb_rice_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_golomb_rice_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_golomb_rice_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_golomb_rice_SOURCES = test/fuzz/golomb_rice.cpp + +test_fuzz_hex_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_hex_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_hex_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_hex_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_hex_SOURCES = test/fuzz/hex.cpp + +test_fuzz_http_request_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_http_request_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_http_request_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_http_request_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_http_request_SOURCES = test/fuzz/http_request.cpp + +test_fuzz_integer_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_integer_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_integer_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_integer_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_integer_SOURCES = test/fuzz/integer.cpp + +test_fuzz_inv_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DINV_DESERIALIZE=1 +test_fuzz_inv_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_inv_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_inv_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_inv_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_key_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_key_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_key_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_key_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_key_SOURCES = test/fuzz/key.cpp + +test_fuzz_key_io_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_key_io_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_key_io_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_key_io_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_key_io_SOURCES = test/fuzz/key_io.cpp + +test_fuzz_key_origin_info_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DKEY_ORIGIN_INFO_DESERIALIZE=1 +test_fuzz_key_origin_info_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_key_origin_info_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_key_origin_info_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_key_origin_info_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_kitchen_sink_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_kitchen_sink_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_kitchen_sink_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_kitchen_sink_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_kitchen_sink_SOURCES = test/fuzz/kitchen_sink.cpp + +test_fuzz_load_external_block_file_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_load_external_block_file_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_load_external_block_file_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_load_external_block_file_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_load_external_block_file_SOURCES = test/fuzz/load_external_block_file.cpp + +test_fuzz_locale_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_locale_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_locale_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_locale_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_locale_SOURCES = test/fuzz/locale.cpp + +test_fuzz_merkle_block_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMERKLE_BLOCK_DESERIALIZE=1 +test_fuzz_merkle_block_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_merkle_block_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_merkle_block_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_merkle_block_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_merkleblock_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_merkleblock_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_merkleblock_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_merkleblock_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_merkleblock_SOURCES = test/fuzz/merkleblock.cpp + +test_fuzz_message_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_message_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_message_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_message_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_message_SOURCES = test/fuzz/message.cpp + +test_fuzz_messageheader_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGEHEADER_DESERIALIZE=1 +test_fuzz_messageheader_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_messageheader_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_messageheader_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_messageheader_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_multiplication_overflow_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_multiplication_overflow_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_multiplication_overflow_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_multiplication_overflow_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_multiplication_overflow_SOURCES = test/fuzz/multiplication_overflow.cpp + +test_fuzz_net_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_net_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_net_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_net_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_net_SOURCES = test/fuzz/net.cpp + +test_fuzz_net_permissions_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_net_permissions_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_net_permissions_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_net_permissions_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_net_permissions_SOURCES = test/fuzz/net_permissions.cpp + +test_fuzz_netaddr_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DNETADDR_DESERIALIZE=1 +test_fuzz_netaddr_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_netaddr_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_netaddr_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_netaddr_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_netaddress_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_netaddress_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_netaddress_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_netaddress_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_netaddress_SOURCES = test/fuzz/netaddress.cpp + +test_fuzz_out_point_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DOUT_POINT_DESERIALIZE=1 +test_fuzz_out_point_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_out_point_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_out_point_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_out_point_deserialize_SOURCES = test/fuzz/deserialize.cpp -test_test_pocketcoin_fuzzy_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) -# +test_fuzz_p2p_transport_deserializer_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_p2p_transport_deserializer_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_p2p_transport_deserializer_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_p2p_transport_deserializer_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_p2p_transport_deserializer_SOURCES = test/fuzz/p2p_transport_deserializer.cpp + +test_fuzz_parse_hd_keypath_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_parse_hd_keypath_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_parse_hd_keypath_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_parse_hd_keypath_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_parse_hd_keypath_SOURCES = test/fuzz/parse_hd_keypath.cpp + +test_fuzz_parse_iso8601_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_parse_iso8601_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_parse_iso8601_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_parse_iso8601_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_parse_iso8601_SOURCES = test/fuzz/parse_iso8601.cpp + +test_fuzz_parse_numbers_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_parse_numbers_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_parse_numbers_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_parse_numbers_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_parse_numbers_SOURCES = test/fuzz/parse_numbers.cpp + +test_fuzz_parse_script_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_parse_script_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_parse_script_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_parse_script_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_parse_script_SOURCES = test/fuzz/parse_script.cpp + +test_fuzz_parse_univalue_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_parse_univalue_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_parse_univalue_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_parse_univalue_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_parse_univalue_SOURCES = test/fuzz/parse_univalue.cpp + +test_fuzz_prevector_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_prevector_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_prevector_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_prevector_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_prevector_SOURCES = test/fuzz/prevector.cpp + +test_fuzz_partial_merkle_tree_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DPARTIAL_MERKLE_TREE_DESERIALIZE=1 +test_fuzz_partial_merkle_tree_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_partial_merkle_tree_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_partial_merkle_tree_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_partial_merkle_tree_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_partially_signed_transaction_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DPARTIALLY_SIGNED_TRANSACTION_DESERIALIZE=1 +test_fuzz_partially_signed_transaction_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_partially_signed_transaction_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_partially_signed_transaction_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_partially_signed_transaction_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_policy_estimator_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_policy_estimator_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_policy_estimator_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_policy_estimator_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_policy_estimator_SOURCES = test/fuzz/policy_estimator.cpp + +test_fuzz_policy_estimator_io_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_policy_estimator_io_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_policy_estimator_io_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_policy_estimator_io_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_policy_estimator_io_SOURCES = test/fuzz/policy_estimator_io.cpp + +test_fuzz_pow_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_pow_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_pow_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_pow_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_pow_SOURCES = test/fuzz/pow.cpp + +test_fuzz_prefilled_transaction_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DPREFILLED_TRANSACTION_DESERIALIZE=1 +test_fuzz_prefilled_transaction_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_prefilled_transaction_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_prefilled_transaction_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_prefilled_transaction_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_primitives_transaction_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_primitives_transaction_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_primitives_transaction_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_primitives_transaction_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_primitives_transaction_SOURCES = test/fuzz/primitives_transaction.cpp + +test_fuzz_process_messages_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_process_messages_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_messages_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_messages_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_messages_SOURCES = test/fuzz/process_messages.cpp + +test_fuzz_process_message_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_process_message_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_addr_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=addr +test_fuzz_process_message_addr_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_addr_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_addr_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_addr_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_block_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=block +test_fuzz_process_message_block_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_block_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_block_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_block_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_blocktxn_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=blocktxn +test_fuzz_process_message_blocktxn_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_blocktxn_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_blocktxn_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_blocktxn_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_cmpctblock_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=cmpctblock +test_fuzz_process_message_cmpctblock_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_cmpctblock_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_cmpctblock_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_cmpctblock_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_feefilter_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=feefilter +test_fuzz_process_message_feefilter_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_feefilter_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_feefilter_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_feefilter_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_filteradd_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=filteradd +test_fuzz_process_message_filteradd_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_filteradd_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_filteradd_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_filteradd_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_filterclear_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=filterclear +test_fuzz_process_message_filterclear_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_filterclear_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_filterclear_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_filterclear_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_filterload_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=filterload +test_fuzz_process_message_filterload_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_filterload_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_filterload_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_filterload_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_getaddr_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=getaddr +test_fuzz_process_message_getaddr_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_getaddr_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_getaddr_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_getaddr_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_getblocks_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=getblocks +test_fuzz_process_message_getblocks_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_getblocks_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_getblocks_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_getblocks_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_getblocktxn_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=getblocktxn +test_fuzz_process_message_getblocktxn_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_getblocktxn_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_getblocktxn_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_getblocktxn_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_getdata_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=getdata +test_fuzz_process_message_getdata_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_getdata_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_getdata_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_getdata_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_getheaders_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=getheaders +test_fuzz_process_message_getheaders_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_getheaders_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_getheaders_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_getheaders_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_headers_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=headers +test_fuzz_process_message_headers_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_headers_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_headers_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_headers_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_inv_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=inv +test_fuzz_process_message_inv_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_inv_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_inv_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_inv_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_mempool_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=mempool +test_fuzz_process_message_mempool_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_mempool_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_mempool_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_mempool_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_notfound_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=notfound +test_fuzz_process_message_notfound_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_notfound_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_notfound_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_notfound_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_ping_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=ping +test_fuzz_process_message_ping_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_ping_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_ping_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_ping_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_pong_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=pong +test_fuzz_process_message_pong_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_pong_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_pong_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_pong_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_sendcmpct_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=sendcmpct +test_fuzz_process_message_sendcmpct_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_sendcmpct_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_sendcmpct_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_sendcmpct_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_sendheaders_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=sendheaders +test_fuzz_process_message_sendheaders_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_sendheaders_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_sendheaders_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_sendheaders_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_tx_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=tx +test_fuzz_process_message_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_tx_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_tx_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_tx_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_verack_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=verack +test_fuzz_process_message_verack_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_verack_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_verack_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_verack_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_process_message_version_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DMESSAGE_TYPE=version +test_fuzz_process_message_version_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_process_message_version_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_process_message_version_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_process_message_version_SOURCES = test/fuzz/process_message.cpp + +test_fuzz_protocol_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_protocol_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_protocol_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_protocol_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_protocol_SOURCES = test/fuzz/protocol.cpp + +test_fuzz_psbt_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_psbt_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_psbt_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_psbt_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_psbt_SOURCES = test/fuzz/psbt.cpp + +test_fuzz_psbt_input_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DPSBT_INPUT_DESERIALIZE=1 +test_fuzz_psbt_input_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_psbt_input_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_psbt_input_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_psbt_input_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_psbt_output_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DPSBT_OUTPUT_DESERIALIZE=1 +test_fuzz_psbt_output_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_psbt_output_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_psbt_output_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_psbt_output_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_pub_key_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DPUB_KEY_DESERIALIZE=1 +test_fuzz_pub_key_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_pub_key_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_pub_key_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_pub_key_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_random_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_random_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_random_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_random_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_random_SOURCES = test/fuzz/random.cpp + +test_fuzz_rbf_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_rbf_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_rbf_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_rbf_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_rbf_SOURCES = test/fuzz/rbf.cpp + +test_fuzz_rolling_bloom_filter_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_rolling_bloom_filter_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_rolling_bloom_filter_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_rolling_bloom_filter_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_rolling_bloom_filter_SOURCES = test/fuzz/rolling_bloom_filter.cpp + +test_fuzz_script_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_SOURCES = test/fuzz/script.cpp + +test_fuzz_script_pocketcoin_consensus_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_pocketcoin_consensus_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_pocketcoin_consensus_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_pocketcoin_consensus_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_pocketcoin_consensus_SOURCES = test/fuzz/script_pocketcoin_consensus.cpp + +test_fuzz_script_descriptor_cache_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_descriptor_cache_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_descriptor_cache_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_descriptor_cache_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_descriptor_cache_SOURCES = test/fuzz/script_descriptor_cache.cpp + +test_fuzz_script_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DSCRIPT_DESERIALIZE=1 +test_fuzz_script_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_script_flags_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_flags_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_flags_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_flags_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_flags_SOURCES = test/fuzz/script_flags.cpp + +test_fuzz_script_interpreter_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_interpreter_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_interpreter_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_interpreter_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_interpreter_SOURCES = test/fuzz/script_interpreter.cpp + +test_fuzz_script_assets_test_minimizer_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_assets_test_minimizer_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_assets_test_minimizer_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_assets_test_minimizer_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +test_fuzz_script_assets_test_minimizer_SOURCES = test/fuzz/script_assets_test_minimizer.cpp + +test_fuzz_script_ops_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_ops_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_ops_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_ops_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_ops_SOURCES = test/fuzz/script_ops.cpp + +test_fuzz_script_sigcache_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_sigcache_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_sigcache_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_sigcache_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_sigcache_SOURCES = test/fuzz/script_sigcache.cpp + +test_fuzz_script_sign_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_script_sign_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_script_sign_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_script_sign_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_script_sign_SOURCES = test/fuzz/script_sign.cpp + +test_fuzz_scriptnum_ops_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_scriptnum_ops_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_scriptnum_ops_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_scriptnum_ops_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_scriptnum_ops_SOURCES = test/fuzz/scriptnum_ops.cpp + +test_fuzz_secp256k1_ec_seckey_import_export_der_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_secp256k1_ec_seckey_import_export_der_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_secp256k1_ec_seckey_import_export_der_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_secp256k1_ec_seckey_import_export_der_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_secp256k1_ec_seckey_import_export_der_SOURCES = test/fuzz/secp256k1_ec_seckey_import_export_der.cpp + +test_fuzz_secp256k1_ecdsa_signature_parse_der_lax_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_secp256k1_ecdsa_signature_parse_der_lax_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_secp256k1_ecdsa_signature_parse_der_lax_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_secp256k1_ecdsa_signature_parse_der_lax_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_secp256k1_ecdsa_signature_parse_der_lax_SOURCES = test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp + +test_fuzz_service_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DSERVICE_DESERIALIZE=1 +test_fuzz_service_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_service_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_service_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_service_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_signature_checker_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_signature_checker_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_signature_checker_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_signature_checker_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_signature_checker_SOURCES = test/fuzz/signature_checker.cpp + +test_fuzz_signet_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_signet_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_signet_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_signet_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +test_fuzz_signet_SOURCES = test/fuzz/signet.cpp + +test_fuzz_snapshotmetadata_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DSNAPSHOTMETADATA_DESERIALIZE=1 +test_fuzz_snapshotmetadata_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_snapshotmetadata_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_snapshotmetadata_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_snapshotmetadata_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_span_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_span_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_span_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_span_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_span_SOURCES = test/fuzz/span.cpp + +test_fuzz_spanparsing_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_spanparsing_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_spanparsing_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_spanparsing_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_spanparsing_SOURCES = test/fuzz/spanparsing.cpp + +test_fuzz_string_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_string_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_string_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_string_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_string_SOURCES = test/fuzz/string.cpp + +test_fuzz_strprintf_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_strprintf_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_strprintf_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_strprintf_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_strprintf_SOURCES = test/fuzz/strprintf.cpp + +test_fuzz_sub_net_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DSUB_NET_DESERIALIZE=1 +test_fuzz_sub_net_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_sub_net_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_sub_net_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_sub_net_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_system_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_system_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_system_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_system_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_system_SOURCES = test/fuzz/system.cpp + +test_fuzz_timedata_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_timedata_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_timedata_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_timedata_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_timedata_SOURCES = test/fuzz/timedata.cpp + +test_fuzz_transaction_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_transaction_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_transaction_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_transaction_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_transaction_SOURCES = test/fuzz/transaction.cpp + +test_fuzz_tx_in_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_tx_in_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_tx_in_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_tx_in_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_tx_in_SOURCES = test/fuzz/tx_in.cpp + +test_fuzz_tx_in_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DTX_IN_DESERIALIZE=1 +test_fuzz_tx_in_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_tx_in_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_tx_in_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_tx_in_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_tx_out_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_tx_out_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_tx_out_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_tx_out_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_tx_out_SOURCES = test/fuzz/tx_out.cpp + +test_fuzz_txoutcompressor_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DTXOUTCOMPRESSOR_DESERIALIZE=1 +test_fuzz_txoutcompressor_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_txoutcompressor_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_txoutcompressor_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_txoutcompressor_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_txrequest_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_txrequest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_txrequest_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_txrequest_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_txrequest_SOURCES = test/fuzz/txrequest.cpp + +test_fuzz_txundo_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DTXUNDO_DESERIALIZE=1 +test_fuzz_txundo_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_txundo_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_txundo_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_txundo_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_uint160_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DUINT160_DESERIALIZE=1 +test_fuzz_uint160_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_uint160_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_uint160_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_uint160_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_uint256_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) -DUINT256_DESERIALIZE=1 +test_fuzz_uint256_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_uint256_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_uint256_deserialize_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_uint256_deserialize_SOURCES = test/fuzz/deserialize.cpp + +test_fuzz_versionbits_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) +test_fuzz_versionbits_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_versionbits_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_versionbits_LDFLAGS = $(FUZZ_SUITE_LDFLAGS_COMMON) +test_fuzz_versionbits_SOURCES = test/fuzz/versionbits.cpp + +endif # ENABLE_FUZZ nodist_test_test_pocketcoin_SOURCES = $(GENERATED_TEST_FILES) $(POCKETCOIN_TESTS): $(GENERATED_TEST_FILES) -CLEAN_POCKETCOIN_TEST = test/*.gcda test/*.gcno $(GENERATED_TEST_FILES) $(POCKETCOIN_TESTS:=.log) +CLEAN_POCKETCOIN_TEST = test/*.gcda test/*.gcno test/fuzz/*.gcda test/fuzz/*.gcno test/util/*.gcda test/util/*.gcno $(GENERATED_TEST_FILES) $(POCKETCOIN_TESTS:=.log) CLEANFILES += $(CLEAN_POCKETCOIN_TEST) +if TARGET_WINDOWS pocketcoin_test: $(TEST_BINARY) +else +if ENABLE_BENCH +pocketcoin_test: $(TEST_BINARY) $(BENCH_BINARY) +else +pocketcoin_test: $(TEST_BINARY) +endif +endif pocketcoin_test_check: $(TEST_BINARY) FORCE $(MAKE) check-TESTS TESTS=$^ @@ -194,10 +1318,19 @@ pocketcoin_test_clean : FORCE rm -f $(CLEAN_POCKETCOIN_TEST) $(test_test_pocketcoin_OBJECTS) $(TEST_BINARY) check-local: $(POCKETCOIN_TESTS:.cpp=.cpp.test) -# @echo "Running test/util/pocketcoin-util-test.py..." -# $(PYTHON) $(top_builddir)/test/util/pocketcoin-util-test.py -# @echo "Running test/util/rpcauth-test.py..." -# $(PYTHON) $(top_builddir)/test/util/rpcauth-test.py +# if BUILD_POCKETCOIN_TX +# @echo "Running test/util/pocketcoin-util-test.py..." +# $(PYTHON) $(top_builddir)/test/util/pocketcoin-util-test.py +# endif +# @echo "Running test/util/rpcauth-test.py..." +# $(PYTHON) $(top_builddir)/test/util/rpcauth-test.py +if TARGET_WINDOWS +else +if ENABLE_BENCH + @echo "Running bench/bench_pocketcoin ..." + $(BENCH_BINARY) > /dev/null +endif +endif $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check if EMBEDDED_UNIVALUE $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check @@ -216,3 +1349,12 @@ endif echo "};};"; \ } > "$@.new" && mv -f "$@.new" "$@" @echo "Generated $@" + +%.raw.h: %.raw + @$(MKDIR_P) $(@D) + @{ \ + echo "static unsigned const char $(*F)_raw[] = {" && \ + $(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \ + echo "};"; \ + } > "$@.new" && mv -f "$@.new" "$@" + @echo "Generated $@" diff --git a/src/Makefile.test_fuzz.include b/src/Makefile.test_fuzz.include new file mode 100644 index 000000000..569c7574a --- /dev/null +++ b/src/Makefile.test_fuzz.include @@ -0,0 +1,24 @@ +# Copyright (c) 2013-2020 The Pocketcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +LIBTEST_FUZZ=libtest_fuzz.a + +EXTRA_LIBRARIES += \ + $(LIBTEST_FUZZ) + +TEST_FUZZ_H = \ + test/fuzz/fuzz.h \ + test/fuzz/FuzzedDataProvider.h \ + test/fuzz/util.h + +libtest_fuzz_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) +libtest_fuzz_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +libtest_fuzz_a_SOURCES = \ + test/fuzz/fuzz.cpp \ + $(TEST_FUZZ_H) + +LIBTEST_FUZZ += $(LIBPOCKETCOIN_SERVER) +LIBTEST_FUZZ += $(LIBPOCKETCOIN_COMMON) +LIBTEST_FUZZ += $(LIBPOCKETCOIN_UTIL) +LIBTEST_FUZZ += $(LIBPOCKETCOIN_CRYPTO_BASE) diff --git a/src/Makefile.test_util.include b/src/Makefile.test_util.include new file mode 100644 index 000000000..294138432 --- /dev/null +++ b/src/Makefile.test_util.include @@ -0,0 +1,38 @@ +# Copyright (c) 2013-2019 The Pocketcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +LIBTEST_UTIL=libtest_util.a + +EXTRA_LIBRARIES += \ + $(LIBTEST_UTIL) + +TEST_UTIL_H = \ + test/util/blockfilter.h \ + test/util/logging.h \ + test/util/mining.h \ + test/util/net.h \ + test/util/setup_common.h \ + test/util/str.h \ + test/util/transaction_utils.h \ + test/util/validation.h \ + test/util/wallet.h + +libtest_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(POCKETCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) +libtest_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +libtest_util_a_SOURCES = \ + test/util/blockfilter.cpp \ + test/util/logging.cpp \ + test/util/mining.cpp \ + test/util/net.cpp \ + test/util/setup_common.cpp \ + test/util/str.cpp \ + test/util/transaction_utils.cpp \ + test/util/validation.cpp \ + test/util/wallet.cpp \ + $(TEST_UTIL_H) + +LIBTEST_UTIL += $(LIBPOCKETCOIN_SERVER) +LIBTEST_UTIL += $(LIBPOCKETCOIN_COMMON) +LIBTEST_UTIL += $(LIBPOCKETCOIN_UTIL) +LIBTEST_UTIL += $(LIBPOCKETCOIN_CRYPTO_BASE) diff --git a/src/addrdb.cpp b/src/addrdb.cpp index cd77a5b83..96c8a9f12 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -8,11 +8,13 @@ #include #include #include +#include #include +#include #include #include #include -#include +#include namespace { @@ -36,7 +38,7 @@ template bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data& data) { // Generate random temporary filename - unsigned short randv = 0; + uint16_t randv = 0; GetRandBytes((unsigned char*)&randv, sizeof(randv)); std::string tmpfn = strprintf("%s.%04x", prefix, randv); @@ -44,18 +46,30 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data fs::path pathTmp = GetDataDir() / tmpfn; FILE *file = fsbridge::fopen(pathTmp, "wb"); CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); - if (fileout.IsNull()) + if (fileout.IsNull()) { + fileout.fclose(); + remove(pathTmp); return error("%s: Failed to open file %s", __func__, pathTmp.string()); + } // Serialize - if (!SerializeDB(fileout, data)) return false; - if (!FileCommit(fileout.Get())) + if (!SerializeDB(fileout, data)) { + fileout.fclose(); + remove(pathTmp); + return false; + } + if (!FileCommit(fileout.Get())) { + fileout.fclose(); + remove(pathTmp); return error("%s: Failed to flush file %s", __func__, pathTmp.string()); + } fileout.fclose(); // replace existing file, if any, with new file - if (!RenameOver(pathTmp, path)) + if (!RenameOver(pathTmp, path)) { + remove(pathTmp); return error("%s: Rename-into-place failed", __func__); + } return true; } @@ -105,19 +119,18 @@ bool DeserializeFileDB(const fs::path& path, Data& data) } -CBanDB::CBanDB() +CBanDB::CBanDB(fs::path ban_list_path) : m_ban_list_path(std::move(ban_list_path)) { - pathBanlist = GetDataDir() / "banlist.dat"; } bool CBanDB::Write(const banmap_t& banSet) { - return SerializeFileDB("banlist", pathBanlist, banSet); + return SerializeFileDB("banlist", m_ban_list_path, banSet); } bool CBanDB::Read(banmap_t& banSet) { - return DeserializeFileDB(pathBanlist, banSet); + return DeserializeFileDB(m_ban_list_path, banSet); } CAddrDB::CAddrDB() @@ -144,3 +157,22 @@ bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers) } return ret; } + +void DumpAnchors(const fs::path& anchors_db_path, const std::vector& anchors) +{ + LOG_TIME_SECONDS(strprintf("Flush %d outbound block-relay-only peer addresses to anchors.dat", anchors.size())); + SerializeFileDB("anchors", anchors_db_path, anchors); +} + +std::vector ReadAnchors(const fs::path& anchors_db_path) +{ + std::vector anchors; + if (DeserializeFileDB(anchors_db_path, anchors)) { + LogPrintf("Loaded %i addresses from %s\n", anchors.size(), anchors_db_path.filename()); + } else { + anchors.clear(); + } + + fs::remove(anchors_db_path); + return anchors; +} diff --git a/src/addrdb.h b/src/addrdb.h index ce30d3dc7..0cb874985 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -7,22 +7,16 @@ #define POCKETCOIN_ADDRDB_H #include +#include // For banmap_t #include #include -#include +#include -class CSubNet; +class CAddress; class CAddrMan; class CDataStream; -typedef enum BanReason -{ - BanReasonUnknown = 0, - BanReasonNodeMisbehaving = 1, - BanReasonManuallyAdded = 2 -} BanReason; - class CBanEntry { public: @@ -30,7 +24,6 @@ class CBanEntry int nVersion; int64_t nCreateTime; int64_t nBanUntil; - uint8_t banReason; CBanEntry() { @@ -43,11 +36,10 @@ class CBanEntry nCreateTime = nCreateTimeIn; } - SERIALIZE_METHODS(CBanEntry, obj) { - READWRITE(obj.nVersion); - READWRITE(obj.nCreateTime); - READWRITE(obj.nBanUntil); - READWRITE(obj.banReason); + SERIALIZE_METHODS(CBanEntry, obj) + { + uint8_t ban_reason = 2; //! For backward compatibility + READWRITE(obj.nVersion, obj.nCreateTime, obj.nBanUntil, ban_reason); } void SetNull() @@ -55,24 +47,9 @@ class CBanEntry nVersion = CBanEntry::CURRENT_VERSION; nCreateTime = 0; nBanUntil = 0; - banReason = BanReasonUnknown; - } - - std::string banReasonToString() const - { - switch (banReason) { - case BanReasonNodeMisbehaving: - return "node misbehaving"; - case BanReasonManuallyAdded: - return "manually added"; - default: - return "unknown"; - } } }; -typedef std::map banmap_t; - /** Access to the (IP) address database (peers.dat) */ class CAddrDB { @@ -89,11 +66,27 @@ class CAddrDB class CBanDB { private: - fs::path pathBanlist; + const fs::path m_ban_list_path; public: - CBanDB(); + explicit CBanDB(fs::path ban_list_path); bool Write(const banmap_t& banSet); bool Read(banmap_t& banSet); }; +/** + * Dump the anchor IP address database (anchors.dat) + * + * Anchors are last known outgoing block-relay-only peers that are + * tried to re-connect to on startup. + */ +void DumpAnchors(const fs::path& anchors_db_path, const std::vector& anchors); + +/** + * Read the anchor IP address database (anchors.dat) + * + * Deleting anchors.dat is intentional as it avoids renewed peering to anchors after + * an unclean shutdown and thus potential exploitation of the anchor peer policy. + */ +std::vector ReadAnchors(const fs::path& anchors_db_path); + #endif // POCKETCOIN_ADDRDB_H diff --git a/src/addrman.cpp b/src/addrman.cpp index bebf4a58a..d65511d84 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -6,27 +6,33 @@ #include #include +#include #include -#include -int CAddrInfo::GetTriedBucket(const uint256& nKey) const +int CAddrInfo::GetTriedBucket(const uint256& nKey, const std::vector &asmap) const { - uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetHash().GetCheapHash(); - uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup() << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetHash().GetCheapHash(); - return hash2 % ADDRMAN_TRIED_BUCKET_COUNT; + uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetKey()).GetCheapHash(); + uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP)).GetCheapHash(); + int tried_bucket = hash2 % ADDRMAN_TRIED_BUCKET_COUNT; + uint32_t mapped_as = GetMappedAS(asmap); + LogPrint(BCLog::NET, "IP %s mapped to AS%i belongs to tried bucket %i\n", ToStringIP(), mapped_as, tried_bucket); + return tried_bucket; } -int CAddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src) const +int CAddrInfo::GetNewBucket(const uint256& nKey, const CNetAddr& src, const std::vector &asmap) const { - std::vector vchSourceGroupKey = src.GetGroup(); - uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup() << vchSourceGroupKey).GetHash().GetCheapHash(); - uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP)).GetHash().GetCheapHash(); - return hash2 % ADDRMAN_NEW_BUCKET_COUNT; + std::vector vchSourceGroupKey = src.GetGroup(asmap); + uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << GetGroup(asmap) << vchSourceGroupKey).GetCheapHash(); + uint64_t hash2 = (CHashWriter(SER_GETHASH, 0) << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP)).GetCheapHash(); + int new_bucket = hash2 % ADDRMAN_NEW_BUCKET_COUNT; + uint32_t mapped_as = GetMappedAS(asmap); + LogPrint(BCLog::NET, "IP %s mapped to AS%i belongs to new bucket %i\n", ToStringIP(), mapped_as, new_bucket); + return new_bucket; } int CAddrInfo::GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const { - uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << (fNew ? 'N' : 'K') << nBucket << GetKey()).GetHash().GetCheapHash(); + uint64_t hash1 = (CHashWriter(SER_GETHASH, 0) << nKey << (fNew ? 'N' : 'K') << nBucket << GetKey()).GetCheapHash(); return hash1 % ADDRMAN_BUCKET_SIZE; } @@ -154,7 +160,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId) assert(info.nRefCount == 0); // which tried bucket to move the entry to - int nKBucket = info.GetTriedBucket(nKey); + int nKBucket = info.GetTriedBucket(nKey, m_asmap); int nKBucketPos = info.GetBucketPosition(nKey, false, nKBucket); // first make space to add it (the existing tried entry there is moved to new, deleting whatever is there). @@ -170,7 +176,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId) nTried--; // find which new bucket it belongs to - int nUBucket = infoOld.GetNewBucket(nKey); + int nUBucket = infoOld.GetNewBucket(nKey, m_asmap); int nUBucketPos = infoOld.GetBucketPosition(nKey, true, nUBucket); ClearNew(nUBucket, nUBucketPos); assert(vvNew[nUBucket][nUBucketPos] == -1); @@ -217,7 +223,7 @@ void CAddrMan::Good_(const CService& addr, bool test_before_evict, int64_t nTime return; // find a bucket it is in now - int nRnd = RandomInt(ADDRMAN_NEW_BUCKET_COUNT); + int nRnd = insecure_rand.randrange(ADDRMAN_NEW_BUCKET_COUNT); int nUBucket = -1; for (unsigned int n = 0; n < ADDRMAN_NEW_BUCKET_COUNT; n++) { int nB = (n + nRnd) % ADDRMAN_NEW_BUCKET_COUNT; @@ -234,12 +240,14 @@ void CAddrMan::Good_(const CService& addr, bool test_before_evict, int64_t nTime return; // which tried bucket to move the entry to - int tried_bucket = info.GetTriedBucket(nKey); + int tried_bucket = info.GetTriedBucket(nKey, m_asmap); int tried_bucket_pos = info.GetBucketPosition(nKey, false, tried_bucket); // Will moving this address into tried evict another entry? if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1)) { - LogPrint(BCLog::ADDRMAN, "Collision inserting element into tried table, moving %s to m_tried_collisions=%d\n", addr.ToString(), m_tried_collisions.size()); + // Output the entry we'd be colliding with, for debugging purposes + auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]); + LogPrint(BCLog::ADDRMAN, "Collision inserting element into tried table (%s), moving %s to m_tried_collisions=%d\n", colliding_entry != mapInfo.end() ? colliding_entry->second.ToString() : "", addr.ToString(), m_tried_collisions.size()); if (m_tried_collisions.size() < ADDRMAN_SET_TRIED_COLLISION_SIZE) { m_tried_collisions.insert(nId); } @@ -291,7 +299,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP int nFactor = 1; for (int n = 0; n < pinfo->nRefCount; n++) nFactor *= 2; - if (nFactor > 1 && (RandomInt(nFactor) != 0)) + if (nFactor > 1 && (insecure_rand.randrange(nFactor) != 0)) return false; } else { pinfo = Create(addr, source, &nId); @@ -300,7 +308,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP fNew = true; } - int nUBucket = pinfo->GetNewBucket(nKey, source); + int nUBucket = pinfo->GetNewBucket(nKey, source, m_asmap); int nUBucketPos = pinfo->GetBucketPosition(nKey, true, nUBucket); if (vvNew[nUBucket][nUBucketPos] != nId) { bool fInsert = vvNew[nUBucket][nUBucketPos] == -1; @@ -356,12 +364,12 @@ CAddrInfo CAddrMan::Select_(bool newOnly) // Use a 50% chance for choosing between tried and new table entries. if (!newOnly && - (nTried > 0 && (nNew == 0 || RandomInt(2) == 0))) { + (nTried > 0 && (nNew == 0 || insecure_rand.randbool() == 0))) { // use a tried node double fChanceFactor = 1.0; while (1) { - int nKBucket = RandomInt(ADDRMAN_TRIED_BUCKET_COUNT); - int nKBucketPos = RandomInt(ADDRMAN_BUCKET_SIZE); + int nKBucket = insecure_rand.randrange(ADDRMAN_TRIED_BUCKET_COUNT); + int nKBucketPos = insecure_rand.randrange(ADDRMAN_BUCKET_SIZE); while (vvTried[nKBucket][nKBucketPos] == -1) { nKBucket = (nKBucket + insecure_rand.randbits(ADDRMAN_TRIED_BUCKET_COUNT_LOG2)) % ADDRMAN_TRIED_BUCKET_COUNT; nKBucketPos = (nKBucketPos + insecure_rand.randbits(ADDRMAN_BUCKET_SIZE_LOG2)) % ADDRMAN_BUCKET_SIZE; @@ -369,7 +377,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly) int nId = vvTried[nKBucket][nKBucketPos]; assert(mapInfo.count(nId) == 1); CAddrInfo& info = mapInfo[nId]; - if (RandomInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30)) + if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30)) return info; fChanceFactor *= 1.2; } @@ -377,8 +385,8 @@ CAddrInfo CAddrMan::Select_(bool newOnly) // use a new node double fChanceFactor = 1.0; while (1) { - int nUBucket = RandomInt(ADDRMAN_NEW_BUCKET_COUNT); - int nUBucketPos = RandomInt(ADDRMAN_BUCKET_SIZE); + int nUBucket = insecure_rand.randrange(ADDRMAN_NEW_BUCKET_COUNT); + int nUBucketPos = insecure_rand.randrange(ADDRMAN_BUCKET_SIZE); while (vvNew[nUBucket][nUBucketPos] == -1) { nUBucket = (nUBucket + insecure_rand.randbits(ADDRMAN_NEW_BUCKET_COUNT_LOG2)) % ADDRMAN_NEW_BUCKET_COUNT; nUBucketPos = (nUBucketPos + insecure_rand.randbits(ADDRMAN_BUCKET_SIZE_LOG2)) % ADDRMAN_BUCKET_SIZE; @@ -386,7 +394,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly) int nId = vvNew[nUBucket][nUBucketPos]; assert(mapInfo.count(nId) == 1); CAddrInfo& info = mapInfo[nId]; - if (RandomInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30)) + if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30)) return info; fChanceFactor *= 1.2; } @@ -438,7 +446,7 @@ int CAddrMan::Check_() if (vvTried[n][i] != -1) { if (!setTried.count(vvTried[n][i])) return -11; - if (mapInfo[vvTried[n][i]].GetTriedBucket(nKey) != n) + if (mapInfo[vvTried[n][i]].GetTriedBucket(nKey, m_asmap) != n) return -17; if (mapInfo[vvTried[n][i]].GetBucketPosition(nKey, false, n) != i) return -18; @@ -471,18 +479,22 @@ int CAddrMan::Check_() } #endif -void CAddrMan::GetAddr_(std::vector& vAddr) +void CAddrMan::GetAddr_(std::vector& vAddr, size_t max_addresses, size_t max_pct) { - unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100; - if (nNodes > ADDRMAN_GETADDR_MAX) - nNodes = ADDRMAN_GETADDR_MAX; + size_t nNodes = vRandom.size(); + if (max_pct != 0) { + nNodes = max_pct * nNodes / 100; + } + if (max_addresses != 0) { + nNodes = std::min(nNodes, max_addresses); + } // gather a list of random nodes, skipping those of low quality for (unsigned int n = 0; n < vRandom.size(); n++) { if (vAddr.size() >= nNodes) break; - int nRndPos = RandomInt(vRandom.size() - n) + n; + int nRndPos = insecure_rand.randrange(vRandom.size() - n) + n; SwapRandom(n, nRndPos); assert(mapInfo.count(vRandom[n]) == 1); @@ -530,10 +542,6 @@ void CAddrMan::SetServices_(const CService& addr, ServiceFlags nServices) info.nServices = nServices; } -int CAddrMan::RandomInt(int nMax){ - return GetRandInt(nMax); -} - void CAddrMan::ResolveCollisions_() { for (std::set::iterator it = m_tried_collisions.begin(); it != m_tried_collisions.end();) { @@ -548,7 +556,7 @@ void CAddrMan::ResolveCollisions_() CAddrInfo& info_new = mapInfo[id_new]; // Which tried bucket to move the entry to. - int tried_bucket = info_new.GetTriedBucket(nKey); + int tried_bucket = info_new.GetTriedBucket(nKey, m_asmap); int tried_bucket_pos = info_new.GetBucketPosition(nKey, false, tried_bucket); if (!info_new.IsValid()) { // id_new may no longer map to a valid address erase_collision = true; @@ -565,12 +573,19 @@ void CAddrMan::ResolveCollisions_() // Give address at least 60 seconds to successfully connect if (GetAdjustedTime() - info_old.nLastTry > 60) { - LogPrint(BCLog::ADDRMAN, "Swapping %s for %s in tried table\n", info_new.ToString(), info_old.ToString()); + LogPrint(BCLog::ADDRMAN, "Replacing %s with %s in tried table\n", info_old.ToString(), info_new.ToString()); // Replaces an existing address already in the tried table with the new address Good_(info_new, false, GetAdjustedTime()); erase_collision = true; } + } else if (GetAdjustedTime() - info_new.nLastSuccess > ADDRMAN_TEST_WINDOW) { + // If the collision hasn't resolved in some reasonable amount of time, + // just evict the old entry -- we must not be able to + // connect to it for some reason. + LogPrint(BCLog::ADDRMAN, "Unable to test; replacing %s with %s in tried table anyway\n", info_old.ToString(), info_new.ToString()); + Good_(info_new, false, GetAdjustedTime()); + erase_collision = true; } } else { // Collision is not actually a collision anymore Good_(info_new, false, GetAdjustedTime()); @@ -593,7 +608,7 @@ CAddrInfo CAddrMan::SelectTriedCollision_() std::set::iterator it = m_tried_collisions.begin(); // Selects a random element from m_tried_collisions - std::advance(it, GetRandInt(m_tried_collisions.size())); + std::advance(it, insecure_rand.randrange(m_tried_collisions.size())); int id_new = *it; // If id_new not found in mapInfo remove it from m_tried_collisions @@ -605,10 +620,37 @@ CAddrInfo CAddrMan::SelectTriedCollision_() CAddrInfo& newInfo = mapInfo[id_new]; // which tried bucket to move the entry to - int tried_bucket = newInfo.GetTriedBucket(nKey); + int tried_bucket = newInfo.GetTriedBucket(nKey, m_asmap); int tried_bucket_pos = newInfo.GetBucketPosition(nKey, false, tried_bucket); int id_old = vvTried[tried_bucket][tried_bucket_pos]; return mapInfo[id_old]; } + +std::vector CAddrMan::DecodeAsmap(fs::path path) +{ + std::vector bits; + FILE *filestr = fsbridge::fopen(path, "rb"); + CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); + if (file.IsNull()) { + LogPrintf("Failed to open asmap file from disk\n"); + return bits; + } + fseek(filestr, 0, SEEK_END); + int length = ftell(filestr); + LogPrintf("Opened asmap file %s (%d bytes) from disk\n", path, length); + fseek(filestr, 0, SEEK_SET); + char cur_byte; + for (int i = 0; i < length; ++i) { + file >> cur_byte; + for (int bit = 0; bit < 8; ++bit) { + bits.push_back((cur_byte >> bit) & 1); + } + } + if (!SanityCheckASMap(bits)) { + LogPrintf("Sanity check of asmap file %s failed\n", path); + return {}; + } + return bits; +} diff --git a/src/addrman.h b/src/addrman.h index 701126791..3c8dca358 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -6,16 +6,25 @@ #ifndef POCKETCOIN_ADDRMAN_H #define POCKETCOIN_ADDRMAN_H +#include +#if defined(HAVE_CONFIG_H) +#include +#endif #include #include #include #include #include -#include +#include +#include +#include +#include +#include #include #include #include +#include #include /** @@ -23,76 +32,60 @@ */ class CAddrInfo : public CAddress { - - public: //! last try whatsoever by us (memory only) - int64_t nLastTry; + int64_t nLastTry{0}; //! last counted attempt (memory only) - int64_t nLastCountAttempt; + int64_t nLastCountAttempt{0}; private: //! where knowledge about this address first came from CNetAddr source; //! last successful connection by us - int64_t nLastSuccess; + int64_t nLastSuccess{0}; //! connection attempts since last successful attempt - int nAttempts; + int nAttempts{0}; //! reference count in new sets (memory only) - int nRefCount; + int nRefCount{0}; //! in tried set? (memory only) - bool fInTried; + bool fInTried{false}; //! position in vRandom - int nRandomPos; + int nRandomPos{-1}; friend class CAddrMan; public: - SERIALIZE_METHODS(CAddrInfo, obj) { - READWRITEAS(CAddress, obj); - READWRITE(obj.source); - READWRITE(obj.nLastSuccess); - READWRITE(obj.nAttempts); - } - - void Init() + SERIALIZE_METHODS(CAddrInfo, obj) { - nLastSuccess = 0; - nLastTry = 0; - nLastCountAttempt = 0; - nAttempts = 0; - nRefCount = 0; - fInTried = false; - nRandomPos = -1; + READWRITEAS(CAddress, obj); + READWRITE(obj.source, obj.nLastSuccess, obj.nAttempts); } CAddrInfo(const CAddress &addrIn, const CNetAddr &addrSource) : CAddress(addrIn), source(addrSource) { - Init(); } CAddrInfo() : CAddress(), source() { - Init(); } //! Calculate in which "tried" bucket this entry belongs - int GetTriedBucket(const uint256 &nKey) const; + int GetTriedBucket(const uint256 &nKey, const std::vector &asmap) const; //! Calculate in which "new" bucket this entry belongs, given a certain source - int GetNewBucket(const uint256 &nKey, const CNetAddr& src) const; + int GetNewBucket(const uint256 &nKey, const CNetAddr& src, const std::vector &asmap) const; //! Calculate in which "new" bucket this entry belongs, using its default source - int GetNewBucket(const uint256 &nKey) const + int GetNewBucket(const uint256 &nKey, const std::vector &asmap) const { - return GetNewBucket(nKey, source); + return GetNewBucket(nKey, source, asmap); } //! Calculate in which position of a bucket to store this entry. @@ -103,7 +96,6 @@ class CAddrInfo : public CAddress //! Calculate the relative chance this entry should be given when selecting nodes to connect to double GetChance(int64_t nNow = GetAdjustedTime()) const; - }; /** Stochastic address manager @@ -165,12 +157,6 @@ class CAddrInfo : public CAddress //! how recent a successful connection should be before we allow an address to be evicted from tried #define ADDRMAN_REPLACEMENT_HOURS 4 -//! the maximum percentage of nodes to return in a getaddr call -#define ADDRMAN_GETADDR_MAX_PCT 23 - -//! the maximum number of nodes to return in a getaddr call -#define ADDRMAN_GETADDR_MAX 2500 - //! Convenience #define ADDRMAN_TRIED_BUCKET_COUNT (1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2) #define ADDRMAN_NEW_BUCKET_COUNT (1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2) @@ -179,41 +165,68 @@ class CAddrInfo : public CAddress //! the maximum number of tried addr collisions to store #define ADDRMAN_SET_TRIED_COLLISION_SIZE 10 +//! the maximum time we'll spend trying to resolve a tried table collision, in seconds +static const int64_t ADDRMAN_TEST_WINDOW = 40*60; // 40 minutes + /** * Stochastical (IP) address manager */ class CAddrMan { -private: +friend class CAddrManTest; +protected: //! critical section to protect the inner data structures - mutable CCriticalSection cs; + mutable RecursiveMutex cs; + +private: + //! Serialization versions. + enum Format : uint8_t { + V0_HISTORICAL = 0, //!< historic format, before commit e6b343d88 + V1_DETERMINISTIC = 1, //!< for pre-asmap files + V2_ASMAP = 2, //!< for files including asmap version + V3_BIP155 = 3, //!< same as V2_ASMAP plus addresses are in BIP155 format + }; + + //! The maximum format this software knows it can unserialize. Also, we always serialize + //! in this format. + //! The format (first byte in the serialized stream) can be higher than this and + //! still this software may be able to unserialize the file - if the second byte + //! (see `lowest_compatible` in `Unserialize()`) is less or equal to this. + static constexpr Format FILE_FORMAT = Format::V3_BIP155; + + //! The initial value of a field that is incremented every time an incompatible format + //! change is made (such that old software versions would not be able to parse and + //! understand the new file format). This is 32 because we overtook the "key size" + //! field which was 32 historically. + //! @note Don't increment this. Increment `lowest_compatible` in `Serialize()` instead. + static constexpr uint8_t INCOMPATIBILITY_BASE = 32; //! last used nId - int nIdCount; + int nIdCount GUARDED_BY(cs); //! table with information about all nIds - std::map mapInfo; + std::map mapInfo GUARDED_BY(cs); //! find an nId based on its network address - std::map mapAddr; + std::map mapAddr GUARDED_BY(cs); //! randomly-ordered vector of all nIds - std::vector vRandom; + std::vector vRandom GUARDED_BY(cs); // number of "tried" entries - int nTried; + int nTried GUARDED_BY(cs); //! list of "tried" buckets - int vvTried[ADDRMAN_TRIED_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE]; + int vvTried[ADDRMAN_TRIED_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE] GUARDED_BY(cs); //! number of (unique) "new" entries - int nNew; + int nNew GUARDED_BY(cs); //! list of "new" buckets - int vvNew[ADDRMAN_NEW_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE]; + int vvNew[ADDRMAN_NEW_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE] GUARDED_BY(cs); //! last time Good was called (memory only) - int64_t nLastGood; + int64_t nLastGood GUARDED_BY(cs); //! Holds addrs inserted into tried table that collide with existing entries. Test-before-evict discipline used to resolve these collisions. std::set m_tried_collisions; @@ -226,64 +239,91 @@ class CAddrMan FastRandomContext insecure_rand; //! Find an entry. - CAddrInfo* Find(const CNetAddr& addr, int *pnId = nullptr); + CAddrInfo* Find(const CNetAddr& addr, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs); //! find an entry, creating it if necessary. //! nTime and nServices of the found node are updated, if necessary. - CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = nullptr); + CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Swap two elements in vRandom. - void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2); + void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Move an entry from the "new" table(s) to the "tried" table - void MakeTried(CAddrInfo& info, int nId); + void MakeTried(CAddrInfo& info, int nId) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Delete an entry. It must not be in tried, and have refcount 0. - void Delete(int nId); + void Delete(int nId) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Clear a position in a "new" table. This is the only place where entries are actually deleted. - void ClearNew(int nUBucket, int nUBucketPos); + void ClearNew(int nUBucket, int nUBucketPos) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Mark an entry "good", possibly moving it from "new" to "tried". - void Good_(const CService &addr, bool test_before_evict, int64_t time); + void Good_(const CService &addr, bool test_before_evict, int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Add an entry to the "new" table. - bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty); + bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Mark an entry as attempted to connect. - void Attempt_(const CService &addr, bool fCountFailure, int64_t nTime); + void Attempt_(const CService &addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Select an address to connect to, if newOnly is set to true, only the new table is selected from. - CAddrInfo Select_(bool newOnly); + CAddrInfo Select_(bool newOnly) EXCLUSIVE_LOCKS_REQUIRED(cs); //! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions. - void ResolveCollisions_(); + void ResolveCollisions_() EXCLUSIVE_LOCKS_REQUIRED(cs); //! Return a random to-be-evicted tried table address. - CAddrInfo SelectTriedCollision_(); - - //! Wraps GetRandInt to allow tests to override RandomInt and make it determinismistic. - virtual int RandomInt(int nMax); + CAddrInfo SelectTriedCollision_() EXCLUSIVE_LOCKS_REQUIRED(cs); #ifdef DEBUG_ADDRMAN //! Perform consistency check. Returns an error code or zero. - int Check_(); + int Check_() EXCLUSIVE_LOCKS_REQUIRED(cs); #endif //! Select several addresses at once. - void GetAddr_(std::vector &vAddr); + void GetAddr_(std::vector &vAddr, size_t max_addresses, size_t max_pct) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Mark an entry as currently-connected-to. - void Connected_(const CService &addr, int64_t nTime); + void Connected_(const CService &addr, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs); //! Update an entry's service bits. - void SetServices_(const CService &addr, ServiceFlags nServices); + void SetServices_(const CService &addr, ServiceFlags nServices) EXCLUSIVE_LOCKS_REQUIRED(cs); public: + // Compressed IP->ASN mapping, loaded from a file when a node starts. + // Should be always empty if no file was provided. + // This mapping is then used for bucketing nodes in Addrman. + // + // If asmap is provided, nodes will be bucketed by + // AS they belong to, in order to make impossible for a node + // to connect to several nodes hosted in a single AS. + // This is done in response to Erebus attack, but also to generally + // diversify the connections every node creates, + // especially useful when a large fraction of nodes + // operate under a couple of cloud providers. + // + // If a new asmap was provided, the existing records + // would be re-bucketed accordingly. + std::vector m_asmap; + + // Read asmap from provided binary file + static std::vector DecodeAsmap(fs::path path); + + /** - * serialized format: - * * version byte (currently 1) - * * 0x20 + nKey (serialized as if it were a vector, for backward compatibility) + * Serialized format. + * * format version byte (@see `Format`) + * * lowest compatible format version byte. This is used to help old software decide + * whether to parse the file. For example: + * * Pocketcoin Core version N knows how to parse up to format=3. If a new format=4 is + * introduced in version N+1 that is compatible with format=3 and it is known that + * version N will be able to parse it, then version N+1 will write + * (format=4, lowest_compatible=3) in the first two bytes of the file, and so + * version N will still try to parse it. + * * Pocketcoin Core version N+2 introduces a new incompatible format=5. It will write + * (format=5, lowest_compatible=5) and so any versions that do not know how to parse + * format=5 will not try to read the file. + * * nKey * * nNew * * nTried * * number of "new" buckets XOR 2**30 @@ -306,17 +346,25 @@ class CAddrMan * This format is more complex, but significantly smaller (at most 1.5 MiB), and supports * changes to the ADDRMAN_ parameters without breaking the on-disk structure. * - * We don't use ADD_SERIALIZE_METHODS since the serialization and deserialization code has + * We don't use SERIALIZE_METHODS since the serialization and deserialization code has * very little in common. */ - template - void Serialize(Stream &s) const + template + void Serialize(Stream& s_) const { LOCK(cs); - unsigned char nVersion = 1; - s << nVersion; - s << ((unsigned char)32); + // Always serialize in the latest version (FILE_FORMAT). + + OverrideStream s(&s_, s_.GetType(), s_.GetVersion() | ADDRV2_FORMAT); + + s << static_cast(FILE_FORMAT); + + // Increment `lowest_compatible` iff a newly introduced format is incompatible with + // the previous one. + static constexpr uint8_t lowest_compatible = Format::V3_BIP155; + s << static_cast(INCOMPATIBILITY_BASE + lowest_compatible); + s << nKey; s << nNew; s << nTried; @@ -357,26 +405,50 @@ class CAddrMan } } } + // Store asmap version after bucket entries so that it + // can be ignored by older clients for backward compatibility. + uint256 asmap_version; + if (m_asmap.size() != 0) { + asmap_version = SerializeHash(m_asmap); + } + s << asmap_version; } - template - void Unserialize(Stream& s) + template + void Unserialize(Stream& s_) { LOCK(cs); Clear(); - unsigned char nVersion; - s >> nVersion; - unsigned char nKeySize; - s >> nKeySize; - if (nKeySize != 32) throw std::ios_base::failure("Incorrect keysize in addrman deserialization"); + Format format; + s_ >> Using>(format); + + int stream_version = s_.GetVersion(); + if (format >= Format::V3_BIP155) { + // Add ADDRV2_FORMAT to the version so that the CNetAddr and CAddress + // unserialize methods know that an address in addrv2 format is coming. + stream_version |= ADDRV2_FORMAT; + } + + OverrideStream s(&s_, s_.GetType(), stream_version); + + uint8_t compat; + s >> compat; + const uint8_t lowest_compatible = compat - INCOMPATIBILITY_BASE; + if (lowest_compatible > FILE_FORMAT) { + throw std::ios_base::failure(strprintf( + "Unsupported format of addrman database: %u. It is compatible with formats >=%u, " + "but the maximum supported by this version of %s is %u.", + format, lowest_compatible, PACKAGE_NAME, static_cast(FILE_FORMAT))); + } + s >> nKey; s >> nNew; s >> nTried; int nUBuckets = 0; s >> nUBuckets; - if (nVersion != 0) { + if (format >= Format::V1_DETERMINISTIC) { nUBuckets ^= (1 << 30); } @@ -395,16 +467,6 @@ class CAddrMan mapAddr[info] = n; info.nRandomPos = vRandom.size(); vRandom.push_back(n); - if (nVersion != 1 || nUBuckets != ADDRMAN_NEW_BUCKET_COUNT) { - // In case the new table data cannot be used (nVersion unknown, or bucket count wrong), - // immediately try to give them a reference based on their primary source address. - int nUBucket = info.GetNewBucket(nKey); - int nUBucketPos = info.GetBucketPosition(nKey, true, nUBucket); - if (vvNew[nUBucket][nUBucketPos] == -1) { - vvNew[nUBucket][nUBucketPos] = n; - info.nRefCount++; - } - } } nIdCount = nNew; @@ -413,7 +475,7 @@ class CAddrMan for (int n = 0; n < nTried; n++) { CAddrInfo info; s >> info; - int nKBucket = info.GetTriedBucket(nKey); + int nKBucket = info.GetTriedBucket(nKey, m_asmap); int nKBucketPos = info.GetBucketPosition(nKey, false, nKBucket); if (vvTried[nKBucket][nKBucketPos] == -1) { info.nRandomPos = vRandom.size(); @@ -429,7 +491,9 @@ class CAddrMan } nTried -= nLost; - // Deserialize positions in the new table (if possible). + // Store positions in the new table buckets to apply later (if possible). + std::map entryToBucket; // Represents which entry belonged to which bucket when serializing + for (int bucket = 0; bucket < nUBuckets; bucket++) { int nSize = 0; s >> nSize; @@ -437,12 +501,38 @@ class CAddrMan int nIndex = 0; s >> nIndex; if (nIndex >= 0 && nIndex < nNew) { - CAddrInfo &info = mapInfo[nIndex]; - int nUBucketPos = info.GetBucketPosition(nKey, true, bucket); - if (nVersion == 1 && nUBuckets == ADDRMAN_NEW_BUCKET_COUNT && vvNew[bucket][nUBucketPos] == -1 && info.nRefCount < ADDRMAN_NEW_BUCKETS_PER_ADDRESS) { - info.nRefCount++; - vvNew[bucket][nUBucketPos] = nIndex; - } + entryToBucket[nIndex] = bucket; + } + } + } + + uint256 supplied_asmap_version; + if (m_asmap.size() != 0) { + supplied_asmap_version = SerializeHash(m_asmap); + } + uint256 serialized_asmap_version; + if (format >= Format::V2_ASMAP) { + s >> serialized_asmap_version; + } + + for (int n = 0; n < nNew; n++) { + CAddrInfo &info = mapInfo[n]; + int bucket = entryToBucket[n]; + int nUBucketPos = info.GetBucketPosition(nKey, true, bucket); + if (format >= Format::V2_ASMAP && nUBuckets == ADDRMAN_NEW_BUCKET_COUNT && vvNew[bucket][nUBucketPos] == -1 && + info.nRefCount < ADDRMAN_NEW_BUCKETS_PER_ADDRESS && serialized_asmap_version == supplied_asmap_version) { + // Bucketing has not changed, using existing bucket positions for the new table + vvNew[bucket][nUBucketPos] = n; + info.nRefCount++; + } else { + // In case the new table data cannot be used (format unknown, bucket count wrong or new asmap), + // try to give them a reference based on their primary source address. + LogPrint(BCLog::ADDRMAN, "Bucketing method was updated, re-bucketing addrman entries from disk\n"); + bucket = info.GetNewBucket(nKey, m_asmap); + nUBucketPos = info.GetBucketPosition(nKey, true, bucket); + if (vvNew[bucket][nUBucketPos] == -1) { + vvNew[bucket][nUBucketPos] = n; + info.nRefCount++; } } } @@ -469,7 +559,7 @@ class CAddrMan { LOCK(cs); std::vector().swap(vRandom); - nKey = GetRandHash(); + nKey = insecure_rand.rand256(); for (size_t bucket = 0; bucket < ADDRMAN_NEW_BUCKET_COUNT; bucket++) { for (size_t entry = 0; entry < ADDRMAN_BUCKET_SIZE; entry++) { vvNew[bucket][entry] = -1; @@ -604,13 +694,13 @@ class CAddrMan } //! Return a bunch of addresses, selected at random. - std::vector GetAddr() + std::vector GetAddr(size_t max_addresses, size_t max_pct) { Check(); std::vector vAddr; { LOCK(cs); - GetAddr_(vAddr); + GetAddr_(vAddr, max_addresses, max_pct); } Check(); return vAddr; diff --git a/src/amount.h b/src/amount.h index 8e65f1a6f..422f9828b 100644 --- a/src/amount.h +++ b/src/amount.h @@ -12,7 +12,6 @@ typedef int64_t CAmount; static const CAmount COIN = 100000000; -static const CAmount CENT = 1000000; /** No amount larger than this (in satoshi) is valid. * diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index 774636f9c..eab2be4e3 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -6,11 +6,8 @@ #include #include -#include #include -#include -#include template base_uint::base_uint(const std::string& str) @@ -176,7 +173,7 @@ unsigned int base_uint::bits() const for (int pos = WIDTH - 1; pos >= 0; pos--) { if (pn[pos]) { for (int nbits = 31; nbits > 0; nbits--) { - if (pn[pos] & 1 << nbits) + if (pn[pos] & 1U << nbits) return 32 * pos + nbits + 1; } return 32 * pos + 1; diff --git a/src/arith_uint256.h b/src/arith_uint256.h index 2c577926d..37f9bcf89 100644 --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -6,12 +6,11 @@ #ifndef POCKETCOIN_ARITH_UINT256_H #define POCKETCOIN_ARITH_UINT256_H -#include #include +#include #include #include #include -#include class uint256; @@ -189,7 +188,7 @@ class base_uint { // prefix operator int i = 0; - while (i < WIDTH && --pn[i] == (uint32_t)-1) + while (i < WIDTH && --pn[i] == std::numeric_limits::max()) i++; return *this; } diff --git a/src/attributes.h b/src/attributes.h index 5ecbb5b02..03345e2f0 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -7,6 +7,19 @@ #ifndef POCKETCOIN_ATTRIBUTES_H #define POCKETCOIN_ATTRIBUTES_H +#if defined(__has_cpp_attribute) +# if __has_cpp_attribute(nodiscard) +# define NODISCARD [[nodiscard]] +# endif +#endif +#ifndef NODISCARD +# if defined(_MSC_VER) && _MSC_VER >= 1700 +# define NODISCARD _Check_return_ +# else +# define NODISCARD __attribute__((warn_unused_result)) +# endif +#endif + #if defined(__clang__) # if __has_attribute(lifetimebound) # define LIFETIMEBOUND [[clang::lifetimebound]] @@ -17,4 +30,4 @@ # define LIFETIMEBOUND #endif -#endif // POCETCOIN_ATTRIBUTES_H \ No newline at end of file +#endif // POCKETCOIN_ATTRIBUTES_H \ No newline at end of file diff --git a/src/banman.cpp b/src/banman.cpp new file mode 100644 index 000000000..d45fee1bb --- /dev/null +++ b/src/banman.cpp @@ -0,0 +1,213 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2019 The Bitcoin Core developers +// Copyright (c) 2021 The Pocketcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include +#include +#include +#include +#include + + +BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time) + : m_client_interface(client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time) +{ + if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist...").translated); + + int64_t n_start = GetTimeMillis(); + m_is_dirty = false; + banmap_t banmap; + if (m_ban_db.Read(banmap)) { + SetBanned(banmap); // thread save setter + SetBannedSetDirty(false); // no need to write down, just read data + SweepBanned(); // sweep out unused entries + + LogPrint(BCLog::NET, "Loaded %d banned node ips/subnets from banlist.dat %dms\n", + m_banned.size(), GetTimeMillis() - n_start); + } else { + LogPrintf("Invalid or missing banlist.dat; recreating\n"); + SetBannedSetDirty(true); // force write + DumpBanlist(); + } +} + +BanMan::~BanMan() +{ + DumpBanlist(); +} + +void BanMan::DumpBanlist() +{ + SweepBanned(); // clean unused entries (if bantime has expired) + + if (!BannedSetIsDirty()) return; + + int64_t n_start = GetTimeMillis(); + + banmap_t banmap; + GetBanned(banmap); + if (m_ban_db.Write(banmap)) { + SetBannedSetDirty(false); + } + + LogPrint(BCLog::NET, "Flushed %d banned node ips/subnets to banlist.dat %dms\n", + banmap.size(), GetTimeMillis() - n_start); +} + +void BanMan::ClearBanned() +{ + { + LOCK(m_cs_banned); + m_banned.clear(); + m_is_dirty = true; + } + DumpBanlist(); //store banlist to disk + if (m_client_interface) m_client_interface->BannedListChanged(); +} + +bool BanMan::IsDiscouraged(const CNetAddr& net_addr) +{ + LOCK(m_cs_banned); + return m_discouraged.contains(net_addr.GetAddrBytes()); +} + +bool BanMan::IsBanned(const CNetAddr& net_addr) +{ + auto current_time = GetTime(); + LOCK(m_cs_banned); + for (const auto& it : m_banned) { + CSubNet sub_net = it.first; + CBanEntry ban_entry = it.second; + + if (current_time < ban_entry.nBanUntil && sub_net.Match(net_addr)) { + return true; + } + } + return false; +} + +bool BanMan::IsBanned(const CSubNet& sub_net) +{ + auto current_time = GetTime(); + LOCK(m_cs_banned); + banmap_t::iterator i = m_banned.find(sub_net); + if (i != m_banned.end()) { + CBanEntry ban_entry = (*i).second; + if (current_time < ban_entry.nBanUntil) { + return true; + } + } + return false; +} + +void BanMan::Ban(const CNetAddr& net_addr, int64_t ban_time_offset, bool since_unix_epoch) +{ + CSubNet sub_net(net_addr); + Ban(sub_net, ban_time_offset, since_unix_epoch); +} + +void BanMan::Discourage(const CNetAddr& net_addr) +{ + LOCK(m_cs_banned); + m_discouraged.insert(net_addr.GetAddrBytes()); +} + +void BanMan::Ban(const CSubNet& sub_net, int64_t ban_time_offset, bool since_unix_epoch) +{ + CBanEntry ban_entry(GetTime()); + + int64_t normalized_ban_time_offset = ban_time_offset; + bool normalized_since_unix_epoch = since_unix_epoch; + if (ban_time_offset <= 0) { + normalized_ban_time_offset = m_default_ban_time; + normalized_since_unix_epoch = false; + } + ban_entry.nBanUntil = (normalized_since_unix_epoch ? 0 : GetTime()) + normalized_ban_time_offset; + + { + LOCK(m_cs_banned); + if (m_banned[sub_net].nBanUntil < ban_entry.nBanUntil) { + m_banned[sub_net] = ban_entry; + m_is_dirty = true; + } else + return; + } + if (m_client_interface) m_client_interface->BannedListChanged(); + + //store banlist to disk immediately + DumpBanlist(); +} + +bool BanMan::Unban(const CNetAddr& net_addr) +{ + CSubNet sub_net(net_addr); + return Unban(sub_net); +} + +bool BanMan::Unban(const CSubNet& sub_net) +{ + { + LOCK(m_cs_banned); + if (m_banned.erase(sub_net) == 0) return false; + m_is_dirty = true; + } + if (m_client_interface) m_client_interface->BannedListChanged(); + DumpBanlist(); //store banlist to disk immediately + return true; +} + +void BanMan::GetBanned(banmap_t& banmap) +{ + LOCK(m_cs_banned); + // Sweep the banlist so expired bans are not returned + SweepBanned(); + banmap = m_banned; //create a thread safe copy +} + +void BanMan::SetBanned(const banmap_t& banmap) +{ + LOCK(m_cs_banned); + m_banned = banmap; + m_is_dirty = true; +} + +void BanMan::SweepBanned() +{ + int64_t now = GetTime(); + bool notify_ui = false; + { + LOCK(m_cs_banned); + banmap_t::iterator it = m_banned.begin(); + while (it != m_banned.end()) { + CSubNet sub_net = (*it).first; + CBanEntry ban_entry = (*it).second; + if (!sub_net.IsValid() || now > ban_entry.nBanUntil) { + m_banned.erase(it++); + m_is_dirty = true; + notify_ui = true; + LogPrint(BCLog::NET, "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, sub_net.ToString()); + } else + ++it; + } + } + // update UI + if (notify_ui && m_client_interface) { + m_client_interface->BannedListChanged(); + } +} + +bool BanMan::BannedSetIsDirty() +{ + LOCK(m_cs_banned); + return m_is_dirty; +} + +void BanMan::SetBannedSetDirty(bool dirty) +{ + LOCK(m_cs_banned); //reuse m_banned lock for the m_is_dirty flag + m_is_dirty = dirty; +} diff --git a/src/banman.h b/src/banman.h new file mode 100644 index 000000000..c6afbb8f3 --- /dev/null +++ b/src/banman.h @@ -0,0 +1,99 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2020 The Bitcoin Core developers +// Copyright (c) 2021 The Pocketcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef POCKETCOIN_BANMAN_H +#define POCKETCOIN_BANMAN_H + +#include +#include +#include +#include // For banmap_t +#include + +#include +#include +#include + +// NOTE: When adjusting this, update rpcnet:setban's help ("24h") +static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban +// How often to dump addresses to banlist.dat +static constexpr std::chrono::minutes DUMP_BANS_INTERVAL{15}; + +class CClientUIInterface; +class CNetAddr; +class CSubNet; + +// Banman manages two related but distinct concepts: +// +// 1. Banning. This is configured manually by the user, through the setban RPC. +// If an address or subnet is banned, we never accept incoming connections from +// it and never create outgoing connections to it. We won't gossip its address +// to other peers in addr messages. Banned addresses and subnets are stored to +// banlist.dat on shutdown and reloaded on startup. Banning can be used to +// prevent connections with spy nodes or other griefers. +// +// 2. Discouragement. If a peer misbehaves enough (see Misbehaving() in +// net_processing.cpp), we'll mark that address as discouraged. We still allow +// incoming connections from them, but they're preferred for eviction when +// we receive new incoming connections. We never make outgoing connections to +// them, and do not gossip their address to other peers. This is implemented as +// a bloom filter. We can (probabilistically) test for membership, but can't +// list all discouraged addresses or unmark them as discouraged. Discouragement +// can prevent our limited connection slots being used up by incompatible +// or broken peers. +// +// Neither banning nor discouragement are protections against denial-of-service +// attacks, since if an attacker has a way to waste our resources and we +// disconnect from them and ban that address, it's trivial for them to +// reconnect from another IP address. +// +// Attempting to automatically disconnect or ban any class of peer carries the +// risk of splitting the network. For example, if we banned/disconnected for a +// transaction that fails a policy check and a future version changes the +// policy check so the transaction is accepted, then that transaction could +// cause the network to split between old nodes and new nodes. + +class BanMan +{ +public: + ~BanMan(); + BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time); + void Ban(const CNetAddr& net_addr, int64_t ban_time_offset = 0, bool since_unix_epoch = false); + void Ban(const CSubNet& sub_net, int64_t ban_time_offset = 0, bool since_unix_epoch = false); + void Discourage(const CNetAddr& net_addr); + void ClearBanned(); + + //! Return whether net_addr is banned + bool IsBanned(const CNetAddr& net_addr); + + //! Return whether sub_net is exactly banned + bool IsBanned(const CSubNet& sub_net); + + //! Return whether net_addr is discouraged. + bool IsDiscouraged(const CNetAddr& net_addr); + + bool Unban(const CNetAddr& net_addr); + bool Unban(const CSubNet& sub_net); + void GetBanned(banmap_t& banmap); + void DumpBanlist(); + +private: + void SetBanned(const banmap_t& banmap); + bool BannedSetIsDirty(); + //!set the "dirty" flag for the banlist + void SetBannedSetDirty(bool dirty = true); + //!clean unused entries (if bantime has expired) + void SweepBanned(); + + RecursiveMutex m_cs_banned; + banmap_t m_banned GUARDED_BY(m_cs_banned); + bool m_is_dirty GUARDED_BY(m_cs_banned); + CClientUIInterface* m_client_interface = nullptr; + CBanDB m_ban_db; + const int64_t m_default_ban_time; + CRollingBloomFilter m_discouraged GUARDED_BY(m_cs_banned) {50000, 0.000001}; +}; + +#endif diff --git a/src/base58.cpp b/src/base58.cpp index 926123621..2f449ad62 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -6,10 +6,14 @@ #include #include +#include +#include #include #include +#include + /** All alphanumeric characters except for "0", "I", "O", and "l" */ static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; static const int8_t mapBase58[256] = { @@ -31,16 +35,17 @@ static const int8_t mapBase58[256] = { -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, }; -bool DecodeBase58(const char* psz, std::vector& vch) +NODISCARD static bool DecodeBase58(const char* psz, std::vector& vch, int max_ret_len) { // Skip leading spaces. - while (*psz && isspace(*psz)) + while (*psz && IsSpace(*psz)) psz++; // Skip and count leading '1's. int zeroes = 0; int length = 0; while (*psz == '1') { zeroes++; + if (zeroes > max_ret_len) return false; psz++; } // Allocate enough space in big-endian base256 representation. @@ -48,7 +53,7 @@ bool DecodeBase58(const char* psz, std::vector& vch) std::vector b256(size); // Process the characters. static_assert(sizeof(mapBase58)/sizeof(mapBase58[0]) == 256, "mapBase58.size() should be 256"); // guarantee not out of range - while (*psz && !isspace(*psz)) { + while (*psz && !IsSpace(*psz)) { // Decode base58 character int carry = mapBase58[(uint8_t)*psz]; if (carry == -1) // Invalid b58 character @@ -61,17 +66,16 @@ bool DecodeBase58(const char* psz, std::vector& vch) } assert(carry == 0); length = i; + if (length + zeroes > max_ret_len) return false; psz++; } // Skip trailing spaces. - while (isspace(*psz)) + while (IsSpace(*psz)) psz++; if (*psz != 0) return false; // Skip leading zeroes in b256. std::vector::iterator it = b256.begin() + (size - length); - while (it != b256.end() && *it == 0) - it++; // Copy result into output vector. vch.reserve(zeroes + (b256.end() - it)); vch.assign(zeroes, 0x00); @@ -80,21 +84,21 @@ bool DecodeBase58(const char* psz, std::vector& vch) return true; } -std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) +std::string EncodeBase58(Span input) { // Skip & count leading zeroes. int zeroes = 0; int length = 0; - while (pbegin != pend && *pbegin == 0) { - pbegin++; + while (input.size() > 0 && input[0] == 0) { + input = input.subspan(1); zeroes++; } // Allocate enough space in big-endian base58 representation. - int size = (pend - pbegin) * 138 / 100 + 1; // log(256) / log(58), rounded up. + int size = input.size() * 138 / 100 + 1; // log(256) / log(58), rounded up. std::vector b58(size); // Process the bytes. - while (pbegin != pend) { - int carry = *pbegin; + while (input.size() > 0) { + int carry = input[0]; int i = 0; // Apply "b58 = b58 * 256 + ch". for (std::vector::reverse_iterator it = b58.rbegin(); (carry != 0 || i < length) && (it != b58.rend()); it++, i++) { @@ -105,7 +109,7 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) assert(carry == 0); length = i; - pbegin++; + input = input.subspan(1); } // Skip leading zeroes in base58 result. std::vector::iterator it = b58.begin() + (size - length); @@ -120,34 +124,32 @@ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) return str; } -std::string EncodeBase58(const std::vector& vch) -{ - return EncodeBase58(vch.data(), vch.data() + vch.size()); -} - -bool DecodeBase58(const std::string& str, std::vector& vchRet) +bool DecodeBase58(const std::string& str, std::vector& vchRet, int max_ret_len) { - return DecodeBase58(str.c_str(), vchRet); + if (!ValidAsCString(str)) { + return false; + } + return DecodeBase58(str.c_str(), vchRet, max_ret_len); } -std::string EncodeBase58Check(const std::vector& vchIn) +std::string EncodeBase58Check(Span input) { // add 4-byte hash check to the end - std::vector vch(vchIn); - uint256 hash = Hash(vch.begin(), vch.end()); + std::vector vch(input.begin(), input.end()); + uint256 hash = Hash(vch); vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4); return EncodeBase58(vch); } -bool DecodeBase58Check(const char* psz, std::vector& vchRet) +NODISCARD static bool DecodeBase58Check(const char* psz, std::vector& vchRet, int max_ret_len) { - if (!DecodeBase58(psz, vchRet) || + if (!DecodeBase58(psz, vchRet, max_ret_len > std::numeric_limits::max() - 4 ? std::numeric_limits::max() : max_ret_len + 4) || (vchRet.size() < 4)) { vchRet.clear(); return false; } // re-calculate the checksum, ensure it matches the included 4-byte checksum - uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4); + uint256 hash = Hash(MakeSpan(vchRet).first(vchRet.size() - 4)); if (memcmp(&hash, &vchRet[vchRet.size() - 4], 4) != 0) { vchRet.clear(); return false; @@ -156,7 +158,10 @@ bool DecodeBase58Check(const char* psz, std::vector& vchRet) return true; } -bool DecodeBase58Check(const std::string& str, std::vector& vchRet) +bool DecodeBase58Check(const std::string& str, std::vector& vchRet, int max_ret) { - return DecodeBase58Check(str.c_str(), vchRet); + if (!ValidAsCString(str)) { + return false; + } + return DecodeBase58Check(str.c_str(), vchRet, max_ret); } diff --git a/src/base58.h b/src/base58.h index a5de3d519..e39df2d08 100644 --- a/src/base58.h +++ b/src/base58.h @@ -14,48 +14,32 @@ #ifndef POCKETCOIN_BASE58_H #define POCKETCOIN_BASE58_H +#include +#include + #include #include /** - * Encode a byte sequence as a base58-encoded string. - * pbegin and pend cannot be nullptr, unless both are. - */ -std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend); - -/** - * Encode a byte vector as a base58-encoded string - */ -std::string EncodeBase58(const std::vector& vch); - -/** - * Decode a base58-encoded string (psz) into a byte vector (vchRet). - * return true if decoding is successful. - * psz cannot be nullptr. + * Encode a byte span as a base58-encoded string */ -bool DecodeBase58(const char* psz, std::vector& vchRet); +std::string EncodeBase58(Span input); /** * Decode a base58-encoded string (str) into a byte vector (vchRet). * return true if decoding is successful. */ -bool DecodeBase58(const std::string& str, std::vector& vchRet); - -/** - * Encode a byte vector into a base58-encoded string, including checksum - */ -std::string EncodeBase58Check(const std::vector& vchIn); +NODISCARD bool DecodeBase58(const std::string& str, std::vector& vchRet, int max_ret_len); /** - * Decode a base58-encoded string (psz) that includes a checksum into a byte - * vector (vchRet), return true if decoding is successful + * Encode a byte span into a base58-encoded string, including checksum */ -bool DecodeBase58Check(const char* psz, std::vector& vchRet); +std::string EncodeBase58Check(Span input); /** * Decode a base58-encoded string (str) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful */ -bool DecodeBase58Check(const std::string& str, std::vector& vchRet); +NODISCARD bool DecodeBase58Check(const std::string& str, std::vector& vchRet, int max_ret_len); #endif // POCKETCOIN_BASE58_H diff --git a/src/bech32.cpp b/src/bech32.cpp index d6b29391a..32aad0701 100644 --- a/src/bech32.cpp +++ b/src/bech32.cpp @@ -3,16 +3,22 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include + +#include + +namespace bech32 +{ namespace { typedef std::vector data; -/** The Bech32 character set for encoding. */ +/** The Bech32 and Bech32m character set for encoding. */ const char* CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; -/** The Bech32 character set for decoding. */ +/** The Bech32 and Bech32m character set for decoding. */ const int8_t CHARSET_REV[128] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -24,11 +30,10 @@ const int8_t CHARSET_REV[128] = { 1, 0, 3, 16, 11, 28, 12, 14, 6, 4, 2, -1, -1, -1, -1, -1 }; -/** Concatenate two byte arrays. */ -data Cat(data x, const data& y) -{ - x.insert(x.end(), y.begin(), y.end()); - return x; +/* Determine the final constant to use for the specified encoding. */ +uint32_t EncodingConstant(Encoding encoding) { + assert(encoding == Encoding::BECH32 || encoding == Encoding::BECH32M); + return encoding == Encoding::BECH32 ? 1 : 0x2bc830a3; } /** This function will compute what 6 5-bit values to XOR into the last 6 input values, in order to @@ -58,7 +63,7 @@ uint32_t PolyMod(const data& v) // During the course of the loop below, `c` contains the bitpacked coefficients of the // polynomial constructed from just the values of v that were processed so far, mod g(x). In - // the above example, `c` initially corresponds to 1 mod (x), and after processing 2 inputs of + // the above example, `c` initially corresponds to 1 mod g(x), and after processing 2 inputs of // v, it corresponds to x^2 + v0*x + v1 mod g(x). As 1 mod g(x) = 1, that is the starting value // for `c`. uint32_t c = 1; @@ -115,21 +120,24 @@ data ExpandHRP(const std::string& hrp) } /** Verify a checksum. */ -bool VerifyChecksum(const std::string& hrp, const data& values) +Encoding VerifyChecksum(const std::string& hrp, const data& values) { // PolyMod computes what value to xor into the final values to make the checksum 0. However, // if we required that the checksum was 0, it would be the case that appending a 0 to a valid // list of values would result in a new valid list. For that reason, Bech32 requires the - // resulting checksum to be 1 instead. - return PolyMod(Cat(ExpandHRP(hrp), values)) == 1; + // resulting checksum to be 1 instead. In Bech32m, this constant was amended. + const uint32_t check = PolyMod(Cat(ExpandHRP(hrp), values)); + if (check == EncodingConstant(Encoding::BECH32)) return Encoding::BECH32; + if (check == EncodingConstant(Encoding::BECH32M)) return Encoding::BECH32M; + return Encoding::INVALID; } /** Create a checksum. */ -data CreateChecksum(const std::string& hrp, const data& values) +data CreateChecksum(Encoding encoding, const std::string& hrp, const data& values) { data enc = Cat(ExpandHRP(hrp), values); enc.resize(enc.size() + 6); // Append 6 zeroes - uint32_t mod = PolyMod(enc) ^ 1; // Determine what to XOR into those 6 zeroes. + uint32_t mod = PolyMod(enc) ^ EncodingConstant(encoding); // Determine what to XOR into those 6 zeroes. data ret(6); for (size_t i = 0; i < 6; ++i) { // Convert the 5-bit groups in mod to checksum values. @@ -140,12 +148,13 @@ data CreateChecksum(const std::string& hrp, const data& values) } // namespace -namespace bech32 -{ - -/** Encode a Bech32 string. */ -std::string Encode(const std::string& hrp, const data& values) { - data checksum = CreateChecksum(hrp, values); +/** Encode a Bech32 or Bech32m string. */ +std::string Encode(Encoding encoding, const std::string& hrp, const data& values) { + // First ensure that the HRP is all lowercase. BIP-173 and BIP350 require an encoder + // to return a lowercase Bech32/Bech32m string, but if given an uppercase HRP, the + // result will always be invalid. + for (const char& c : hrp) assert(c < 'A' || c > 'Z'); + data checksum = CreateChecksum(encoding, hrp, values); data combined = Cat(values, checksum); std::string ret = hrp + '1'; ret.reserve(ret.size() + combined.size()); @@ -155,8 +164,8 @@ std::string Encode(const std::string& hrp, const data& values) { return ret; } -/** Decode a Bech32 string. */ -std::pair Decode(const std::string& str) { +/** Decode a Bech32 or Bech32m string. */ +DecodeResult Decode(const std::string& str) { bool lower = false, upper = false; for (size_t i = 0; i < str.size(); ++i) { unsigned char c = str[i]; @@ -183,10 +192,9 @@ std::pair Decode(const std::string& str) { for (size_t i = 0; i < pos; ++i) { hrp += LowerCase(str[i]); } - if (!VerifyChecksum(hrp, values)) { - return {}; - } - return {hrp, data(values.begin(), values.end() - 6)}; + Encoding result = VerifyChecksum(hrp, values); + if (result == Encoding::INVALID) return {}; + return {result, std::move(hrp), data(values.begin(), values.end() - 6)}; } } // namespace bech32 diff --git a/src/bech32.h b/src/bech32.h index 96f887c28..11a313feb 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -2,12 +2,13 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -// Bech32 is a string encoding format used in newer address types. -// The output consists of a human-readable part (alphanumeric), a -// separator character (1), and a base32 data section, the last -// 6 characters of which are a checksum. +// Bech32 and Bech32m are string encoding formats used in newer +// address types. The outputs consist of a human-readable part +// (alphanumeric), a separator character (1), and a base32 data +// section, the last 6 characters of which are a checksum. The +// module is namespaced under bech32 for historical reasons. // -// For more information, see BIP 173. +// For more information, see BIP 173 and BIP 350. #ifndef POCKETCOIN_BECH32_H #define POCKETCOIN_BECH32_H @@ -19,11 +20,29 @@ namespace bech32 { -/** Encode a Bech32 string. Returns the empty string in case of failure. */ -std::string Encode(const std::string& hrp, const std::vector& values); +enum class Encoding { + INVALID, //!< Failed decoding -/** Decode a Bech32 string. Returns (hrp, data). Empty hrp means failure. */ -std::pair> Decode(const std::string& str); + BECH32, //!< Bech32 encoding as defined in BIP173 + BECH32M, //!< Bech32m encoding as defined in BIP350 +}; + +/** Encode a Bech32 or Bech32m string. If hrp contains uppercase characters, this will cause an + * assertion error. Encoding must be one of BECH32 or BECH32M. */ +std::string Encode(Encoding encoding, const std::string& hrp, const std::vector& values); + +struct DecodeResult +{ + Encoding encoding; //!< What encoding was detected in the result; Encoding::INVALID if failed. + std::string hrp; //!< The human readable part + std::vector data; //!< The payload (excluding checksum) + + DecodeResult() : encoding(Encoding::INVALID) {} + DecodeResult(Encoding enc, std::string&& h, std::vector&& d) : encoding(enc), hrp(std::move(h)), data(std::move(d)) {} +}; + +/** Decode a Bech32 or Bech32m string. */ +DecodeResult Decode(const std::string& str); } // namespace bech32 diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp new file mode 100644 index 000000000..0ce4815a3 --- /dev/null +++ b/src/bench/addrman.cpp @@ -0,0 +1,140 @@ +// Copyright (c) 2020-2020 The Pocketcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include +#include + +#include + +/* A "source" is a source address from which we have received a bunch of other addresses. */ + +static constexpr size_t NUM_SOURCES = 64; +static constexpr size_t NUM_ADDRESSES_PER_SOURCE = 256; + +static std::vector g_sources; +static std::vector> g_addresses; + +static void CreateAddresses() +{ + if (g_sources.size() > 0) { // already created + return; + } + + FastRandomContext rng(uint256(std::vector(32, 123))); + + auto randAddr = [&rng]() { + in6_addr addr; + memcpy(&addr, rng.randbytes(sizeof(addr)).data(), sizeof(addr)); + + uint16_t port; + memcpy(&port, rng.randbytes(sizeof(port)).data(), sizeof(port)); + if (port == 0) { + port = 1; + } + + CAddress ret(CService(addr, port), NODE_NETWORK); + + ret.nTime = GetAdjustedTime(); + + return ret; + }; + + for (size_t source_i = 0; source_i < NUM_SOURCES; ++source_i) { + g_sources.emplace_back(randAddr()); + g_addresses.emplace_back(); + for (size_t addr_i = 0; addr_i < NUM_ADDRESSES_PER_SOURCE; ++addr_i) { + g_addresses[source_i].emplace_back(randAddr()); + } + } +} + +static void AddAddressesToAddrMan(CAddrMan& addrman) +{ + for (size_t source_i = 0; source_i < NUM_SOURCES; ++source_i) { + addrman.Add(g_addresses[source_i], g_sources[source_i]); + } +} + +static void FillAddrMan(CAddrMan& addrman) +{ + CreateAddresses(); + + AddAddressesToAddrMan(addrman); +} + +/* Benchmarks */ + +static void AddrManAdd(benchmark::Bench& bench) +{ + CreateAddresses(); + + CAddrMan addrman; + + bench.run([&] { + AddAddressesToAddrMan(addrman); + addrman.Clear(); + }); +} + +static void AddrManSelect(benchmark::Bench& bench) +{ + CAddrMan addrman; + + FillAddrMan(addrman); + + bench.run([&] { + const auto& address = addrman.Select(); + assert(address.GetPort() > 0); + }); +} + +static void AddrManGetAddr(benchmark::Bench& bench) +{ + CAddrMan addrman; + + FillAddrMan(addrman); + + bench.run([&] { + const auto& addresses = addrman.GetAddr(2500, 23); + assert(addresses.size() > 0); + }); +} + +static void AddrManGood(benchmark::Bench& bench) +{ + /* Create many CAddrMan objects - one to be modified at each loop iteration. + * This is necessary because the CAddrMan::Good() method modifies the + * object, affecting the timing of subsequent calls to the same method and + * we want to do the same amount of work in every loop iteration. */ + + bench.epochs(5).epochIterations(1); + + std::vector addrmans(bench.epochs() * bench.epochIterations()); + for (auto& addrman : addrmans) { + FillAddrMan(addrman); + } + + auto markSomeAsGood = [](CAddrMan& addrman) { + for (size_t source_i = 0; source_i < NUM_SOURCES; ++source_i) { + for (size_t addr_i = 0; addr_i < NUM_ADDRESSES_PER_SOURCE; ++addr_i) { + if (addr_i % 32 == 0) { + addrman.Good(g_addresses[source_i][addr_i]); + } + } + } + }; + + uint64_t i = 0; + bench.run([&] { + markSomeAsGood(addrmans.at(i)); + ++i; + }); +} + +BENCHMARK(AddrManAdd); +BENCHMARK(AddrManSelect); +BENCHMARK(AddrManGetAddr); +BENCHMARK(AddrManGood); diff --git a/src/bench/base58.cpp b/src/bench/base58.cpp index 8854b18a1..9fdd4a7d6 100644 --- a/src/bench/base58.cpp +++ b/src/bench/base58.cpp @@ -4,12 +4,10 @@ #include -#include #include #include #include -#include static void Base58Encode(benchmark::Bench& bench) @@ -21,8 +19,8 @@ static void Base58Encode(benchmark::Bench& bench) 200, 24 } }; - bench.run([&] { - EncodeBase58(buff.data(), buff.data() + buff.size()); + bench.batch(buff.size()).unit("byte").run([&] { + EncodeBase58(buff); }); } @@ -36,10 +34,8 @@ static void Base58CheckEncode(benchmark::Bench& bench) 200, 24 } }; - std::vector vch; - vch.assign(buff.begin(), buff.end()); - bench.run([&] { - EncodeBase58Check(vch); + bench.batch(buff.size()).unit("byte").run([&] { + EncodeBase58Check(buff); }); } @@ -48,8 +44,8 @@ static void Base58Decode(benchmark::Bench& bench) { const char* addr = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem"; std::vector vch; - bench.run([&] { - DecodeBase58(addr, vch); + bench.batch(strlen(addr)).unit("byte").run([&] { + (void) DecodeBase58(addr, vch, 64); }); } diff --git a/src/bench/bech32.cpp b/src/bench/bech32.cpp index 4685aeaf6..698f3aa48 100644 --- a/src/bench/bech32.cpp +++ b/src/bench/bech32.cpp @@ -3,13 +3,13 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include -#include #include -#include +#include -#include #include +#include static void Bech32Encode(benchmark::Bench& bench) @@ -18,8 +18,8 @@ static void Bech32Encode(benchmark::Bench& bench) std::vector tmp = {0}; tmp.reserve(1 + 32 * 8 / 5); ConvertBits<8, 5, true>([&](unsigned char c) { tmp.push_back(c); }, v.begin(), v.end()); - bench.run([&] { - bech32::Encode("bc", tmp); + bench.batch(v.size()).unit("byte").run([&] { + bech32::Encode(bech32::Encoding::BECH32, "bc", tmp); }); } @@ -27,7 +27,7 @@ static void Bech32Encode(benchmark::Bench& bench) static void Bech32Decode(benchmark::Bench& bench) { std::string addr = "bc1qkallence7tjawwvy0dwt4twc62qjgaw8f4vlhyd006d99f09"; - bench.run([&] { + bench.batch(addr.size()).unit("byte").run([&] { bech32::Decode(addr); }); } diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index 06316dd2b..e3308aa8f 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -12,6 +12,7 @@ #include #include #include +#include using namespace std::chrono_literals; @@ -91,4 +92,4 @@ void benchmark::BenchRunner::RunAll(const Args& args) "{{#result}}{{name}}, {{epochs}}, {{average(iterations)}}, {{sumProduct(iterations, elapsed)}}, {{minimum(elapsed)}}, {{maximum(elapsed)}}, {{median(elapsed)}}\n" "{{/result}}"); GenerateTemplateResults(benchmarkResults, args.output_json, ankerl::nanobench::templates::json()); -} \ No newline at end of file +} diff --git a/src/bench/bench.h b/src/bench/bench.h index 79a31b9c6..0d82b3f83 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -5,15 +5,15 @@ #ifndef POCKETCOIN_BENCH_BENCH_H #define POCKETCOIN_BENCH_BENCH_H +#include #include -#include #include #include #include -#include #include -#include +#include +#include /* * Usage: @@ -21,12 +21,10 @@ static void NameOfYourBenchmarkFunction(benchmark::Bench& bench) { ...do any setup needed... - bench.run([&] { ...do stuff you want to time; refer to src/bench/nanobench.h for more information and the options that can be passed here... }); - ...do any cleanup needed... } @@ -59,10 +57,9 @@ class BenchRunner static void RunAll(const Args& args); }; -} // namespace benchmark - -// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_11foo("foo", foo); +} +// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_11foo("foo"); #define BENCHMARK(n) \ - benchmark::BenchRunner PASTE2(bench_, PASTE2(__LINE__, n))(STRINGIZE(n), n); + benchmark::BenchRunner BOOST_PP_CAT(bench_, BOOST_PP_CAT(__LINE__, n))(BOOST_PP_STRINGIZE(n), n); -#endif // BITCOIN_BENCH_BENCH_H +#endif // POCKETCOIN_BENCH_BENCH_H diff --git a/src/bench/bench_pocketcoin.cpp b/src/bench/bench_pocketcoin.cpp index 6f90611ba..736e92ff6 100644 --- a/src/bench/bench_pocketcoin.cpp +++ b/src/bench/bench_pocketcoin.cpp @@ -5,11 +5,8 @@ #include #include -#include -#include -#include -#include -#include +#include +#include #include @@ -27,25 +24,17 @@ static const char* DEFAULT_BENCH_FILTER = ".*"; static constexpr int64_t DEFAULT_MIN_TIME_MS{10}; const std::function G_TRANSLATION_FUN = nullptr; -static std::unique_ptr globalVerifyHandle; - -// TAWMAZ: -static void SetupHelpOptions(ArgsManager& args) -{ - args.AddArg("-?", "Print this help message and exit", false, OptionsCategory::OPTIONS); - args.AddHiddenArgs({"-h", "-help"}); -} static void SetupBenchArgs(ArgsManager& argsman) { SetupHelpOptions(argsman); - argsman.AddArg("-asymptote=", "Test asymptotic growth of the runtime of an algorithm, if supported by the benchmark", false, OptionsCategory::OPTIONS); - argsman.AddArg("-filter=", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), false, OptionsCategory::OPTIONS); - argsman.AddArg("-list", "List benchmarks without executing them", false, OptionsCategory::OPTIONS); - argsman.AddArg("-min_time=", strprintf("Minimum runtime per benchmark, in milliseconds (default: %d)", DEFAULT_MIN_TIME_MS), false, OptionsCategory::OPTIONS); - argsman.AddArg("-output_csv=", "Generate CSV file with the most important benchmark results", false, OptionsCategory::OPTIONS); - argsman.AddArg("-output_json=", "Generate JSON file with all benchmark results", false, OptionsCategory::OPTIONS); + argsman.AddArg("-list", "List benchmarks without executing them", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-filter=", strprintf("Regular expression filter to select benchmark by name (default: %s)", DEFAULT_BENCH_FILTER), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-asymptote=n1,n2,n3,...", strprintf("Test asymptotic growth of the runtime of an algorithm, if supported by the benchmark"), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-min_time=", strprintf("Minimum runtime per benchmark, in milliseconds (default: %d)", DEFAULT_MIN_TIME_MS), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-output_csv=", "Generate CSV file with the most important benchmark results.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-output_json=", "Generate JSON file with all benchmark results.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); } // parses a comma separated list like "10,20,30,50" @@ -67,8 +56,8 @@ int main(int argc, char** argv) SetupBenchArgs(argsman); SHA256AutoDetect(); std::string error; - if (!gArgs.ParseParameters(argc, argv, error)) { - fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str()); + if (!argsman.ParseParameters(argc, argv, error)) { + tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error); return EXIT_FAILURE; } @@ -122,24 +111,6 @@ int main(int argc, char** argv) return EXIT_SUCCESS; } - SHA256AutoDetect(); - RandomInit(); - ECC_Start(); - globalVerifyHandle.reset(new ECCVerifyHandle()); - //SetupEnvironment(); - //SetupNetworking(); - //InitSignatureCache(); - //InitScriptExecutionCache(); - - SelectParams(CBaseChainParams::REGTEST); - - - PocketDb::InitSQLite(GetDataDir() / "pocketdb"); - - // Go up two directories to access the checkpoints folder, assume we are running in /src/test - fs::path checkpointsPath = fs::system_complete("../.."); - PocketDb::InitSQLiteCheckpoints(checkpointsPath / "checkpoints"); - benchmark::Args args; args.asymptote = parseAsymptote(argsman.GetArg("-asymptote", "")); args.is_list_only = argsman.GetBoolArg("-list", false); diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp index 0497fe0d4..8cef9d215 100644 --- a/src/bench/block_assemble.cpp +++ b/src/bench/block_assemble.cpp @@ -3,78 +3,45 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include -#include -#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include #include -#include +#include +#include -#include -#include #include #include "pocketdb/services/Serializer.h" -static std::shared_ptr StakeBlock(const CScript& coinbase_scriptPubKey) -{ - auto block = std::make_shared( - BlockAssembler{Params()} - .CreateNewBlock(coinbase_scriptPubKey, /* fMineWitnessTx */ true, /*fProofOfStake */ true) - ->block); - - block->nTime = ::chainActive.Tip()->GetMedianTimePast() + 1; - block->hashMerkleRoot = BlockMerkleRoot(*block); - - return block; -} - - -static std::shared_ptr PrepareBlock(const CScript& coinbase_scriptPubKey) +static std::shared_ptr StakeBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey) { auto block = std::make_shared( - BlockAssembler{Params()} - .CreateNewBlock(coinbase_scriptPubKey, /* fMineWitnessTx */ true, /*fProofOfStake */ false) + BlockAssembler{*Assert(node.mempool), Params()} + .CreateNewBlock(coinbase_scriptPubKey, /*fProofOfStake */ true) ->block); - block->nTime = ::chainActive.Tip()->GetMedianTimePast() + 1; + block->nTime = ::ChainActive().Tip()->GetMedianTimePast() + 1; block->hashMerkleRoot = BlockMerkleRoot(*block); return block; } -static CTxIn MineBlock(const CScript& coinbase_scriptPubKey) -{ - auto block = PrepareBlock(coinbase_scriptPubKey); - - while (!CheckProofOfWork(block->GetHash(), block->nBits, Params().GetConsensus(), 0)) { - ++block->nNonce; - assert(block->nNonce); - } - - CValidationState state; - UniValue pocketData; - bool ignored; - auto[deserializeOk, pocketBlock] = PocketServices::Serializer::DeserializeBlock(*block); - auto pocketBlockRef = std::make_shared(pocketBlock); - bool processed{ProcessNewBlock(state, Params(), block, pocketBlockRef, true, true, &ignored)}; - assert(processed); - - return CTxIn{block->vtx[0]->GetHash(), 0}; -} - - static void AssembleBlock(benchmark::Bench& bench) { + TestingSetup test_setup{ + CBaseChainParams::REGTEST, + /* extra_args */ { + "-nodebuglogfile", + "-nodebug", + }, + }; + const std::vector op_true{OP_TRUE}; CScriptWitness witness; witness.stack.push_back(op_true); @@ -84,32 +51,12 @@ static void AssembleBlock(benchmark::Bench& bench) const CScript SCRIPT_PUB{CScript(OP_0) << std::vector{witness_program.begin(), witness_program.end()}}; - InitScriptExecutionCache(); - - boost::thread_group thread_group; - CScheduler scheduler; - { - ::pblocktree.reset(new CBlockTreeDB(1 << 20, true)); - ::pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true)); - ::pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get())); - - const CChainParams& chainparams = Params(); - thread_group.create_thread(boost::bind(&CScheduler::serviceQueue, &scheduler)); - GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); - LoadGenesisBlock(chainparams); - CValidationState state; - ActivateBestChain(state, chainparams); - assert(::chainActive.Tip() != nullptr); - const bool witness_enabled{IsWitnessEnabled(::chainActive.Tip(), chainparams.GetConsensus())}; - assert(witness_enabled); - } - // Collect some loose transactions that spend the coinbases of our mined blocks constexpr size_t NUM_BLOCKS{200}; std::array txs; for (size_t b{0}; b < NUM_BLOCKS; ++b) { CMutableTransaction tx; - tx.vin.push_back(MineBlock(SCRIPT_PUB)); + tx.vin.push_back(MineBlock(test_setup.m_node, SCRIPT_PUB)); tx.vin.back().scriptWitness = witness; tx.vout.emplace_back(1337, SCRIPT_PUB); if (NUM_BLOCKS - b >= COINBASE_MATURITY) @@ -119,26 +66,15 @@ static void AssembleBlock(benchmark::Bench& bench) LOCK(::cs_main); // Required for ::AcceptToMemoryPool. for (const auto& txr : txs) { - CValidationState state; - bool ret{::AcceptToMemoryPool(::mempool, state, txr, - nullptr /* pocketTx */, - nullptr /* pfMissingInputs */, - nullptr /* plTxnReplaced */, - false /* bypass_limits */, - 0 /* nAbsurdFee */, - false /* test_accept */)}; + TxValidationState state; + bool ret{::AcceptToMemoryPool(*test_setup.m_node.mempool, state, txr, nullptr, nullptr /* plTxnReplaced */, false /* bypass_limits */)}; assert(ret); } } bench.run([&] { - StakeBlock(SCRIPT_PUB); + StakeBlock(test_setup.m_node, SCRIPT_PUB); }); - - thread_group.interrupt_all(); - thread_group.join_all(); - GetMainSignals().FlushBackgroundCallbacks(); - GetMainSignals().UnregisterBackgroundSignalScheduler(); } BENCHMARK(AssembleBlock); diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp index 8dddd1a43..aa585eecc 100644 --- a/src/bench/ccoins_caching.cpp +++ b/src/bench/ccoins_caching.cpp @@ -5,48 +5,11 @@ #include #include #include -#include +#include -
- )DELIM"; } @@ -3362,4 +3327,4 @@ std::ostream& operator<<(std::ostream& os, std::vector } // namespace ankerl #endif // ANKERL_NANOBENCH_IMPLEMENT -#endif // ANKERL_NANOBENCH_H_INCLUDED +#endif // ANKERL_NANOBENCH_H_INCLUDED \ No newline at end of file diff --git a/src/bench/poly1305.cpp b/src/bench/poly1305.cpp new file mode 100644 index 000000000..28a015a35 --- /dev/null +++ b/src/bench/poly1305.cpp @@ -0,0 +1,41 @@ +// Copyright (c) 2019 The Pocketcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +#include +#include + +/* Number of bytes to process per iteration */ +static constexpr uint64_t BUFFER_SIZE_TINY = 64; +static constexpr uint64_t BUFFER_SIZE_SMALL = 256; +static constexpr uint64_t BUFFER_SIZE_LARGE = 1024*1024; + +static void POLY1305(benchmark::Bench& bench, size_t buffersize) +{ + std::vector tag(POLY1305_TAGLEN, 0); + std::vector key(POLY1305_KEYLEN, 0); + std::vector in(buffersize, 0); + bench.batch(in.size()).unit("byte").run([&] { + poly1305_auth(tag.data(), in.data(), in.size(), key.data()); + }); +} + +static void POLY1305_64BYTES(benchmark::Bench& bench) +{ + POLY1305(bench, BUFFER_SIZE_TINY); +} + +static void POLY1305_256BYTES(benchmark::Bench& bench) +{ + POLY1305(bench, BUFFER_SIZE_SMALL); +} + +static void POLY1305_1MB(benchmark::Bench& bench) +{ + POLY1305(bench, BUFFER_SIZE_LARGE); +} + +BENCHMARK(POLY1305_64BYTES); +BENCHMARK(POLY1305_256BYTES); +BENCHMARK(POLY1305_1MB); diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp index 1938a2458..1e1c14b9e 100644 --- a/src/bench/prevector.cpp +++ b/src/bench/prevector.cpp @@ -3,13 +3,21 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include -#include #include #include #include #include -#include +#include + +#include + +// GCC 4.8 is missing some C++11 type_traits, +// https://www.gnu.org/software/gcc/gcc-5/changes.html +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 +#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor +#else +#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible +#endif struct nontrivial_t { int x; diff --git a/src/bench/rollingbloom.cpp b/src/bench/rollingbloom.cpp index 3129756e1..b8760df3b 100644 --- a/src/bench/rollingbloom.cpp +++ b/src/bench/rollingbloom.cpp @@ -27,4 +27,13 @@ static void RollingBloom(benchmark::Bench& bench) }); } +static void RollingBloomReset(benchmark::Bench& bench) +{ + CRollingBloomFilter filter(120000, 0.000001); + bench.run([&] { + filter.reset(); + }); +} + BENCHMARK(RollingBloom); +BENCHMARK(RollingBloomReset); diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp new file mode 100644 index 000000000..32c281029 --- /dev/null +++ b/src/bench/rpc_blockchain.cpp @@ -0,0 +1,33 @@ +// Copyright (c) 2016-2020 The Pocketcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include + +#include +#include +#include + +#include + +static void BlockToJsonVerbose(benchmark::Bench& bench) +{ + CDataStream stream(benchmark::data::block1533073, SER_NETWORK, PROTOCOL_VERSION); + char a = '\0'; + stream.write(&a, 1); // Prevent compaction + + CBlock block; + stream >> block; + + CBlockIndex blockindex; + const uint256 blockHash = block.GetHash(); + blockindex.phashBlock = &blockHash; + blockindex.nBits = 403014710; + + bench.run([&] { + (void)blockToJSON(block, &blockindex, &blockindex, /*verbose*/ true); + }); +} + +BENCHMARK(BlockToJsonVerbose); diff --git a/src/bench/rpc_mempool.cpp b/src/bench/rpc_mempool.cpp new file mode 100644 index 000000000..cca6024e0 --- /dev/null +++ b/src/bench/rpc_mempool.cpp @@ -0,0 +1,40 @@ +// Copyright (c) 2011-2019 The Pocketcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include + +#include + + +static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) +{ + LockPoints lp; + pool.addUnchecked(CTxMemPoolEntry(tx, fee, /* time */ 0, /* height */ 1, /* spendsCoinbase */ false, /* sigOpCost */ 4, lp)); +} + +static void RpcMempool(benchmark::Bench& bench) +{ + CTxMemPool pool; + LOCK2(cs_main, pool.cs); + + for (int i = 0; i < 1000; ++i) { + CMutableTransaction tx = CMutableTransaction(); + tx.vin.resize(1); + tx.vin[0].scriptSig = CScript() << OP_1; + tx.vin[0].scriptWitness.stack.push_back({1}); + tx.vout.resize(1); + tx.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; + tx.vout[0].nValue = i; + const CTransactionRef tx_r{MakeTransactionRef(tx)}; + AddTx(tx_r, /* fee */ i, pool); + } + + bench.run([&] { + (void)MempoolToJSON(pool, /*verbose*/ true); + }); +} + +BENCHMARK(RpcMempool); diff --git a/src/bench/util_time.cpp b/src/bench/util_time.cpp new file mode 100644 index 000000000..7c5d89910 --- /dev/null +++ b/src/bench/util_time.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2019 The Pocketcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include + +static void BenchTimeDeprecated(benchmark::Bench& bench) +{ + bench.run([&] { + (void)GetTime(); + }); +} + +static void BenchTimeMock(benchmark::Bench& bench) +{ + SetMockTime(111); + bench.run([&] { + (void)GetTime(); + }); + SetMockTime(0); +} + +static void BenchTimeMillis(benchmark::Bench& bench) +{ + bench.run([&] { + (void)GetTime(); + }); +} + +static void BenchTimeMillisSys(benchmark::Bench& bench) +{ + bench.run([&] { + (void)GetTimeMillis(); + }); +} + +BENCHMARK(BenchTimeDeprecated); +BENCHMARK(BenchTimeMillis); +BENCHMARK(BenchTimeMillisSys); +BENCHMARK(BenchTimeMock); diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp index 3393b3260..ef1710920 100644 --- a/src/bench/verify_script.cpp +++ b/src/bench/verify_script.cpp @@ -9,51 +9,19 @@ #endif #include #include