Page MenuHomePhabricator

D4619.vs14737.id15017.diff
No OneTemporary

D4619.vs14737.id15017.diff

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -198,6 +198,11 @@
[disable ZMQ notifications])],
[use_zmq=$enableval],
[use_zmq=yes])
+AC_ARG_ENABLE([bip70],
+ [AS_HELP_STRING([--disable-bip70],
+ [disable BIP70 (payment protocol) support in GUI (enabled by default)])],
+ [enable_bip70=$enableval],
+ [enable_bip70=yes])
AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
@@ -924,7 +929,9 @@
[
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)])])
+ if test x$enable_bip70 != xno; then
+ BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
+ fi
if test x$use_qr != xno; then
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
fi
@@ -984,7 +991,9 @@
esac
fi
- BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
+ if test x$enable_bip70 != xno; then
+ BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
+ fi
if test x$use_qr != xno; then
BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])])
BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
@@ -1046,7 +1055,9 @@
AC_SUBST(UNIVALUE_CFLAGS)
AC_SUBST(UNIVALUE_LIBS)
-BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
+if test x$enable_bip70 != xno; then
+ BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
+fi
AC_MSG_CHECKING([whether to build bitcoind])
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
@@ -1164,6 +1175,15 @@
else
AC_MSG_RESULT([no])
fi
+
+ AC_MSG_CHECKING([whether to build BIP70 support])
+ if test x$enable_bip70 != xno; then
+ AC_DEFINE([ENABLE_BIP70],[1],[Define if BIP70 support should be compiled in])
+ enable_bip70=yes
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
fi
AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])
@@ -1195,6 +1215,7 @@
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
+AM_CONDITIONAL([ENABLE_BIP70],[test x$enable_bip70 = 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])
@@ -1323,6 +1344,7 @@
echo " with wallet = $enable_wallet"
echo " with gui / qt = $bitcoin_enable_qt"
if test x$bitcoin_enable_qt != xno; then
+ echo " with bip70 = $enable_bip70"
echo " with qr = $use_qr"
fi
echo " with zmq = $use_zmq"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,6 +16,7 @@
option(BUILD_BITCOIN_TX "Build bitcoin-tx" ON)
option(BUILD_BITCOIN_QT "Build bitcoin-qt" ON)
option(BUILD_LIBBITCOINCONSENSUS "Build the bitcoinconsenus shared library" ON)
+option(ENABLE_BIP70 "Enable BIP70 (payment protocol) support in GUI" ON)
option(ENABLE_HARDENING "Harden the executables" ON)
option(ENABLE_REDUCE_EXPORTS "Reduce the amount of exported symbols" OFF)
option(ENABLE_STATIC_LIBSTDCXX "Statically link libstdc++" OFF)
diff --git a/src/Makefile.am b/src/Makefile.am
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -668,9 +668,11 @@
$(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
endif
+if ENABLE_BIP70
%.pb.cc %.pb.h: %.proto
@test -f $(PROTOC)
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(<D) $<
+endif
if EMBEDDED_LEVELDB
include Makefile.leveldb.include
diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include
--- a/src/Makefile.qt.include
+++ b/src/Makefile.qt.include
@@ -176,9 +176,15 @@
QT_QRC_LOCALE_CPP = qt/qrc_bitcoin_locale.cpp
QT_QRC_LOCALE = qt/bitcoin_locale.qrc
+if ENABLE_BIP70
PROTOBUF_CC = qt/paymentrequest.pb.cc
PROTOBUF_H = qt/paymentrequest.pb.h
PROTOBUF_PROTO = qt/paymentrequest.proto
+else
+PROTOBUF_CC =
+PROTOBUF_H =
+PROTOBUF_PROTO =
+endif
BITCOIN_QT_H = \
qt/addressbookpage.h \
@@ -329,7 +335,6 @@
qt/editaddressdialog.cpp \
qt/openuridialog.cpp \
qt/overviewpage.cpp \
- qt/paymentrequestplus.cpp \
qt/paymentserver.cpp \
qt/receivecoinsdialog.cpp \
qt/receiverequestdialog.cpp \
@@ -348,13 +353,19 @@
qt/walletmodeltransaction.cpp \
qt/walletview.cpp
+BITCOIN_QT_WALLET_BIP70_CPP = \
+ qt/paymentrequestplus.cpp
+
BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP)
if TARGET_WINDOWS
BITCOIN_QT_CPP += $(BITCOIN_QT_WINDOWS_CPP)
endif
if ENABLE_WALLET
BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_CPP)
-endif
+if ENABLE_BIP70
+BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_BIP70_CPP)
+endif # ENABLE_BIP70
+endif # ENABLE_WALLET
RES_IMAGES =
@@ -406,8 +417,11 @@
if ENABLE_ZMQ
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
+if ENABLE_BIP70
+qt_bitcoin_qt_LDADD += $(SSL_LIBS)
+endif
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_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) \
+ $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
qt_bitcoin_qt_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag CXX
diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include
--- a/src/Makefile.qttest.include
+++ b/src/Makefile.qttest.include
@@ -16,9 +16,12 @@
if ENABLE_WALLET
TEST_QT_MOC_CPP += \
qt/test/moc_addressbooktests.cpp \
- qt/test/moc_paymentservertests.cpp \
qt/test/moc_wallettests.cpp
-endif
+if ENABLE_BIP70
+TEST_QT_MOC_CPP += \
+ qt/test/moc_paymentservertests.cpp
+endif # ENABLE_BIP70
+endif # ENABLE_WALLET
TEST_QT_H = \
qt/test/addressbooktests.h \
@@ -57,10 +60,13 @@
if ENABLE_WALLET
qt_test_test_bitcoin_qt_SOURCES += \
qt/test/addressbooktests.cpp \
- qt/test/paymentservertests.cpp \
qt/test/wallettests.cpp \
wallet/test/wallet_test_fixture.cpp
-endif
+if ENABLE_BIP70
+qt_test_test_bitcoin_qt_SOURCES += \
+ qt/test/paymentservertests.cpp
+endif # ENABLE_BIP70
+endif # ENABLE_WALLET
nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
diff --git a/src/config/bitcoin-config.h.cmake.in b/src/config/bitcoin-config.h.cmake.in
--- a/src/config/bitcoin-config.h.cmake.in
+++ b/src/config/bitcoin-config.h.cmake.in
@@ -62,6 +62,7 @@
#define FDELT_TYPE ${FDELT_TYPE}
+#cmakedefine ENABLE_BIP70 1
#cmakedefine ENABLE_WALLET 1
#cmakedefine ENABLE_ZMQ 1
diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt
--- a/src/qt/CMakeLists.txt
+++ b/src/qt/CMakeLists.txt
@@ -74,10 +74,6 @@
# Handle qrc resources
qt5_add_resources(QRC_BITCOIN_CPP bitcoin.qrc)
-# Do protobuf codegen
-find_package(Protobuf REQUIRED)
-protobuf_generate_cpp(PROTOBUF_SOURCES PROTOBUF_HEADERS paymentrequest.proto)
-
add_library(bitcoin-qt-base
bantablemodel.cpp
bitcoin.cpp
@@ -106,10 +102,6 @@
# Handle ui files
${UI_GENERATED_HEADERS}
- # Protobuf codegen
- ${PROTOBUF_HEADERS}
- ${PROTOBUF_SOURCES}
-
# Translations
${BITCOIN_QM_FILES}
@@ -118,7 +110,20 @@
qrc_bitcoin_locale.cpp
)
-target_include_directories(bitcoin-qt-base PUBLIC ${Protobuf_INCLUDE_DIRS})
+if(ENABLE_BIP70)
+ # Do protobuf codegen
+ find_package(Protobuf REQUIRED)
+ protobuf_generate_cpp(PROTOBUF_SOURCES PROTOBUF_HEADERS paymentrequest.proto)
+
+ target_sources(bitcoin-qt-base
+ PRIVATE
+ # Protobuf codegen
+ ${PROTOBUF_HEADERS}
+ ${PROTOBUF_SOURCES}
+ )
+
+ target_include_directories(bitcoin-qt-base PUBLIC ${Protobuf_INCLUDE_DIRS})
+endif()
# Add the minimal integration plugin, and other plugins according to the target
# platform.
@@ -232,8 +237,6 @@
rpcclient
Qt5::Widgets
Qt5::Network
- OpenSSL::SSL
- ${Protobuf_LIBRARIES}
)
if(ENABLE_NOTIFICATIONS)
target_link_libraries(bitcoin-qt-base Qt5::DBus)
@@ -255,7 +258,6 @@
editaddressdialog.cpp
openuridialog.cpp
overviewpage.cpp
- paymentrequestplus.cpp
paymentserver.cpp
receivecoinsdialog.cpp
receiverequestdialog.cpp
@@ -275,6 +277,18 @@
walletview.cpp
)
+ # Add BIP70 functionality to bitcoin-qt
+ if(ENABLE_BIP70)
+ target_link_libraries(bitcoin-qt-base
+ OpenSSL::SSL
+ ${Protobuf_LIBRARIES}
+ )
+ target_sources(bitcoin-qt-base
+ PRIVATE
+ paymentrequestplus.cpp
+ )
+ endif()
+
target_link_libraries(bitcoin-qt-base wallet)
if(ENABLE_QRCODE)
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -365,8 +365,10 @@
window->setCurrentWallet(walletModel);
}
+#ifdef ENABLE_BIP70
connect(walletModel, &WalletModel::coinsSent, paymentServer,
&PaymentServer::fetchPaymentACK);
+#endif
connect(walletModel, &WalletModel::unload, this,
&BitcoinApplication::removeWallet);
@@ -398,7 +400,9 @@
// guaranteed complete.
qWarning() << "Platform customization:" << platformStyle->getName();
#ifdef ENABLE_WALLET
+#ifdef ENABLE_BIP70
PaymentServer::LoadRootCAs();
+#endif
if (paymentServer) {
paymentServer->setOptionsModel(optionsModel);
}
@@ -477,7 +481,7 @@
}
static void SetupUIArgs() {
-#ifdef ENABLE_WALLET
+#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
gArgs.AddArg("-allowselfsignedrootcertificates",
strprintf("Allow self signed root certificates (default: %d)",
DEFAULT_SELFSIGNED_ROOTCERTS),
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -2,9 +2,14 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/coincontroldialog.h>
#include <qt/forms/ui_coincontroldialog.h>
+#include <base58.h>
#include <cashaddrenc.h>
#include <interfaces/node.h>
#include <key_io.h>
diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h
--- a/src/qt/paymentserver.h
+++ b/src/qt/paymentserver.h
@@ -28,7 +28,13 @@
// to the server.
//
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
+#ifdef ENABLE_BIP70
#include <qt/paymentrequestplus.h>
+#endif
#include <qt/walletmodel.h>
#include <QObject>
@@ -71,6 +77,7 @@
// OptionsModel is used for getting proxy settings and display unit
void setOptionsModel(OptionsModel *optionsModel);
+#ifdef ENABLE_BIP70
// Load root certificate authorities. Pass nullptr (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,
@@ -90,6 +97,7 @@
static bool verifySize(qint64 requestSize);
// Verify the payment request amount is valid
static bool verifyAmount(const Amount requestAmount);
+#endif
Q_SIGNALS:
// Fired when a valid payment request is received
@@ -99,8 +107,10 @@
void message(const QString &title, const QString &message,
unsigned int style);
+#ifdef ENABLE_BIP70
// Fired when a valid PaymentACK is received
void receivedPaymentACK(const QString &paymentACKMsg);
+#endif
public Q_SLOTS:
// Signal this when the main window's UI is ready to display payment
@@ -110,16 +120,20 @@
// Handle an incoming URI, URI with local file scheme or file
void handleURIOrFile(const QString &s);
+#ifdef ENABLE_BIP70
// Submit Payment message to a merchant, get back PaymentACK:
void fetchPaymentACK(WalletModel *walletModel,
const SendCoinsRecipient &recipient,
QByteArray transaction);
+#endif
private Q_SLOTS:
void handleURIConnection();
+#ifdef ENABLE_BIP70
void netRequestFinished(QNetworkReply *);
void reportSslErrors(QNetworkReply *, const QList<QSslError> &);
void handlePaymentACK(const QString &paymentACKMsg);
+#endif
protected:
// Constructor registers this on the parent QApplication to receive
@@ -134,6 +148,7 @@
bool handleURI(const CChainParams &params, const QString &s);
+#ifdef ENABLE_BIP70
static bool readPaymentRequestFromFile(const QString &filename,
PaymentRequestPlus &request);
bool processPaymentRequest(const PaymentRequestPlus &request,
@@ -145,6 +160,7 @@
// Used to fetch payment requests
QNetworkAccessManager *netManager;
+#endif
};
#endif // BITCOIN_QT_PAYMENTSERVER_H
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/paymentserver.h>
#include <cashaddrenc.h>
@@ -44,6 +48,7 @@
#include <memory>
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
+#ifdef ENABLE_BIP70
// BIP70 payment protocol messages
const char *BIP70_MESSAGE_PAYMENTACK = "PaymentACK";
const char *BIP70_MESSAGE_PAYMENTREQUEST = "PaymentRequest";
@@ -52,6 +57,7 @@
const char *BIP71_MIMETYPE_PAYMENTACK = "application/bitcoincash-paymentack";
const char *BIP71_MIMETYPE_PAYMENTREQUEST =
"application/bitcoincash-paymentrequest";
+#endif
//
// Create a name that is unique for:
@@ -142,6 +148,7 @@
}
}
+#ifdef ENABLE_BIP70
if (!itemNetwork && QFile::exists(arg)) {
// Filename
PaymentRequestPlus request;
@@ -153,6 +160,7 @@
}
}
}
+#endif
if (itemNetwork == nullptr) {
// Printing to debug.log is about the best we can do here, the GUI
@@ -163,6 +171,7 @@
continue;
}
+#ifdef ENABLE_BIP70
if (chosenNetwork && chosenNetwork != itemNetwork) {
qWarning() << "PaymentServer::ipcSendCommandLine: Payment request "
"from network "
@@ -173,6 +182,7 @@
}
savedPaymentRequests.append(arg);
+#endif
chosenNetwork = itemNetwork;
}
@@ -217,11 +227,18 @@
}
PaymentServer::PaymentServer(QObject *parent, bool startLocalServer)
- : QObject(parent), saveURIs(true), uriServer(0), optionsModel(0),
- netManager(0) {
+ : QObject(parent), saveURIs(true), uriServer(0), optionsModel(0)
+// clang-format off
+#ifdef ENABLE_BIP70
+ ,netManager(0)
+#endif
+// clang-format on
+{
+#ifdef ENABLE_BIP70
// 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;
+#endif
// Install global event filter to catch QFileOpenEvents
// on Mac: sent when you click bitcoincash: links
@@ -246,14 +263,18 @@
} else {
connect(uriServer, &QLocalServer::newConnection, this,
&PaymentServer::handleURIConnection);
+#ifdef ENABLE_BIP70
connect(this, &PaymentServer::receivedPaymentACK, this,
&PaymentServer::handlePaymentACK);
+#endif
}
}
}
PaymentServer::~PaymentServer() {
+#ifdef ENABLE_BIP70
google::protobuf::ShutdownProtobufLibrary();
+#endif
}
//
@@ -277,7 +298,9 @@
}
void PaymentServer::uiReady() {
+#ifdef ENABLE_BIP70
initNetManager();
+#endif
saveURIs = false;
for (const QString &s : savedPaymentRequests) {
@@ -293,8 +316,9 @@
}
QUrlQuery uri((QUrl(s)));
+ // payment request URI
if (uri.hasQueryItem("r")) {
- // payment request URI
+#ifdef ENABLE_BIP70
QByteArray temp;
temp.append(uri.queryItemValue("r"));
QString decoded = QUrl::fromPercentEncoding(temp);
@@ -313,6 +337,12 @@
CClientUIInterface::ICON_WARNING);
}
+#else
+ Q_EMIT message(tr("URI handling"),
+ tr("Cannot process payment request because BIP70 "
+ "support was not compiled in."),
+ CClientUIInterface::ICON_WARNING);
+#endif
return true;
}
@@ -350,6 +380,7 @@
return;
}
+#ifdef ENABLE_BIP70
// payment request file
if (QFile::exists(s)) {
PaymentRequestPlus request;
@@ -365,6 +396,7 @@
return;
}
+#endif
}
void PaymentServer::handleURIConnection() {
@@ -392,6 +424,7 @@
this->optionsModel = _optionsModel;
}
+#ifdef ENABLE_BIP70
struct X509StoreDeleter {
void operator()(X509_STORE *b) { X509_STORE_free(b); }
};
@@ -879,3 +912,4 @@
X509_STORE *PaymentServer::getCertStore() {
return certStore.get();
}
+#endif
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/forms/ui_sendcoinsdialog.h>
#include <qt/sendcoinsdialog.h>
@@ -309,8 +313,11 @@
QString recipientElement;
recipientElement = "<br />";
+#ifdef ENABLE_BIP70
// normal payment
- if (!rcp.paymentRequest.IsInitialized()) {
+ if (!rcp.paymentRequest.IsInitialized())
+#endif
+ {
if (rcp.label.length() > 0) {
// label with address
recipientElement.append(
@@ -320,8 +327,10 @@
// just address
recipientElement.append(tr("%1 to %2").arg(amount, address));
}
- } else if (!rcp.authenticatedMerchant.isEmpty()) {
- // authenticated payment request
+ }
+#ifdef ENABLE_BIP70
+ // authenticated payment request
+ else if (!rcp.authenticatedMerchant.isEmpty()) {
recipientElement.append(
tr("%1 to %2")
.arg(amount,
@@ -330,6 +339,7 @@
// unauthenticated payment request
recipientElement.append(tr("%1 to %2").arg(amount, address));
}
+#endif
formatted.append(recipientElement);
}
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/forms/ui_sendcoinsentry.h>
#include <qt/sendcoinsentry.h>
@@ -151,10 +155,12 @@
// Check input validity
bool retval = true;
+#ifdef ENABLE_BIP70
// Skip checks for payment request
if (recipient.paymentRequest.IsInitialized()) {
return retval;
}
+#endif
if (!model->validateAddress(ui->payTo->text())) {
ui->payTo->setValid(false);
@@ -183,10 +189,12 @@
}
SendCoinsRecipient SendCoinsEntry::getValue() {
+#ifdef ENABLE_BIP70
// Payment request
if (recipient.paymentRequest.IsInitialized()) {
return recipient;
}
+#endif
// Normal payment
recipient.address = ui->payTo->text();
@@ -214,6 +222,7 @@
void SendCoinsEntry::setValue(const SendCoinsRecipient &value) {
recipient = value;
+#ifdef ENABLE_BIP70
// payment request
if (recipient.paymentRequest.IsInitialized()) {
// unauthenticated
@@ -236,7 +245,9 @@
}
// normal payment
- else {
+ else
+#endif
+ {
// message
ui->messageTextLabel->setText(recipient.message);
ui->messageTextLabel->setVisible(!recipient.message.isEmpty());
diff --git a/src/qt/test/CMakeLists.txt b/src/qt/test/CMakeLists.txt
--- a/src/qt/test/CMakeLists.txt
+++ b/src/qt/test/CMakeLists.txt
@@ -28,10 +28,16 @@
target_sources(test_bitcoin-qt
PRIVATE
addressbooktests.cpp
- paymentservertests.cpp
wallettests.cpp
../../wallet/test/wallet_test_fixture.cpp
)
+ if(ENABLE_BIP70)
+ target_sources(test_bitcoin-qt
+ PRIVATE
+ paymentservertests.cpp
+ )
+ endif()
+
target_link_libraries(test_bitcoin-qt wallet)
endif()
diff --git a/src/qt/test/compattests.cpp b/src/qt/test/compattests.cpp
--- a/src/qt/test/compattests.cpp
+++ b/src/qt/test/compattests.cpp
@@ -2,10 +2,18 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/test/compattests.h>
+#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
+// this includes protobuf's port.h which defines its own bswap macos
+#include <qt/paymentrequestplus.h>
+#endif
+
#include <compat/byteswap.h>
-#include <qt/paymentrequestplus.h> // this includes protobuf's port.h which defines its own bswap macos
void CompatTests::bswapTests() {
// Sibling in bitcoin/src/test/bswap_tests.cpp
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -21,15 +21,19 @@
#include <qt/test/uritests.h>
#ifdef ENABLE_WALLET
#include <qt/test/addressbooktests.h>
+#ifdef ENABLE_BIP70
#include <qt/test/paymentservertests.h>
+#endif // ENABLE_BIP70
#include <qt/test/wallettests.h>
-#endif
+#endif // ENABLE_WALLET
#include <QApplication>
#include <QObject>
#include <QTest>
+#ifdef ENABLE_BIP70
#include <openssl/ssl.h>
+#endif
#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
@@ -74,9 +78,11 @@
BitcoinApplication app(*node, argc, argv);
app.setApplicationName("BitcoinABC-Qt-test");
+#ifdef ENABLE_BIP70
// This is necessary to initialize openssl on the test framework
// (at least on Darwin).
SSL_library_init();
+#endif
AppTests app_tests(app);
if (QTest::qExec(&app_tests) != 0) {
@@ -86,7 +92,7 @@
if (QTest::qExec(&test1) != 0) {
fInvalid = true;
}
-#ifdef ENABLE_WALLET
+#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
PaymentServerTests test2;
if (QTest::qExec(&test2) != 0) {
fInvalid = true;
diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
--- a/src/qt/test/wallettests.cpp
+++ b/src/qt/test/wallettests.cpp
@@ -1,6 +1,7 @@
#include <qt/test/util.h>
#include <qt/test/wallettests.h>
+#include <base58.h>
#include <cashaddrenc.h>
#include <chain.h>
#include <chainparams.h>
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#ifdef HAVE_CONFIG_H
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/transactiondesc.h>
#include <cashaddrenc.h>
@@ -311,6 +315,7 @@
}
}
+#ifdef ENABLE_BIP70
//
// PaymentRequest info:
//
@@ -326,6 +331,7 @@
}
}
}
+#endif
if (wtx.is_coinbase) {
quint32 numBlocksToMaturity = COINBASE_MATURITY + 1;
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -17,7 +17,9 @@
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
#include <qt/intro.h>
+#ifdef ENABLE_BIP70
#include <qt/paymentrequestplus.h>
+#endif
#include <util/system.h>
#include <QCloseEvent>
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -7,7 +7,14 @@
#include <chainparams.h>
#include <interfaces/wallet.h>
+
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
+#ifdef ENABLE_BIP70
#include <qt/paymentrequestplus.h>
+#endif
#include <qt/walletmodeltransaction.h>
#include <support/allocators/secure.h>
@@ -60,8 +67,14 @@
// If from a payment request, this is used for storing the memo
QString message;
+#ifdef ENABLE_BIP70
// If from a payment request, paymentRequest.IsInitialized() will be true
PaymentRequestPlus paymentRequest;
+#else
+ // If building with BIP70 is disabled, keep the payment request around as
+ // serialized string to ensure load/store is lossless
+ std::string sPaymentRequest;
+#endif
// Empty if no authentication or invalid signature/cert/etc.
QString authenticatedMerchant;
@@ -78,10 +91,12 @@
std::string sAddress = address.toStdString();
std::string sLabel = label.toStdString();
std::string sMessage = message.toStdString();
+#ifdef ENABLE_BIP70
std::string sPaymentRequest;
if (!ser_action.ForRead() && paymentRequest.IsInitialized()) {
paymentRequest.SerializeToString(&sPaymentRequest);
}
+#endif
std::string sAuthenticatedMerchant =
authenticatedMerchant.toStdString();
@@ -98,10 +113,12 @@
address = QString::fromStdString(sAddress);
label = QString::fromStdString(sLabel);
message = QString::fromStdString(sMessage);
+#ifdef ENABLE_BIP70
if (!sPaymentRequest.empty()) {
paymentRequest.parse(QByteArray::fromRawData(
sPaymentRequest.data(), sPaymentRequest.size()));
}
+#endif
authenticatedMerchant =
QString::fromStdString(sAuthenticatedMerchant);
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/walletmodel.h>
#include <cashaddrenc.h>
@@ -132,6 +136,7 @@
for (const SendCoinsRecipient &rcp : recipients) {
if (rcp.fSubtractFeeFromAmount) fSubtractFeeFromAmount = true;
+#ifdef ENABLE_BIP70
// PaymentRequest...
if (rcp.paymentRequest.IsInitialized()) {
Amount subtotal = Amount::zero();
@@ -157,8 +162,12 @@
return InvalidAmount;
}
total += subtotal;
- } else {
- // User-entered bitcoin address / amount:
+ }
+
+ // User-entered bitcoin address / amount:
+ else
+#endif
+ {
if (!validateAddress(rcp.address)) {
return InvalidAddress;
}
@@ -226,6 +235,7 @@
std::vector<std::pair<std::string, std::string>> vOrderForm;
for (const SendCoinsRecipient &rcp : transaction.getRecipients()) {
+#ifdef ENABLE_BIP70
if (rcp.paymentRequest.IsInitialized()) {
// Make sure any payment requests involved are still valid.
if (PaymentServer::verifyExpired(rcp.paymentRequest.getDetails())) {
@@ -236,7 +246,9 @@
std::string value;
rcp.paymentRequest.SerializeToString(&value);
vOrderForm.emplace_back("PaymentRequest", std::move(value));
- } else if (!rcp.message.isEmpty()) {
+ } else
+#endif
+ if (!rcp.message.isEmpty()) {
// Message from normal bitcoincash:URI
// (bitcoincash:123...?message=example)
vOrderForm.emplace_back("Message", rcp.message.toStdString());
@@ -259,7 +271,10 @@
// 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()) {
+#ifdef ENABLE_BIP70
+ if (!rcp.paymentRequest.IsInitialized())
+#endif
+ {
std::string strAddress = rcp.address.toStdString();
CTxDestination dest =
DecodeDestination(strAddress, getChainParams());
diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h
--- a/src/qt/walletmodeltransaction.h
+++ b/src/qt/walletmodeltransaction.h
@@ -7,6 +7,8 @@
#include <qt/walletmodel.h>
+#include <amount.h>
+
#include <QObject>
#include <memory>
diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp
--- a/src/qt/walletmodeltransaction.cpp
+++ b/src/qt/walletmodeltransaction.cpp
@@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#ifdef HAVE_CONFIG_H
+#include <config/bitcoin-config.h>
+#endif
+
#include <qt/walletmodeltransaction.h>
#include <interfaces/node.h>
@@ -35,6 +39,7 @@
const CTransaction *walletTransaction = &wtx->get();
int i = 0;
for (SendCoinsRecipient &rcp : recipients) {
+#ifdef ENABLE_BIP70
if (rcp.paymentRequest.IsInitialized()) {
Amount subtotal = Amount::zero();
const payments::PaymentDetails &details =
@@ -53,8 +58,12 @@
i++;
}
rcp.amount = subtotal;
- } else {
- // normal recipient (no payment request)
+ }
+
+ // normal recipient (no payment request)
+ else
+#endif
+ {
if (i == nChangePosRet) {
i++;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 09:42 (3 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5179592
Default Alt Text
D4619.vs14737.id15017.diff (29 KB)

Event Timeline