From ae47613f39f2e3f675816717385960bd866bd49f Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Fri, 26 Mar 2021 23:44:55 -0700 Subject: [PATCH 01/10] build: remove protobuf from depends --- depends/config.site.in | 4 ---- depends/packages/native_protobuf.mk | 25 --------------------- depends/packages/packages.mk | 3 +-- depends/packages/protobuf.mk | 34 ----------------------------- 4 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 depends/packages/native_protobuf.mk delete mode 100644 depends/packages/protobuf.mk diff --git a/depends/config.site.in b/depends/config.site.in index 26f32dc698f4..65e50cb02c5e 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -19,10 +19,6 @@ fi if test -z $with_qt_bindir && test -z "@no_qt@"; then with_qt_bindir=$depends_prefix/native/bin fi -if test -z $with_protoc_bindir && test -z "@no_qt@"; then - with_protoc_bindir=$depends_prefix/native/bin -fi - if test -z $enable_wallet && test -n "@no_wallet@"; then enable_wallet=no diff --git a/depends/packages/native_protobuf.mk b/depends/packages/native_protobuf.mk deleted file mode 100644 index 1de8c37d362a..000000000000 --- a/depends/packages/native_protobuf.mk +++ /dev/null @@ -1,25 +0,0 @@ -package=native_protobuf -$(package)_version=2.6.1 -$(package)_download_path=https://github.com/google/protobuf/releases/download/v$($(package)_version) -$(package)_file_name=protobuf-$($(package)_version).tar.bz2 -$(package)_sha256_hash=ee445612d544d885ae240ffbcbf9267faa9f593b7b101f21d58beceb92661910 - -define $(package)_set_vars -$(package)_config_opts=--disable-shared --without-zlib -endef - -define $(package)_config_cmds - $($(package)_autoconf) -endef - -define $(package)_build_cmds - $(MAKE) -C src protoc -endef - -define $(package)_stage_cmds - $(MAKE) -C src DESTDIR=$($(package)_staging_dir) install-strip -endef - -define $(package)_postprocess_cmds - rm -rf lib include -endef diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index abfa8cdbbec9..3eb62cc1261d 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -74,8 +74,7 @@ rust_crates := \ rust_packages := rust $(rust_crates) packages:=boost openssl libevent gmp $(zcash_packages) libsodium -qt_native_packages = native_protobuf -qt_packages = qrencode protobuf zlib +qt_packages = qrencode zlib qt_linux_packages:=qt expat dbus libxcb xcb_proto libXau xproto freetype fontconfig diff --git a/depends/packages/protobuf.mk b/depends/packages/protobuf.mk deleted file mode 100644 index d201d1183f16..000000000000 --- a/depends/packages/protobuf.mk +++ /dev/null @@ -1,34 +0,0 @@ -package=protobuf -$(package)_version=$(native_$(package)_version) -$(package)_download_path=$(native_$(package)_download_path) -$(package)_file_name=$(native_$(package)_file_name) -$(package)_sha256_hash=$(native_$(package)_sha256_hash) -$(package)_dependencies=native_$(package) -$(package)_cxxflags=-std=c++11 - -define $(package)_set_vars - $(package)_config_opts=--disable-shared --with-protoc=$(build_prefix)/bin/protoc - $(package)_config_opts_linux=--with-pic -endef - -define $(package)_preprocess_cmds - cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . &&\ - cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub gtest/build-aux -endef - -define $(package)_config_cmds - $($(package)_autoconf) -endef - -define $(package)_build_cmds - $(MAKE) -C src libprotobuf.la -endef - -define $(package)_stage_cmds - $(MAKE) DESTDIR=$($(package)_staging_dir) -C src install-libLTLIBRARIES install-nobase_includeHEADERS &&\ - $(MAKE) DESTDIR=$($(package)_staging_dir) install-pkgconfigDATA -endef - -define $(package)_postprocess_cmds - rm lib/libprotoc.a -endef From b047918d949c75d8d2c6786ed23839102c4cadf5 Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Fri, 26 Mar 2021 23:48:19 -0700 Subject: [PATCH 02/10] docs: remove protobuf from docs --- doc/build-osx.md | 2 +- doc/build-unix.md | 5 ++--- doc/build-windows.md | 3 +-- doc/dependencies.md | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/build-osx.md b/doc/build-osx.md index 303792f3c4e6..a768dadf5e25 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -16,7 +16,7 @@ Then install [Homebrew](https://brew.sh). Dependencies ---------------------- - brew install autoconf automake berkeley-db4 libtool boost miniupnpc openssl pkg-config protobuf python3 qt5 zmq libevent qrencode gmp libsodium rust + brew install autoconf automake berkeley-db4 libtool boost miniupnpc openssl pkg-config python3 qt5 zmq libevent qrencode gmp libsodium rust See [dependencies.md](dependencies.md) for a complete overview. diff --git a/doc/build-unix.md b/doc/build-unix.md index 85050f26b0c3..7097a04ca7ed 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -44,7 +44,6 @@ Optional dependencies: miniupnpc | UPnP Support | Firewall-jumping support libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled) qt | GUI | GUI toolkit (only needed when GUI enabled) - protobuf | Payments in GUI | Data interchange format used for payment protocol (only needed when GUI enabled) univalue | Utility | JSON parsing and encoding (bundled version will be used unless --with-system-univalue passed to configure) libzmq3 | ZMQ notification | Optional, allows generating ZMQ notifications (requires ZMQ version >= 4.0.0) @@ -111,7 +110,7 @@ To build without GUI pass `--without-gui`. To build with Qt 5 you need the following: - sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 libqt5svg5-dev libqt5charts5-dev qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libqrencode-dev + sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 libqt5svg5-dev libqt5charts5-dev qttools5-dev qttools5-dev-tools libqrencode-dev **Note:** Ubuntu versions prior to Bionic (18.04), and Debian version prior to Buster, do not have the `libqt5charts5-dev` package. If you are compiling on one of these older versions, you will need to omit `libqt5charts5-dev` from the above command. @@ -133,7 +132,7 @@ Optional: To build with Qt 5 you need the following: - sudo dnf install qt5-qttools-devel qt5-qtbase-devel qt5-qtsvg-devel qt5-qtcharts-devel protobuf-devel qrencode-devel + sudo dnf install qt5-qttools-devel qt5-qtbase-devel qt5-qtsvg-devel qt5-qtcharts-devel qrencode-devel Notes ----- diff --git a/doc/build-windows.md b/doc/build-windows.md index b3a5da8daa17..a6062b4bc52c 100644 --- a/doc/build-windows.md +++ b/doc/build-windows.md @@ -62,8 +62,7 @@ First, install the general dependencies: sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git A host toolchain (`build-essential`) is necessary because some dependency -packages (such as `protobuf`) need to build host utilities that are used in the -build process. +packages need to build host utilities that are used in the build process. See [dependencies.md](dependencies.md) for a complete overview. diff --git a/doc/dependencies.md b/doc/dependencies.md index 6f406e1bf469..ab004f83e799 100644 --- a/doc/dependencies.md +++ b/doc/dependencies.md @@ -22,7 +22,6 @@ These are the dependencies currently used by PIVX Core. You can find instruction | OpenSSL | [1.0.1k](https://www.openssl.org/source) | | Yes | | | | GMP | [6.1.2](https://gmplib.org/) | | No | | | | PCRE | | | | | [Yes](https://github.com/pivx-project/pivx/blob/master/depends/packages/qt.mk#L66) | -| protobuf | [2.6.1](https://github.com/google/protobuf/releases) | | No | | | | Python (tests) | | [3.5](https://www.python.org/downloads) | | | | | qrencode | [3.4.4](https://fukuchi.org/works/qrencode) | | No | | | | Qt | [5.9.7](https://download.qt.io/official_releases/qt/) | [5.5.1](https://github.com/bitcoin/bitcoin/issues/13478) | No | | | From 18626651a8cce3ed2312759edfb8742dde85723d Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Sat, 27 Mar 2021 03:21:36 -0700 Subject: [PATCH 03/10] Remove BIP70 support This removes the support for BIP 70 payment requests. Protobuf is no longer required by any binary target, and OpenSSL is also no longer needed for the GUI target (when building with GMP support). --- .github/workflows/build-and-test.yml | 12 +- CMakeLists.txt | 9 +- configure.ac | 8 - contrib/pivxd.bash-completion | 2 +- src/Makefile.am | 8 +- src/Makefile.bench.include | 2 +- src/Makefile.qt.include | 24 +- src/Makefile.qttest.include | 16 +- src/Makefile.test.include | 2 +- src/qt/CMakeLists.txt | 13 +- src/qt/optionsmodel.cpp | 19 +- src/qt/optionsmodel.h | 5 - src/qt/paymentrequest.proto | 46 --- src/qt/paymentrequestplus.cpp | 204 ------------- src/qt/paymentrequestplus.h | 51 ---- src/qt/paymentserver.cpp | 424 +-------------------------- src/qt/paymentserver.h | 36 --- src/qt/pivx.cpp | 4 - src/qt/pivx/sendmultirow.cpp | 9 - src/qt/test/paymentrequestdata.h | 311 -------------------- src/qt/test/paymentservertests.cpp | 127 -------- src/qt/test/paymentservertests.h | 35 --- src/qt/test/test_main.cpp | 13 - src/qt/utilitydialog.cpp | 1 - src/qt/walletmodel.cpp | 33 +-- src/qt/walletmodel.h | 16 +- src/qt/walletmodeltransaction.h | 3 + src/test/CMakeLists.txt | 2 +- 28 files changed, 40 insertions(+), 1395 deletions(-) delete mode 100644 src/qt/paymentrequest.proto delete mode 100644 src/qt/paymentrequestplus.cpp delete mode 100644 src/qt/paymentrequestplus.h delete mode 100644 src/qt/test/paymentrequestdata.h delete mode 100644 src/qt/test/paymentservertests.cpp delete mode 100644 src/qt/test/paymentservertests.h diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fa528f3e7257..03cfb765a1b1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -73,13 +73,13 @@ jobs: config: - name: Linux os: ubuntu-16.04 - packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev libgmp-dev libsodium-dev cargo + packages: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo cc: gcc cxx: g++ - name: macOS os: macos-10.15 - packages: python3 autoconf automake berkeley-db4 libtool boost miniupnpc pkg-config protobuf qt5 zmq libevent qrencode gmp libsodium rust + packages: python3 autoconf automake berkeley-db4 libtool boost miniupnpc pkg-config qt5 zmq libevent qrencode gmp libsodium rust cc: $(brew --prefix llvm)/bin/clang cxx: $(brew --prefix llvm)/bin/clang++ @@ -163,7 +163,7 @@ jobs: - name: x86_64 Linux os: ubuntu-18.04 host: x86_64-unknown-linux-gnu - apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libqrencode-dev protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev + apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libqrencode-dev libdbus-1-dev libharfbuzz-dev dep_opts: NO_QT=1 NO_UPNP=1 DEBUG=1 ALLOW_HOST_PACKAGES=1 - name: macOS 10.10 @@ -278,7 +278,7 @@ jobs: - name: x86_64 Linux [GOAL:install] [bionic] os: ubuntu-18.04 host: x86_64-unknown-linux-gnu - apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libqrencode-dev protobuf-compiler libdbus-1-dev libharfbuzz-dev libprotobuf-dev + apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libqrencode-dev libdbus-1-dev libharfbuzz-dev unit_tests: true functional_tests: true goal: install @@ -298,7 +298,7 @@ jobs: - name: x86_64 Linux [GOAL:install] [xenial] [no depends only system libs] os: ubuntu-16.04 host: x86_64-unknown-linux-gnu - apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev libgmp-dev libsodium-dev cargo + apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo unit_tests: true functional_tests: true no_depends: 1 @@ -309,7 +309,7 @@ jobs: - name: x86_64 Linux [GOAL:install] [bionic] [no depends only system libs] os: ubuntu-18.04 host: x86_64-unknown-linux-gnu - apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev libgmp-dev libsodium-dev cargo + apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo unit_tests: true no_depends: 1 goal: install diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dca15e626e3..31d7496cfeab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,9 +40,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/qt5) list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/openssl@1.1) list(APPEND CMAKE_PREFIX_PATH /usr/local/Cellar/berkeley-db@4) - #set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl@1.1/") - #set(ENV{CPPFLAGS} "-I${OPENSSL_ROOT_DIR}/include") - #set(ENV{LDFLAGS} "-L${OPENSSL_ROOT_DIR}/lib") set(BerkeleyDB_ROOT_DIR "/usr/local/Cellar/berkeley-db@4/${BDB_VER}/") set(Boost_USE_MULTITHREADED ON) set(Boost_NO_BOOST_CMAKE ON) @@ -508,7 +505,7 @@ target_link_libraries(pivx-cli BITCOIN_CRYPTO_A SAPLING_A rustzcash - ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${LIBEVENT_LIB} ${sodium_LIBRARY_RELEASE} -ldl pthread + ${Boost_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} ${LIBEVENT_LIB} ${sodium_LIBRARY_RELEASE} -ldl pthread ) if($ENV{target} MATCHES "Windows") target_link_libraries(pivx-cli ${WINDOWS_LDADD}) @@ -532,7 +529,7 @@ target_link_libraries(pivx-tx secp256k1 SAPLING_A rustzcash - ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${LIBEVENT_LIB} ${sodium_LIBRARY_RELEASE} -ldl pthread + ${Boost_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} ${LIBEVENT_LIB} ${sodium_LIBRARY_RELEASE} -ldl pthread ) if($ENV{target} MATCHES "Windows") target_link_libraries(pivx-tx ${WINDOWS_LDADD}) @@ -569,7 +566,7 @@ target_link_libraries(pivxd crc32c secp256k1 rustzcash - ${BerkeleyDB_LIBRARIES} ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${LIBEVENT_LIB} pthread + ${BerkeleyDB_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} ${Boost_LIBRARIES} ${LIBEVENT_LIB} pthread ) if($ENV{target} MATCHES "Windows") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wstack-protector -fstack-protector-all -fPIE -pipe -O2 -pthread -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -pie --static") diff --git a/configure.ac b/configure.ac index 24d322fbb089..7b2e1cd2cd60 100644 --- a/configure.ac +++ b/configure.ac @@ -243,8 +243,6 @@ AC_ARG_WITH([zerocoin-bignum], [req_bignum=$withval], [req_bignum=auto]) -AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], []) - AC_ARG_ENABLE(man, [AS_HELP_STRING([--disable-man], [do not install man pages (default is to install)])],, @@ -1093,7 +1091,6 @@ if test x$use_pkgconfig = xyes; then [ PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) - BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])]) BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode],,[BITCOIN_QT_FAIL(libqrencode not found)])]) if test x$use_qtcharts != xno; then BITCOIN_QT_CHECK([PKG_CHECK_MODULES([CHARTS], [Qt5Charts],[have_qtcharts=yes], [have_qtcharts=no])]) @@ -1158,8 +1155,6 @@ else esac fi - BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found))) - BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], BITCOIN_QT_FAIL(libqrencode not found))]) BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, BITCOIN_QT_FAIL(libqrencode not found))]) if test x$use_qtcharts != xno; then @@ -1216,8 +1211,6 @@ AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes]) AC_SUBST(UNIVALUE_CFLAGS) AC_SUBST(UNIVALUE_LIBS) -BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path) - RUST_LIBS="" case $host in *mingw*) @@ -1505,7 +1498,6 @@ AC_SUBST(EVENT_PTHREADS_LIBS) AC_SUBST(SODIUM_LIBS) AC_SUBST(ZMQ_LIBS) AC_SUBST(LIBZCASH_LIBS) -AC_SUBST(PROTOBUF_LIBS) AC_SUBST(QR_LIBS) AC_SUBST(USE_NUM_GMP) AC_SUBST(USE_NUM_OPENSSL) diff --git a/contrib/pivxd.bash-completion b/contrib/pivxd.bash-completion index 00382780daeb..5fdfd7b9af16 100644 --- a/contrib/pivxd.bash-completion +++ b/contrib/pivxd.bash-completion @@ -15,7 +15,7 @@ _pivxd() { _get_comp_words_by_ref -n = cur prev words cword case "$cur" in - -conf=*|-pid=*|-loadblock=*|-rootcertificates=*|-rpccookiefile=*|-wallet=*) + -conf=*|-pid=*|-loadblock=*|-rpccookiefile=*|-wallet=*) cur="${cur#*=}" _filedir return 0 diff --git a/src/Makefile.am b/src/Makefile.am index ec0037e22ded..159a241d5be5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -623,7 +623,7 @@ pivxd_LDADD = \ $(LIBRUSTZCASH) \ $(LIBZCASH_LIBS) -pivxd_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) +pivxd_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS) # pivx-cli binary # pivx_cli_SOURCES = pivx-cli.cpp @@ -644,7 +644,7 @@ pivx_cli_LDADD = \ $(LIBRUSTZCASH) \ $(LIBZCASH_LIBS) -pivx_cli_LDADD += $(BOOST_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS) +pivx_cli_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS) # # pivx-tx binary # @@ -770,10 +770,6 @@ if HARDEN $(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(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=$( forms/ui_foo.h QT_FORMS_H=$(join $(dir $(QT_FORMS_UI)),$(addprefix ui_, $(notdir $(QT_FORMS_UI:.ui=.h)))) @@ -633,14 +626,9 @@ QT_FORMS_H=$(join $(dir $(QT_FORMS_UI)),$(addprefix ui_, $(notdir $(QT_FORMS_UI: $(QT_MOC): $(QT_FORMS_H) $(qt_libbitcoinqt_a_OBJECTS) $(qt_pivx_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) - # pivx-qt binary # qt_pivx_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(PROTOBUF_CFLAGS) $(QR_CFLAGS) $(SVG_CFLAGS) $(CHARTS_CFLAGS) + $(QT_INCLUDES) $(QR_CFLAGS) $(SVG_CFLAGS) $(CHARTS_CFLAGS) qt_pivx_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) qt_pivx_qt_SOURCES = qt/pivx.cpp @@ -658,7 +646,7 @@ if ENABLE_ZMQ qt_pivx_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif qt_pivx_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBBITCOIN_ZEROCOIN) $(LIBSAPLING) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \ - $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(SVG_LIBS) $(CHARTS_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ + $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(SVG_LIBS) $(CHARTS_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) qt_pivx_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) qt_pivx_qt_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag CXX @@ -683,7 +671,7 @@ $(QT_QRC_LOCALE_CPP): $(QT_QRC_LOCALE) $(QT_QM) $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ @rm $(@D)/temp_$( $@ diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index a9637ddc9bba..ac5b0345418c 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -6,26 +6,16 @@ TESTS += qt/test/test_pivx-qt TEST_QT_MOC_CPP = qt/test/moc_uritests.cpp -if ENABLE_WALLET -TEST_QT_MOC_CPP += qt/test/moc_paymentservertests.cpp -endif - TEST_QT_H = \ - qt/test/uritests.h \ - qt/test/paymentrequestdata.h \ - qt/test/paymentservertests.h + qt/test/uritests.h qt_test_test_pivx_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(PROTOBUF_CFLAGS) + $(QT_INCLUDES) $(QT_TEST_INCLUDES) qt_test_test_pivx_qt_SOURCES = \ qt/test/test_main.cpp \ qt/test/uritests.cpp \ $(TEST_QT_H) -if ENABLE_WALLET -qt_test_test_pivx_qt_SOURCES += \ - qt/test/paymentservertests.cpp -endif nodist_qt_test_test_pivx_qt_SOURCES = $(TEST_QT_MOC_CPP) @@ -38,7 +28,7 @@ qt_test_test_pivx_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) endif qt_test_test_pivx_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBBITCOIN_ZEROCOIN) $(LIBLEVELDB) $(LIBSAPLING) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) \ $(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) \ + $(QR_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \ $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) qt_test_test_pivx_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) qt_test_test_pivx_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index d4f6a77eb346..a4b3bd4e3643 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -141,7 +141,7 @@ endif test_test_pivx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_pivx_LDADD += $(LIBRUSTZCASH) $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBZCASH_LIBS) +test_test_pivx_LDADD += $(LIBRUSTZCASH) $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBZCASH_LIBS) test_test_pivx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static if ENABLE_ZMQ diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index ecec5dc0130c..1a7d9cbee9f1 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -67,16 +67,6 @@ endif() file(GLOB LOCAL_QT_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h) source_group("QtHeaders" FILES ${LOCAL_QT_HEADERS}) -find_package(Protobuf REQUIRED) -if(Protobuf_FOUND) - message(STATUS "Found Protobuf compiler: ${Protobuf_PROTOC_EXECUTABLE}") - message(STATUS "Found Protobuf library: ${Protobuf_LIBRARIES}") -endif() -include_directories(${PROTOBUF_INCLUDE_DIRS}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/paymentrequest.proto) - SET(QT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/bantablemodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/bitcoinaddressvalidator.cpp @@ -103,7 +93,6 @@ SET(QT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/coincontroltreewidget.cpp ${CMAKE_CURRENT_SOURCE_DIR}/editaddressdialog.cpp ${CMAKE_CURRENT_SOURCE_DIR}/openuridialog.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/paymentrequestplus.cpp ${CMAKE_CURRENT_SOURCE_DIR}/paymentserver.cpp ${CMAKE_CURRENT_SOURCE_DIR}/recentrequeststablemodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/transactionfilterproxy.cpp @@ -215,7 +204,7 @@ target_link_libraries(pivx-qt univalue SERVER_A WALLET_A COMMON_A ZEROCOIN_A UTIL_A SAPLING_A BITCOIN_CRYPTO_A CLI_A leveldb crc32c secp256k1 rustzcash - ${BerkeleyDB_LIBRARIES} ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${PROTOBUF_LIBRARIES} ${LIBEVENT_LIB} + ${BerkeleyDB_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} ${Boost_LIBRARIES} ${LIBEVENT_LIB} ${sodium_LIBRARY_RELEASE} -ldl pthread ) diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index bdb2e4cfadbc..09c1a585bd80 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -26,7 +26,7 @@ #include "wallet/walletdb.h" #endif -#include +#include #include OptionsModel::OptionsModel(QObject* parent) : QAbstractListModel(parent) @@ -454,23 +454,6 @@ void OptionsModel::setDisplayUnit(const QVariant& value) } } -bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const -{ - // Directly query current base proxy, because - // GUI settings can be overridden with -proxy. - proxyType curProxy; - if (GetProxy(NET_IPV4, curProxy)) { - proxy.setType(QNetworkProxy::Socks5Proxy); - proxy.setHostName(QString::fromStdString(curProxy.proxy.ToStringIP())); - proxy.setPort(curProxy.proxy.GetPort()); - - return true; - } else - proxy.setType(QNetworkProxy::NoProxy); - - return false; -} - void OptionsModel::setRestartRequired(bool fRequired) { QSettings settings; diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 1c9bc7c5efd9..8e7b81e5181c 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -11,10 +11,6 @@ #include #include -QT_BEGIN_NAMESPACE -class QNetworkProxy; -QT_END_NAMESPACE - /** Interface from Qt to configuration data structure for PIVX client. To Qt, the options are presented as a list with the different options laid out vertically. @@ -75,7 +71,6 @@ class OptionsModel : public QAbstractListModel bool getMinimizeOnClose() { return fMinimizeOnClose; } int getDisplayUnit() { return nDisplayUnit; } QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; } - bool getProxySettings(QNetworkProxy& proxy) const; bool getCoinControlFeatures() { return fCoinControlFeatures; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } const QString& getLang() { return language; } diff --git a/src/qt/paymentrequest.proto b/src/qt/paymentrequest.proto deleted file mode 100644 index b2281c4c7b34..000000000000 --- a/src/qt/paymentrequest.proto +++ /dev/null @@ -1,46 +0,0 @@ -// -// Simple Bitcoin Payment Protocol messages -// -// Use fields 100+ for extensions; -// to avoid conflicts, register extensions at: -// https://en.bitcoin.it/wiki/Payment_Request -// - -package payments; -option java_package = "org.bitcoin.protocols.payments"; -option java_outer_classname = "Protos"; - -// Generalized form of "send payment to this/these bitcoin addresses" -message Output { - optional uint64 amount = 1 [default = 0]; // amount is integer-number-of-satoshis - required bytes script = 2; // usually one of the standard Script forms -} -message PaymentDetails { - optional string network = 1 [default = "main"]; // "main" or "test" - repeated Output outputs = 2; // Where payment should be sent - required uint64 time = 3; // Timestamp; when payment request created - optional uint64 expires = 4; // Timestamp; when this request should be considered invalid - optional string memo = 5; // Human-readable description of request for the customer - optional string payment_url = 6; // URL to send Payment and get PaymentACK - optional bytes merchant_data = 7; // Arbitrary data to include in the Payment message -} -message PaymentRequest { - optional uint32 payment_details_version = 1 [default = 1]; - optional string pki_type = 2 [default = "none"]; // none / x509+sha256 / x509+sha1 - optional bytes pki_data = 3; // depends on pki_type - required bytes serialized_payment_details = 4; // PaymentDetails - optional bytes signature = 5; // pki-dependent signature -} -message X509Certificates { - repeated bytes certificate = 1; // DER-encoded X.509 certificate chain -} -message Payment { - optional bytes merchant_data = 1; // From PaymentDetails.merchant_data - repeated bytes transactions = 2; // Signed transactions that satisfy PaymentDetails.outputs - repeated Output refund_to = 3; // Where to send refunds, if a refund is necessary - optional string memo = 4; // Human-readable message for the merchant -} -message PaymentACK { - required Payment payment = 1; // Payment message that triggered this ACK - optional string memo = 2; // human-readable message for customer -} diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp deleted file mode 100644 index 271c32e16ec9..000000000000 --- a/src/qt/paymentrequestplus.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) 2011-2014 The Bitcoin developers -// Copyright (c) 2017-2019 The PIVX developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -// -// Wraps dumb protocol buffer paymentRequest -// with some extra methods -// - -#include "paymentrequestplus.h" - -#include - -#include -#include -#include - - -class SSLVerifyError : public std::runtime_error -{ -public: - SSLVerifyError(std::string err) : std::runtime_error(err) {} -}; - -bool PaymentRequestPlus::parse(const QByteArray& data) -{ - bool parseOK = paymentRequest.ParseFromArray(data.data(), data.size()); - if (!parseOK) { - qWarning() << "PaymentRequestPlus::parse : Error parsing payment request"; - return false; - } - if (paymentRequest.payment_details_version() > 1) { - qWarning() << "PaymentRequestPlus::parse : Received up-version payment details, version=" << paymentRequest.payment_details_version(); - return false; - } - - parseOK = details.ParseFromString(paymentRequest.serialized_payment_details()); - if (!parseOK) { - qWarning() << "PaymentRequestPlus::parse : Error parsing payment details"; - paymentRequest.Clear(); - return false; - } - return true; -} - -bool PaymentRequestPlus::SerializeToString(std::string* output) const -{ - return paymentRequest.SerializeToString(output); -} - -bool PaymentRequestPlus::IsInitialized() const -{ - return paymentRequest.IsInitialized(); -} - -QString PaymentRequestPlus::getPKIType() const -{ - if (!IsInitialized()) return QString("none"); - return QString::fromStdString(paymentRequest.pki_type()); -} - -bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) const -{ - merchant.clear(); - - if (!IsInitialized()) - return false; - - // One day we'll support more PKI types, but just - // x509 for now: - const EVP_MD* digestAlgorithm = NULL; - if (paymentRequest.pki_type() == "x509+sha256") { - digestAlgorithm = EVP_sha256(); - } else if (paymentRequest.pki_type() == "x509+sha1") { - digestAlgorithm = EVP_sha1(); - } else if (paymentRequest.pki_type() == "none") { - qWarning() << "PaymentRequestPlus::getMerchant : Payment request: pki_type == none"; - return false; - } else { - qWarning() << "PaymentRequestPlus::getMerchant : Payment request: unknown pki_type " << QString::fromStdString(paymentRequest.pki_type()); - return false; - } - - payments::X509Certificates certChain; - if (!certChain.ParseFromString(paymentRequest.pki_data())) { - qWarning() << "PaymentRequestPlus::getMerchant : Payment request: error parsing pki_data"; - return false; - } - - std::vector certs; - const QDateTime currentTime = QDateTime::currentDateTime(); - for (int i = 0; i < certChain.certificate_size(); i++) { - QByteArray certData(certChain.certificate(i).data(), certChain.certificate(i).size()); - QSslCertificate qCert(certData, QSsl::Der); - if (currentTime < qCert.effectiveDate() || currentTime > qCert.expiryDate()) { - qWarning() << "PaymentRequestPlus::getMerchant : Payment request: certificate expired or not yet active: " << qCert; - return false; - } - if (qCert.isBlacklisted()) { - qWarning() << "PaymentRequestPlus::getMerchant : Payment request: certificate blacklisted: " << qCert; - return false; - } - const unsigned char *data = (const unsigned char *)certChain.certificate(i).data(); - X509 *cert = d2i_X509(nullptr, &data, certChain.certificate(i).size()); - if (cert) - certs.push_back(cert); - } - if (certs.empty()) { - qWarning() << "PaymentRequestPlus::getMerchant : Payment request: empty certificate chain"; - return false; - } - - // The first cert is the signing cert, the rest are untrusted certs that chain - // to a valid root authority. OpenSSL needs them separately. - STACK_OF(X509)* chain = sk_X509_new_null(); - for (int i = certs.size() - 1; i > 0; i--) { - sk_X509_push(chain, certs[i]); - } - X509* signing_cert = certs[0]; - - // Now create a "store context", which is a single use object for checking, - // load the signing cert into it and verify. - X509_STORE_CTX* store_ctx = X509_STORE_CTX_new(); - if (!store_ctx) { - qWarning() << "PaymentRequestPlus::getMerchant : Payment request: error creating X509_STORE_CTX"; - return false; - } - - char* website = NULL; - bool fResult = true; - try { - if (!X509_STORE_CTX_init(store_ctx, certStore, signing_cert, chain)) { - int error = X509_STORE_CTX_get_error(store_ctx); - throw SSLVerifyError(X509_verify_cert_error_string(error)); - } - - // Now do the verification! - int result = X509_verify_cert(store_ctx); - if (result != 1) { - int error = X509_STORE_CTX_get_error(store_ctx); - throw SSLVerifyError(X509_verify_cert_error_string(error)); - } - X509_NAME* certname = X509_get_subject_name(signing_cert); - - // Valid cert; check signature: - payments::PaymentRequest rcopy(paymentRequest); // Copy - rcopy.set_signature(std::string("")); - std::string data_to_verify; // Everything but the signature - rcopy.SerializeToString(&data_to_verify); - -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - EVP_MD_CTX *ctx = EVP_MD_CTX_new(); - if (!ctx) throw SSLVerifyError("Error allocating OpenSSL context."); -#else - EVP_MD_CTX _ctx; - EVP_MD_CTX *ctx; - ctx = &_ctx; -#endif - EVP_PKEY* pubkey = X509_get_pubkey(signing_cert); - EVP_MD_CTX_init(ctx); - if (!EVP_VerifyInit_ex(ctx, digestAlgorithm, NULL) || - !EVP_VerifyUpdate(ctx, data_to_verify.data(), data_to_verify.size()) || - !EVP_VerifyFinal(ctx, (const unsigned char*)paymentRequest.signature().data(), paymentRequest.signature().size(), pubkey)) { - throw SSLVerifyError("Bad signature, invalid PaymentRequest."); - } -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - EVP_MD_CTX_free(ctx); -#endif - - // OpenSSL API for getting human printable strings from certs is baroque. - int textlen = X509_NAME_get_text_by_NID(certname, NID_commonName, NULL, 0); - website = new char[textlen + 1]; - if (X509_NAME_get_text_by_NID(certname, NID_commonName, website, textlen + 1) == textlen && textlen > 0) { - merchant = website; - } else { - throw SSLVerifyError("Bad certificate, missing common name."); - } - // TODO: detect EV certificates and set merchant = business name instead of unfriendly NID_commonName ? - } catch (const SSLVerifyError& err) { - fResult = false; - qWarning() << "PaymentRequestPlus::getMerchant : SSL error: " << err.what(); - } - - if (website) - delete[] website; - X509_STORE_CTX_free(store_ctx); - for (unsigned int i = 0; i < certs.size(); i++) - X509_free(certs[i]); - - return fResult; -} - -QList > PaymentRequestPlus::getPayTo() const -{ - QList > result; - for (int i = 0; i < details.outputs_size(); i++) { - const unsigned char* scriptStr = (const unsigned char*)details.outputs(i).script().data(); - CScript s(scriptStr, scriptStr + details.outputs(i).script().size()); - - result.append(std::make_pair(s, details.outputs(i).amount())); - } - return result; -} diff --git a/src/qt/paymentrequestplus.h b/src/qt/paymentrequestplus.h deleted file mode 100644 index 3e8e27eedbc7..000000000000 --- a/src/qt/paymentrequestplus.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2011-2014 The Bitcoin developers -// Copyright (c) 2017-2019 The PIVX developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_PAYMENTREQUESTPLUS_H -#define BITCOIN_QT_PAYMENTREQUESTPLUS_H - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#include "paymentrequest.pb.h" -#pragma GCC diagnostic pop - -#include "base58.h" - -#include - -#include -#include -#include - -// -// Wraps dumb protocol buffer paymentRequest -// with extra methods -// - -class PaymentRequestPlus -{ -public: - PaymentRequestPlus() {} - - bool parse(const QByteArray& data); - bool SerializeToString(std::string* output) const; - - bool IsInitialized() const; - QString getPKIType() const; - // Returns true if merchant's identity is authenticated, and - // returns human-readable merchant identity in merchant - bool getMerchant(X509_STORE* certStore, QString& merchant) const; - - // Returns list of outputs, amount - QList > getPayTo() const; - - const payments::PaymentDetails& getDetails() const { return details; } - -private: - payments::PaymentRequest paymentRequest; - payments::PaymentDetails details; -}; - -#endif // BITCOIN_QT_PAYMENTREQUESTPLUS_H diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index f4f203492b32..d531b73d6b17 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -30,45 +30,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include #include -#include #include const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds const QString BITCOIN_IPC_PREFIX("pivx:"); -// BIP70 payment protocol messages -const char* BIP70_MESSAGE_PAYMENTACK = "PaymentACK"; -const char* BIP70_MESSAGE_PAYMENTREQUEST = "PaymentRequest"; -// BIP71 payment protocol media types -const char* BIP71_MIMETYPE_PAYMENT = "application/pivx-payment"; -const char* BIP71_MIMETYPE_PAYMENTACK = "application/pivx-paymentack"; -const char* BIP71_MIMETYPE_PAYMENTREQUEST = "application/pivx-paymentrequest"; -// BIP70 max payment request size in bytes (DoS protection) -const qint64 BIP70_MAX_PAYMENTREQUEST_SIZE = 50000; - -struct X509StoreDeleter { - void operator()(X509_STORE* b) { - X509_STORE_free(b); - } -}; - -struct X509Deleter { - void operator()(X509* b) { X509_free(b); } -}; - -namespace // Anon namespace -{ - - std::unique_ptr certStore; -} // // Create a name that is unique for: @@ -95,79 +62,6 @@ static QString ipcServerName() static QList savedPaymentRequests; -static void ReportInvalidCertificate(const QSslCertificate& cert) -{ - qDebug() << QString("%1: Payment server found an invalid certificate: ").arg(__func__) << cert.serialNumber() << cert.subjectInfo(QSslCertificate::CommonName) << cert.subjectInfo(QSslCertificate::DistinguishedNameQualifier) << cert.subjectInfo(QSslCertificate::OrganizationalUnitName); -} - -// -// Load OpenSSL's list of root certificate authorities -// -void PaymentServer::LoadRootCAs(X509_STORE* _store) -{ - // Unit tests mostly use this, to pass in fake root CAs: - if (_store) { - certStore.reset(_store); - return; - } - - // Normal execution, use either -rootcertificates or system certs: - certStore.reset(X509_STORE_new()); - - // Note: use "-system-" default here so that users can pass -rootcertificates="" - // and get 'I don't like X.509 certificates, don't trust anybody' behavior: - QString certFile = QString::fromStdString(gArgs.GetArg("-rootcertificates", "-system-")); - - if (certFile.isEmpty()) - return; // Empty store - - QList certList; - - if (certFile != "-system-") { - certList = QSslCertificate::fromPath(certFile); - // Use those certificates when fetching payment requests, too: - QSslConfiguration::defaultConfiguration().setCaCertificates(certList); - } else - certList = QSslConfiguration::systemCaCertificates(); - - int nRootCerts = 0; - const QDateTime currentTime = QDateTime::currentDateTime(); - for (const QSslCertificate& cert : certList) { - if (currentTime < cert.effectiveDate() || currentTime > cert.expiryDate()) { - ReportInvalidCertificate(cert); - continue; - } - - // Blacklisted certificate - if (cert.isBlacklisted()) { - ReportInvalidCertificate(cert); - continue; - } - QByteArray certData = cert.toDer(); - const unsigned char* data = (const unsigned char*)certData.data(); - - std::unique_ptr x509(d2i_X509(0, &data, certData.size())); - if (x509 && X509_STORE_add_cert(certStore.get(), x509.get())) { - // Note: X509_STORE increases the reference count to the X509 object, - // we still have to release our reference to it. - ++nRootCerts; - } else { - ReportInvalidCertificate(cert); - continue; - } - } - qWarning() << "PaymentServer::LoadRootCAs : Loaded " << nRootCerts << " root certificates"; - - // Project for another day: - // Fetch certificate revocation lists, and add them to certStore. - // Issues to consider: - // performance (start a thread to fetch in background?) - // privacy (fetch through tor/proxy so IP address isn't revealed) - // would it be easier to just use a compiled-in blacklist? - // or use Qt's blacklist? - // "certificate stapling" with server-side caching is more efficient -} - // // Sending to the server is done synchronously, at startup. // If the server isn't already running, startup continues, @@ -200,22 +94,6 @@ void PaymentServer::ipcParseCommandLine(int argc, char* argv[]) SelectParams(CBaseChainParams::TESTNET); } } - } else if (QFile::exists(arg)) // Filename - { - savedPaymentRequests.append(arg); - - PaymentRequestPlus request; - if (readPaymentRequestFromFile(arg, request)) { - if (request.getDetails().network() == "main") { - SelectParams(CBaseChainParams::MAIN); - } else if (request.getDetails().network() == "test") { - SelectParams(CBaseChainParams::TESTNET); - } - } - } else { - // Printing to debug.log is about the best we can do here, the - // GUI hasn't started yet so we can't pop up a message box. - qWarning() << "PaymentServer::ipcSendCommandLine : Payment request file does not exist: " << arg; } } } @@ -260,13 +138,8 @@ bool PaymentServer::ipcSendCommandLine() PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : QObject(parent), saveURIs(true), uriServer(0), - netManager(0), optionsModel(0) { - // Verify that the version of the library that we linked against is - // compatible with the version of the headers we compiled against. - GOOGLE_PROTOBUF_VERIFY_VERSION; - // Install global event filter to catch QFileOpenEvents // on Mac: sent when you click pivx: links // other OSes: helpful when dealing with payment request files (in the future) @@ -287,14 +160,12 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : QObject(p tr("Cannot start pivx: click-to-pay handler")); } else { connect(uriServer, &QLocalServer::newConnection, this, &PaymentServer::handleURIConnection); - connect(this, &PaymentServer::receivedPaymentACK, this, &PaymentServer::handlePaymentACK); } } } PaymentServer::~PaymentServer() { - google::protobuf::ShutdownProtobufLibrary(); } // @@ -317,34 +188,8 @@ bool PaymentServer::eventFilter(QObject* object, QEvent* event) return QObject::eventFilter(object, event); } -void PaymentServer::initNetManager() -{ - if (!optionsModel) - return; - if (netManager != NULL) - delete netManager; - - // netManager is used to fetch paymentrequests given in pivx: URIs - netManager = new QNetworkAccessManager(this); - - QNetworkProxy proxy; - - // Query active SOCKS5 proxy - if (optionsModel->getProxySettings(proxy)) { - netManager->setProxy(proxy); - - qDebug() << "PaymentServer::initNetManager : Using SOCKS5 proxy" << proxy.hostName() << ":" << proxy.port(); - } else - qDebug() << "PaymentServer::initNetManager : No active proxy server found."; - - connect(netManager, &QNetworkAccessManager::finished, this, &PaymentServer::netRequestFinished); - connect(netManager, &QNetworkAccessManager::sslErrors, this, &PaymentServer::reportSslErrors); -} - void PaymentServer::uiReady() { - initNetManager(); - saveURIs = false; for (const QString& s : savedPaymentRequests) { handleURIOrFile(s); @@ -362,25 +207,7 @@ void PaymentServer::handleURIOrFile(const QString& s) if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // pivx: URI { QUrlQuery uri((QUrl(s))); - if (uri.hasQueryItem("r")) // payment request URI - { - QByteArray temp; - temp.append(uri.queryItemValue("r")); - QString decoded = QUrl::fromPercentEncoding(temp); - QUrl fetchUrl(decoded, QUrl::StrictMode); - - if (fetchUrl.isValid()) { - qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")"; - fetchRequest(fetchUrl); - } else { - qWarning() << "PaymentServer::handleURIOrFile : Invalid URL: " << fetchUrl; - Q_EMIT message(tr("URI handling"), - tr("Payment request fetch URL is invalid: %1").arg(fetchUrl.toString()), - CClientUIInterface::ICON_WARNING); - } - - return; - } else // normal URI + // normal URI { SendCoinsRecipient recipient; if (GUIUtil::parseBitcoinURI(s, &recipient)) { @@ -397,20 +224,6 @@ void PaymentServer::handleURIOrFile(const QString& s) return; } } - - if (QFile::exists(s)) // payment request file - { - PaymentRequestPlus request; - SendCoinsRecipient recipient; - if (!readPaymentRequestFromFile(s, request)) { - Q_EMIT message(tr("Payment request file handling"), - tr("Payment request file cannot be read! This can be caused by an invalid payment request file."), - CClientUIInterface::ICON_WARNING); - } else if (processPaymentRequest(request, recipient)) - Q_EMIT receivedPaymentRequest(recipient); - - return; - } } void PaymentServer::handleURIConnection() @@ -433,242 +246,7 @@ void PaymentServer::handleURIConnection() handleURIOrFile(msg); } -// -// Warning: readPaymentRequestFromFile() is used in ipcSendCommandLine() -// so don't use "emit message()", but "QMessageBox::"! -// -bool PaymentServer::readPaymentRequestFromFile(const QString& filename, PaymentRequestPlus& request) -{ - QFile f(filename); - if (!f.open(QIODevice::ReadOnly)) { - qWarning() << QString("PaymentServer::%1: Failed to open %2").arg(__func__).arg(filename); - return false; - } - - // BIP70 DoS protection - if (f.size() > BIP70_MAX_PAYMENTREQUEST_SIZE) { - qWarning() << QString("PaymentServer::%1: Payment request %2 is too large (%3 bytes, allowed %4 bytes).") - .arg(__func__) - .arg(filename) - .arg(f.size()) - .arg(BIP70_MAX_PAYMENTREQUEST_SIZE); - return false; - } - - QByteArray data = f.readAll(); - - return request.parse(data); -} - -bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient) -{ - if (!optionsModel) - return false; - - if (request.IsInitialized()) { - const payments::PaymentDetails& details = request.getDetails(); - - // Payment request network matches client network? - if (details.network() != Params().NetworkIDString()) { - Q_EMIT message(tr("Payment request rejected"), tr("Payment request network doesn't match client network."), - CClientUIInterface::MSG_ERROR); - - return false; - } - - // Expired payment request? - if (details.has_expires() && (int64_t)details.expires() < GetTime()) { - Q_EMIT message(tr("Payment request rejected"), tr("Payment request has expired."), - CClientUIInterface::MSG_ERROR); - - return false; - } - } else { - Q_EMIT message(tr("Payment request error"), tr("Payment request is not initialized."), - CClientUIInterface::MSG_ERROR); - - return false; - } - - recipient.paymentRequest = request; - recipient.message = GUIUtil::HtmlEscape(request.getDetails().memo()); - - request.getMerchant(certStore.get(), recipient.authenticatedMerchant); - - QList > sendingTos = request.getPayTo(); - QStringList addresses; - - for (const std::pair & sendingTo : sendingTos) { - // Extract and check destination addresses - CTxDestination dest; - if (ExtractDestination(sendingTo.first, dest)) { - // Append destination address - addresses.append(QString::fromStdString(EncodeDestination(dest))); - } else if (!recipient.authenticatedMerchant.isEmpty()) { - // Insecure payments to custom pivx addresses are not supported - // (there is no good way to tell the user where they are paying in a way - // they'd have a chance of understanding). - Q_EMIT message(tr("Payment request rejected"), - tr("Unverified payment requests to custom payment scripts are unsupported."), - CClientUIInterface::MSG_ERROR); - return false; - } - - // Extract and check amounts - CTxOut txOut(sendingTo.second, sendingTo.first); - if (IsDust(txOut, ::minRelayTxFee)) { - Q_EMIT message(tr("Payment request error"), tr("Requested payment amount of %1 is too small (considered dust).").arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second)), - CClientUIInterface::MSG_ERROR); - - return false; - } - - recipient.amount += sendingTo.second; - } - // Store addresses and format them to fit nicely into the GUI - recipient.address = addresses.join("
"); - - if (!recipient.authenticatedMerchant.isEmpty()) { - qDebug() << "PaymentServer::processPaymentRequest : Secure payment request from " << recipient.authenticatedMerchant; - } else { - qDebug() << "PaymentServer::processPaymentRequest : Insecure payment request to " << addresses.join(", "); - } - - return true; -} - -void PaymentServer::fetchRequest(const QUrl& url) -{ - QNetworkRequest netRequest; - netRequest.setAttribute(QNetworkRequest::User, BIP70_MESSAGE_PAYMENTREQUEST); - netRequest.setUrl(url); - netRequest.setRawHeader("User-Agent", CLIENT_NAME.c_str()); - netRequest.setRawHeader("Accept", BIP71_MIMETYPE_PAYMENTREQUEST); - netManager->get(netRequest); -} - -void PaymentServer::fetchPaymentACK(CWallet* wallet, const SendCoinsRecipient& recipient, const QByteArray& transaction) -{ - const payments::PaymentDetails& details = recipient.paymentRequest.getDetails(); - if (!details.has_payment_url()) - return; - - QNetworkRequest netRequest; - netRequest.setAttribute(QNetworkRequest::User, BIP70_MESSAGE_PAYMENTACK); - netRequest.setUrl(QString::fromStdString(details.payment_url())); - netRequest.setHeader(QNetworkRequest::ContentTypeHeader, BIP71_MIMETYPE_PAYMENT); - netRequest.setRawHeader("User-Agent", CLIENT_NAME.c_str()); - netRequest.setRawHeader("Accept", BIP71_MIMETYPE_PAYMENTACK); - - payments::Payment payment; - payment.set_merchant_data(details.merchant_data()); - payment.add_transactions(transaction.data(), transaction.size()); - - // Create a new refund address, or re-use: - CPubKey newKey; - if (wallet->GetKeyFromPool(newKey)) { - CKeyID keyID = newKey.GetID(); - std::string label = tr("Refund from %1").arg(recipient.authenticatedMerchant).toStdString(); - wallet->SetAddressBook(keyID, label, "refund"); - CScript s = GetScriptForDestination(keyID); - payments::Output* refund_to = payment.add_refund_to(); - refund_to->set_script(&s[0], s.size()); - } else { - // This should never happen, because sending coins should have - // just unlocked the wallet and refilled the keypool. - qWarning() << "PaymentServer::fetchPaymentACK : Error getting refund key, refund_to not set"; - } - - int length = payment.ByteSize(); - netRequest.setHeader(QNetworkRequest::ContentLengthHeader, length); - QByteArray serData(length, '\0'); - if (payment.SerializeToArray(serData.data(), length)) { - netManager->post(netRequest, serData); - } else { - // This should never happen, either. - qWarning() << "PaymentServer::fetchPaymentACK : Error serializing payment message"; - } -} - -void PaymentServer::netRequestFinished(QNetworkReply* reply) -{ - reply->deleteLater(); - - // BIP70 DoS protection - if (reply->size() > BIP70_MAX_PAYMENTREQUEST_SIZE) { - QString msg = tr("Payment request %1 is too large (%2 bytes, allowed %3 bytes).") - .arg(reply->request().url().toString()) - .arg(reply->size()) - .arg(BIP70_MAX_PAYMENTREQUEST_SIZE); - - qWarning() << QString("PaymentServer::%1:").arg(__func__) << msg; - Q_EMIT message(tr("Payment request DoS protection"), msg, CClientUIInterface::MSG_ERROR); - return; - } - - if (reply->error() != QNetworkReply::NoError) { - QString msg = tr("Error communicating with %1: %2") - .arg(reply->request().url().toString()) - .arg(reply->errorString()); - - qWarning() << "PaymentServer::netRequestFinished: " << msg; - Q_EMIT message(tr("Payment request error"), msg, CClientUIInterface::MSG_ERROR); - return; - } - - QByteArray data = reply->readAll(); - - QString requestType = reply->request().attribute(QNetworkRequest::User).toString(); - if (requestType == BIP70_MESSAGE_PAYMENTREQUEST) { - PaymentRequestPlus request; - SendCoinsRecipient recipient; - if (!request.parse(data)) { - qWarning() << "PaymentServer::netRequestFinished : Error parsing payment request"; - Q_EMIT message(tr("Payment request error"), - tr("Payment request cannot be parsed!"), - CClientUIInterface::MSG_ERROR); - } else if (processPaymentRequest(request, recipient)) - Q_EMIT receivedPaymentRequest(recipient); - - return; - } else if (requestType == BIP70_MESSAGE_PAYMENTACK) { - payments::PaymentACK paymentACK; - if (!paymentACK.ParseFromArray(data.data(), data.size())) { - QString msg = tr("Bad response from server %1") - .arg(reply->request().url().toString()); - - qWarning() << "PaymentServer::netRequestFinished : " << msg; - Q_EMIT message(tr("Payment request error"), msg, CClientUIInterface::MSG_ERROR); - } else { - Q_EMIT receivedPaymentACK(GUIUtil::HtmlEscape(paymentACK.memo())); - } - } -} - -void PaymentServer::reportSslErrors(QNetworkReply* reply, const QList& errs) -{ - Q_UNUSED(reply); - - QString errString; - for (const QSslError& err : errs) { - qWarning() << "PaymentServer::reportSslErrors : " << err; - errString += err.errorString() + "\n"; - } - Q_EMIT message(tr("Network request error"), errString, CClientUIInterface::MSG_ERROR); -} - void PaymentServer::setOptionsModel(OptionsModel* optionsModel) { this->optionsModel = optionsModel; } - -void PaymentServer::handlePaymentACK(const QString& paymentACKMsg) -{ - // currently we don't futher process or store the paymentACK message - Q_EMIT message(tr("Payment acknowledged"), paymentACKMsg, CClientUIInterface::ICON_INFORMATION | CClientUIInterface::MODAL); -} - -X509_STORE* PaymentServer::getCertStore() -{ - return certStore.get(); -} diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index 8cff89d8d0eb..6ec5aab59d6e 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -32,7 +32,6 @@ // sends them to the server. // -#include "paymentrequestplus.h" #include "walletmodel.h" #include @@ -46,15 +45,9 @@ QT_BEGIN_NAMESPACE class QApplication; class QByteArray; class QLocalServer; -class QNetworkAccessManager; -class QNetworkReply; -class QSslError; class QUrl; QT_END_NAMESPACE -// BIP70 max payment request size in bytes (DoS protection) -extern const qint64 BIP70_MAX_PAYMENTREQUEST_SIZE; - class PaymentServer : public QObject { Q_OBJECT @@ -75,29 +68,13 @@ class PaymentServer : public QObject PaymentServer(QObject* parent, bool startLocalServer = true); ~PaymentServer(); - // Load root certificate authorities. Pass NULL (default) - // to read from the file specified in the -rootcertificates setting, - // or, if that's not set, to use the system default root certificates. - // If you pass in a store, you should not X509_STORE_free it: it will be - // freed either at exit or when another set of CAs are loaded. - static void LoadRootCAs(X509_STORE* store = NULL); - - // Return certificate store - static X509_STORE* getCertStore(); - // OptionsModel is used for getting proxy settings and display unit void setOptionsModel(OptionsModel* optionsModel); - // This is now public, because we use it in paymentservertests.cpp - static bool readPaymentRequestFromFile(const QString& filename, PaymentRequestPlus& request); - Q_SIGNALS: // Fired when a valid payment request is received void receivedPaymentRequest(const SendCoinsRecipient& recipient); - // Fired when a valid PaymentACK is received - void receivedPaymentACK(const QString& paymentACKMsg); - // Fired when a message should be reported to the user void message(const QString& title, const QString& message, unsigned int style); @@ -106,17 +83,11 @@ public Q_SLOTS: // to display payment requests to the user void uiReady(); - // Submit Payment message to a merchant, get back PaymentACK: - void fetchPaymentACK(CWallet* wallet, const SendCoinsRecipient& recipient, const QByteArray& transaction); - // Handle an incoming URI, URI with local file scheme or file void handleURIOrFile(const QString& s); private Q_SLOTS: void handleURIConnection(); - void netRequestFinished(QNetworkReply*); - void reportSslErrors(QNetworkReply*, const QList&); - void handlePaymentACK(const QString& paymentACKMsg); protected: // Constructor registers this on the parent QApplication to @@ -124,15 +95,8 @@ private Q_SLOTS: bool eventFilter(QObject* object, QEvent* event); private: - bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient); - void fetchRequest(const QUrl& url); - - // Setup networking - void initNetManager(); - bool saveURIs; // true during startup QLocalServer* uriServer; - QNetworkAccessManager* netManager; // Used to fetch payment requests OptionsModel* optionsModel; }; diff --git a/src/qt/pivx.cpp b/src/qt/pivx.cpp index 63fe0e7574e9..0ad72348c936 100644 --- a/src/qt/pivx.cpp +++ b/src/qt/pivx.cpp @@ -480,7 +480,6 @@ void BitcoinApplication::initializeResult(int retval) returnValue = retval ? 0 : 1; if (retval) { #ifdef ENABLE_WALLET - PaymentServer::LoadRootCAs(); paymentServer->setOptionsModel(optionsModel); #endif @@ -494,9 +493,6 @@ void BitcoinApplication::initializeResult(int retval) window->addWallet(PIVXGUI::DEFAULT_WALLET, walletModel); window->setCurrentWallet(PIVXGUI::DEFAULT_WALLET); - - connect(walletModel, &WalletModel::coinsSent, - paymentServer, &PaymentServer::fetchPaymentACK); } #endif diff --git a/src/qt/pivx/sendmultirow.cpp b/src/qt/pivx/sendmultirow.cpp index 431bcc6ed88b..a95cd6ce3b9b 100644 --- a/src/qt/pivx/sendmultirow.cpp +++ b/src/qt/pivx/sendmultirow.cpp @@ -193,10 +193,6 @@ bool SendMultiRow::validate() // Check input validity bool retval = true; - // Skip checks for payment request - if (recipient.paymentRequest.IsInitialized()) - return retval; - // Check address validity, returns false if it's invalid QString address = ui->lineEditAddress->text(); if (address.isEmpty()){ @@ -224,11 +220,6 @@ bool SendMultiRow::validate() SendCoinsRecipient SendMultiRow::getValue() { - // Payment request - if (recipient.paymentRequest.IsInitialized()) - return recipient; - - // Normal payment recipient.address = getAddress(); recipient.label = ui->lineEditDescription->text(); recipient.amount = getAmountValue(); diff --git a/src/qt/test/paymentrequestdata.h b/src/qt/test/paymentrequestdata.h deleted file mode 100644 index aeaa7d89a036..000000000000 --- a/src/qt/test/paymentrequestdata.h +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright (c) 2009-2014 The Bitcoin developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -// -// Data for paymentservertests.cpp -// - -// Base64/DER-encoded fake certificate authority certificate. -// Convert pem to base64/der with: -// cat file.pem | openssl x509 -inform PEM -outform DER | openssl enc -base64 -// -// Serial Number: 10302349811211485352 (0x8ef94c91b112c0a8) -// Issuer: CN=PaymentRequest Test CA -// Subject: CN=PaymentRequest Test CA -// Not Valid After : Dec 8 16:37:24 2022 GMT -// -const char* caCert_BASE64 = -"\ -MIIB0DCCATmgAwIBAgIJAI75TJGxEsCoMA0GCSqGSIb3DQEBCwUAMCExHzAdBgNV\ -BAMTFlBheW1lbnRSZXF1ZXN0IFRlc3QgQ0EwHhcNMTIxMjEwMTYzNzI0WhcNMjIx\ -MjA4MTYzNzI0WjAhMR8wHQYDVQQDExZQYXltZW50UmVxdWVzdCBUZXN0IENBMIGf\ -MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvua59nX9radoqDYyplcns5qdVDTN1\ -7tmcGixmMYOYU3UYMU55VSsJs0dWKnMm3COQDY+N63c0XSbRqarBcsLTkaNASuPX\ -FCv1VWuEKSyy5xe4zeoDU7CVSzlxtQD9wbZW/s3ISjgaXBpwn6eVmntb0JwYxxPc\ -M1u/hrMD8BDbSQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA\ -A4GBADSaRgK5xe47XxycXBhHhr0Wgl4pAsFsufqA9aB9r8KNEHJ0yUvvbD/jaJJM\ -RtQcf0AJ9olzUMY4syehxbzUJP6aeXhZEYiMvdvcv9D55clq6+WLLlNT3jBgAaVn\ -p3waRjPD4bUX3nv+ojz5s4puw7Qq5QUZlhGsMzPvwDGCmZkL\ -"; - -// -// This payment request validates directly against the -// above certificate authority. -// -const char* paymentrequest1_BASE64 = -"\ -Egt4NTA5K3NoYTI1NhrxAwruAzCCAeowggFToAMCAQICAQEwDQYJKoZIhvcNAQEL\ -BQAwITEfMB0GA1UEAxMWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xMjEyMTAx\ -NjM3MjRaFw0yMjEyMDgxNjM3MjRaMEMxGTAXBgNVBAMMEHRlc3RtZXJjaGFudC5v\ -cmcxJjAkBgNVBAoMHVBheW1lbnQgUmVxdWVzdCBUZXN0IE1lcmNoYW50MIGfMA0G\ -CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHkMy8W1u6HsWlSqdWTmMKf54gICxNfxbY\ -+rcMtAftr62hCYx2d2QiSRd1pCUzmo12IiSX3WxSHwaTnT3MFD6jRx6+zM6XdGar\ -I2zpYle11ANzu4gAthN17uRQHV2O5QxVtzNaMdKeJLXT2L9tfEdyL++9ZUqoQmdA\ -YG9ix330hQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4GB\ -AIkyO99KC68bi9PFRyQQ7nvn5GlQEb3Ca1bRG5+AKN9N5vc8rZ9G2hejtM8wEXni\ -eGBP+chVMsbTPEHKLrwREn7IvcyCcbAStaklPC3w0B/2idQSHskb6P3X13OR2bTH\ -a2+6wuhsOZRUrVNr24rM95DKx/eCC6JN1VW+qRPU6fqzIjQSHwiw2wYSGXapFJVg\ -igPI+6XpExtNLO/i1WFV8ZmoiKwYsuHFiwUqC1VuaXRUZXN0T25lKoABS0j59iMU\ -Uc9MdIfwsO1BskIET0eJSGNZ7eXb9N62u+qf831PMpEHkmlGpk8rHy92nPcgua/U\ -Yt8oZMn3QaTZ5A6HjJbc3A73eLylp1a0SwCl+KDMEvDQhqMn1jAVu2v92AH3uB7n\ -SiWVbw0tX/68iSQEGGfh9n6ee/8Myb3ICdw=\ -"; - -// -// Signed, but expired, merchant cert in the request -// -const char* paymentrequest2_BASE64 = -"\ -Egt4NTA5K3NoYTI1NhrsAwrpAzCCAeUwggFOoAMCAQICAQMwDQYJKoZIhvcNAQEL\ -BQAwITEfMB0GA1UEAxMWUGF5bWVudFJlcXVlc3QgVGVzdCBDQTAeFw0xMzAyMjMy\ -MTI2NDNaFw0xMzAyMjQyMTI2NDNaMD4xHDAaBgNVBAMME2V4cGlyZWRtZXJjaGFu\ -dC5vcmcxHjA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fmEeLzImfM1BWddZjnywku9RToNFZZNgow5QnljmF\ -chhR/aHOuEMTxmc12K4rNlgYtHCsxLP9zd+6u0cva3TucZ6EzS8PKEib/+r12/52\ -664NuWA9WtsK7QCFrK2K95PnVCRmWl0=\ -"; - -// -// Long chain, with an invalid (expired) cert in the middle -// -const char* paymentrequest4_BASE64 = -"\ -Egt4NTA5K3NoYTI1NhqeJAr/AzCCAfswggFkoAMCAQICAQEwDQYJKoZIhvcNAQEL\ -BQAwPzEUMBIGA1UEAwwLdGVzdGNhOC5vcmcxJzAlBgNVBAoMHlBheW1lbnQgUmVx\ -dWVzdCBJbnRlcm1lZGlhdGUgODAeFw0xMzAyMjMyMjQyMzFaFw0yMzAyMjEyMjQy\ -MzFaMDYxGjAYBgNVBAMMEXRlc3RtZXJjaGFudDgub3JnMRgwFgYDVQQKDA9UZXN0\ -IE1lcmNoYW50IDgwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMMCHA3hiHbS\ -TKZ5K9jHRwE8NxkGp3IOx56PDB2diNkldG8XweTcRq7bBm7pdiBt4IVggtfs+6hE\ -hDYIOecyoAnVzPFTdvQ7KQdQ/fD9YLe6lk+o0edOqutPMyrxLFjSluXxEQyk7fdt\ -URloMMYfp3p1/hFCboA1rAsQ2RW38hR5AgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8w\ -DQYJKoZIhvcNAQELBQADgYEAPsdFatnc2RJSpvZsw+nCiPVsllycw5ELglq9vfJz\ -nJJucRxgzmqI2iuas1ugwbXn0BEIRLK7vMF/qBzQR6M/nTxttah+KEu+okjps9vJ\ -cIyhfTyGPC5xkHaHZ7sG+UHOFhPw0/kXn0x+pbVgBZ5315axqcp1R+DTSj/whMAr\ -n0AKiAQwggIEMIIBbaADAgECAgECMA0GCSqGSIb3DQEBCwUAMD8xFDASBgNVBAMM\ -C3Rlc3RjYTcub3JnMScwJQYDVQQKDB5QYXltZW50IFJlcXVlc3QgSW50ZXJtZWRp\ -YXRlIDcwH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DjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4GB\ -AGIRwW7I0QvLga+RnJoJSZNZQbtu4rQW3xmoz8WfZMBYXX3QBYg5ftycbdK+/IbP\ -qozfjGW2AS6DNArvpveSPDTK9+GJBNo1paiNtVqwXkC3Ddscv5AIms1eZGiIOQNC\ -mUvdLkpoXo48WAer3EGsZ3B15GyNEELc0q9W5yUebba1IjUSHwiw2wYSGXapFJVg\ -igPI+6XpExtNLO/i1WFV8ZmoiKwYuPvFiwUqDFVuaXRUZXN0Rml2ZSqAAXdsMgdG\ -ssymvca1S/1KeM3n8Ydi2fi1JUzAAr59xPvNJRUeqCLP9upHn5z7br3P12Oz9A20\ -5/4wL4ClPRPVnOHgij0bEg+y0tGESqmF1rfOfXDszlo2U92wCxS07kq79YAZJ1Zo\ -XYh860/Q4wvc7lfiTe+dXBzPKAKhMy91yETY\ -"; diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp deleted file mode 100644 index 860157a44a93..000000000000 --- a/src/qt/test/paymentservertests.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 2009-2014 The Bitcoin developers -// Copyright (c) 2018-2019 The PIVX developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "paymentservertests.h" - -#include "optionsmodel.h" -#include "paymentrequestdata.h" - -#include "random.h" -#include "util.h" -#include "utilstrencodings.h" - -#include -#include - -X509 *parse_b64der_cert(const char* cert_data) -{ - std::vector data = DecodeBase64(cert_data); - assert(data.size() > 0); - const unsigned char* dptr = &data[0]; - X509 *cert = d2i_X509(NULL, &dptr, data.size()); - assert(cert); - return cert; -} - -// -// Test payment request handling -// - -static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector& data) -{ - RecipientCatcher sigCatcher; - QObject::connect(server, &PaymentServer::receivedPaymentRequest, - &sigCatcher, &RecipientCatcher::getRecipient); - - // Write data to a temp file: - QTemporaryFile f; - f.open(); - f.write((const char*)&data[0], data.size()); - f.close(); - - // Create a QObject, install event filter from PaymentServer - // and send a file open event to the object - QObject object; - object.installEventFilter(server); - QFileOpenEvent event(f.fileName()); - // If sending the event fails, this will cause sigCatcher to be empty, - // which will lead to a test failure anyway. - QCoreApplication::sendEvent(&object, &event); - - QObject::disconnect(server, &PaymentServer::receivedPaymentRequest, - &sigCatcher, &RecipientCatcher::getRecipient); - - // Return results from sigCatcher - return sigCatcher.recipient; -} - -void PaymentServerTests::paymentServerTests() -{ - SelectParams(CBaseChainParams::MAIN); - OptionsModel optionsModel; - PaymentServer* server = new PaymentServer(NULL, false); - X509_STORE* caStore = X509_STORE_new(); - X509_STORE_add_cert(caStore, parse_b64der_cert(caCert_BASE64)); - PaymentServer::LoadRootCAs(caStore); - server->setOptionsModel(&optionsModel); - server->uiReady(); - - // Now feed PaymentRequests to server, and observe signals it produces: - std::vector data = DecodeBase64(paymentrequest1_BASE64); - SendCoinsRecipient r = handleRequest(server, data); - QString merchant; - r.paymentRequest.getMerchant(caStore, merchant); - QCOMPARE(merchant, QString("testmerchant.org")); - - // Version of the above, with an expired certificate: - data = DecodeBase64(paymentrequest2_BASE64); - r = handleRequest(server, data); - r.paymentRequest.getMerchant(caStore, merchant); - QCOMPARE(merchant, QString("")); - - // Long certificate chain: - data = DecodeBase64(paymentrequest3_BASE64); - r = handleRequest(server, data); - r.paymentRequest.getMerchant(caStore, merchant); - QCOMPARE(merchant, QString("testmerchant8.org")); - - // Long certificate chain, with an expired certificate in the middle: - data = DecodeBase64(paymentrequest4_BASE64); - r = handleRequest(server, data); - r.paymentRequest.getMerchant(caStore, merchant); - QCOMPARE(merchant, QString("")); - - // Validly signed, but by a CA not in our root CA list: - data = DecodeBase64(paymentrequest5_BASE64); - r = handleRequest(server, data); - r.paymentRequest.getMerchant(caStore, merchant); - QCOMPARE(merchant, QString("")); - - // Try again with no root CA's, verifiedMerchant should be empty: - caStore = X509_STORE_new(); - PaymentServer::LoadRootCAs(caStore); - data = DecodeBase64(paymentrequest1_BASE64); - r = handleRequest(server, data); - r.paymentRequest.getMerchant(caStore, merchant); - QCOMPARE(merchant, QString("")); - - // Test BIP70 DoS protection: - auto randdata = FastRandomContext().randbytes(BIP70_MAX_PAYMENTREQUEST_SIZE + 1); - - // Write data to a temp file: - QTemporaryFile tempFile; - tempFile.open(); - tempFile.write((const char*)randdata.data(), randdata.size()); - tempFile.close(); - // Trigger BIP70 DoS protection - QCOMPARE(PaymentServer::readPaymentRequestFromFile(tempFile.fileName(), r.paymentRequest), false); - - delete server; -} - -void RecipientCatcher::getRecipient(const SendCoinsRecipient& r) -{ - recipient = r; -} diff --git a/src/qt/test/paymentservertests.h b/src/qt/test/paymentservertests.h deleted file mode 100644 index e4dd33faadbe..000000000000 --- a/src/qt/test/paymentservertests.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2009-2014 The Bitcoin developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_TEST_PAYMENTSERVERTESTS_H -#define BITCOIN_QT_TEST_PAYMENTSERVERTESTS_H - -#include "../paymentserver.h" - -#include -#include - -class PaymentServerTests : public QObject -{ - Q_OBJECT - -private Q_SLOTS: - void paymentServerTests(); -}; - -// Dummy class to receive paymentserver signals. -// If SendCoinsRecipient was a proper QObject, then -// we could use QSignalSpy... but it's not. -class RecipientCatcher : public QObject -{ - Q_OBJECT - -public Q_SLOTS: - void getRecipient(const SendCoinsRecipient& r); - -public: - SendCoinsRecipient recipient; -}; - -#endif // BITCOIN_QT_TEST_PAYMENTSERVERTESTS_H diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index afbef1ef86e3..5a23c4e9a394 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -11,16 +11,10 @@ #include "util.h" #include "uritests.h" -#ifdef ENABLE_WALLET -#include "paymentservertests.h" -#endif - #include #include #include -#include - #if defined(QT_STATICPLUGIN) #include #if defined(QT_QPA_PLATFORM_MINIMAL) @@ -48,16 +42,9 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); app.setApplicationName("Pivx-Qt-test"); - SSL_library_init(); - URITests test1; if (QTest::qExec(&test1) != 0) fInvalid = true; -#ifdef ENABLE_WALLET - PaymentServerTests test2; - if (QTest::qExec(&test2) != 0) - fInvalid = true; -#endif return fInvalid; } diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 10bef4e515c6..089a58e5c8ea 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -81,7 +81,6 @@ HelpMessageDialog::HelpMessageDialog(QWidget* parent, bool about) : QDialog(pare strUsage += HelpMessageOpt("-choosedatadir", strprintf(tr("Choose data directory on startup (default: %u)").toStdString(), DEFAULT_CHOOSE_DATADIR)); strUsage += HelpMessageOpt("-lang=", tr("Set language, for example \"de_DE\" (default: system locale)").toStdString()); strUsage += HelpMessageOpt("-min", tr("Start minimized").toStdString()); - strUsage += HelpMessageOpt("-rootcertificates=", tr("Set SSL root certificates for payment request (default: -system-)").toStdString()); strUsage += HelpMessageOpt("-splash", strprintf(tr("Show splash screen on startup (default: %u)").toStdString(), DEFAULT_SPLASHSCREEN)); strUsage += HelpMessageOpt("-hidecharts", strprintf(tr("Hide QT staking charts on startup (default: %u)").toStdString(), false)); QString coreOptions = QString::fromStdString(strUsage); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 07e0735d973d..bbd34d7bb984 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -451,22 +451,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact // Pre-check input data for validity for (const SendCoinsRecipient& rcp : recipients) { - if (rcp.paymentRequest.IsInitialized()) { // PaymentRequest... - CAmount subtotal = 0; - const payments::PaymentDetails& details = rcp.paymentRequest.getDetails(); - for (int i = 0; i < details.outputs_size(); i++) { - const payments::Output& out = details.outputs(i); - if (out.amount() <= 0) continue; - subtotal += out.amount(); - const unsigned char* scriptStr = (const unsigned char*)out.script().data(); - CScript scriptPubKey(scriptStr, scriptStr + out.script().size()); - vecSend.emplace_back(scriptPubKey, static_cast(out.amount()), false); - } - if (subtotal <= 0) { - return InvalidAmount; - } - total += subtotal; - } else { // User-entered pivx address / amount: + { // User-entered pivx address / amount: if (!validateAddress(rcp.address, rcp.isP2CS)) { return InvalidAddress; } @@ -575,20 +560,6 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction& tran LOCK2(cs_main, wallet->cs_wallet); QList recipients = transaction.getRecipients(); - // Store PaymentRequests in wtx.vOrderForm in wallet. - /* todo: clean this functionality, we don't have the payment request server nor using the vOrderForm field. - for (const SendCoinsRecipient& rcp : recipients) { - if (rcp.paymentRequest.IsInitialized()) { - std::string key("PaymentRequest"); - std::string value; - rcp.paymentRequest.SerializeToString(&value); - newTx->vOrderForm.emplace_back(key, value); - } else if (!rcp.message.isEmpty()) // Message from normal pivx:URI (pivx:XyZ...?message=example) - { - newTx->vOrderForm.emplace_back("Message", rcp.message.toStdString()); - } - }*/ - CReserveKey* keyChange = transaction.getPossibleKeyChange(); const CWallet::CommitResult& res = wallet->CommitTransaction(newTx, keyChange, g_connman.get()); if (res.status != CWallet::CommitStatus::OK) { @@ -604,7 +575,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction& tran // and emit coinsSent signal for each recipient for (const SendCoinsRecipient& rcp : transaction.getRecipients()) { // Don't touch the address book when we have a payment request - if (!rcp.paymentRequest.IsInitialized()) { + { bool isStaking = false; bool isShielded = false; auto address = Standard::DecodeDestination(rcp.address.toStdString(), isStaking, isShielded); diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 38dec22c07a4..4306a5ed2a26 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -7,12 +7,16 @@ #ifndef PIVX_QT_WALLETMODEL_H #define PIVX_QT_WALLETMODEL_H +#if defined(HAVE_CONFIG_H) +#include "config/pivx-config.h" +#endif + #include "interfaces/wallet.h" +#include "key.h" #include "operationresult.h" #include "support/allocators/zeroafterfree.h" #include "pairresult.h" -#include "qt/paymentrequestplus.h" #include #include @@ -71,8 +75,9 @@ class SendCoinsRecipient // If from a payment request, this is used for storing the memo QString message{}; - // If from a payment request, paymentRequest.IsInitialized() will be true - PaymentRequestPlus paymentRequest{}; + // serialized string to ensure load/store is lossless + std::string sPaymentRequest{}; + // Empty if no authentication or invalid signature/cert/etc. QString authenticatedMerchant{}; @@ -87,9 +92,6 @@ class SendCoinsRecipient std::string sAddress = address.toStdString(); std::string sLabel = label.toStdString(); std::string sMessage = message.toStdString(); - std::string sPaymentRequest; - if (!ser_action.ForRead() && paymentRequest.IsInitialized()) - paymentRequest.SerializeToString(&sPaymentRequest); std::string sAuthenticatedMerchant = authenticatedMerchant.toStdString(); READWRITE(this->nVersion); @@ -104,8 +106,6 @@ class SendCoinsRecipient address = QString::fromStdString(sAddress); label = QString::fromStdString(sLabel); message = QString::fromStdString(sMessage); - if (!sPaymentRequest.empty()) - paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size())); authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant); } } diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h index 4848377998d9..93fa24b5e5b6 100644 --- a/src/qt/walletmodeltransaction.h +++ b/src/qt/walletmodeltransaction.h @@ -7,6 +7,9 @@ #include "walletmodel.h" +#include "amount.h" +#include "primitives/transaction.h" + #include class SendCoinsRecipient; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index b80d39141f2a..10d6cdaddc0d 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -163,7 +163,7 @@ target_link_libraries(test_pivx PRIVATE crc32c secp256k1 rustzcash - ${BerkeleyDB_LIBRARIES} ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${LIBEVENT_LIB} pthread + ${BerkeleyDB_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY} ${Boost_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${LIBEVENT_LIB} pthread ) if(GMP_FOUND) target_link_libraries(test_pivx PRIVATE ${GMP_LIBRARY}) From 4dc8924906a07e81ce706c33c1f2ee89b0b70cd5 Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Sat, 27 Mar 2021 17:57:35 -0700 Subject: [PATCH 04/10] GUI: remove payment request file handling from OpenURI dialog --- src/qt/forms/openuridialog.ui | 29 ++--------------------------- src/qt/openuridialog.cpp | 28 ---------------------------- src/qt/openuridialog.h | 3 --- src/qt/paymentserver.cpp | 3 +-- src/qt/pivx/send.cpp | 2 +- 5 files changed, 4 insertions(+), 61 deletions(-) diff --git a/src/qt/forms/openuridialog.ui b/src/qt/forms/openuridialog.ui index 699f176f7bc4..0f1f523e9d06 100644 --- a/src/qt/forms/openuridialog.ui +++ b/src/qt/forms/openuridialog.ui @@ -56,7 +56,7 @@ - Open payment request from URI or file + Open PIVX URI Qt::AlignCenter @@ -82,7 +82,7 @@ - TextLabel + TextLabel @@ -101,31 +101,6 @@ - - - - - 0 - 41 - - - - Select payment request file - - - #selectFileButton{ - border-top-left-radius:0px; - border-bottom-left-radius:0px; -} - - - ... - - - false - - - diff --git a/src/qt/openuridialog.cpp b/src/qt/openuridialog.cpp index 699c78e816b4..1cb2a7dd5ec7 100644 --- a/src/qt/openuridialog.cpp +++ b/src/qt/openuridialog.cpp @@ -25,7 +25,6 @@ OpenURIDialog::OpenURIDialog(QWidget* parent) : QDialog(parent, Qt::WindowSystem setCssProperty(ui->labelTitle, "text-title-dialog"); setCssBtnPrimary(ui->pushButtonOK); - setCssBtnPrimary(ui->selectFileButton); setCssProperty(ui->pushButtonCancel, "btn-dialog-cancel"); initCssEditLine(ui->uriEdit, true); @@ -59,33 +58,6 @@ void OpenURIDialog::accept() } } -void OpenURIDialog::on_selectFileButton_clicked() -{ - QString filename = GUIUtil::getOpenFileName(this, tr("Select payment request file to open"), "", "", NULL); - if (filename.isEmpty()) - return; - - QFile file(filename); - if(!file.exists()) { - inform(tr("File not found")); - return; - } - - if (file.open(QIODevice::ReadOnly | QIODevice::Text)){ - QByteArray r = file.readAll(); - if (r.size() > 200) { - inform(tr("Parsed data too large")); - return; - } - - QString str = QString::fromStdString(std::string(r.constData(), r.length())); - if (!str.startsWith("pivx")) { - inform(tr("Invalid URI, not starting with \"pivx\" prefix")); - } - ui->uriEdit->setText(str); - } -} - void OpenURIDialog::inform(const QString& str) { if (!snackBar) snackBar = new SnackBar(nullptr, this); snackBar->setText(str); diff --git a/src/qt/openuridialog.h b/src/qt/openuridialog.h index b2bebafe1ac8..5acdc6f5a662 100644 --- a/src/qt/openuridialog.h +++ b/src/qt/openuridialog.h @@ -27,9 +27,6 @@ class OpenURIDialog : public QDialog protected Q_SLOTS: void accept() override; -private Q_SLOTS: - void on_selectFileButton_clicked(); - private: Ui::OpenURIDialog* ui; SnackBar *snackBar = nullptr; diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index d531b73d6b17..f8265c4fd027 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -169,8 +169,7 @@ PaymentServer::~PaymentServer() } // -// OSX-specific way of handling pivx: URIs and -// PaymentRequest mime types +// OSX-specific way of handling pivx: URIs // bool PaymentServer::eventFilter(QObject* object, QEvent* event) { diff --git a/src/qt/pivx/send.cpp b/src/qt/pivx/send.cpp index b3e21f817e98..ea1e49d39dde 100644 --- a/src/qt/pivx/send.cpp +++ b/src/qt/pivx/send.cpp @@ -73,7 +73,7 @@ SendWidget::SendWidget(PIVXGUI* parent) : // Uri ui->btnUri->setTitleClassAndText("btn-title-grey", tr("Open URI")); - ui->btnUri->setSubTitleClassAndText("text-subtitle", tr("Parse a payment request")); + ui->btnUri->setSubTitleClassAndText("text-subtitle", tr("Parse a PIVX URI")); // Shield coins ui->btnShieldCoins->setTitleClassAndText("btn-title-grey", tr("Shield Coins")); From dc843fb3fdd2ddab8ad018b0351fd04c90615552 Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Sat, 27 Mar 2021 17:59:28 -0700 Subject: [PATCH 05/10] build: remove BIP70 entries from macOS Info.plist --- share/qt/Info.plist.in | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/share/qt/Info.plist.in b/share/qt/Info.plist.in index 8a8adf013388..de57c688b406 100644 --- a/share/qt/Info.plist.in +++ b/share/qt/Info.plist.in @@ -54,43 +54,6 @@ - UTExportedTypeDeclarations - - - UTTypeIdentifier - io.pivx.paymentrequest - UTTypeDescription - Pivx payment request - UTTypeConformsTo - - public.data - - UTTypeTagSpecification - - public.mime-type - application/x-pivx-payment-request - public.filename-extension - - pivxpaymentrequest - - - - - - CFBundleDocumentTypes - - - CFBundleTypeRole - Editor - LSItemContentTypes - - io.pivx.paymentrequest - - LSHandlerRank - Owner - - - NSPrincipalClass NSApplication From dd471deea5e8e8acdbfedfda47081c725a316fc3 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 16 Oct 2019 10:43:16 -0700 Subject: [PATCH 06/10] build: remove SSL lib detection --- CMakeLists.txt | 2 +- configure.ac | 5 ----- src/Makefile.am | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31d7496cfeab..ae6ce0555fcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ if(BerkeleyDB_FOUND) endif() endif() -find_package(OpenSSL REQUIRED) +find_package(OpenSSL COMPONENTS Crypto REQUIRED) if(OPENSSL_FOUND) message(STATUS "Found OpenSSL (${OPENSSL_VERSION}): ${OPENSSL_LIBRARIES}") if(OPENSSL_VERSION VERSION_GREATER_EQUAL 1.1) diff --git a/configure.ac b/configure.ac index 7b2e1cd2cd60..dc917b016087 100644 --- a/configure.ac +++ b/configure.ac @@ -1089,7 +1089,6 @@ if test x$use_pkgconfig = xyes; then 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.)]) BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode],,[BITCOIN_QT_FAIL(libqrencode not found)])]) if test x$use_qtcharts != xno; then @@ -1119,9 +1118,6 @@ 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_bitcoin_utils$build_bitcoind$bitcoin_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)) @@ -1492,7 +1488,6 @@ AC_SUBST(TESTDEFS) 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(SODIUM_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index 159a241d5be5..8d248316fd7b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,7 @@ LIBUNIVALUE = $(UNIVALUE_LIBS) endif BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config -BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) +BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) BITCOIN_INCLUDES += -I$(srcdir)/rust/include BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include From 752a337b2d09abe510c8f402b7cf7cca1271063d Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 15 Oct 2019 14:10:32 -0700 Subject: [PATCH 07/10] build: remove OpenSSL from Qt build More info available from: https://doc.qt.io/qt-5/ssl.html#enabling-and-disabling-ssl-support --- depends/packages/qt.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index a5bb14382905..27753b5520f0 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -4,7 +4,7 @@ $(package)_download_path=https://download.qt.io/official_releases/qt/5.9/$($(pac $(package)_suffix=opensource-src-$($(package)_version).tar.xz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=36dd9574f006eaa1e5af780e4b33d11fe39d09fd7c12f3b9d83294174bd28f00 -$(package)_dependencies=openssl zlib +$(package)_dependencies=zlib $(package)_linux_dependencies=freetype fontconfig libxcb $(package)_build_subdir=qtbase $(package)_qt_libs=corelib network widgets gui plugins testlib concurrent @@ -47,9 +47,11 @@ $(package)_config_opts += -no-kms $(package)_config_opts += -no-linuxfb $(package)_config_opts += -no-libudev $(package)_config_opts += -no-mtdev +$(package)_config_opts += -no-openssl $(package)_config_opts += -no-openvg $(package)_config_opts += -no-reduce-relocations $(package)_config_opts += -no-qml-debug +$(package)_config_opts += -no-securetransport $(package)_config_opts += -no-sql-db2 $(package)_config_opts += -no-sql-ibase $(package)_config_opts += -no-sql-oci @@ -64,7 +66,6 @@ $(package)_config_opts += -no-xinput2 $(package)_config_opts += -nomake examples $(package)_config_opts += -nomake tests $(package)_config_opts += -opensource -$(package)_config_opts += -openssl-linked $(package)_config_opts += -optimized-qmake $(package)_config_opts += -pch $(package)_config_opts += -pkg-config From 317f31410059116c878e83f71fcc29e7b26997d6 Mon Sep 17 00:00:00 2001 From: fanquake Date: Sat, 19 Oct 2019 12:06:47 -0400 Subject: [PATCH 08/10] build: skip building OpenSSL lib_ssl --- depends/packages/openssl.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk index c93e76e1fc35..eb97ec53e092 100644 --- a/depends/packages/openssl.mk +++ b/depends/packages/openssl.mk @@ -74,7 +74,7 @@ define $(package)_config_cmds endef define $(package)_build_cmds - $(MAKE) -j1 build_libs libcrypto.pc libssl.pc openssl.pc + $(MAKE) -j1 build_crypto libcrypto.pc libssl.pc openssl.pc endef define $(package)_stage_cmds From bcd3ee0e4b3d91bbb27d05dc7f3b1dccda1afd13 Mon Sep 17 00:00:00 2001 From: fanquake Date: Sat, 19 Oct 2019 13:45:36 -0400 Subject: [PATCH 09/10] compat: remove bswap_* check on macOS This was originally added in #9366 to fix the gui build, as Protobuf would also define these macros. Now that we're no-longer using Protobuf, remove the additional check. --- src/compat/byteswap.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/compat/byteswap.h b/src/compat/byteswap.h index ae2e080faec0..4ebef1e1dd4d 100644 --- a/src/compat/byteswap.h +++ b/src/compat/byteswap.h @@ -17,20 +17,13 @@ #if defined(__APPLE__) -#if !defined(bswap_16) - -// Mac OS X / Darwin features; we include a check for bswap_16 because if it is already defined, protobuf has -// defined these macros for us already; if it isn't, we do it ourselves. In either case, we get the exact same -// result regardless which path was taken #include #define bswap_16(x) OSSwapInt16(x) #define bswap_32(x) OSSwapInt32(x) #define bswap_64(x) OSSwapInt64(x) -#endif // !defined(bswap_16) - #else -// Non-Mac OS X / non-Darwin +// Non-MacOS / non-Darwin #if HAVE_DECL_BSWAP_16 == 0 inline uint16_t bswap_16(uint16_t x) From 6e25d8320eb9f8f4c2c6f7cd09dd299126cdb454 Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Thu, 1 Apr 2021 01:05:33 -0700 Subject: [PATCH 10/10] Remove remaining references to BIP70 in comments, rpc output, and the REST doc --- doc/REST-interface.md | 2 +- src/chainparams.h | 4 ++-- src/chainparamsbase.h | 6 ++++-- src/qt/networkstyle.h | 2 +- src/rpc/blockchain.cpp | 2 +- src/rpc/mining.cpp | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/REST-interface.md b/doc/REST-interface.md index a9eed451e637..6292bb669f2d 100644 --- a/doc/REST-interface.md +++ b/doc/REST-interface.md @@ -33,7 +33,7 @@ Given a block hash: returns amount of blockheaders in upward direction. Returns various state info regarding block chain processing. Only supports JSON as output format. -* chain : (string) current network name as defined in BIP70 (main, test, regtest) +* chain : (string) current network name (main, test, regtest) * blocks : (numeric) the current number of blocks processed in the server * headers : (numeric) the current number of headers we have validated * bestblockhash : (string) the hash of the currently best block diff --git a/src/chainparams.h b/src/chainparams.h index 85401ebb710b..5b08d6c30d46 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -75,7 +75,7 @@ class CChainParams /** Default value for -checkmempool and -checkblockindex argument */ bool DefaultConsistencyChecks() const { return IsRegTestNet(); } - /** Return the BIP70 network string (main, test or regtest) */ + /** Return the network string */ std::string NetworkIDString() const { return strNetworkID; } const std::vector& DNSSeeds() const { return vSeeds; } const std::vector& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } @@ -115,7 +115,7 @@ std::unique_ptr CreateChainParams(const std::string& chain); const CChainParams& Params(); /** - * Sets the params returned by Params() to those for the given BIP70 chain name. + * Sets the params returned by Params() to those for the given chain name. * @throws std::runtime_error when the chain is not supported. */ void SelectParams(const std::string& chain); diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index 1b9483db6c00..1be1c4c18568 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -17,10 +17,12 @@ class CBaseChainParams { public: - /** BIP70 chain name strings (main, test or regtest) */ + ///@{ + /** Chain name strings */ static const std::string MAIN; static const std::string TESTNET; static const std::string REGTEST; + ///@} const std::string& DataDir() const { return strDataDir; } int RPCPort() const { return nRPCPort; } @@ -55,7 +57,7 @@ const CBaseChainParams& BaseParams(); void SelectBaseParams(const std::string& chain); /** - * Looks for -regtest, -testnet and returns the appropriate BIP70 chain name. + * Returns the appropriate chain name from the program arguments. * @return CBaseChainParams::MAX_NETWORK_TYPES if an invalid combination is given. CBaseChainParams::MAIN by default. */ std::string ChainNameFromCommandLine(); diff --git a/src/qt/networkstyle.h b/src/qt/networkstyle.h index 2533755f9b76..f346cdcf2797 100644 --- a/src/qt/networkstyle.h +++ b/src/qt/networkstyle.h @@ -13,7 +13,7 @@ class NetworkStyle { public: - /** Get style associated with provided BIP70 network id, or 0 if not known */ + /** Get style associated with provided network id, or 0 if not known */ static const NetworkStyle* instantiate(const QString& networkId); const QString& getAppName() const { return appName; } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index c49d1de4eef5..395cbc6e79ec 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -982,7 +982,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) "\nResult:\n" "{\n" - " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" + " \"chain\": \"xxxx\", (string) current network name (main, test, regtest)\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" " \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n" " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n" diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 4fc4c257b255..6c9e4152db76 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -300,7 +300,7 @@ UniValue getmininginfo(const JSONRPCRequest& request) " \"hashespersec\": n (numeric) The hashes per second of the generation, or 0 if no generation.\n" " \"pooledtx\": n (numeric) The size of the mem pool\n" " \"testnet\": true|false (boolean) If using testnet or not\n" - " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" + " \"chain\": \"xxxx\", (string) current network name (main, test, regtest)\n" "}\n" "\nExamples:\n" +